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

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

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

Bytes.putShort介绍

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

代码示例

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

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

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

private static int encodeUnsignedShort(short v, byte[] b, int o) {
  checkForSufficientLength(b, o, Bytes.SIZEOF_SHORT);
  if (v < 0) {
    throw new RuntimeException();
  }
  Bytes.putShort(b, o, v);
  return Bytes.SIZEOF_SHORT;
}

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

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

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

pos = Bytes.putInt(bytes, pos, keylength);
pos = Bytes.putInt(bytes, pos, vlength);
pos = Bytes.putShort(bytes, pos, (short)(rlength & 0x0000ffff));
pos += rlength;
pos = Bytes.putByte(bytes, pos, (byte)(flength & 0x0000ff));

代码示例来源: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

pos = Bytes.putShort(backingArray, pos, (short)elemLen);
IOUtils.readFully(cin, backingArray, pos, elemLen);
pos += elemLen;

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

@Override
 public int encodeShort(short v, byte[] b, int o) {
   if (v < 0) {
     throw new IllegalDataException();
   }
   Bytes.putShort(b, o, v);
   return Bytes.SIZEOF_SHORT;
 }
}

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

pos = Bytes.putInt(buffer, pos, keyLength);
pos = Bytes.putInt(buffer, pos, vlength);
pos = Bytes.putShort(buffer, pos, (short)(rlength & 0x0000ffff));
pos = Bytes.putBytes(buffer, pos, row, roffset, rlength);
pos = Bytes.putByte(buffer, pos, (byte) (flength & 0x0000ff));

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

pos = Bytes.putInt(bytes, pos, keyLength);
pos = Bytes.putInt(bytes, pos, vlength);
pos = Bytes.putShort(bytes, pos, (short)(rlength & 0x0000ffff));
pos = Bytes.putBytes(bytes, pos, row, roffset, rlength);
pos = Bytes.putByte(bytes, pos, (byte)(flength & 0x0000ff));

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

pos = Bytes.putShort(bytes, pos, (short)(rlength & 0x0000ffff));
pos = Bytes.putBytes(bytes, pos, row, roffset, rlength);
pos = Bytes.putByte(bytes, pos, (byte)(flength & 0x0000ff));

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

/**
 * Serialize the value bit set into a byte array. The byte array
 * is expected to have enough room (use {@link #getEstimatedLength()}
 * to ensure enough room exists.
 * @param b the byte array into which to put the serialized bit set
 * @param offset the offset into the byte array
 * @return the incremented offset
 */
public int toBytes(byte[] b, int offset) {
  if (schema == null) {
    return offset;
  }
  // If the total number of possible values is bigger than 16 bits (the
  // size of a short), then serialize the long array followed by the
  // array length.
  if (isVarLength()) {
    short nLongs = (short)((maxSetBit + BITS_PER_LONG) / BITS_PER_LONG);
    for (int i = 0; i < nLongs; i++) {
      offset = Bytes.putLong(b, offset, bits[i]);
    }
    offset = Bytes.putShort(b, offset, nLongs);
  } else { 
    // Else if the number of values is less than or equal to 16,
    // serialize the bits directly into a short.
    offset = Bytes.putShort(b, offset, (short)bits[0]);            
  }
  return offset;
}

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

/**
 * Serialize the value bit set into a byte array. The byte array
 * is expected to have enough room (use {@link #getEstimatedLength()}
 * to ensure enough room exists.
 * @param b the byte array into which to put the serialized bit set
 * @param offset the offset into the byte array
 * @return the incremented offset
 */
public int toBytes(byte[] b, int offset) {
  if (schema == null) {
    return offset;
  }
  // If the total number of possible values is bigger than 16 bits (the
  // size of a short), then serialize the long array followed by the
  // array length.
  if (isVarLength()) {
    short nLongs = (short)((maxSetBit + BITS_PER_LONG - 1) / BITS_PER_LONG);
    for (int i = 0; i < nLongs; i++) {
      offset = Bytes.putLong(b, offset, bits[i]);
    }
    offset = Bytes.putShort(b, offset, nLongs);
  } else { 
    // Else if the number of values is less than or equal to 16,
    // serialize the bits directly into a short.
    offset = Bytes.putShort(b, offset, (short)bits[0]);            
  }
  return offset;
}

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

compression.getDictionary(CompressionContext.DictionaryIndex.ROW));
checkLength(elemLen, Short.MAX_VALUE);
pos = Bytes.putShort(backingArray, pos, (short)elemLen);
pos += elemLen;

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

@Override
 public int encodeShort(short v, byte[] b, int o) {
  checkForSufficientLength(b, o, Bytes.SIZEOF_SHORT);
  if (v < 0) {
   throw newIllegalDataException();
  }
  Bytes.putShort(b, o, v);
  return Bytes.SIZEOF_SHORT;
 }
}

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

int offsetArrayElementSize = useShortNew ? Bytes.SIZEOF_SHORT : Bytes.SIZEOF_INT;
if (useShortNew) {
  Bytes.putShort(newArray, currentPosition, (short)(0 - Short.MAX_VALUE));
} else {
  Bytes.putInt(newArray, currentPosition, 0);
  if (arrayBytes[offset + oldOffset] == QueryConstants.SEPARATOR_BYTE && nullsAtBeginning) {
    if (useShortNew) {
      Bytes.putShort(newArray, currentPosition, (short)(oldOffset - Short.MAX_VALUE));
    } else {
      Bytes.putInt(newArray, currentPosition, oldOffset);
      Bytes.putShort(newArray, currentPosition, (short)(oldOffset + offsetShift - Short.MAX_VALUE));
    } else {
      Bytes.putInt(newArray, currentPosition, oldOffset + offsetShift);

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

? (short) pos
            : (short) (pos - Short.MAX_VALUE);
Bytes.putShort(offsetArr, off, val);
off += Bytes.SIZEOF_SHORT;

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

System.arraycopy(arrayBytes, offset + offsetArrayPosition, newArray, newOffsetArrayPosition,
    offsetArrayLength);
Bytes.putShort(newArray, newOffsetArrayPosition + offsetArrayLength,
    (short)(newElementPosition - Short.MAX_VALUE));

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

int offset = getOffset(array1Bytes, index, !useIntArray1, array1BytesOffset
    + offsetArrayPositionArray1, serializationVersion1);
Bytes.putShort(newArray, currentPosition, (short)(offset - Short.MAX_VALUE));
currentPosition += Bytes.SIZEOF_SHORT;
int offset = getOffset(array2Bytes, index, !useIntArray2, array2BytesOffset
    + offsetArrayPositionArray2, serializationVersion2);
Bytes.putShort(newArray, currentPosition,
    (short)(offset + array2StartingPosition - Short.MAX_VALUE));
currentPosition += Bytes.SIZEOF_SHORT;
int offset = getOffset(array2Bytes, index, !useIntArray2, array2BytesOffset
    + offsetArrayPositionArray2, serializationVersion2);
Bytes.putShort(newArray, currentPosition, (short)(offset - array2FirstNonNullElementOffset
    + part2NonNullStartingPosition - Short.MAX_VALUE));
currentPosition += Bytes.SIZEOF_SHORT;

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

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

相关文章

微信公众号

最新文章

更多