本文整理了Java中org.apache.hadoop.hbase.Cell.getValueLength()
方法的一些代码示例,展示了Cell.getValueLength()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cell.getValueLength()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.Cell
类名称:Cell
方法名:getValueLength
暂无
代码示例来源:origin: apache/hbase
public static ByteBuffer getValueBufferShallowCopy(Cell cell) {
ByteBuffer buffer =
ByteBuffer.wrap(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
return buffer;
}
代码示例来源:origin: apache/kylin
private void consume(Result r, int nBytesToConsume) {
Cell cell = r.getColumnLatestCell(CF, QN);
byte mix = 0;
byte[] valueArray = cell.getValueArray();
int n = Math.min(nBytesToConsume, cell.getValueLength());
for (int i = 0; i < n; i++) {
mix ^= valueArray[i];
bytesRead++;
}
discard(mix);
rowsRead++;
}
代码示例来源:origin: apache/hbase
/**
* Gets the mob file name from the mob ref cell.
* A mob ref cell has a mob reference tag.
* The value of a mob ref cell consists of two parts, real mob value length and mob file name.
* The real mob value length takes 4 bytes.
* The remaining part is the mob file name.
* @param cell The mob ref cell.
* @return The mob file name.
*/
public static String getMobFileName(Cell cell) {
return Bytes.toString(cell.getValueArray(), cell.getValueOffset() + Bytes.SIZEOF_INT,
cell.getValueLength() - Bytes.SIZEOF_INT);
}
代码示例来源:origin: apache/hbase
public static ByteRange fillValueRange(Cell cell, ByteRange range) {
return range.set(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
}
代码示例来源:origin: apache/hbase
private static long getReplicationBarrier(Cell c) {
return Bytes.toLong(c.getValueArray(), c.getValueOffset(), c.getValueLength());
}
代码示例来源:origin: apache/hbase
/**
* Returns the value wrapped in a new <code>ByteBuffer</code>.
*
* @param family family name
* @param qualifier column qualifier
*
* @return the latest version of the column, or <code>null</code> if none found
*/
public ByteBuffer getValueAsByteBuffer(byte [] family, byte [] qualifier) {
Cell kv = getColumnLatestCell(family, 0, family.length, qualifier, 0, qualifier.length);
if (kv == null) {
return null;
}
return ByteBuffer.wrap(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()).
asReadOnlyBuffer();
}
代码示例来源:origin: apache/hbase
@Override
public WALItem next() {
Result next = it.next();
List<Cell> cells = next.listCells();
byte[] buf = cells.get(0).getValueArray();
int len = cells.get(0).getValueLength();
int offset = cells.get(0).getValueOffset();
String backupId = new String(buf, offset, len);
buf = cells.get(1).getValueArray();
len = cells.get(1).getValueLength();
offset = cells.get(1).getValueOffset();
String walFile = new String(buf, offset, len);
buf = cells.get(2).getValueArray();
len = cells.get(2).getValueLength();
offset = cells.get(2).getValueOffset();
String backupRoot = new String(buf, offset, len);
return new WALItem(backupId, walFile, backupRoot);
}
代码示例来源:origin: apache/hbase
private static Optional<TableState> getTableState(Result r) throws IOException {
Cell cell = r.getColumnLatestCell(getTableFamily(), getStateColumn());
if (cell == null) return Optional.empty();
try {
return Optional.of(TableState.parseFrom(
TableName.valueOf(r.getRow()),
Arrays.copyOfRange(cell.getValueArray(), cell.getValueOffset(), cell.getValueOffset()
+ cell.getValueLength())));
} catch (DeserializationException e) {
throw new IOException("Failed to parse table state from result: " + r, e);
}
}
代码示例来源:origin: apache/hbase
/**
* Returns the value wrapped in a new <code>ByteBuffer</code>.
*
* @param family family name
* @param foffset family offset
* @param flength family length
* @param qualifier column qualifier
* @param qoffset qualifier offset
* @param qlength qualifier length
*
* @return the latest version of the column, or <code>null</code> if none found
*/
public ByteBuffer getValueAsByteBuffer(byte [] family, int foffset, int flength,
byte [] qualifier, int qoffset, int qlength) {
Cell kv = getColumnLatestCell(family, foffset, flength, qualifier, qoffset, qlength);
if (kv == null) {
return null;
}
return ByteBuffer.wrap(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()).
asReadOnlyBuffer();
}
代码示例来源:origin: apache/hbase
/**
* Converts the value bytes of the given cell into a BigDecimal
* @param cell
* @return value as BigDecimal
*/
public static BigDecimal getValueAsBigDecimal(Cell cell) {
if (cell instanceof ByteBufferExtendedCell) {
return ByteBufferUtils.toBigDecimal(((ByteBufferExtendedCell) cell).getValueByteBuffer(),
((ByteBufferExtendedCell) cell).getValuePosition(), cell.getValueLength());
}
return Bytes.toBigDecimal(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
}
代码示例来源:origin: apache/hbase
public static boolean matchingValue(final Cell left, final byte[] buf) {
if (left instanceof ByteBufferExtendedCell) {
return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getValueByteBuffer(),
((ByteBufferExtendedCell) left).getValuePosition(), left.getValueLength(), buf, 0,
buf.length) == 0;
}
return Bytes.equals(left.getValueArray(), left.getValueOffset(), left.getValueLength(), buf, 0,
buf.length);
}
代码示例来源:origin: apache/hbase
/**
* The latest seqnum that the server writing to meta observed when opening the region.
* E.g. the seqNum when the result of {@link #getServerName(Result, int)} was written.
* @param r Result to pull the seqNum from
* @return SeqNum, or HConstants.NO_SEQNUM if there's no value written.
*/
private static long getSeqNumDuringOpen(final Result r, final int replicaId) {
Cell cell = r.getColumnLatestCell(getCatalogFamily(), getSeqNumColumn(replicaId));
if (cell == null || cell.getValueLength() == 0) return HConstants.NO_SEQNUM;
return Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
}
代码示例来源:origin: apache/hbase
/**
* The latest seqnum that the server writing to meta observed when opening the region.
* E.g. the seqNum when the result of {@link #getServerName(Result, int)} was written.
* @param r Result to pull the seqNum from
* @return SeqNum, or HConstants.NO_SEQNUM if there's no value written.
*/
private static long getSeqNumDuringOpen(final Result r, final int replicaId) {
Cell cell = r.getColumnLatestCell(getCatalogFamily(), getSeqNumColumn(replicaId));
if (cell == null || cell.getValueLength() == 0) return HConstants.NO_SEQNUM;
return Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
}
代码示例来源:origin: apache/hbase
/**
* Returns the RegionInfo object from the column {@link HConstants#CATALOG_FAMILY} and
* <code>qualifier</code> of the catalog table result.
* @param r a Result object from the catalog table scan
* @param qualifier Column family qualifier
* @return An RegionInfo instance.
*/
private static Optional<RegionInfo> getHRegionInfo(final Result r, byte[] qualifier) {
Cell cell = r.getColumnLatestCell(getCatalogFamily(), qualifier);
if (cell == null) return Optional.empty();
return Optional.ofNullable(RegionInfo.parseFromOrNull(cell.getValueArray(),
cell.getValueOffset(), cell.getValueLength()));
}
代码示例来源:origin: apache/hbase
/**
* Loads the latest version of the specified column into the provided <code>ByteBuffer</code>.
* <p>
* Does not clear or flip the buffer.
*
* @param family family name
* @param foffset family offset
* @param flength family length
* @param qualifier column qualifier
* @param qoffset qualifier offset
* @param qlength qualifier length
* @param dst the buffer where to write the value
*
* @return <code>true</code> if a value was found, <code>false</code> otherwise
*
* @throws BufferOverflowException there is insufficient space remaining in the buffer
*/
public boolean loadValue(byte [] family, int foffset, int flength,
byte [] qualifier, int qoffset, int qlength, ByteBuffer dst)
throws BufferOverflowException {
Cell kv = getColumnLatestCell(family, foffset, flength, qualifier, qoffset, qlength);
if (kv == null) {
return false;
}
dst.put(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength());
return true;
}
代码示例来源:origin: apache/hbase
/**
* Pull the region state from a catalog table {@link Result}.
* @param r Result to pull the region state from
* @return the region state, or null if unknown.
*/
@VisibleForTesting
public static State getRegionState(final Result r, int replicaId) {
Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, getStateColumn(replicaId));
if (cell == null || cell.getValueLength() == 0) {
return null;
}
return State.valueOf(Bytes.toString(cell.getValueArray(), cell.getValueOffset(),
cell.getValueLength()));
}
代码示例来源:origin: apache/hbase
/**
* Compare cell's value against given comparator
* @param cell
* @param comparator
* @return result comparing cell's value
*/
public static int compareValue(Cell cell, ByteArrayComparable comparator) {
if (cell instanceof ByteBufferExtendedCell) {
return comparator.compareTo(((ByteBufferExtendedCell) cell).getValueByteBuffer(),
((ByteBufferExtendedCell) cell).getValuePosition(), cell.getValueLength());
}
return comparator.compareTo(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
}
代码示例来源:origin: apache/hbase
/**
* Parses the snapshot size from the given Cell's value.
*/
static long parseSnapshotSize(Cell c) throws InvalidProtocolBufferException {
ByteString bs = UnsafeByteOperations.unsafeWrap(
c.getValueArray(), c.getValueOffset(), c.getValueLength());
return QuotaProtos.SpaceQuotaSnapshot.parseFrom(bs).getQuotaUsage();
}
代码示例来源:origin: apache/hbase
/**
* Before 0.95, when you called Increment#getFamilyMap(), you got back
* a map of families to a list of Longs. Now, {@link #getFamilyCellMap()} returns
* families by list of Cells. This method has been added so you can have the
* old behavior.
* @return Map of families to a Map of qualifiers and their Long increments.
* @since 0.95.0
*/
public Map<byte[], NavigableMap<byte [], Long>> getFamilyMapOfLongs() {
NavigableMap<byte[], List<Cell>> map = super.getFamilyCellMap();
Map<byte [], NavigableMap<byte[], Long>> results = new TreeMap<>(Bytes.BYTES_COMPARATOR);
for (Map.Entry<byte [], List<Cell>> entry: map.entrySet()) {
NavigableMap<byte [], Long> longs = new TreeMap<>(Bytes.BYTES_COMPARATOR);
for (Cell cell: entry.getValue()) {
longs.put(CellUtil.cloneQualifier(cell),
Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
}
results.put(entry.getKey(), longs);
}
return results;
}
代码示例来源:origin: apache/hbase
/**
* Returns a {@link ServerName} from catalog table {@link Result}.
* @param r Result to pull from
* @return A ServerName instance.
*/
private static Optional<ServerName> getServerName(final Result r, final int replicaId) {
byte[] serverColumn = getServerColumn(replicaId);
Cell cell = r.getColumnLatestCell(getCatalogFamily(), serverColumn);
if (cell == null || cell.getValueLength() == 0) return Optional.empty();
String hostAndPort = Bytes.toString(cell.getValueArray(), cell.getValueOffset(),
cell.getValueLength());
byte[] startcodeColumn = getStartCodeColumn(replicaId);
cell = r.getColumnLatestCell(getCatalogFamily(), startcodeColumn);
if (cell == null || cell.getValueLength() == 0) return Optional.empty();
try {
return Optional.of(ServerName.valueOf(hostAndPort,
Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())));
} catch (IllegalArgumentException e) {
LOG.error("Ignoring invalid region for server " + hostAndPort + "; cell=" + cell, e);
return Optional.empty();
}
}
内容来源于网络,如有侵权,请联系作者删除!