use of com.linkedin.pinot.core.io.reader.impl.FixedByteSingleValueMultiColReader in project pinot by linkedin.
the class FixedByteWidthRowColDataFileWriterTest method testSingleColDouble.
@Test
public void testSingleColDouble() throws Exception {
File wfile = new File("test_single_col_writer.dat");
wfile.delete();
final int rows = 100;
final int cols = 1;
final int[] columnSizes = new int[] { 8 };
FixedByteSingleValueMultiColWriter writer = new FixedByteSingleValueMultiColWriter(wfile, rows, cols, columnSizes);
final double[] data = new double[rows];
Random r = new Random();
for (int i = 0; i < rows; i++) {
data[i] = r.nextDouble();
writer.setDouble(i, 0, data[i]);
}
writer.close();
File rfile = new File("test_single_col_writer.dat");
PinotDataBuffer buffer = PinotDataBuffer.fromFile(rfile, ReadMode.mmap, FileChannel.MapMode.READ_WRITE, "testing");
FixedByteSingleValueMultiColReader reader = new FixedByteSingleValueMultiColReader(buffer, rows, cols, columnSizes);
for (int i = 0; i < rows; i++) {
Assert.assertEquals(reader.getDouble(i, 0), data[i]);
}
reader.close();
rfile.delete();
}
use of com.linkedin.pinot.core.io.reader.impl.FixedByteSingleValueMultiColReader in project pinot by linkedin.
the class FixedByteSingleColumnMultiValueReaderWriter method getBytesArray.
@Override
public int getBytesArray(int row, byte[][] bytesArray) {
int bufferIndex = headerReader.getInt(row, 1);
int startIndex = headerReader.getInt(row, 1);
int length = headerReader.getInt(row, 2);
FixedByteSingleValueMultiColReader dataReader = dataReaders.get(bufferIndex);
for (int i = 0; i < length; i++) {
bytesArray[i] = dataReader.getBytes(startIndex + i, 0);
}
return length;
}
use of com.linkedin.pinot.core.io.reader.impl.FixedByteSingleValueMultiColReader in project pinot by linkedin.
the class FixedByteSingleColumnMultiValueReaderWriter method getIntArray.
@Override
public int getIntArray(int row, int[] intArray) {
int bufferIndex = headerReader.getInt(row, 0);
int startIndex = headerReader.getInt(row, 1);
int length = headerReader.getInt(row, 2);
FixedByteSingleValueMultiColReader dataReader = dataReaders.get(bufferIndex);
for (int i = 0; i < length; i++) {
intArray[i] = dataReader.getInt(startIndex + i, 0);
}
return length;
}
use of com.linkedin.pinot.core.io.reader.impl.FixedByteSingleValueMultiColReader in project pinot by linkedin.
the class FixedByteSingleColumnMultiValueReaderWriter method getLongArray.
@Override
public int getLongArray(int row, long[] longArray) {
int bufferIndex = headerReader.getInt(row, 0);
int startIndex = headerReader.getInt(row, 1);
int length = headerReader.getInt(row, 2);
FixedByteSingleValueMultiColReader dataReader = dataReaders.get(bufferIndex);
for (int i = 0; i < length; i++) {
longArray[i] = dataReader.getLong(startIndex + i, 0);
}
return length;
}
use of com.linkedin.pinot.core.io.reader.impl.FixedByteSingleValueMultiColReader in project pinot by linkedin.
the class ColumnIndexContainer method loadSorted.
private static ColumnIndexContainer loadSorted(String column, SegmentDirectory.Reader segmentReader, ColumnMetadata metadata, ImmutableDictionaryReader dictionary) throws IOException {
PinotDataBuffer dataBuffer = segmentReader.getIndexFor(column, ColumnIndexType.FORWARD_INDEX);
FixedByteSingleValueMultiColReader indexReader = new FixedByteSingleValueMultiColReader(dataBuffer, metadata.getCardinality(), 2, new int[] { 4, 4 });
return new SortedSVColumnIndexContainer(column, metadata, indexReader, dictionary);
}
Aggregations