public void setValue(int i, Object value) { ByteArray space = new ByteArray(info.codeSystem.maxCodeLength(i)); ByteBuffer buf = space.asBuffer(); info.codeSystem.encodeColumnValue(i, value, buf); set(i, space); cols[i].reset(buf.array(), buf.arrayOffset(), buf.position()); }
public static byte[] serializeGTFilter(TupleFilter gtFilter, GTInfo info) { IFilterCodeSystem<ByteArray> filterCodeSystem = wrap(info.codeSystem.getComparator()); return TupleFilterSerializer.serialize(gtFilter, filterCodeSystem); }
public boolean isUsingDatetimeEncoding(int index) { return info.getCodeSystem().getDimEnc(index) instanceof AbstractDateDimEnc; }
public int getMaxColumnLength() { int max = 0; for (int i = 0; i < nColumns; i++) max = Math.max(max, codeSystem.maxCodeLength(i)); return max; }
protected ByteArray translate(int col, Object value, int roundingFlag) { try { buf.clear(); info.codeSystem.encodeColumnValue(col, value, roundingFlag, buf); return ByteArray.copyOf(buf.array(), 0, buf.position()); } catch (IllegalArgumentException ex) { return null; } } }
public Object getValue(int i) { return info.codeSystem.decodeColumnValue(i, cols[i].asBuffer()); }
/** change pointers to point to data in given buffer, this * method allows to defined specific column to load */ public void loadColumns(int selectedCol, ByteBuffer buf) { int pos = buf.position(); int len = info.codeSystem.codeLength(selectedCol, buf); cols[selectedCol].reset(buf.array(), buf.arrayOffset() + pos, len); }
private MeasureAggregator[] newAggregators() { return info.codeSystem.newMetricsAggregators(metrics, metricsAggrFuncs); }
void validate() { if (codeSystem == null) throw new IllegalStateException(); if (primaryKey == null || primaryKey.cardinality() == 0) throw new IllegalStateException(); codeSystem.init(this); validateColumnBlocks(); }
private void validate() { if (info.getColumnCount() != colSpecs.size()) throw new IllegalArgumentException(); for (int i = 0; i < colSpecs.size(); i++) { ColSpec spec = colSpecs.get(i); if (info.getCodeSystem().maxCodeLength(i) < spec.length) throw new IllegalArgumentException(); } }
/** set record to the codes of specified values, reuse given space to hold the codes */ public GTRecord setValues(ImmutableBitSet selectedCols, ByteArray space, Object... values) { assert selectedCols.cardinality() == values.length; ByteBuffer buf = space.asBuffer(); int pos = buf.position(); for (int i = 0; i < selectedCols.trueBitCount(); i++) { int c = selectedCols.trueBitAt(i); info.codeSystem.encodeColumnValue(c, values[i], buf); int newPos = buf.position(); cols[c].reset(buf.array(), buf.arrayOffset() + pos, newPos - pos); pos = newPos; } return this; }
public Object decodeValue(int c) { ByteArray col = cols[c]; if (col != null && col.array() != null) { return info.codeSystem.decodeColumnValue(c, col.asBuffer()); } return null; }
/** * Change pointers to point to data in given buffer, UNLIKE deserialize * @param selectedCols positions of column to load * @param buf buffer containing continuous data of selected columns */ public void loadColumns(Iterable<Integer> selectedCols, ByteBuffer buf) { int pos = buf.position(); for (int c : selectedCols) { int len = info.codeSystem.codeLength(c, buf); cols[c].reset(buf.array(), buf.arrayOffset() + pos, len); pos += len; buf.position(pos); } }
@Override public E next() { if (!hasNext()) { throw new NoSuchElementException(); } // WATCH OUT! record returned by "input" scanner could be changed later, // so we must make a shallow copy of it. first.shallowCopyFrom(input.next()); // shortcut to avoid extra deserialize/serialize cost if (!shouldMergeNext(first)) { return finalizeResult(first); } // merge records with the same key MeasureAggregator[] aggrs = codeSystem.newMetricsAggregators(metrics, metricFuncs); aggregate(aggrs, first); aggregate(aggrs, input.next()); // no need to copy record because it's not referred to later while (shouldMergeNext(first)) { aggregate(aggrs, input.next()); } Object[] aggStates = new Object[aggrs.length]; for (int i = 0; i < aggStates.length; i++) { aggStates[i] = aggrs[i].getState(); } return finalizeResult(first, aggStates); }
void validate() { if (codeSystem == null) throw new IllegalStateException(); if (primaryKey == null || primaryKey.cardinality() == 0) throw new IllegalStateException(); codeSystem.init(this); validateColumnBlocks(); }
public int getMaxLength() { int ret = 0; for (int i = 0; i < colAll.trueBitCount(); i++) { ret += codeSystem.maxCodeLength(colAll.trueBitAt(i)); } return ret; }
public static CompareTupleFilter getCompareTupleFilter(int col, Object value) { TblColRef colRef = gtInfo.colRef(col); ColumnTupleFilter colFilter = new ColumnTupleFilter(colRef); ByteArray space = new ByteArray(gtInfo.getCodeSystem().maxCodeLength(col)); gtInfo.getCodeSystem().encodeColumnValue(col, value, space.asBuffer()); ConstantTupleFilter constFilter = new ConstantTupleFilter(space); CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ); compareFilter.addChild(colFilter); compareFilter.addChild(constFilter); return compareFilter; }
public static TupleFilter deserializeGTFilter(byte[] bytes, GTInfo info) { IFilterCodeSystem<ByteArray> filterCodeSystem = wrap(info.codeSystem.getComparator()); return TupleFilterSerializer.deserialize(bytes, filterCodeSystem); }
public static ByteArray enc(GTInfo info, int col, String value) { ByteBuffer buf = ByteBuffer.allocate(info.getMaxColumnLength()); info.getCodeSystem().encodeColumnValue(col, value, buf); return ByteArray.copyOf(buf.array(), buf.arrayOffset(), buf.position()); }
private static RawScan mockFullScan(GTInfo gtInfo, KylinConfig kylinConfig) { final List<Pair<byte[], byte[]>> selectedColumns = Lists.newArrayList(); selectedColumns.add(new Pair<>(FAM, COL_M)); int headerLength = RowConstants.ROWKEY_SHARD_AND_CUBOID_LEN; int bodyLength = 0; ImmutableBitSet primaryKey = gtInfo.getPrimaryKey(); for (int i = 0; i < primaryKey.trueBitCount(); i++) { bodyLength += gtInfo.getCodeSystem().getDimEnc(primaryKey.trueBitAt(i)).getLengthOfEncoding(); } //Mock start key byte[] start = new byte[headerLength + bodyLength]; BytesUtil.writeShort((short) 0, start, 0, RowConstants.ROWKEY_SHARDID_LEN); System.arraycopy(Bytes.toBytes(baseCuboid), 0, start, RowConstants.ROWKEY_SHARDID_LEN, RowConstants.ROWKEY_CUBOIDID_LEN); //Mock end key byte[] end = new byte[headerLength + bodyLength + 1]; for (int i = 0; i < end.length - 1; i++) { end[i] = RowConstants.ROWKEY_UPPER_BYTE; } BytesUtil.writeShort((short) 0, end, 0, RowConstants.ROWKEY_SHARDID_LEN); System.arraycopy(Bytes.toBytes(baseCuboid), 0, end, RowConstants.ROWKEY_SHARDID_LEN, RowConstants.ROWKEY_CUBOIDID_LEN); //Mock fuzzy key List<Pair<byte[], byte[]>> fuzzyKeys = Collections.emptyList(); return new RawScan(start, end, selectedColumns, fuzzyKeys, kylinConfig.getHBaseScanCacheRows(), kylinConfig.getHBaseScanMaxResultSize()); }