本文整理汇总了Java中org.apache.kylin.common.util.BytesUtil.readLong方法的典型用法代码示例。如果您正苦于以下问题:Java BytesUtil.readLong方法的具体用法?Java BytesUtil.readLong怎么用?Java BytesUtil.readLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.kylin.common.util.BytesUtil
的用法示例。
在下文中一共展示了BytesUtil.readLong方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decode
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@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);
}
示例2: getFirstValue
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
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();
}
示例3: decode
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@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];
}
示例4: decode
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@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);
}
示例5: decode
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@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);
}
示例6: lookupSeqNoFromValue
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
/**
* returns a code point from [0, nValues), preserving order of value
*
* @param n -- the offset of current node
* @param inp -- input value bytes to lookup
* @param o -- offset in the input value bytes matched so far
* @param inpEnd -- end of input
* @param roundingFlag -- =0: return -1 if not found
* -- <0: return closest smaller if not found, return -1
* -- >0: return closest bigger if not found, return nValues
*/
private int lookupSeqNoFromValue(int n, byte[] inp, int o, int inpEnd, int roundingFlag) {
while (true) {
// match the current node
int p = n + firstByteOffset; // start of node's value
int end = p + BytesUtil.readUnsigned(trieBytes, p - 1, 1); // end of node's value
for (; p < end && o < inpEnd; p++, o++) { // note matching start from [0]
if (trieBytes[p] != inp[o]) {
return -1; // mismatch
}
}
// node completely matched, is input all consumed?
boolean isEndOfValue = checkFlag(n, BIT_IS_END_OF_VALUE);
if (o == inpEnd) {
return p == end && isEndOfValue ? BytesUtil.readUnsigned(trieBytes, end, sizeOfId) : -1;
}
// find a child to continue
int c = headSize + (int) (BytesUtil.readLong(trieBytes, n, sizeChildOffset) & childOffsetMask);
if (c == headSize) // has no children
return -1;
byte inpByte = inp[o];
int comp;
while (true) {
p = c + firstByteOffset;
comp = BytesUtil.compareByteUnsigned(trieBytes[p], inpByte);
if (comp == 0) { // continue in the matching child, reset n and loop again
n = c;
break;
} else if (comp < 0) { // try next child
if (checkFlag(c, BIT_IS_LAST_CHILD))
return -1;
c = p + BytesUtil.readUnsigned(trieBytes, p - 1, 1) + (checkFlag(c, BIT_IS_END_OF_VALUE) ? sizeOfId : 0);
} else { // children are ordered by their first value byte
return -1;
}
}
}
}
示例7: rebuildTrieTreeR
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
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;
}
示例8: deserialize
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@Override
public Long deserialize(ByteBuffer in) {
return BytesUtil.readLong(in);
}
示例9: deserialize
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@Override
public Object deserialize(ByteBuffer buf) {
return BytesUtil.readLong(buf);
}
示例10: encode
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
private long encode(String value) {
enc.encode(value, buf, 0);
return BytesUtil.readLong(buf, 0, buf.length);
}
示例11: doCheck
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
public boolean doCheck() {
int offset = headSize;
HashSet<Integer> parentSet = new HashSet<>();
boolean lastChild = false;
while (offset < trieBytes.length) {
if (lastChild) {
boolean contained = parentSet.remove(offset - headSize);
// Can't find parent, the data is corrupted
if (!contained) {
return false;
}
lastChild = false;
}
int p = offset + firstByteOffset;
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);
// Copy value overflow, the data is corrupted
if (trieBytes.length < p + parLen) {
return false;
}
// Check id is fine
if (isEndOfValue) {
BytesUtil.readUnsigned(trieBytes, p + parLen, sizeOfId);
}
// Record it if has children
if (childOffset != 0) {
parentSet.add(childOffset);
}
// brothers done, move to next parent
if (checkFlag(offset, BIT_IS_LAST_CHILD)) {
lastChild = true;
}
// move to next node
offset += firstByteOffset + parLen + (isEndOfValue ? sizeOfId : 0);
}
// ParentMap is empty, meaning all nodes has parent, the data is correct
return parentSet.isEmpty();
}