本文整理汇总了Java中org.apache.kylin.common.util.BytesUtil.compareBytes方法的典型用法代码示例。如果您正苦于以下问题:Java BytesUtil.compareBytes方法的具体用法?Java BytesUtil.compareBytes怎么用?Java BytesUtil.compareBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.kylin.common.util.BytesUtil
的用法示例。
在下文中一共展示了BytesUtil.compareBytes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
private void init() {
if (BytesUtil.compareBytes(HEAD_MAGIC, 0, trieBytes, 0, HEAD_MAGIC.length) != 0)
throw new IllegalArgumentException("Wrong file type (magic does not match)");
try {
DataInputStream headIn = new DataInputStream(new ByteArrayInputStream(trieBytes, HEAD_SIZE_I, trieBytes.length - HEAD_SIZE_I));
this.headSize = headIn.readShort();
this.bodyLen = headIn.readInt();
this.nValues = headIn.readInt();
this.sizeChildOffset = headIn.read();
this.sizeOfId = headIn.read();
this.childOffsetMask = ~(((long) (BIT_IS_LAST_CHILD | BIT_IS_END_OF_VALUE)) << ((sizeChildOffset - 1) * 8));
this.firstByteOffset = sizeChildOffset + 1; // the offset from begin of node to its first value byte
} catch (Exception e) {
if (e instanceof RuntimeException)
throw (RuntimeException) e;
else
throw new RuntimeException(e);
}
}
示例2: deserializeFrom
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
public static AppendDictSlice deserializeFrom(DataInput in) throws IOException {
byte[] headPartial = new byte[HEAD_MAGIC.length + Short.SIZE / Byte.SIZE + Integer.SIZE / Byte.SIZE];
in.readFully(headPartial);
if (BytesUtil.compareBytes(HEAD_MAGIC, 0, headPartial, 0, HEAD_MAGIC.length) != 0)
throw new IllegalArgumentException("Wrong file type (magic does not match)");
DataInputStream headIn = new DataInputStream(//
new ByteArrayInputStream(headPartial, HEAD_SIZE_I, headPartial.length - HEAD_SIZE_I));
int headSize = headIn.readShort();
int bodyLen = headIn.readInt();
headIn.close();
byte[] all = new byte[headSize + bodyLen];
System.arraycopy(headPartial, 0, all, 0, headPartial.length);
in.readFully(all, headPartial.length, all.length - headPartial.length);
return new AppendDictSlice(all);
}
示例3: readFields
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
@Override
public void readFields(DataInput in) throws IOException {
byte[] headPartial = new byte[MAGIC.length + Short.SIZE + Integer.SIZE];
in.readFully(headPartial);
if (BytesUtil.compareBytes(MAGIC, 0, headPartial, 0, MAGIC.length) != 0)
throw new IllegalArgumentException("Wrong file type (magic does not match)");
DataInputStream headIn = new DataInputStream(//
new ByteArrayInputStream(headPartial, MAGIC_SIZE_I, headPartial.length - MAGIC_SIZE_I));
int headSize = headIn.readShort();
int bodyLen = headIn.readInt();
headIn.close();
byte[] all = new byte[headSize + bodyLen];
System.arraycopy(headPartial, 0, all, 0, headPartial.length);
in.readFully(all, headPartial.length, all.length - headPartial.length);
init(all);
}
示例4: init
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
private void init(byte[] trieBytes) {
this.trieBytes = trieBytes;
if (BytesUtil.compareBytes(MAGIC, 0, trieBytes, 0, MAGIC.length) != 0)
throw new IllegalArgumentException("Wrong file type (magic does not match)");
try {
DataInputStream headIn = new DataInputStream(//
new ByteArrayInputStream(trieBytes, MAGIC_SIZE_I, trieBytes.length - MAGIC_SIZE_I));
this.headSize = headIn.readShort();
this.bodyLen = headIn.readInt();
this.sizeChildOffset = headIn.read();
this.sizeNoValuesBeneath = headIn.read();
this.baseId = headIn.readShort();
this.maxValueLength = headIn.readShort();
if (maxValueLength < 0) {
throw new IllegalStateException("maxValueLength is negative (" + maxValueLength
+ "). Dict value is too long, whose length is larger than " + Short.MAX_VALUE);
}
String converterName = headIn.readUTF();
if (converterName.isEmpty() == false)
setConverterByName(converterName);
this.nValues = BytesUtil.readUnsigned(trieBytes, headSize + sizeChildOffset, sizeNoValuesBeneath);
this.sizeOfId = BytesUtil.sizeForValue(baseId + nValues + 1L); // note baseId could raise 1 byte in ID space, +1 to reserve all 0xFF for NULL case
this.childOffsetMask = ~((long) (BIT_IS_LAST_CHILD | BIT_IS_END_OF_VALUE) << ((sizeChildOffset - 1) * 8));
this.firstByteOffset = sizeChildOffset + sizeNoValuesBeneath + 1; // the offset from begin of node to its first value byte
enableCache();
} catch (Exception e) {
if (e instanceof RuntimeException)
throw (RuntimeException) e;
else
throw new RuntimeException(e);
}
}
示例5: findCell
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
public static Cell findCell(List<Cell> cells, byte[] familyName, byte[] columnName) {
for (Cell c : cells) {
if (BytesUtil.compareBytes(familyName, 0, c.getFamilyArray(), c.getFamilyOffset(), familyName.length) == 0 && //
BytesUtil.compareBytes(columnName, 0, c.getQualifierArray(), c.getQualifierOffset(), columnName.length) == 0) {
return c;
}
}
return null;
}
示例6: checkCache
import org.apache.kylin.common.util.BytesUtil; //导入方法依赖的package包/类
public boolean[] checkCache(GTRecord record) {
if (!enabled)
return null;
count++;
// disable the cache if the hit rate is bad
if (count == CHECKPOINT) {
if ((double) hit / (double) count < HIT_RATE_THRESHOLD) {
enabled = false;
}
}
boolean match = count > 1;
int p = 0;
for (int i = 0; i < colsInFilter.trueBitCount(); i++) {
int c = colsInFilter.trueBitAt(i);
ByteArray col = record.get(c);
if (match) {
match = BytesUtil.compareBytes(col.array(), col.offset(), lastValues, p, col.length()) == 0;
}
if (!match) {
System.arraycopy(col.array(), col.offset(), lastValues, p, col.length());
}
p += col.length();
}
if (match) {
hit++;
return lastResult;
} else {
return null;
}
}