All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bazaarvoice.emodb.sor.db.astyanax.StitchedColumn Maven / Gradle / Ivy

There is a newer version: 6.5.190
Show newest version
package com.bazaarvoice.emodb.sor.db.astyanax;


import com.netflix.astyanax.Serializer;
import com.netflix.astyanax.model.AbstractColumnImpl;
import com.netflix.astyanax.model.Column;
import com.netflix.astyanax.serializers.UUIDSerializer;

import java.nio.ByteBuffer;
import java.util.UUID;

public class StitchedColumn extends AbstractColumnImpl {
    private Column _oldColumn;
    private ByteBuffer _content;
    private int _numBlocks;

    public StitchedColumn(Column oldColumn, ByteBuffer content, int numBlocks) {
        super(oldColumn.getName().getChangeId());
        _oldColumn = oldColumn;
        _content = content;
        _numBlocks = numBlocks;
    }

    public StitchedColumn(Column oldColumn) {
        super(oldColumn.getName().getChangeId());
        _oldColumn = oldColumn;
        _numBlocks = 1;
    }

    @Override
    public ByteBuffer getRawName() {
        return UUIDSerializer.get().toByteBuffer(getName());
    }

    @Override
    public long getTimestamp() {
        return _oldColumn.getTimestamp();
    }

    // content will be null if delta fit in a single block, as no stitching was performed
    @Override
    public  V getValue(Serializer serializer) {
        return _content != null ? serializer.fromByteBuffer(_content) : _oldColumn.getValue(serializer);
    }

    @Override
    public int getTtl() {
        return _oldColumn.getTtl();
    }

    @Override
    public boolean hasValue() {
        return _oldColumn.hasValue();
    }

    public int getNumBlocks() {
        return _numBlocks;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy