/** * To compare the data * * @param rowId row index to be compared * @param compareValue value to compare * @return compare result */ @Override public int compareTo(int rowId, byte[] compareValue) { // TODO Auto-generated method stub return dataChunkStore.compareTo(rowId, compareValue); }
/** * below method will be used to free the allocated memory */ @Override public void freeMemory() { if (dataChunkStore != null) { dataChunkStore.freeMemory(); dataChunkStore = null; } }
/** * @param rowId * @return inverted index reverse */ @Override public int getInvertedReverseIndex(int rowId) { return dataChunkStore.getInvertedReverseIndex(rowId); }
/** * Below method will be used to fill the data based on offset and row id * * @param rowId row id of the chunk * @param offset offset from which data need to be filed * @param data data to filed * @return how many bytes was copied */ @Override public int fillRawData(int rowId, int offset, byte[] data) { dataChunkStore.fillRow(rowId, data, offset); return dataChunkStore.getColumnValueSize(); }
/** * Constructor * * @param dataChunk data chunk * @param invertedIndex inverted index * @param invertedIndexReverse reverse inverted index * @param numberOfRows number of rows * @param columnValueSize size of each column value */ public FixedLengthDimensionColumnPage(byte[] dataChunk, int[] invertedIndex, int[] invertedIndexReverse, int numberOfRows, int columnValueSize, int dataLength) { boolean isExplicitSorted = isExplicitSorted(invertedIndex); long totalSize = isExplicitSorted ? dataLength + (2 * numberOfRows * CarbonCommonConstants.INT_SIZE_IN_BYTE) : dataLength; dataChunkStore = DimensionChunkStoreFactory.INSTANCE .getDimensionChunkStore(columnValueSize, isExplicitSorted, numberOfRows, totalSize, DimensionStoreType.FIXED_LENGTH, null, false, dataLength); dataChunkStore.putArray(invertedIndex, invertedIndexReverse, dataChunk); }
/** * Converts to column dictionary integer value * * @param rowId * @param chunkIndex * @param outputSurrogateKey * @return */ @Override public int fillSurrogateKey(int rowId, int chunkIndex, int[] outputSurrogateKey) { outputSurrogateKey[chunkIndex] = dataChunkStore.getSurrogate(rowId); return chunkIndex + 1; }
@Override public int fillVector(ColumnVectorInfo[] vectorInfo, int chunkIndex) { ColumnVectorInfo columnVectorInfo = vectorInfo[chunkIndex]; CarbonColumnVector vector = columnVectorInfo.vector; int offset = columnVectorInfo.offset; int vectorOffset = columnVectorInfo.vectorOffset; int len = offset + columnVectorInfo.size; for (int i = offset; i < len; i++) { fillRow(i, vector, vectorOffset++); } return chunkIndex + 1; }
/** * @return whether columns where explicitly sorted or not */ @Override public boolean isExplicitSorted() { return dataChunkStore.isExplicitSorted(); }
/** * @return inverted index */ @Override public int getInvertedIndex(int rowId) { return dataChunkStore.getInvertedIndex(rowId); }
/** * Fill the data to vector * * @param vectorInfo * @param chunkIndex * @return next column index */ @Override public int fillVector(ColumnVectorInfo[] vectorInfo, int chunkIndex) { ColumnVectorInfo columnVectorInfo = vectorInfo[chunkIndex]; CarbonColumnVector vector = columnVectorInfo.vector; int offset = columnVectorInfo.offset; int vectorOffset = columnVectorInfo.vectorOffset; int len = offset + columnVectorInfo.size; for (int i = offset; i < len; i++) { // Considering only String case now as we support only // string in no dictionary case at present. dataChunkStore.fillRow(i, vector, vectorOffset++); } return chunkIndex + 1; }
/** * Below method will be used to put the rows and its metadata in offheap * * @param invertedIndex inverted index to be stored * @param invertedIndexReverse inverted index reverse to be stored * @param data data to be stored */ public void putArray(int[] invertedIndex, int[] invertedIndexReverse, byte[] data) { this.dimensionDataChunkStore.putArray(invertedIndex, invertedIndexReverse, data); }
/** * Below method to get the data based in row id * * @param rowId row id of the data * @return chunk */ @Override public byte[] getChunkData(int rowId) { return dataChunkStore.getRow(rowId); }
@Override public int compareTo(int rowId, byte[] compareValue) { return dimensionDataChunkStore.compareTo(rowId, compareValue); }
/** * Below method will be used to free the memory occupied by the column chunk */ @Override public void freeMemory() { if (null != dimensionDataChunkStore) { this.dimensionDataChunkStore.freeMemory(); this.dictionary = null; this.dimensionDataChunkStore = null; } } }
@Override public int getInvertedReverseIndex(int rowId) { return this.dimensionDataChunkStore.getInvertedReverseIndex(rowId); }
@Override public byte[] getRow(int rowId) { return dictionary.getDictionaryValue(dimensionDataChunkStore.getSurrogate(rowId)); }
@Override public int fillVector(int[] filteredRowId, ColumnVectorInfo[] vectorInfo, int chunkIndex) { ColumnVectorInfo columnVectorInfo = vectorInfo[chunkIndex]; CarbonColumnVector vector = columnVectorInfo.vector; int offset = columnVectorInfo.offset; int vectorOffset = columnVectorInfo.vectorOffset; int len = offset + columnVectorInfo.size; for (int i = offset; i < len; i++) { fillRow(filteredRowId[i], vector, vectorOffset++); } return chunkIndex + 1; }
@Override public boolean isExplicitSorted() { return this.dimensionDataChunkStore.isExplicitSorted(); }
@Override public int getInvertedIndex(int rowId) { return this.dimensionDataChunkStore.getInvertedIndex(rowId); }
/** * Fill the data to vector * * @param filteredRowId * @param vectorInfo * @param chunkIndex * @return next column index */ @Override public int fillVector(int[] filteredRowId, ColumnVectorInfo[] vectorInfo, int chunkIndex) { ColumnVectorInfo columnVectorInfo = vectorInfo[chunkIndex]; CarbonColumnVector vector = columnVectorInfo.vector; int offset = columnVectorInfo.offset; int vectorOffset = columnVectorInfo.vectorOffset; int len = offset + columnVectorInfo.size; for (int i = offset; i < len; i++) { // Considering only String case now as we support only // string in no dictionary case at present. dataChunkStore.fillRow(filteredRowId[i], vector, vectorOffset++); } return chunkIndex + 1; } }