コード例 #1
0
ファイル: ByteValue.java プロジェクト: Tommy-Neubert/ozone
 @Override
 public void copyNormalizedKey(MemorySegment target, int offset, int len) {
   if (len == 1) {
     // default case, full normalized key. need to explicitly convert to int to
     // avoid false results due to implicit type conversion to int when subtracting
     // the min byte value
     int highByte = this.value & 0xff;
     highByte -= Byte.MIN_VALUE;
     target.put(offset, (byte) highByte);
   } else if (len <= 0) {
   } else {
     int highByte = this.value & 0xff;
     highByte -= Byte.MIN_VALUE;
     target.put(offset, (byte) highByte);
     for (int i = 1; i < len; i++) {
       target.put(offset + i, (byte) 0);
     }
   }
 }
コード例 #2
0
  @Override
  public void putNormalizedKey(String record, MemorySegment target, int offset, int len) {
    ;
    final int limit = offset + len;
    final int end = record.length();
    int pos = 0;

    while (pos < end && offset < limit) {
      char c = record.charAt(pos++);
      if (c < HIGH_BIT) {
        target.put(offset++, (byte) c);
      } else if (c < HIGH_BIT2) {
        target.put(offset++, (byte) ((c >>> 7) | HIGH_BIT));
        if (offset < limit) target.put(offset++, (byte) c);
      } else {
        target.put(offset++, (byte) ((c >>> 10) | HIGH_BIT2_MASK));
        if (offset < limit) target.put(offset++, (byte) (c >>> 2));
        if (offset < limit) target.put(offset++, (byte) c);
      }
    }
    while (offset < limit) {
      target.put(offset++, (byte) 0);
    }
  }