use of org.apache.hadoop.hbase.CellBuilderType in project hbase by apache.
the class Mutation method getCellBuilder.
/**
* get a CellBuilder instance that already has relevant Type and Row set.
* @param cellBuilderType e.g CellBuilderType.SHALLOW_COPY
* @param cellType e.g Cell.Type.Put
* @return CellBuilder which already has relevant Type and Row set.
*/
protected CellBuilder getCellBuilder(CellBuilderType cellBuilderType, Cell.Type cellType) {
CellBuilder builder = CellBuilderFactory.create(cellBuilderType).setRow(row).setType(cellType);
return new CellBuilder() {
@Override
public CellBuilder setRow(byte[] row) {
return this;
}
@Override
public CellBuilder setType(Cell.Type type) {
return this;
}
@Override
public CellBuilder setRow(byte[] row, int rOffset, int rLength) {
return this;
}
@Override
public CellBuilder setFamily(byte[] family) {
builder.setFamily(family);
return this;
}
@Override
public CellBuilder setFamily(byte[] family, int fOffset, int fLength) {
builder.setFamily(family, fOffset, fLength);
return this;
}
@Override
public CellBuilder setQualifier(byte[] qualifier) {
builder.setQualifier(qualifier);
return this;
}
@Override
public CellBuilder setQualifier(byte[] qualifier, int qOffset, int qLength) {
builder.setQualifier(qualifier, qOffset, qLength);
return this;
}
@Override
public CellBuilder setTimestamp(long timestamp) {
builder.setTimestamp(timestamp);
return this;
}
@Override
public CellBuilder setValue(byte[] value) {
builder.setValue(value);
return this;
}
@Override
public CellBuilder setValue(byte[] value, int vOffset, int vLength) {
builder.setValue(value, vOffset, vLength);
return this;
}
@Override
public Cell build() {
return builder.build();
}
@Override
public CellBuilder clear() {
builder.clear();
// reset the row and type
builder.setRow(row);
builder.setType(cellType);
return this;
}
};
}
Aggregations