private int getChildOffset(int n) { long offset = headSize + (BytesUtil.readLong(trieBytes, n, sizeChildOffset) & childOffsetMask); assert offset < trieBytes.length; return (int) offset; }
@Override public Object deserialize(ByteBuffer buf) { return BytesUtil.readLong(buf); }
@Override public Long deserialize(ByteBuffer in) { return BytesUtil.readLong(in); }
@Override public String decode(byte[] bytes, int offset, int len) { if (isNull(bytes, offset, len)) { return null; } int x = (int) BytesUtil.readLong(bytes, offset, len); if (x >= ALLOWED_VALUES.length) { throw new IllegalStateException(); } return ALLOWED_VALUES[x]; }
@Override public String decode(byte[] bytes, int offset, int len) { if (isNull(bytes, offset, len)) { return null; } long integer = BytesUtil.readLong(bytes, offset, len) - CAP[fixedLen]; //only take useful bytes integer = integer & MASK[fixedLen]; boolean positive = (integer & ((0x80L) << ((fixedLen - 1) << 3))) == 0; if (!positive) { integer |= (~MASK[fixedLen]); } return String.valueOf(integer); }
@Override public String decode(byte[] bytes, int offset, int len) { if (isNull(bytes, offset, len)) { return null; } long integer = BytesUtil.readLong(bytes, offset, len); return String.valueOf(integer); }
@Override public int hashCode() { if (data == null) { return 0; } else { if (length <= Bytes.SIZEOF_LONG && length > 0) { // to avoid hash collision of byte arrays those are converted from nearby integers/longs, which is the case for kylin dictionary long value = BytesUtil.readLong(data, offset, length); return (int) (value ^ (value >>> 32)); } return Bytes.hashCode(data, offset, length); } }
@Override public String decode(byte[] bytes, int offset, int len) { if (isNull(bytes, offset, len)) { return null; } long code = BytesUtil.readLong(bytes, offset, fixedLen); if (code < 0) throw new IllegalArgumentException(); return codec.codeToValue(code); }
public byte[] getFirstValue() { int nodeOffset = headSize; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); while (true) { int valueLen = BytesUtil.readUnsigned(trieBytes, nodeOffset + firstByteOffset - 1, 1); bytes.write(trieBytes, nodeOffset + firstByteOffset, valueLen); if (checkFlag(nodeOffset, BIT_IS_END_OF_VALUE)) { break; } nodeOffset = headSize + (int) (BytesUtil.readLong(trieBytes, nodeOffset, sizeChildOffset) & childOffsetMask); if (nodeOffset == headSize) { break; } } return bytes.toByteArray(); }
private long encode(String value) { enc.encode(value, buf, 0); return BytesUtil.readLong(buf, 0, buf.length); }
private long encode(String value) { enc.encode(value, buf, 0); return BytesUtil.readLong(buf, 0, buf.length); }
int childOffset = (int) (BytesUtil.readLong(trieBytes, offset, sizeChildOffset) & childOffsetMask); int parLen = BytesUtil.readUnsigned(trieBytes, p - 1, 1); boolean isEndOfValue = checkFlag(offset, BIT_IS_END_OF_VALUE);
long ttt = BytesUtil.readLong(bytes, 2, 8); System.out.println(time(ttt));
private AppendDictNode rebuildTrieTreeR(int n, AppendDictNode parent) { AppendDictNode root = null; while (true) { int p = n + firstByteOffset; int childOffset = (int) (BytesUtil.readLong(trieBytes, n, sizeChildOffset) & childOffsetMask); int parLen = BytesUtil.readUnsigned(trieBytes, p - 1, 1); boolean isEndOfValue = checkFlag(n, BIT_IS_END_OF_VALUE); byte[] value = new byte[parLen]; System.arraycopy(trieBytes, p, value, 0, parLen); AppendDictNode node = new AppendDictNode(value, isEndOfValue); if (isEndOfValue) { int id = BytesUtil.readUnsigned(trieBytes, p + parLen, sizeOfId); node.id = id; } if (parent == null) { root = node; } else { parent.addChild(node); } if (childOffset != 0) { rebuildTrieTreeR(childOffset + headSize, node); } if (checkFlag(n, BIT_IS_LAST_CHILD)) { break; } else { n += firstByteOffset + parLen + (isEndOfValue ? sizeOfId : 0); } } return root; }
int c = headSize + (int) (BytesUtil.readLong(trieBytes, n, sizeChildOffset) & childOffsetMask); if (c == headSize) // has no children return -1;
@Override public LongWritable read(byte[] buf, int offset) { current.set(BytesUtil.readLong(buf, offset, SIZE)); return current; }
private void decodeKey(ImmutableBytesWritable k) { byte[] buf = k.get(); int i = k.getOffset(); curShard = (short) BytesUtil.readUnsigned(buf, i, SHARD_LEN); i += SHARD_LEN; curSliceTimestamp = BytesUtil.readLong(buf, i, TIMEPART_LEN); i += TIMEPART_LEN; curCol = BytesUtil.readUnsigned(buf, i, COLNO_LEN); i += COLNO_LEN; if (i - k.getOffset() < k.getLength()) { // bitmap int colLen = info.length(curCol); curColValue = BytesUtil.readUnsigned(buf, i, colLen); i += colLen; } else { // value list curColValue = -1; } }
@Override public LongMutable read(byte[] buf, int offset) { current.set(BytesUtil.readLong(buf, offset, SIZE)); return current; }
@Override public LongMutable read(ByteBuffer buffer) { current.set(BytesUtil.readLong(buffer, SIZE)); return current; } }
@Override public LongWritable read(byte[] buf, int offset) { current.set(BytesUtil.readLong(buf, offset, SIZE)); return current; }