org.apache.accumulo.core.data.Key.toPrintableString()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(121)

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

Key.toPrintableString介绍

[英]Returns an ASCII printable string form of the given byte array, treating the bytes as ASCII characters. See #appendPrintableString(byte[],int,int,int,StringBuilder) for caveats.
[中]返回给定字节数组的ASCII可打印字符串形式,将字节视为ASCII字符。有关注意事项,请参见#appendPrintableString(字节[],int,int,int,StringBuilder)。

代码示例

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

/**
  * Print the unencrypted parameters that tell the Crypto Service how to decrypt the file. This
  * information is useful for debugging if and how a file was encrypted.
  */
 private void printCryptoParams(Path path, FileSystem fs) {
  byte[] noCryptoBytes = new NoFileEncrypter().getDecryptionParameters();
  try (FSDataInputStream fsDis = fs.open(path)) {
   long fileLength = fs.getFileStatus(path).getLen();
   fsDis.seek(fileLength - 16 - Utils.Version.size() - (Long.BYTES));
   long cryptoParamOffset = fsDis.readLong();
   fsDis.seek(cryptoParamOffset);
   byte[] cryptoParams = CryptoUtils.readParams(fsDis);
   if (!Arrays.equals(noCryptoBytes, cryptoParams)) {
    System.out.println("Encrypted with Params: "
      + Key.toPrintableString(cryptoParams, 0, cryptoParams.length, cryptoParams.length));
   } else {
    System.out.println("No on disk encryption detected.");
   }
  } catch (IOException ioe) {
   log.error("Error reading crypto params", ioe);
  }
 }
}

代码示例来源:origin: NationalSecurityAgency/datawave

Text colVis, byte[] val) {
String labelString = new ColumnVisibility(colVis).toString();
String s = Key.toPrintableString(row, 0, row.length, Constants.MAX_DATA_TO_PRINT) + " "
        + Key.toPrintableString(colFamily, 0, colFamily.length, Constants.MAX_DATA_TO_PRINT) + ":"
        + Key.toPrintableString(colQualifier, 0, colQualifier.length, Constants.MAX_DATA_TO_PRINT) + " " + labelString + " "
        + (val == null ? "null" : String.valueOf(val.length) + " value bytes");

代码示例来源:origin: Accla/graphulo

public void PrintTableDebug(String table) throws TableNotFoundException {
  Scanner scanner;
//    try {
   scanner = connector.createScanner(table, Authorizations.EMPTY);
//    } catch (TableNotFoundException e) {
//      log.error("error scaning table "+table, e);
//      throw new RuntimeException(e);
//    }

  for (Map.Entry<Key, Value> entry : scanner) {
   byte[] b = entry.getValue().get();
   System.out.println(entry.getKey().toStringNoTime()+"    "+
     Key.toPrintableString(b, 0, b.length, 300));
  }
  scanner.close();
 }

相关文章