@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); }
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); }
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); } }
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; }
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)");
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; } }
@Override public void readFields(DataInput in) throws IOException { byte[] headPartial = new byte[HEAD_MAGIC.length + Short.SIZE + Integer.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); init(all); }
private void init(byte[] trieBytes) { this.trieBytes = trieBytes; if (BytesUtil.compareBytes(HEAD_MAGIC, 0, trieBytes, 0, HEAD_MAGIC.length) != 0) throw new IllegalArgumentException("Wrong file type (magic does not match)");
@Override public void readFields(DataInput in) throws IOException { byte[] headPartial = new byte[HEAD_MAGIC.length + Short.SIZE + Integer.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); init(all); }
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); }
@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); }
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); } }
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; }
private void init(byte[] trieBytes) { this.trieBytes = trieBytes; if (BytesUtil.compareBytes(HEAD_MAGIC, 0, trieBytes, 0, HEAD_MAGIC.length) != 0) throw new IllegalArgumentException("Wrong file type (magic does not match)");
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)");
public void updateWith(Cell c) { if (BytesUtil.compareBytes(IIDesc.HBASE_QUALIFIER_BYTES, 0, c.getQualifierArray(), c.getQualifierOffset(), IIDesc.HBASE_QUALIFIER_BYTES.length) == 0) { this.getKey().set(c.getRowArray(), c.getRowOffset(), c.getRowLength()); this.getValue().set(c.getValueArray(), c.getValueOffset(), c.getValueLength()); } else if (BytesUtil.compareBytes(IIDesc.HBASE_DICTIONARY_BYTES, 0, c.getQualifierArray(), c.getQualifierOffset(), IIDesc.HBASE_DICTIONARY_BYTES.length) == 0) { this.getDictionary().set(c.getValueArray(), c.getValueOffset(), c.getValueLength()); } }
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; } }