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

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

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

Bytes.putLong介绍

[英]Put a long value out to the specified byte array position.
[中]将长值输出到指定的字节数组位置。

代码示例

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

/**
  * Write instance {@code val} into buffer {@code buff}.
  */
 public int encodeLong(byte[] buff, int offset, long val) {
  return Bytes.putLong(buff, offset, val);
 }
}

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

/**
 * @param bytes byte array
 * @param offset offset to write to
 * @param d value
 * @return New offset into array <code>bytes</code>
 */
public static int putDouble(byte [] bytes, int offset, double d) {
 return putLong(bytes, offset, Double.doubleToLongBits(d));
}

代码示例来源:origin: alibaba/canal

private static int encodeDouble(double v, byte[] b, int o) {
  checkForSufficientLength(b, o, Bytes.SIZEOF_LONG);
  long l = Double.doubleToLongBits(v);
  l = (l ^ ((l >> Long.SIZE - 1) | Long.MIN_VALUE)) + 1;
  Bytes.putLong(b, o, l);
  return Bytes.SIZEOF_LONG;
}

代码示例来源:origin: alibaba/canal

private static int encodeUnsignedLong(long v, byte[] b, int o) {
  checkForSufficientLength(b, o, Bytes.SIZEOF_LONG);
  if (v < 0) {
    throw new RuntimeException();
  }
  Bytes.putLong(b, o, v);
  return Bytes.SIZEOF_LONG;
}

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

/**
 * @return a unique ID incorporating IP address, PID, TID and timer. Might be an overkill...
 * Note though that new UUID in java by default is just a random number.
 */
public static byte[] generateClientId() {
 byte[] selfBytes = getIpAddressBytes();
 Long pid = getPid();
 long tid = Thread.currentThread().getId();
 long ts = System.currentTimeMillis();
 byte[] id = new byte[selfBytes.length + ((pid != null ? 1 : 0) + 2) * Bytes.SIZEOF_LONG];
 int offset = Bytes.putBytes(id, 0, selfBytes, 0, selfBytes.length);
 if (pid != null) {
  offset = Bytes.putLong(id, offset, pid);
 }
 offset = Bytes.putLong(id, offset, tid);
 offset = Bytes.putLong(id, offset, ts);
 assert offset == id.length;
 return id;
}

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

@Override
public int encode(PositionedByteRange dst, Long val) {
 Bytes.putLong(dst.getBytes(), dst.getOffset() + dst.getPosition(), val);
 return skip(dst);
}

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

Bytes.putLong(newKey, rightKey.length - TIMESTAMP_TYPE_SIZE, HConstants.LATEST_TIMESTAMP);
Bytes.putByte(newKey, rightKey.length - TYPE_SIZE, Type.Maximum.getCode());
return newKey;

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

pos = Bytes.putByte(bytes, pos, (byte)(flength & 0x0000ff));
pos += flength + qlength;
pos = Bytes.putLong(bytes, pos, timestamp);
pos = Bytes.putByte(bytes, pos, type.getCode());
pos += vlength;

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

@Test
public void testCopyFromArrayToBuffer() {
 byte[] b = new byte[15];
 b[0] = -1;
 long l = 988L;
 int i = 135;
 short s = 7;
 Bytes.putLong(b, 1, l);
 Bytes.putShort(b, 9, s);
 Bytes.putInt(b, 11, i);
 ByteBuffer buffer = ByteBuffer.allocate(14);
 ByteBufferUtils.copyFromArrayToBuffer(buffer, b, 1, 14);
 buffer.rewind();
 assertEquals(l, buffer.getLong());
 assertEquals(s, buffer.getShort());
 assertEquals(i, buffer.getInt());
}

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

public static int appendKeyTo(final Cell cell, final byte[] output,
  final int offset) {
 int nextOffset = offset;
 nextOffset = Bytes.putShort(output, nextOffset, cell.getRowLength());
 nextOffset = CellUtil.copyRowTo(cell, output, nextOffset);
 nextOffset = Bytes.putByte(output, nextOffset, cell.getFamilyLength());
 nextOffset = CellUtil.copyFamilyTo(cell, output, nextOffset);
 nextOffset = CellUtil.copyQualifierTo(cell, output, nextOffset);
 nextOffset = Bytes.putLong(output, nextOffset, cell.getTimestamp());
 nextOffset = Bytes.putByte(output, nextOffset, cell.getTypeByte());
 return nextOffset;
}

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

/**
 * Put the header into the given byte array at the given offset.
 * @param onDiskSize size of the block on disk header + data + checksum
 * @param uncompressedSize size of the block after decompression (but
 *          before optional data block decoding) including header
 * @param onDiskDataSize size of the block on disk with header
 *        and data but not including the checksums
 */
private void putHeader(byte[] dest, int offset, int onDiskSize,
  int uncompressedSize, int onDiskDataSize) {
 offset = blockType.put(dest, offset);
 offset = Bytes.putInt(dest, offset, onDiskSize - HConstants.HFILEBLOCK_HEADER_SIZE);
 offset = Bytes.putInt(dest, offset, uncompressedSize - HConstants.HFILEBLOCK_HEADER_SIZE);
 offset = Bytes.putLong(dest, offset, prevOffset);
 offset = Bytes.putByte(dest, offset, fileContext.getChecksumType().getCode());
 offset = Bytes.putInt(dest, offset, fileContext.getBytesPerChecksum());
 Bytes.putInt(dest, offset, onDiskDataSize);
}

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

Bytes.putLong(row, 0, byteSwapped);
 for (int j = 0; j < numBackReferencesPerRow; j++) {
  long referredRow = blockStart - BLOCK_SIZE + rand.nextInt(BLOCK_SIZE);
  Bytes.putLong(row, 0, swapLong(referredRow));
  p.addColumn(TEST_FAMILY, row, HConstants.EMPTY_BYTE_ARRAY);

代码示例来源:origin: forcedotcom/phoenix

@Override
public int encodeDouble(double v, byte[] b, int o) {
  long l = Double.doubleToLongBits(v);
  l = (l ^ ((l >> Long.SIZE - 1) | Long.MIN_VALUE)) + 1;
  Bytes.putLong(b, o, l);
  return Bytes.SIZEOF_LONG;
}

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

@Override
public int encodeDouble(double v, byte[] b, int o) {
 checkForSufficientLength(b, o, Bytes.SIZEOF_LONG);
 long l = Double.doubleToLongBits(v);
 l = (l ^ ((l >> Long.SIZE - 1) | Long.MIN_VALUE)) + 1;
 Bytes.putLong(b, o, l);
 return Bytes.SIZEOF_LONG;
}

代码示例来源:origin: forcedotcom/phoenix

@Override
  public int encodeLong(long v, byte[] b, int o) {
    if (v < 0) {
      throw new IllegalDataException();
    }
    Bytes.putLong(b, o, v);
    return Bytes.SIZEOF_LONG;
  }
}

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

pos = Bytes.putLong(bytes, pos, timestamp);
pos = Bytes.putByte(bytes, pos, type.getCode());
if (vlength > 0) {

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

current.timestamp = current.timestamp - timestampOrDiff;
Bytes.putLong(current.keyBuffer, pos, current.timestamp);
pos += Bytes.SIZEOF_LONG;

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

pos = Bytes.putBytes(buffer, pos, qualifier, qoffset, qlength);
pos = Bytes.putLong(buffer, pos, timestamp);
pos = Bytes.putByte(buffer, pos, type.getCode());
if (value != null && value.length > 0) {

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

pos = Bytes.putBytes(bytes, pos, qualifier, qoffset, qlength);
pos = Bytes.putLong(bytes, pos, timestamp);
pos = Bytes.putByte(bytes, pos, type.getCode());
if (value != null && value.length > 0) {

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

@Override
  public int encodeLong(long v, byte[] b, int o) {
    checkForSufficientLength(b, o, Bytes.SIZEOF_LONG);
    if (v < 0) {
      throw newIllegalDataException();
    }
    Bytes.putLong(b, o, v);
    return Bytes.SIZEOF_LONG;
  }
}

相关文章

微信公众号

最新文章

更多