本文整理了Java中org.apache.hadoop.hbase.util.Bytes.tail()
方法的一些代码示例,展示了Bytes.tail()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.tail()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.util.Bytes
类名称:Bytes
方法名:tail
暂无
代码示例来源:origin: apache/hbase
@Override
public byte[] next() {
i++;
if (i == 0) return a;
if (i == num + 1) return b;
BigInteger curBI = startBI.add(intervalBI.multiply(BigInteger.valueOf(i)));
byte [] padded = curBI.toByteArray();
if (padded[1] == 0)
padded = tail(padded, padded.length - 2);
else
padded = tail(padded, padded.length - 1);
return padded;
}
代码示例来源:origin: apache/hive
keyRef.setData(Bytes.tail(e.getKey(), e.getKey().length-qualPrefix.length)); //cut prefix from hive's map key
}else{
代码示例来源:origin: com.sitewhere/sitewhere-hbase
/**
* Get encoding scheme from qualifier.
*
* @param qualifier
* @return
*/
public static byte[] getEncodingFromQualifier(byte[] qualifier) {
int encLength = qualifier.length - 4;
return Bytes.tail(qualifier, encLength);
}
代码示例来源:origin: dbs-leipzig/gradoop
/**
* Get the original key by the given key with a prefix.
*
* @param adjustedKey the key with a prefix
* @return the original key without the prefix
*/
public byte[] getOriginalKey(byte[] adjustedKey) {
return Bytes.tail(adjustedKey, adjustedKey.length - 1);
}
代码示例来源:origin: sematext/HBaseWD
@Override
public byte[] getOriginalKey(byte[] adjustedKey) {
return Bytes.tail(adjustedKey, adjustedKey.length - 1);
}
代码示例来源:origin: cdapio/cdap
@Override
public byte[] getOriginalKey(byte[] adjustedKey) {
return Bytes.tail(adjustedKey, adjustedKey.length - 1);
}
代码示例来源:origin: co.cask.cdap/cdap-hbase-compat-base
@Override
public byte[] getOriginalKey(byte[] adjustedKey) {
return Bytes.tail(adjustedKey, adjustedKey.length - 1);
}
代码示例来源:origin: KylinOLAP/Kylin
byte[] key = rowkey.getBytes();
byte[] header = Bytes.head(key, 26);
byte[] sellerId = Bytes.tail(header, 18);
byte[] cuboidId = Bytes.head(header, 8);
byte[] restKey = Bytes.tail(key, rowkey.getLength() - 26);
代码示例来源:origin: KylinOLAP/Kylin
@Test
public void testMapperWithHeader() throws Exception {
String cubeName = "test_kylin_cube_with_slr_1_new_segment";
String segmentName = "20130331080000_20131212080000";
mapDriver.getConfiguration().set(BatchConstants.CFG_CUBE_NAME, cubeName);
mapDriver.getConfiguration().set(BatchConstants.CFG_CUBE_SEGMENT_NAME, segmentName);
// mapDriver.getConfiguration().set(BatchConstants.CFG_METADATA_URL,
// metadata);
mapDriver.withInput(new Text("key"), new Text("2012-12-15118480Health & BeautyFragrancesWomenAuction15123456789132.33"));
List<Pair<Text, Text>> result = mapDriver.run();
CubeManager cubeMgr = CubeManager.getInstance(getTestConfig());
CubeInstance cube = cubeMgr.getCube(cubeName);
assertEquals(1, result.size());
Text rowkey = result.get(0).getFirst();
byte[] key = rowkey.getBytes();
byte[] header = Bytes.head(key, 26);
byte[] sellerId = Bytes.tail(header, 18);
byte[] cuboidId = Bytes.head(header, 8);
byte[] restKey = Bytes.tail(key, rowkey.getLength() - 26);
RowKeyDecoder decoder = new RowKeyDecoder(cube.getFirstSegment());
decoder.decode(key);
assertEquals("[123456789, 2012-12-15, 11848, Health & Beauty, Fragrances, Women, Auction, 0, 15]", decoder.getValues().toString());
assertTrue(Bytes.toString(sellerId).startsWith("123456789"));
assertEquals(511, Bytes.toLong(cuboidId));
assertEquals(22, restKey.length);
verifyMeasures(cube.getDescriptor().getMeasures(), result.get(0).getSecond(), "132.33", "132.33", "132.33");
}
代码示例来源:origin: co.cask.hbase/hbase
@Override
public byte[] next() {
i++;
if (i == 0) return a;
if (i == num + 1) return b;
BigInteger curBI = startBI.add(intervalBI.multiply(BigInteger.valueOf(i)));
byte [] padded = curBI.toByteArray();
if (padded[1] == 0)
padded = tail(padded, padded.length - 2);
else
padded = tail(padded, padded.length - 1);
return padded;
}
代码示例来源:origin: org.apache.hbase/hbase-common
@Override
public byte[] next() {
i++;
if (i == 0) return a;
if (i == num + 1) return b;
BigInteger curBI = startBI.add(intervalBI.multiply(BigInteger.valueOf(i)));
byte [] padded = curBI.toByteArray();
if (padded[1] == 0)
padded = tail(padded, padded.length - 2);
else
padded = tail(padded, padded.length - 1);
return padded;
}
代码示例来源:origin: com.aliyun.hbase/alihbase-common
@Override
public byte[] next() {
i++;
if (i == 0) return a;
if (i == num + 1) return b;
BigInteger curBI = startBI.add(intervalBI.multiply(BigInteger.valueOf(i)));
byte [] padded = curBI.toByteArray();
if (padded[1] == 0)
padded = tail(padded, padded.length - 2);
else
padded = tail(padded, padded.length - 1);
return padded;
}
代码示例来源:origin: harbby/presto-connectors
@Override
public byte[] next() {
i++;
if (i == 0) return a;
if (i == num + 1) return b;
BigInteger curBI = startBI.add(intervalBI.multiply(BigInteger.valueOf(i)));
byte [] padded = curBI.toByteArray();
if (padded[1] == 0)
padded = tail(padded, padded.length - 2);
else
padded = tail(padded, padded.length - 1);
return padded;
}
代码示例来源:origin: cdapio/cdap
@Override
public byte[] getOriginalKey(byte[] adjustedKey) {
int prefixLength = hasher.getPrefixLength(adjustedKey);
if (prefixLength > 0) {
return Bytes.tail(adjustedKey, adjustedKey.length - prefixLength);
} else {
return adjustedKey;
}
}
代码示例来源:origin: co.cask.cdap/cdap-hbase-compat-base
@Override
public byte[] getOriginalKey(byte[] adjustedKey) {
int prefixLength = hasher.getPrefixLength(adjustedKey);
if (prefixLength > 0) {
return Bytes.tail(adjustedKey, adjustedKey.length - prefixLength);
} else {
return adjustedKey;
}
}
代码示例来源:origin: sematext/HBaseWD
@Override
public byte[] getOriginalKey(byte[] adjustedKey) {
int prefixLength = hasher.getPrefixLength(adjustedKey);
if (prefixLength > 0) {
return Bytes.tail(adjustedKey, adjustedKey.length - prefixLength);
} else {
return adjustedKey;
}
}
代码示例来源:origin: com.twitter.hraven/hraven-core
/**
* Converts serialized configuration properties back in to a Configuration
* object.
*
* @param keyValues
* @return
*/
public static Configuration parseConfiguration(
Map<byte[], byte[]> keyValues) {
Configuration config = new Configuration(false);
byte[] configPrefix =
Bytes.add(Constants.JOB_CONF_COLUMN_PREFIX_BYTES, Constants.SEP_BYTES);
for (Map.Entry<byte[], byte[]> entry : keyValues.entrySet()) {
byte[] key = entry.getKey();
if (Bytes.startsWith(key, configPrefix)
&& key.length > configPrefix.length) {
byte[] name = Bytes.tail(key, key.length - configPrefix.length);
config.set(Bytes.toString(name), Bytes.toString(entry.getValue()));
}
}
return config;
}
代码示例来源:origin: NGDATA/hbase-indexer
private void extractWithDynamicOutputFieldNames(Result result, Record record) {
Iterator<byte[]> iter = extractor.extract(result).iterator();
NavigableMap<byte[], byte[]> qualifiersToValues = result.getFamilyMap(columnFamily);
if (qualifiersToValues != null) {
for (byte[] matchingQualifier : qualifiersToValues.navigableKeySet().tailSet(qualifier)) {
if (Bytes.startsWith(matchingQualifier, qualifier)) {
byte[] tail = Bytes.tail(matchingQualifier, matchingQualifier.length - qualifier.length);
String outputField = outputFieldName + Bytes.toString(tail);
for (Object value : byteArrayMapper.map(iter.next())) {
record.put(outputField, value);
}
} else {
break;
}
}
assert !iter.hasNext();
}
}
代码示例来源:origin: com.sitewhere/sitewhere-hbase
/**
* Decodes an event id into a {@link KeyValue} that can be used to access
* the data in HBase.
*
* @param id
* @return
* @throws SiteWhereException
*/
public static byte[][] getDecodedEventId(String id) throws SiteWhereException {
int rowLength = HBaseSite.SITE_IDENTIFIER_LENGTH + 1 + HBaseDeviceAssignment.ASSIGNMENT_IDENTIFIER_LENGTH + 5;
try {
byte[] decoded = Base58.decode(id);
byte[] row = Bytes.head(decoded, rowLength);
byte[] qual = Bytes.tail(decoded, decoded.length - rowLength);
return new byte[][] { row, qual };
} catch (AddressFormatException e) {
throw new SiteWhereException("Invalid event id: " + id);
}
}
代码示例来源:origin: com.ngdata/hbase-indexer-morphlines
private void extractWithDynamicOutputFieldNames(Result result, Record record) {
Iterator<byte[]> iter = extractor.extract(result).iterator();
NavigableMap<byte[], byte[]> qualifiersToValues = result.getFamilyMap(columnFamily);
if (qualifiersToValues != null) {
for (byte[] matchingQualifier : qualifiersToValues.navigableKeySet().tailSet(qualifier)) {
if (Bytes.startsWith(matchingQualifier, qualifier)) {
byte[] tail = Bytes.tail(matchingQualifier, matchingQualifier.length - qualifier.length);
String outputField = outputFieldName + Bytes.toString(tail);
for (Object value : byteArrayMapper.map(iter.next())) {
record.put(outputField, value);
}
} else {
break;
}
}
assert !iter.hasNext();
}
}
内容来源于网络,如有侵权,请联系作者删除!