org.apache.kylin.common.util.Bytes.toString()方法的使用及代码示例

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

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

Bytes.toString介绍

暂无

代码示例

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

/**
 * Joins two byte arrays together using a separator.
 *
 * @param b1  The first byte array.
 * @param sep The separator to use.
 * @param b2  The second byte array.
 */
public static String toString(final byte[] b1, String sep, final byte[] b2) {
  return toString(b1, 0, b1.length) + sep + toString(b2, 0, b2.length);
}

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

/**
 * @param b Presumed UTF-8 encoded byte array.
 * @return String made from <code>b</code>
 */
public static String toString(final byte[] b) {
  if (b == null) {
    return null;
  }
  return toString(b, 0, b.length);
}

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

@Override
public String convertFromBytes(byte[] b, int offset, int length) {
  return Bytes.toString(b, offset, length);
}

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

/**
 * Reads a fixed-size field and interprets it as a string padded with zeros.
 */
public static String readStringFixedSize(final DataInput in, int size) throws IOException {
  byte[] b = new byte[size];
  in.readFully(b);
  int n = b.length;
  while (n > 0 && b[n - 1] == 0)
    --n;
  return toString(b, 0, n);
}

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

@Override
  public String[] call(Text text) throws Exception {
    String s = Bytes.toString(text.getBytes(), 0, text.getLength());
    return s.split(BatchConstants.SEQUENCE_FILE_DEFAULT_DELIMITER, -1);
  }
});

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

@Override
public Collection<String[]> parseMapperInput(Object mapperInput) {
  Text text = (Text) mapperInput;
  String[] columns = Bytes.toString(text.getBytes(), 0, text.getLength()).split(delimiter, -1);
  return Collections.singletonList(columns);
}

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

private void fillKeys(byte[] rowKey, String[] result) {
  int keyNum = keyIndexes.length;
  ByteBuffer byteBuffer = ByteBuffer.wrap(rowKey);
  byteBuffer.getShort(); // read shard
  for (int i = 0; i < keyNum; i++) {
    short keyLen = byteBuffer.getShort();
    byte[] keyBytes = new byte[keyLen];
    byteBuffer.get(keyBytes);
    result[keyIndexes[i]] = Bytes.toString(keyBytes);
  }
}

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

@Override
public String toString() {
  StringBuilder buf = new StringBuilder();
  buf.append("[");
  for (int i = 0; i < bufferSize; i++) {
    if (i > 0)
      buf.append(", ");
    buf.append(Bytes.toString(splitBuffers[i].value, 0, splitBuffers[i].length));
  }
  return buf.toString();
}

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

@Override
public String nextLine() throws IOException {
  boolean hasNext = reader.next(key, value);
  if (hasNext)
    return Bytes.toString(value.getBytes(), 0, value.getLength());
  else
    return null;
}

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

private void fillValues(Map<byte[], byte[]> qualifierValMap, String[] result) {
  for (Entry<byte[], byte[]> qualifierValEntry : qualifierValMap.entrySet()) {
    byte[] qualifier = qualifierValEntry.getKey();
    byte[] value = qualifierValEntry.getValue();
    int valIdx = Integer.parseInt(Bytes.toString(qualifier));
    result[valIdx] = fromBytes(value);
  }
}

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

@Override
public String decode(byte[] bytes, int offset, int len) {
  if (isNull(bytes, offset, len)) {
    return null;
  }
  while (len > 0 && bytes[offset + len - 1] == ROWKEY_PLACE_HOLDER_BYTE)
    len--;
  return Bytes.toString(bytes, offset, len);
}

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

protected String fromBytes(byte[] bytes) {
    if (DimensionEncoding.isNull(bytes, 0, bytes.length)) {
      return null;
    }
    return Bytes.toString(bytes);
  }
}

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

@Override
public void reload(Object measureValue) {
  if (measureValue == null) {
    value = null;
    return;
  }
  ByteArray byteArray = (ByteArray) measureValue;
  //the array in ByteArray is guaranteed to be completed owned by the ByteArray
  value = Bytes.toString(byteArray.array());
}

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

private void saveResource(byte[] content, String path) throws IOException {
  System.out.println("Generated " + outputStore.getReadableResourcePath(path));
  if (outprint) {
    System.out.println(Bytes.toString(content));
  }
  outputStore.putResource(path, new ByteArrayInputStream(content), System.currentTimeMillis());
}

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

@Override
public void doReduce(SelfDefineSortableKey skey, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
  Text key = skey.getText();
  String value = Bytes.toString(key.getBytes(), 1, key.getLength() - 1);
  builder.addValue(value);
}

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

@Override
public String convertFromBytes(byte[] b, int offset, int length) {
  NumberBytesCodec codec = getCodec(this.maxDigitsBeforeDecimalPoint);
  byte[] backup = codec.buf;
  codec.buf = b;
  codec.bufOffset = offset;
  codec.bufLen = length;
  int len = codec.decodeNumber(backup, 0);
  codec.buf = backup;
  return Bytes.toString(backup, 0, len);
}

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

private String printKey(SelfDefineSortableKey key) {
  Text data = key.getText();
  String fieldValue = Bytes.toString(data.getBytes(), 1, data.getLength() - 1);
  System.out.println("type flag:" + key.getTypeId() + " fieldValue:" + fieldValue);
  return fieldValue;
}

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

private String decodeNumber(String code) {
  byte[] buf = Bytes.toBytes(code);
  System.arraycopy(buf, 0, codec.buf, 0, buf.length);
  codec.bufOffset = 0;
  codec.bufLen = buf.length;
  int len = codec.decodeNumber(buf, 0);
  return Bytes.toString(buf, 0, len);
}

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

private String encodeNumber(String number) {
  byte[] num1 = Bytes.toBytes(number);
  codec.encodeNumber(num1, 0, num1.length);
  return Bytes.toString(codec.buf, codec.bufOffset, codec.bufLen);
}

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

@Test
public void testEnDeCode() {
  HBaseLookupRowEncoder lookupRowEncoder = new HBaseLookupRowEncoder(tableDesc, new String[] { "COUNTRY" }, 1);
  String[] row = new String[] { "AD", "42.546245", "1.601554", "Andorra" };
  HBaseRow hBaseRow = lookupRowEncoder.encode(row);
  assertEquals(6, hBaseRow.getRowKey().length);
  assertEquals(3, hBaseRow.getQualifierValMap().size());
  NavigableMap<byte[], byte[]> qualifierMap = hBaseRow.getQualifierValMap();
  assertEquals("42.546245", Bytes.toString(qualifierMap.get(Bytes.toBytes("1"))));
  assertEquals("1.601554", Bytes.toString(qualifierMap.get(Bytes.toBytes("2"))));
  String[] decodeRow = lookupRowEncoder.decode(hBaseRow);
  assertArrayEquals(row, decodeRow);
}

相关文章