public static byte[] readByteArray(ByteBuffer in) { int len = readVInt(in); if (len < 0) return null; byte[] array = new byte[len]; in.get(array); return array; }
public static boolean[] readBooleanArray(ByteBuffer in) { int len = readVInt(in); if (len < 0) return null; boolean[] array = new boolean[len]; byte b_true = (byte) 1; for (int i = 0; i < array.length; i++) { byte temp = in.get(); if (temp == b_true) array[i] = true; else array[i] = false; } return array; }
public static int peekByteArrayLength(ByteBuffer in) { int start = in.position(); int arrayLen = readVInt(in); int sizeLen = in.position() - start; in.position(start); if (arrayLen < 0) return sizeLen; else return sizeLen + arrayLen; }
@Override public int peekLength(ByteBuffer in) { int mark = in.position(); int size = BytesUtil.readVInt(in); int total = in.position() - mark; if (size >= 0) { //size <0 is the null case total += size; } in.position(mark); return total; }
@Override public IGTCodeSystem deserialize(ByteBuffer in) { Map<Integer, Integer> dependentMetricsMap = Maps.newHashMap(); int size = BytesUtil.readVInt(in); for (int i = 0; i < size; ++i) { int key = BytesUtil.readVInt(in); int value = BytesUtil.readVInt(in); dependentMetricsMap.put(key, value); } DimensionEncoding[] dimEncs = new DimensionEncoding[BytesUtil.readVInt(in)]; for (int i = 0; i < dimEncs.length; i++) { dimEncs[i] = readDimensionEncoding(in); } return new TrimmedCubeCodeSystem(dimEncs, dependentMetricsMap); } };
private List<RawScan> deserializeRawScans(ByteBuffer in) { int rawScanCount = BytesUtil.readVInt(in); List<RawScan> ret = Lists.newArrayList(); for (int i = 0; i < rawScanCount; i++) { RawScan temp = RawScan.serializer.deserialize(in); ret.add(temp); } return ret; }
public static String[] readAsciiStringArray(ByteBuffer in) { int len = readVInt(in); String[] strs = new String[len]; for (int i = 0; i < len; i++) strs[i] = readAsciiString(in); return strs; }
@Override public void deserialize(IFilterCodeSystem<?> cs, ByteBuffer buffer) { this.constantValues.clear(); int size = BytesUtil.readVInt(buffer); for (int i = 0; i < size; i++) { this.constantValues.add(cs.deserialize(buffer)); } }
public int peekLength(ByteBuffer in) { int mark = in.position(); int len; byte scheme = in.get(); if (scheme == 0) { // map scheme int size = BytesUtil.readVInt(in); int indexLen = getRegisterIndexSize(); len = in.position() - mark + (indexLen + 1) * size; } else { len = in.position() - mark + m; } in.position(mark); return len; }
public int peekLength(ByteBuffer in) { int mark = in.position(); int len; byte scheme = in.get(); if (scheme == 0) { // map scheme int size = BytesUtil.readVInt(in); int indexLen = getRegisterIndexSize(); len = in.position() - mark + (indexLen + 1) * size; } else { len = in.position() - mark + m; } in.position(mark); return len; }
public static DimensionEncoding readDimensionEncoding(ByteBuffer in) { try { int isNull = BytesUtil.readVInt(in); if (isNull == 1) { return null; } byte[] bytes = BytesUtil.readByteArray(in); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); DimensionEncoding ret = (DimensionEncoding) ois.readObject(); return ret; } catch (IOException | ClassNotFoundException e) { throw new RuntimeException(e); } }
@Override public int peekLength(ByteBuffer in) { int mark = in.position(); int len = 0; if (in.hasRemaining()) { int size = BytesUtil.readVInt(in); len = in.position() - mark; for (int i = 0; i < size; i++) { int length = BytesUtil.peekByteArrayLength(in); in.position(in.position() + length); len += length; } } in.position(mark); return len; }
@Override public CoprocessorProjector deserialize(ByteBuffer in) { byte[] mask = BytesUtil.readByteArray(in); boolean hasGroupBy = BytesUtil.readVInt(in) == 1; return new CoprocessorProjector(mask, hasGroupBy); } };
private GTRecord deserializeGTRecord(ByteBuffer in, GTInfo sInfo) { int colLength = BytesUtil.readVInt(in); ByteArray[] sCols = new ByteArray[colLength]; for (int i = 0; i < colLength; i++) { sCols[i] = ByteArray.importData(in); } return new GTRecord(sInfo, sCols); }
@Override public void deserialize(IFilterCodeSystem<?> cs, ByteBuffer buffer) { this.dynamicVariables.clear(); int size = BytesUtil.readVInt(buffer); for (int i = 0; i < size; i++) { String name = BytesUtil.readUTFString(buffer); Object value = cs.deserialize(buffer); bindVariable(name, value); } }
@Override public void deserialize(IFilterCodeSystem<?> cs, ByteBuffer buffer) { int nWhenEntries = BytesUtil.readVInt(buffer); List<Pair<TupleFilter, TupleExpression>> whenList = Lists.newArrayListWithExpectedSize(nWhenEntries); for (int i = 0; i < nWhenEntries; i++) { TupleFilter tupleFilter = TupleFilterSerializer.deserialize(BytesUtil.readByteArray(buffer), cs); TupleExpression tupleExpression = TupleExpressionSerializer.deserialize(BytesUtil.readByteArray(buffer), cs); whenList.add(new Pair<>(tupleFilter, tupleExpression)); } this.whenList = whenList; int flag = BytesUtil.readVInt(buffer); if (flag == 1) { this.elseExpr = TupleExpressionSerializer.deserialize(BytesUtil.readByteArray(buffer), cs); } }