org.apache.hadoop.hbase.util.Bytes.toHex()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中org.apache.hadoop.hbase.util.Bytes.toHex()方法的一些代码示例,展示了Bytes.toHex()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.toHex()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.util.Bytes
类名称:Bytes
方法名:toHex

Bytes.toHex介绍

[英]Convert a byte array into a hex string
[中]将字节数组转换为十六进制字符串

代码示例

代码示例来源:origin: apache/hbase

/**
 * Convert a byte array into a hex string
 */
public static String toHex(byte[] b) {
 return toHex(b, 0, b.length);
}

代码示例来源:origin: apache/hbase

@Override
public String toString() {
 StringBuilder sb = new StringBuilder();
 sb.append("tableName=").append(tableName);
 if (families != null) {
  sb.append(", families=").append(families);
 }
 sb.append(", batchSize=").append(batchSize);
 sb.append(", numHashFiles=").append(numHashFiles);
 if (!isTableStartRow(startRow)) {
  sb.append(", startRowHex=").append(Bytes.toHex(startRow));
 }
 if (!isTableEndRow(stopRow)) {
  sb.append(", stopRowHex=").append(Bytes.toHex(stopRow));
 }
 if (scanBatch >= 0) {
  sb.append(", scanBatch=").append(scanBatch);
 }
 if (versions >= 0) {
  sb.append(", versions=").append(versions);
 }
 if (startTime != 0) {
  sb.append("startTime=").append(startTime);
 }
 if (endTime != 0) {
  sb.append("endTime=").append(endTime);
 }
 return sb.toString();
}

代码示例来源:origin: apache/hbase

void writePropertiesFile(FileSystem fs, Path path) throws IOException {
 Properties p = new Properties();
 p.setProperty("table", tableName);
 if (families != null) {
  p.setProperty("columnFamilies", families);
 }
 p.setProperty("targetBatchSize", Long.toString(batchSize));
 p.setProperty("numHashFiles", Integer.toString(numHashFiles));
 if (!isTableStartRow(startRow)) {
  p.setProperty("startRowHex", Bytes.toHex(startRow));
 }
 if (!isTableEndRow(stopRow)) {
  p.setProperty("stopRowHex", Bytes.toHex(stopRow));
 }
 if (scanBatch > 0) {
  p.setProperty("scanBatch", Integer.toString(scanBatch));
 }
 if (versions >= 0) {
  p.setProperty("versions", Integer.toString(versions));
 }
 if (startTime != 0) {
  p.setProperty("startTimestamp", Long.toString(startTime));
 }
 if (endTime != 0) {
  p.setProperty("endTimestamp", Long.toString(endTime));
 }
 try (OutputStreamWriter osw = new OutputStreamWriter(fs.create(path), Charsets.UTF_8)) {
  p.store(osw, null);
 }
}

代码示例来源:origin: apache/hbase

String byteString = Bytes.toHex((byte[])object);
 builder.append("'").append(escape(byteString)).append("'");
} else {

代码示例来源:origin: apache/hbase

private static String toHex(ImmutableBytesWritable bytes) {
 return Bytes.toHex(bytes.get(), bytes.getOffset(), bytes.getLength());
}

代码示例来源:origin: apache/hbase

String result = Bytes.toHex(byteData);
Assert.assertTrue(testString.equalsIgnoreCase(result));
String hexString = Bytes.toHex(testData);
Assert.assertEquals(testData.length * 2, hexString.length());
byte[] result = Bytes.fromHex(hexString);

代码示例来源:origin: apache/hbase

LOG.debug("Different values: ");
LOG.debug("  source cell: " + sourceCell
  + " value: " + Bytes.toHex(sourceCell.getValueArray(),
    sourceCell.getValueOffset(), sourceCell.getValueLength()));
LOG.debug("  target cell: " + targetCell
  + " value: " + Bytes.toHex(targetCell.getValueArray(),
    targetCell.getValueOffset(), targetCell.getValueLength()));

代码示例来源:origin: apache/hbase

throw new IOException("Why the RegionScanner#nextRaw returns the data of different"
  + " rows?? first row="
  + Bytes.toHex(firstCell.getRowArray(), firstCell.getRowOffset(),
   firstCell.getRowLength())
  + ", current row="
  + Bytes.toHex(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()));

代码示例来源:origin: apache/hbase

if (rowComparison < 0) {
 if (LOG.isInfoEnabled()) {
  LOG.info("Target missing row: " + Bytes.toHex(nextSourceRow));
  LOG.info("Source missing row: " + Bytes.toHex(nextTargetRow));

代码示例来源:origin: apache/hbase

ImmutableBytesWritable hash = new ImmutableBytesWritable();
while(reader.next(key, hash)) {
 String keyString = Bytes.toHex(key.get(), key.getOffset(), key.getLength());
 LOG.debug("Key: " + (keyString.isEmpty() ? "-1" : Integer.parseInt(keyString, 16))
   + " Hash: " + Bytes.toHex(hash.get(), hash.getOffset(), hash.getLength()));

代码示例来源:origin: org.apache.hbase/hbase-common

/**
 * Convert a byte array into a hex string
 */
public static String toHex(byte[] b) {
 return toHex(b, 0, b.length);
}

代码示例来源:origin: com.aliyun.hbase/alihbase-common

/**
 * Convert a byte array into a hex string
 */
public static String toHex(byte[] b) {
 return toHex(b, 0, b.length);
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Convert a byte array into a hex string
 */
public static String toHex(byte[] b) {
 return toHex(b, 0, b.length);
}

代码示例来源:origin: com.aliyun.hbase/alihbase-mapreduce

@Override
public String toString() {
 StringBuilder sb = new StringBuilder();
 sb.append("tableName=").append(tableName);
 if (families != null) {
  sb.append(", families=").append(families);
 }
 sb.append(", batchSize=").append(batchSize);
 sb.append(", numHashFiles=").append(numHashFiles);
 if (!isTableStartRow(startRow)) {
  sb.append(", startRowHex=").append(Bytes.toHex(startRow));
 }
 if (!isTableEndRow(stopRow)) {
  sb.append(", stopRowHex=").append(Bytes.toHex(stopRow));
 }
 if (scanBatch >= 0) {
  sb.append(", scanBatch=").append(scanBatch);
 }
 if (versions >= 0) {
  sb.append(", versions=").append(versions);
 }
 if (startTime != 0) {
  sb.append("startTime=").append(startTime);
 }
 if (endTime != 0) {
  sb.append("endTime=").append(endTime);
 }
 return sb.toString();
}

代码示例来源:origin: org.apache.hbase/hbase-mapreduce

private static String toHex(ImmutableBytesWritable bytes) {
 return Bytes.toHex(bytes.get(), bytes.getOffset(), bytes.getLength());
}

代码示例来源:origin: harbby/presto-connectors

private static String toHex(ImmutableBytesWritable bytes) {
 return Bytes.toHex(bytes.get(), bytes.getOffset(), bytes.getLength());
}

代码示例来源:origin: com.aliyun.hbase/alihbase-mapreduce

private static String toHex(ImmutableBytesWritable bytes) {
 return Bytes.toHex(bytes.get(), bytes.getOffset(), bytes.getLength());
}

代码示例来源:origin: opencb/opencga

void assertOrder(List<byte[]> bytes, int expectedSize) {
    String prev = "0";
    for (byte[] bytesKey : bytes) {
      String key = new String(bytesKey);
      if (StringUtils.isAsciiPrintable(key)) {
        System.out.println("key = " + key);
      } else {
        System.out.println("key = " + Bytes.toHex(bytesKey));
      }
//            System.out.println(prev + ".compareTo(" + key + ") = " + prev.compareTo(key));
      assertTrue(prev.compareTo(key) < 0);
      prev = key;
    }
    assertEquals(expectedSize, bytes.size());
  }

代码示例来源:origin: opencb/opencga

@Override
protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException,
    InterruptedException {
  String hexBytes = Bytes.toHex(key.get());
  Cell[] cells = value.rawCells();
  try {
    if (cells.length < 2) {
      context.getCounter("opencga", "row.empty").increment(1);
      return;
    }
    context.getCounter("opencga", "variant.read").increment(1);
    logger.info("Convert ... ");
    long start = System.nanoTime();
    Variant variant = this.getHbaseToVariantConverter().convert(value);
    if (!requireAnnotation(variant)) {
      context.getCounter("opencga", "variant.no-annotation-required").increment(1);
      return; // No annotation needed
    }
    logger.info("Add to annotate set {} [convert time: {}] ... ", variant, System.nanoTime() - start);
    variantsToAnnotate.add(variant);
  } catch (Exception e) {
    throw new IllegalStateException("Problems with row [hex:" + hexBytes + "] for cells " + cells.length, e);
  }
}

代码示例来源:origin: opencb/opencga

@Override
  protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException {
    boolean done = false;
    try {
      Variant variant = this.getHbaseToVariantConverter().convert(value);
      List<VariantStatsWrapper> annotations = this.variantStatisticsCalculator.calculateBatch(
          Collections.singletonList(variant), this.studyId, this.samples);
      for (VariantStatsWrapper annotation : annotations) {
        Put convert = this.variantStatsToHBaseConverter.convert(annotation);
        if (null != convert) {
          context.write(key, convert);
          done = true;
          context.getCounter(VariantsTableMapReduceHelper.COUNTER_GROUP_NAME, "stats.put").increment(1);
        }
      }
      if (done) {
        context.getCounter(VariantsTableMapReduceHelper.COUNTER_GROUP_NAME, "variants").increment(1);
      }
    } catch (IllegalStateException e) {
      throw new IllegalStateException("Problem with row [hex:" + Bytes.toHex(key.copyBytes()) + "]", e);
    }
  }
}

相关文章

微信公众号

最新文章

更多