/** 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); }
/** * 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); } }
/** create a row block, allocate memory, get ready for writing */ public static GTRowBlock allocate(GTInfo info) { GTRowBlock b = new GTRowBlock(info); byte[] array = new byte[info.getMaxColumnLength(info.primaryKey)]; b.primaryKey.reset(array, 0, array.length); int maxRows = info.isRowBlockEnabled() ? info.rowBlockSize : 1; for (int i = 0; i < b.cellBlocks.length; i++) { array = new byte[info.getMaxColumnLength(info.colBlocks[i]) * maxRows]; b.cellBlocks[i].reset(array, 0, array.length); } return b; }
public void loadColumnsFromColumnBlocks(ImmutableBitSet[] selectedColumnBlocks, ImmutableBitSet selectedCols, ByteBuffer buf) { int pos = buf.position(); for (ImmutableBitSet selectedColBlock : selectedColumnBlocks) { for (int i = 0; i < selectedColBlock.trueBitCount(); i++) { int c = selectedColBlock.trueBitAt(i); int len = info.codeSystem.codeLength(c, buf); if (selectedCols.get(c)) { cols[c].reset(buf.array(), buf.arrayOffset() + pos, len); } pos += len; buf.position(pos); } } }
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()); }
/** 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 void shallowCopyFrom(GTRecord source) { assert info == source.info; for (int i = 0; i < cols.length; i++) { cols[i].reset(source.cols[i].array(), source.cols[i].offset(), source.cols[i].length()); } }
public void set(int i, ByteArray data) { cols[i].reset(data.array(), data.offset(), data.length()); }
@Override protected GTRecord finalizeResult(GTRecord record, Object[] aggStates) { // 1. load dimensions for (int c : dimensions) { returnRecord.cols[c] = record.cols[c]; } // 2. serialize metrics byte[] bytes = measureCodec.encode(aggStates).array(); int[] sizes = measureCodec.getMeasureSizes(); // 3. load metrics int offset = 0; for (int i = 0; i < metrics.trueBitCount(); i++) { int c = metrics.trueBitAt(i); returnRecord.cols[c].reset(bytes, offset, sizes[i]); offset += sizes[i]; } return returnRecord; } }
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]; } } }
@Override public List<ByteArray> reEncodeDictionary(List<ByteArray> value, MeasureDesc measureDesc, Map<TblColRef, Dictionary<String>> oldDicts, Map<TblColRef, Dictionary<String>> newDicts) { TblColRef colRef = getRawColumn(measureDesc.getFunction()); Dictionary<String> sourceDict = oldDicts.get(colRef); Dictionary<String> mergedDict = newDicts.get(colRef); int valueSize = value.size(); byte[] newIdBuf = new byte[valueSize * mergedDict.getSizeOfId()]; int bufOffset = 0; for (ByteArray c : value) { int oldId = BytesUtil.readUnsigned(c.array(), c.offset(), c.length()); int newId; String v = sourceDict.getValueFromId(oldId); if (v == null) { newId = mergedDict.nullId(); } else { newId = mergedDict.getIdFromValue(v); } BytesUtil.writeUnsigned(newId, newIdBuf, bufOffset, mergedDict.getSizeOfId()); c.reset(newIdBuf, bufOffset, mergedDict.getSizeOfId()); bufOffset += mergedDict.getSizeOfId(); } return value; } };
c.getItem().reset(newIdBuf, bufOffset, newKeyLength); bufOffset += newKeyLength;
/** 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); }
/** * 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); } }
/** create a row block, allocate memory, get ready for writing */ public static GTRowBlock allocate(GTInfo info) { GTRowBlock b = new GTRowBlock(info); byte[] array = new byte[info.getMaxColumnLength(info.primaryKey)]; b.primaryKey.reset(array, 0, array.length); int maxRows = info.isRowBlockEnabled() ? info.rowBlockSize : 1; for (int i = 0; i < b.cellBlocks.length; i++) { array = new byte[info.getMaxColumnLength(info.colBlocks[i]) * maxRows]; b.cellBlocks[i].reset(array, 0, array.length); } return b; }
public void loadColumnsFromColumnBlocks(ImmutableBitSet[] selectedColumnBlocks, ImmutableBitSet selectedCols, ByteBuffer buf) { int pos = buf.position(); for (ImmutableBitSet selectedColBlock : selectedColumnBlocks) { for (int i = 0; i < selectedColBlock.trueBitCount(); i++) { int c = selectedColBlock.trueBitAt(i); int len = info.codeSystem.codeLength(c, buf); if (selectedCols.get(c)) { cols[c].reset(buf.array(), buf.arrayOffset() + pos, len); } pos += len; buf.position(pos); } } }
/** 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 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 void shallowCopyFrom(GTRecord source) { assert info == source.info; for (int i = 0; i < cols.length; i++) { cols[i].reset(source.cols[i].array(), source.cols[i].offset(), source.cols[i].length()); } }
public void set(int i, ByteArray data) { cols[i].reset(data.array(), data.offset(), data.length()); }