本文整理了Java中org.apache.hadoop.hbase.Cell.getQualifierArray()
方法的一些代码示例,展示了Cell.getQualifierArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cell.getQualifierArray()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.Cell
类名称:Cell
方法名:getQualifierArray
[英]Contiguous raw bytes that may start at any index in the containing array.
[中]可以从包含数组中的任何索引开始的连续原始字节。
代码示例来源:origin: apache/hbase
protected static String extractSnapshotNameFromSizeCell(Cell c) {
return Bytes.toString(
c.getQualifierArray(), c.getQualifierOffset() + QUOTA_SNAPSHOT_SIZE_QUALIFIER.length,
c.getQualifierLength() - QUOTA_SNAPSHOT_SIZE_QUALIFIER.length);
}
代码示例来源:origin: apache/kylin
public static Cell findCell(List<Cell> cells, byte[] familyName, byte[] columnName) {
for (Cell c : cells) {
if (BytesUtil.compareBytes(familyName, 0, c.getFamilyArray(), c.getFamilyOffset(), familyName.length) == 0 && //
BytesUtil.compareBytes(columnName, 0, c.getQualifierArray(), c.getQualifierOffset(), columnName.length) == 0) {
return c;
}
}
return null;
}
代码示例来源:origin: apache/hbase
public static byte getQualifierByte(Cell cell, int index) {
if (cell instanceof ByteBufferExtendedCell) {
return ((ByteBufferExtendedCell) cell).getQualifierByteBuffer()
.get(((ByteBufferExtendedCell) cell).getQualifierPosition() + index);
}
return cell.getQualifierArray()[cell.getQualifierOffset() + index];
}
代码示例来源:origin: apache/kylin
public static ByteBuffer getValueAsByteBuffer(Result hbaseRow, byte[] cf, byte[] cq) {
List<Cell> cells = hbaseRow.listCells();
if (cells == null || cells.size() == 0) {
return null;
} else {
for (Cell c : cells) {
if (Bytes.compareTo(cf, 0, cf.length, c.getFamilyArray(), c.getFamilyOffset(), c.getFamilyLength()) == 0 && //
Bytes.compareTo(cq, 0, cq.length, c.getQualifierArray(), c.getQualifierOffset(), c.getQualifierLength()) == 0) {
return ByteBuffer.wrap(c.getValueArray(), c.getValueOffset(), c.getValueLength());
}
}
}
return null;
}
代码示例来源:origin: apache/hbase
if ((left.getRowLength() + left.getFamilyLength() + left.getQualifierLength()) != (right
.getRowLength() + right.getFamilyLength() + right.getQualifierLength())) {
return false;
int lfoffset = left.getFamilyOffset();
int rfoffset = right.getFamilyOffset();
int lclength = left.getQualifierLength();
int rclength = right.getQualifierLength();
int lfamilylength = left.getFamilyLength();
int rfamilylength = right.getFamilyLength();
int diff = compareFamilies(left.getFamilyArray(), lfoffset, lfamilylength,
right.getFamilyArray(), rfoffset, rfamilylength);
if (diff != 0) {
return false;
} else {
diff = compareColumns(left.getQualifierArray(), left.getQualifierOffset(), lclength,
right.getQualifierArray(), right.getQualifierOffset(), rclength);
return diff == 0;
代码示例来源:origin: apache/hbase
/**
* @param cell
* @return cell's qualifier wrapped into a ByteBuffer.
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
*/
@Deprecated
public static ByteBuffer getQualifierBufferShallowCopy(Cell cell) {
// No usage of this in code.
ByteBuffer buffer = ByteBuffer.wrap(cell.getQualifierArray(), cell.getQualifierOffset(),
cell.getQualifierLength());
return buffer;
}
代码示例来源:origin: apache/hbase
@Test
public void testCellBuilderWithShallowCopy() {
byte[] row = new byte[]{OLD_DATA};
byte[] family = new byte[]{OLD_DATA};
byte[] qualifier = new byte[]{OLD_DATA};
byte[] value = new byte[]{OLD_DATA};
Cell cell = CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
.setRow(row)
.setFamily(family)
.setQualifier(qualifier)
.setType(Cell.Type.Put)
.setValue(value)
.build();
row[0] = NEW_DATA;
family[0] = NEW_DATA;
qualifier[0] = NEW_DATA;
value[0] = NEW_DATA;
assertEquals(NEW_DATA, cell.getRowArray()[cell.getRowOffset()]);
assertEquals(NEW_DATA, cell.getFamilyArray()[cell.getFamilyOffset()]);
assertEquals(NEW_DATA, cell.getQualifierArray()[cell.getQualifierOffset()]);
assertEquals(NEW_DATA, cell.getValueArray()[cell.getValueOffset()]);
}
代码示例来源:origin: apache/hbase
/**
* Writes the qualifier from the given cell to the output stream
* @param out The outputstream to which the data has to be written
* @param cell The cell whose contents has to be written
* @param qlength the qualifier length
* @throws IOException
*/
public static void writeQualifier(OutputStream out, Cell cell, int qlength) throws IOException {
if (cell instanceof ByteBufferExtendedCell) {
ByteBufferUtils
.copyBufferToStream(out, ((ByteBufferExtendedCell) cell).getQualifierByteBuffer(),
((ByteBufferExtendedCell) cell).getQualifierPosition(), qlength);
} else {
out.write(cell.getQualifierArray(), cell.getQualifierOffset(), qlength);
}
}
代码示例来源:origin: apache/hbase
public void hashResult(Result result) {
if (!batchStarted) {
throw new RuntimeException("Cannot add to batch that has not been started.");
}
for (Cell cell : result.rawCells()) {
int rowLength = cell.getRowLength();
int familyLength = cell.getFamilyLength();
int qualifierLength = cell.getQualifierLength();
int valueLength = cell.getValueLength();
digest.update(cell.getRowArray(), cell.getRowOffset(), rowLength);
digest.update(cell.getFamilyArray(), cell.getFamilyOffset(), familyLength);
digest.update(cell.getQualifierArray(), cell.getQualifierOffset(), qualifierLength);
long ts = cell.getTimestamp();
for (int i = 8; i > 0; i--) {
digest.update((byte) ts);
ts >>>= 8;
}
digest.update(cell.getValueArray(), cell.getValueOffset(), valueLength);
batchSize += rowLength + familyLength + qualifierLength + 8 + valueLength;
}
}
代码示例来源:origin: apache/hbase
public static int compareCommonQualifierPrefix(Cell left, Cell right, int qualCommonPrefix) {
return Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset() + qualCommonPrefix,
left.getQualifierLength() - qualCommonPrefix, right.getQualifierArray(),
right.getQualifierOffset() + qualCommonPrefix, right.getQualifierLength()
- qualCommonPrefix);
}
代码示例来源:origin: apache/hbase
@Test
public void testCellBuilderWithDeepCopy() {
byte[] row = new byte[]{OLD_DATA};
byte[] family = new byte[]{OLD_DATA};
byte[] qualifier = new byte[]{OLD_DATA};
byte[] value = new byte[]{OLD_DATA};
Cell cell = CellBuilderFactory.create(CellBuilderType.DEEP_COPY)
.setRow(row)
.setFamily(family)
.setQualifier(qualifier)
.setType(Cell.Type.Put)
.setValue(value)
.build();
row[0] = NEW_DATA;
family[0] = NEW_DATA;
qualifier[0] = NEW_DATA;
value[0] = NEW_DATA;
assertEquals(OLD_DATA, cell.getRowArray()[cell.getRowOffset()]);
assertEquals(OLD_DATA, cell.getFamilyArray()[cell.getFamilyOffset()]);
assertEquals(OLD_DATA, cell.getQualifierArray()[cell.getQualifierOffset()]);
assertEquals(OLD_DATA, cell.getValueArray()[cell.getValueOffset()]);
}
代码示例来源:origin: apache/hbase
/**
* Writes the qualifier from the given cell to the output stream excluding the common prefix
* @param out The dataoutputstream to which the data has to be written
* @param cell The cell whose contents has to be written
* @param qlength the qualifier length
* @throws IOException
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
*/
@Deprecated
public static void writeQualifierSkippingBytes(DataOutputStream out, Cell cell,
int qlength, int commonPrefix) throws IOException {
if (cell instanceof ByteBufferExtendedCell) {
ByteBufferUtils.copyBufferToStream((DataOutput)out,
((ByteBufferExtendedCell) cell).getQualifierByteBuffer(),
((ByteBufferExtendedCell) cell).getQualifierPosition() + commonPrefix,
qlength - commonPrefix);
} else {
out.write(cell.getQualifierArray(), cell.getQualifierOffset() + commonPrefix,
qlength - commonPrefix);
}
}
代码示例来源:origin: apache/hbase
/**
* @param cell
* @return The Key portion of the passed <code>cell</code> as a String.
*/
public static String getCellKeyAsString(Cell cell) {
StringBuilder sb = new StringBuilder(Bytes.toStringBinary(
cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()));
sb.append('/');
sb.append(cell.getFamilyLength() == 0? "":
Bytes.toStringBinary(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength()));
// KeyValue only added ':' if family is non-null. Do same.
if (cell.getFamilyLength() > 0) sb.append(':');
sb.append(cell.getQualifierLength() == 0? "":
Bytes.toStringBinary(cell.getQualifierArray(), cell.getQualifierOffset(),
cell.getQualifierLength()));
sb.append('/');
sb.append(KeyValue.humanReadableTimestamp(cell.getTimestamp()));
sb.append('/');
sb.append(Type.codeToType(cell.getTypeByte()));
if (!(cell instanceof KeyValue.KeyOnlyKeyValue)) {
sb.append("/vlen=");
sb.append(cell.getValueLength());
}
sb.append("/seqid=");
sb.append(cell.getSequenceId());
return sb.toString();
}
代码示例来源:origin: apache/hbase
private static int findCommonPrefixInQualifierPart(Cell left, Cell right,
int qualifierCommonPrefix) {
return Bytes.findCommonPrefix(left.getQualifierArray(), right.getQualifierArray(),
left.getQualifierLength() - qualifierCommonPrefix, right.getQualifierLength()
- qualifierCommonPrefix, left.getQualifierOffset() + qualifierCommonPrefix,
right.getQualifierOffset() + qualifierCommonPrefix);
}
代码示例来源:origin: apache/hbase
@Test
public void testExtendedCellBuilderWithShallowCopy() {
byte[] row = new byte[]{OLD_DATA};
byte[] family = new byte[]{OLD_DATA};
byte[] qualifier = new byte[]{OLD_DATA};
byte[] value = new byte[]{OLD_DATA};
byte[] tags = new byte[]{OLD_DATA};
long seqId = 999;
Cell cell = ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
.setRow(row)
.setFamily(family)
.setQualifier(qualifier)
.setType(KeyValue.Type.Put.getCode())
.setValue(value)
.setTags(tags)
.setSequenceId(seqId)
.build();
row[0] = NEW_DATA;
family[0] = NEW_DATA;
qualifier[0] = NEW_DATA;
value[0] = NEW_DATA;
tags[0] = NEW_DATA;
assertEquals(NEW_DATA, cell.getRowArray()[cell.getRowOffset()]);
assertEquals(NEW_DATA, cell.getFamilyArray()[cell.getFamilyOffset()]);
assertEquals(NEW_DATA, cell.getQualifierArray()[cell.getQualifierOffset()]);
assertEquals(NEW_DATA, cell.getValueArray()[cell.getValueOffset()]);
assertEquals(NEW_DATA, cell.getTagsArray()[cell.getTagsOffset()]);
assertEquals(seqId, cell.getSequenceId());
}
代码示例来源:origin: apache/hbase
/**
* Writes the qualifier from the given cell to the output stream excluding the common prefix
* @param out The dataoutputstream to which the data has to be written
* @param cell The cell whose contents has to be written
* @param qlength the qualifier length
* @throws IOException
*/
public static void writeQualifierSkippingBytes(DataOutputStream out, Cell cell, int qlength,
int commonPrefix) throws IOException {
if (cell instanceof ByteBufferExtendedCell) {
ByteBufferUtils.copyBufferToStream((DataOutput) out,
((ByteBufferExtendedCell) cell).getQualifierByteBuffer(),
((ByteBufferExtendedCell) cell).getQualifierPosition() + commonPrefix,
qlength - commonPrefix);
} else {
out.write(cell.getQualifierArray(), cell.getQualifierOffset() + commonPrefix,
qlength - commonPrefix);
}
}
代码示例来源:origin: apache/hbase
public static boolean matchingRowColumnBytes(final Cell left, final Cell right) {
int lrowlength = left.getRowLength();
int rrowlength = right.getRowLength();
int lfamlength = left.getFamilyLength();
int rfamlength = right.getFamilyLength();
int lqlength = left.getQualifierLength();
int rqlength = right.getQualifierLength();
// match length
if ((lrowlength + lfamlength + lqlength) !=
(rrowlength + rfamlength + rqlength)) {
return false;
}
// match row
if (!Bytes.equals(left.getRowArray(), left.getRowOffset(), lrowlength, right.getRowArray(),
right.getRowOffset(), rrowlength)) {
return false;
}
//match family
if (!Bytes.equals(left.getFamilyArray(), left.getFamilyOffset(), lfamlength,
right.getFamilyArray(), right.getFamilyOffset(), rfamlength)) {
return false;
}
//match qualifier
return Bytes.equals(left.getQualifierArray(), left.getQualifierOffset(),
lqlength, right.getQualifierArray(), right.getQualifierOffset(),
rqlength);
}
代码示例来源:origin: apache/hbase
public static ByteRange fillQualifierRange(Cell cell, ByteRange range) {
return range.set(cell.getQualifierArray(), cell.getQualifierOffset(),
cell.getQualifierLength());
}
代码示例来源:origin: apache/hbase
@Test
public void testExtendedCellBuilderWithDeepCopy() {
byte[] row = new byte[]{OLD_DATA};
byte[] family = new byte[]{OLD_DATA};
byte[] qualifier = new byte[]{OLD_DATA};
byte[] value = new byte[]{OLD_DATA};
byte[] tags = new byte[]{OLD_DATA};
long seqId = 999;
Cell cell = ExtendedCellBuilderFactory.create(CellBuilderType.DEEP_COPY)
.setRow(row)
.setFamily(family)
.setQualifier(qualifier)
.setType(KeyValue.Type.Put.getCode())
.setValue(value)
.setTags(tags)
.setSequenceId(seqId)
.build();
row[0] = NEW_DATA;
family[0] = NEW_DATA;
qualifier[0] = NEW_DATA;
value[0] = NEW_DATA;
tags[0] = NEW_DATA;
assertEquals(OLD_DATA, cell.getRowArray()[cell.getRowOffset()]);
assertEquals(OLD_DATA, cell.getFamilyArray()[cell.getFamilyOffset()]);
assertEquals(OLD_DATA, cell.getQualifierArray()[cell.getQualifierOffset()]);
assertEquals(OLD_DATA, cell.getValueArray()[cell.getValueOffset()]);
assertEquals(OLD_DATA, cell.getTagsArray()[cell.getTagsOffset()]);
assertEquals(seqId, cell.getSequenceId());
}
}
代码示例来源:origin: apache/hbase
private static int compareQualifierPart(Cell cell, int length, byte[] prefix) {
if (cell instanceof ByteBufferExtendedCell) {
return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) cell).getQualifierByteBuffer(),
((ByteBufferExtendedCell) cell).getQualifierPosition(), length, prefix, 0, length);
}
return Bytes.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(), length, prefix, 0,
length);
}
内容来源于网络,如有侵权,请联系作者删除!