public int getMaxColumnLength() { int max = 0; for (int i = 0; i < nColumns; i++) max = Math.max(max, codeSystem.maxCodeLength(i)); return max; }
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(); } }
public int getMaxLength() { int ret = 0; for (int i = 0; i < colAll.trueBitCount(); i++) { ret += codeSystem.maxCodeLength(colAll.trueBitAt(i)); } return ret; }
public int getMaxColumnLength(ImmutableBitSet selectedCols) { int result = 0; for (int i = 0; i < selectedCols.trueBitCount(); i++) { int c = selectedCols.trueBitAt(i); result += codeSystem.maxCodeLength(c); } return result; }
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()); }
private boolean[] createCompareMask() { int keyLength = 0; for (int i = 0; i < dimensions.trueBitCount(); i++) { int c = dimensions.trueBitAt(i); int l = info.codeSystem.maxCodeLength(c); keyLength += l; } boolean[] mask = new boolean[keyLength]; int p = 0; for (int i = 0; i < dimensions.trueBitCount(); i++) { int c = dimensions.trueBitAt(i); int l = info.codeSystem.maxCodeLength(c); boolean m = groupBy.get(c); for (int j = 0; j < l; j++) { mask[p++] = m; } } return mask; }
private byte[] createKey(GTRecord record) { byte[] result = new byte[keyLength]; int offset = 0; for (int i = 0; i < dimensions.trueBitCount(); i++) { int c = dimensions.trueBitAt(i); final ByteArray byteArray = record.cols[c]; final int columnLength = info.codeSystem.maxCodeLength(c); System.arraycopy(byteArray.array(), byteArray.offset(), result, offset, byteArray.length()); offset += columnLength; } assert offset == result.length; return result; }
ByPassChecker(int aggregateBufferSizeLimit) { this.aggregateBufferSizeLimit = aggregateBufferSizeLimit; //init groupOffsetsInLastKey int p = 0; int idx = 0; this.groupOffsetsInLastKey = new int[groupBy.trueBitCount()]; for (int i = 0; i < dimensions.trueBitCount(); i++) { int c = dimensions.trueBitAt(i); int l = info.codeSystem.maxCodeLength(c); if (groupBy.get(c)) groupOffsetsInLastKey[idx++] = p; p += l; } }
private CompareTupleFilter eq(ColumnTupleFilter col, int... values) { CompareTupleFilter r = new CompareTupleFilter(FilterOperatorEnum.IN); r.addChild(col); List<ByteArray> list = Lists.newArrayList(); for (int v : values) { int c = col.getColumn().getColumnDesc().getZeroBasedIndex(); int len = info.getCodeSystem().maxCodeLength(c); ByteArray bytes = new ByteArray(len); BytesUtil.writeLong(v, bytes.array(), bytes.offset(), len); list.add(bytes); } r.addChild(new ConstantTupleFilter(list)); return r; }
private CompareTupleFilter eq(ColumnTupleFilter col, int... values) { CompareTupleFilter r = new CompareTupleFilter(FilterOperatorEnum.IN); r.addChild(col); List<ByteArray> list = Lists.newArrayList(); for (int v : values) { int c = col.getColumn().getColumnDesc().getZeroBasedIndex(); int len = info.getCodeSystem().maxCodeLength(c); ByteArray bytes = new ByteArray(len); BytesUtil.writeLong(v, bytes.array(), bytes.offset(), len); list.add(bytes); } r.addChild(new ConstantTupleFilter(list)); return r; }
void load(byte[] key, MeasureAggregator[] value) { int offset = 0; for (int i = 0; i < dimensions.trueBitCount(); i++) { int c = dimensions.trueBitAt(i); final int columnLength = info.codeSystem.maxCodeLength(c); record.cols[c].reset(key, offset, columnLength); offset += columnLength; } for (int i = 0; i < value.length; i++) { tmpValues[i] = value[i].getState(); } byte[] bytes = measureCodec.encode(tmpValues).array(); int[] sizes = measureCodec.getMeasureSizes(); offset = 0; for (int i = 0; i < value.length; i++) { int col = metrics.trueBitAt(i); record.cols[col].reset(bytes, offset, sizes[i]); offset += sizes[i]; } } }
private void compareTwoGTInfo(GTInfo info, GTInfo sInfo) { Assert.assertEquals(info.tableName, sInfo.tableName); Assert.assertEquals(info.primaryKey, sInfo.primaryKey); for (int i = 0; i < info.colTypes.length; i++) { Assert.assertEquals(info.codeSystem.maxCodeLength(i), sInfo.codeSystem.maxCodeLength(i)); Assert.assertTrue(info.codeSystem.maxCodeLength(i) > 0); Assert.assertEquals(info.colRef(i), sInfo.colRef(i)); } Assert.assertArrayEquals(info.colBlocks, sInfo.colBlocks); Assert.assertEquals(info.getRowBlockSize(), sInfo.getRowBlockSize()); Assert.assertEquals(info.rowBlockSize, sInfo.rowBlockSize); } }
private void encodeDims(GTRecord record, ImmutableBitSet selectedCols, ByteArray buf, byte defaultValue) { int pos = 0; for (int i = 0; i < selectedCols.trueBitCount(); i++) { int c = selectedCols.trueBitAt(i); ByteArray columnC = record.get(c); if (columnC.array() != null) { System.arraycopy(record.get(c).array(), columnC.offset(), buf.array(), buf.offset() + pos, columnC.length()); pos += columnC.length(); } else { int maxLength = record.getInfo().getCodeSystem().maxCodeLength(c); Arrays.fill(buf.array(), buf.offset() + pos, buf.offset() + pos + maxLength, defaultValue); pos += maxLength; } } buf.setLength(pos); }
private CompareTupleFilter gt(ColumnTupleFilter col, int v) { CompareTupleFilter r = new CompareTupleFilter(FilterOperatorEnum.GT); r.addChild(col); int c = col.getColumn().getColumnDesc().getZeroBasedIndex(); int len = info.getCodeSystem().maxCodeLength(c); ByteArray bytes = new ByteArray(len); BytesUtil.writeLong(v, bytes.array(), bytes.offset(), len); r.addChild(new ConstantTupleFilter(bytes)); return r; }
private CompareTupleFilter gt(ColumnTupleFilter col, int v) { CompareTupleFilter r = new CompareTupleFilter(FilterOperatorEnum.GT); r.addChild(col); int c = col.getColumn().getColumnDesc().getZeroBasedIndex(); int len = info.getCodeSystem().maxCodeLength(c); ByteArray bytes = new ByteArray(len); BytesUtil.writeLong(v, bytes.array(), bytes.offset(), len); r.addChild(new ConstantTupleFilter(bytes)); return r; }
@Override public void encode(GTRecord record, ImmutableBitSet keyColumns, byte[] buf) { ByteArray byteArray = new ByteArray(buf, getHeaderLength(), 0); GTInfo info = record.getInfo(); byte fill; int pos = 0; for (int i = 0; i < info.getPrimaryKey().trueBitCount(); i++) { int c = info.getPrimaryKey().trueBitAt(i); int colLength = info.getCodeSystem().maxCodeLength(c); if (record.get(c).array() != null) { fill = RowConstants.BYTE_ZERO; } else { fill = RowConstants.BYTE_ONE; } Arrays.fill(byteArray.array(), byteArray.offset() + pos, byteArray.offset() + pos + colLength, fill); pos += colLength; } byteArray.setLength(pos); //fill shard and cuboid fillHeader(buf); }
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 int getMaxColumnLength() { int max = 0; for (int i = 0; i < nColumns; i++) max = Math.max(max, codeSystem.maxCodeLength(i)); return max; }
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()); }
private CompareTupleFilter gt(ColumnTupleFilter col, int v) { CompareTupleFilter r = new CompareTupleFilter(FilterOperatorEnum.GT); r.addChild(col); int c = col.getColumn().getColumnDesc().getZeroBasedIndex(); int len = info.getCodeSystem().maxCodeLength(c); ByteArray bytes = new ByteArray(len); BytesUtil.writeLong(v, bytes.array(), bytes.offset(), len); r.addChild(new ConstantTupleFilter(bytes)); return r; }