Search in sources :

Example 16 with FixedByteSingleValueMultiColReader

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();
}
Also used : FixedByteSingleValueMultiColReader(com.linkedin.pinot.core.io.reader.impl.FixedByteSingleValueMultiColReader) Random(java.util.Random) PinotDataBuffer(com.linkedin.pinot.core.segment.memory.PinotDataBuffer) File(java.io.File) FixedByteSingleValueMultiColWriter(com.linkedin.pinot.core.io.writer.impl.FixedByteSingleValueMultiColWriter) Test(org.testng.annotations.Test)

Example 17 with FixedByteSingleValueMultiColReader

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;
}
Also used : FixedByteSingleValueMultiColReader(com.linkedin.pinot.core.io.reader.impl.FixedByteSingleValueMultiColReader)

Example 18 with FixedByteSingleValueMultiColReader

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;
}
Also used : FixedByteSingleValueMultiColReader(com.linkedin.pinot.core.io.reader.impl.FixedByteSingleValueMultiColReader)

Example 19 with FixedByteSingleValueMultiColReader

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;
}
Also used : FixedByteSingleValueMultiColReader(com.linkedin.pinot.core.io.reader.impl.FixedByteSingleValueMultiColReader)

Example 20 with FixedByteSingleValueMultiColReader

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);
}
Also used : FixedByteSingleValueMultiColReader(com.linkedin.pinot.core.io.reader.impl.FixedByteSingleValueMultiColReader) PinotDataBuffer(com.linkedin.pinot.core.segment.memory.PinotDataBuffer)

Aggregations

FixedByteSingleValueMultiColReader (com.linkedin.pinot.core.io.reader.impl.FixedByteSingleValueMultiColReader)20 PinotDataBuffer (com.linkedin.pinot.core.segment.memory.PinotDataBuffer)11 FixedByteSingleValueMultiColWriter (com.linkedin.pinot.core.io.writer.impl.FixedByteSingleValueMultiColWriter)9 File (java.io.File)9 Test (org.testng.annotations.Test)8 Random (java.util.Random)7 DataOutputStream (java.io.DataOutputStream)2 FileOutputStream (java.io.FileOutputStream)2 RandomAccessFile (java.io.RandomAccessFile)2 SortedForwardIndexReader (com.linkedin.pinot.core.io.reader.impl.SortedForwardIndexReader)1 SortedValueReaderContext (com.linkedin.pinot.core.io.reader.impl.SortedValueReaderContext)1 IOException (java.io.IOException)1