本文整理汇总了Java中org.apache.hadoop.hbase.protobuf.generated.CellProtos.Cell方法的典型用法代码示例。如果您正苦于以下问题:Java CellProtos.Cell方法的具体用法?Java CellProtos.Cell怎么用?Java CellProtos.Cell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.protobuf.generated.CellProtos
的用法示例。
在下文中一共展示了CellProtos.Cell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
@Override
public void write(Cell cell) throws IOException {
checkFlushed();
CellProtos.Cell.Builder builder = CellProtos.Cell.newBuilder();
// This copies bytes from Cell to ByteString. I don't see anyway around the copy.
// ByteString is final.
builder.setRow(ByteStringer.wrap(cell.getRowArray(), cell.getRowOffset(),
cell.getRowLength()));
builder.setFamily(ByteStringer.wrap(cell.getFamilyArray(), cell.getFamilyOffset(),
cell.getFamilyLength()));
builder.setQualifier(ByteStringer.wrap(cell.getQualifierArray(),
cell.getQualifierOffset(), cell.getQualifierLength()));
builder.setTimestamp(cell.getTimestamp());
builder.setCellType(CellProtos.CellType.valueOf(cell.getTypeByte()));
builder.setValue(ByteStringer.wrap(cell.getValueArray(), cell.getValueOffset(),
cell.getValueLength()));
CellProtos.Cell pbcell = builder.build();
pbcell.writeDelimitedTo(this.out);
}
示例2: toResult
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
/**
* Convert a protocol buffer Result to a client Result
*
* @param proto the protocol buffer Result to convert
* @return the converted client Result
*/
public static Result toResult(final ClientProtos.Result proto) {
if (proto.hasExists()) {
if (proto.getStale()) {
return proto.getExists() ? EMPTY_RESULT_EXISTS_TRUE_STALE :EMPTY_RESULT_EXISTS_FALSE_STALE;
}
return proto.getExists() ? EMPTY_RESULT_EXISTS_TRUE : EMPTY_RESULT_EXISTS_FALSE;
}
List<CellProtos.Cell> values = proto.getCellList();
if (values.isEmpty()){
return proto.getStale() ? EMPTY_RESULT_STALE : EMPTY_RESULT;
}
List<Cell> cells = new ArrayList<Cell>(values.size());
for (CellProtos.Cell c : values) {
cells.add(toCell(c));
}
return Result.create(cells, null, proto.getStale(), proto.getPartial());
}
示例3: toCell
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
public static CellProtos.Cell toCell(final Cell kv) {
// Doing this is going to kill us if we do it for all data passed.
// St.Ack 20121205
CellProtos.Cell.Builder kvbuilder = CellProtos.Cell.newBuilder();
kvbuilder.setRow(ByteStringer.wrap(kv.getRowArray(), kv.getRowOffset(),
kv.getRowLength()));
kvbuilder.setFamily(ByteStringer.wrap(kv.getFamilyArray(),
kv.getFamilyOffset(), kv.getFamilyLength()));
kvbuilder.setQualifier(ByteStringer.wrap(kv.getQualifierArray(),
kv.getQualifierOffset(), kv.getQualifierLength()));
kvbuilder.setCellType(CellProtos.CellType.valueOf(kv.getTypeByte()));
kvbuilder.setTimestamp(kv.getTimestamp());
kvbuilder.setValue(ByteStringer.wrap(kv.getValueArray(), kv.getValueOffset(),
kv.getValueLength()));
return kvbuilder.build();
}
示例4: write
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
@Override
public void write(Cell cell) throws IOException {
checkFlushed();
CellProtos.Cell.Builder builder = CellProtos.Cell.newBuilder();
// This copies bytes from Cell to ByteString. I don't see anyway around the copy.
// ByteString is final.
builder.setRow(HBaseZeroCopyByteString.wrap(cell.getRowArray(), cell.getRowOffset(),
cell.getRowLength()));
builder.setFamily(HBaseZeroCopyByteString.wrap(cell.getFamilyArray(), cell.getFamilyOffset(),
cell.getFamilyLength()));
builder.setQualifier(HBaseZeroCopyByteString.wrap(cell.getQualifierArray(),
cell.getQualifierOffset(), cell.getQualifierLength()));
builder.setTimestamp(cell.getTimestamp());
builder.setCellType(CellProtos.CellType.valueOf(cell.getTypeByte()));
builder.setValue(HBaseZeroCopyByteString.wrap(cell.getValueArray(), cell.getValueOffset(),
cell.getValueLength()));
CellProtos.Cell pbcell = builder.build();
pbcell.writeDelimitedTo(this.out);
}
示例5: toCell
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
public static CellProtos.Cell toCell(final Cell kv) {
// Doing this is going to kill us if we do it for all data passed.
// St.Ack 20121205
CellProtos.Cell.Builder kvbuilder = CellProtos.Cell.newBuilder();
kvbuilder.setRow(HBaseZeroCopyByteString.wrap(kv.getRowArray(), kv.getRowOffset(),
kv.getRowLength()));
kvbuilder.setFamily(HBaseZeroCopyByteString.wrap(kv.getFamilyArray(),
kv.getFamilyOffset(), kv.getFamilyLength()));
kvbuilder.setQualifier(HBaseZeroCopyByteString.wrap(kv.getQualifierArray(),
kv.getQualifierOffset(), kv.getQualifierLength()));
kvbuilder.setCellType(CellProtos.CellType.valueOf(kv.getTypeByte()));
kvbuilder.setTimestamp(kv.getTimestamp());
kvbuilder.setValue(HBaseZeroCopyByteString.wrap(kv.getValueArray(), kv.getValueOffset(),
kv.getValueLength()));
return kvbuilder.build();
}
示例6: toCell
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
public static CellProtos.Cell toCell(final Cell kv) {
// Doing this is going to kill us if we do it for all data passed.
// St.Ack 20121205
CellProtos.Cell.Builder kvbuilder = CellProtos.Cell.newBuilder();
kvbuilder.setRow(ZeroCopyLiteralByteString.wrap(kv.getRowArray(), kv.getRowOffset(),
kv.getRowLength()));
kvbuilder.setFamily(ZeroCopyLiteralByteString.wrap(kv.getFamilyArray(),
kv.getFamilyOffset(), kv.getFamilyLength()));
kvbuilder.setQualifier(ZeroCopyLiteralByteString.wrap(kv.getQualifierArray(),
kv.getQualifierOffset(), kv.getQualifierLength()));
kvbuilder.setCellType(CellProtos.CellType.valueOf(kv.getTypeByte()));
kvbuilder.setTimestamp(kv.getTimestamp());
kvbuilder.setValue(ZeroCopyLiteralByteString.wrap(kv.getValueArray(), kv.getValueOffset(),
kv.getValueLength()));
return kvbuilder.build();
}
示例7: toResult
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
/**
* Convert a protocol buffer Result to a client Result
*
* @param proto the protocol buffer Result to convert
* @return the converted client Result
*/
public static Result toResult(final ClientProtos.Result proto) {
if (proto.hasExists()) {
return proto.getExists() ? EMPTY_RESULT_EXISTS_TRUE : EMPTY_RESULT_EXISTS_FALSE;
}
List<CellProtos.Cell> values = proto.getCellList();
if (values.isEmpty()){
return EMPTY_RESULT;
}
List<Cell> cells = new ArrayList<Cell>(values.size());
for (CellProtos.Cell c : values) {
cells.add(toCell(c));
}
return Result.create(cells, null);
}
示例8: write
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
@Override
public void write(Cell cell) throws IOException {
checkFlushed();
CellProtos.Cell.Builder builder = CellProtos.Cell.newBuilder();
// This copies bytes from Cell to ByteString. I don't see anyway around the copy.
// ByteString is final.
builder.setRow(ByteString.copyFrom(cell.getRowArray(), cell.getRowOffset(),
cell.getRowLength()));
builder.setFamily(ByteString.copyFrom(cell.getFamilyArray(), cell.getFamilyOffset(),
cell.getFamilyLength()));
builder.setQualifier(ByteString.copyFrom(cell.getQualifierArray(), cell.getQualifierOffset(),
cell.getQualifierLength()));
builder.setTimestamp(cell.getTimestamp());
builder.setCellType(CellProtos.CellType.valueOf(cell.getTypeByte()));
builder.setValue(ByteString.copyFrom(cell.getValueArray(), cell.getValueOffset(),
cell.getValueLength()));
CellProtos.Cell pbcell = builder.build();
pbcell.writeDelimitedTo(this.out);
}
示例9: parseCell
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
protected Cell parseCell() throws IOException {
CellProtos.Cell pbcell = CellProtos.Cell.parseDelimitedFrom(this.in);
return CellUtil.createCell(pbcell.getRow().toByteArray(),
pbcell.getFamily().toByteArray(), pbcell.getQualifier().toByteArray(),
pbcell.getTimestamp(), (byte)pbcell.getCellType().getNumber(),
pbcell.getValue().toByteArray());
}
示例10: getStartCode
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
static CellProtos.Cell getStartCode(final ByteString row) {
CellProtos.Cell.Builder cellBuilder = getBaseCellBuilder(row);
cellBuilder.setQualifier(ByteStringer.wrap(HConstants.STARTCODE_QUALIFIER));
// TODO:
cellBuilder.setValue(ByteStringer.wrap(Bytes.toBytes(META_SERVERNAME.getStartcode())));
return cellBuilder.build();
}
示例11: decode
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
@Override
public CellProtos.Cell decode(PositionedByteRange src) {
CellProtos.Cell.Builder builder = CellProtos.Cell.newBuilder();
CodedInputStream is = inputStreamFromByteRange(src);
is.setSizeLimit(src.getLength());
try {
CellProtos.Cell ret = builder.mergeFrom(is).build();
src.setPosition(src.getPosition() + is.getTotalBytesRead());
return ret;
} catch (IOException e) {
throw new RuntimeException("Error while decoding type.", e);
}
}
示例12: encode
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
@Override
public int encode(PositionedByteRange dst, CellProtos.Cell val) {
CodedOutputStream os = outputStreamFromByteRange(dst);
try {
int before = os.spaceLeft(), after, written;
val.writeTo(os);
after = os.spaceLeft();
written = before - after;
dst.setPosition(dst.getPosition() + written);
return written;
} catch (IOException e) {
throw new RuntimeException("Error while encoding type.", e);
}
}
示例13: testRoundTrip
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
/**
* Basic test to verify utility methods in {@link PBType} and delegation to protobuf works.
*/
@Test
public void testRoundTrip() {
final Cell cell = new KeyValue(Bytes.toBytes("row"), Bytes.toBytes("fam"),
Bytes.toBytes("qual"), Bytes.toBytes("val"));
CellProtos.Cell c = ProtobufUtil.toCell(cell), decoded;
PositionedByteRange pbr = new SimplePositionedByteRange(c.getSerializedSize());
pbr.setPosition(0);
int encodedLength = CODEC.encode(pbr, c);
pbr.setPosition(0);
decoded = CODEC.decode(pbr);
assertEquals(encodedLength, pbr.getPosition());
assertTrue(CellComparator.equals(cell, ProtobufUtil.toCell(decoded)));
}
示例14: toResult
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
/**
* Convert a protocol buffer Result to a client Result
*
* @param proto the protocol buffer Result to convert
* @param scanner Optional cell scanner.
* @return the converted client Result
* @throws IOException
*/
public static Result toResult(final ClientProtos.Result proto, final CellScanner scanner)
throws IOException {
List<CellProtos.Cell> values = proto.getCellList();
if (proto.hasExists()) {
if ((values != null && !values.isEmpty()) ||
(proto.hasAssociatedCellCount() && proto.getAssociatedCellCount() > 0)) {
throw new IllegalArgumentException("bad proto: exists with cells is no allowed " + proto);
}
if (proto.getStale()) {
return proto.getExists() ? EMPTY_RESULT_EXISTS_TRUE_STALE :EMPTY_RESULT_EXISTS_FALSE_STALE;
}
return proto.getExists() ? EMPTY_RESULT_EXISTS_TRUE : EMPTY_RESULT_EXISTS_FALSE;
}
// TODO: Unit test that has some Cells in scanner and some in the proto.
List<Cell> cells = null;
if (proto.hasAssociatedCellCount()) {
int count = proto.getAssociatedCellCount();
cells = new ArrayList<Cell>(count + values.size());
for (int i = 0; i < count; i++) {
if (!scanner.advance()) throw new IOException("Failed get " + i + " of " + count);
cells.add(scanner.current());
}
}
if (!values.isEmpty()){
if (cells == null) cells = new ArrayList<Cell>(values.size());
for (CellProtos.Cell c: values) {
cells.add(toCell(c));
}
}
return (cells == null || cells.isEmpty())
? (proto.getStale() ? EMPTY_RESULT_STALE : EMPTY_RESULT)
: Result.create(cells, null, proto.getStale());
}
示例15: getStartCode
import org.apache.hadoop.hbase.protobuf.generated.CellProtos; //导入方法依赖的package包/类
static CellProtos.Cell getStartCode(final ByteString row) {
CellProtos.Cell.Builder cellBuilder = getBaseCellBuilder(row);
cellBuilder.setQualifier(HBaseZeroCopyByteString.wrap(HConstants.STARTCODE_QUALIFIER));
// TODO:
cellBuilder.setValue(HBaseZeroCopyByteString.wrap(Bytes.toBytes(META_SERVERNAME.getStartcode())));
return cellBuilder.build();
}