use of com.linkedin.pinot.core.segment.index.IndexSegmentImpl in project pinot by linkedin.
the class DictionariesTest method test1.
@Test
public void test1() throws Exception {
final IndexSegmentImpl heapSegment = (IndexSegmentImpl) ColumnarSegmentLoader.load(segmentDirectory, ReadMode.heap);
final IndexSegmentImpl mmapSegment = (IndexSegmentImpl) ColumnarSegmentLoader.load(segmentDirectory, ReadMode.mmap);
for (final String column : ((SegmentMetadataImpl) mmapSegment.getSegmentMetadata()).getColumnMetadataMap().keySet()) {
final ImmutableDictionaryReader heapDictionary = heapSegment.getDictionaryFor(column);
final ImmutableDictionaryReader mmapDictionary = mmapSegment.getDictionaryFor(column);
switch(((SegmentMetadataImpl) mmapSegment.getSegmentMetadata()).getColumnMetadataMap().get(column).getDataType()) {
case BOOLEAN:
case STRING:
Assert.assertTrue(heapDictionary instanceof StringDictionary);
Assert.assertTrue(mmapDictionary instanceof StringDictionary);
break;
case DOUBLE:
Assert.assertTrue(heapDictionary instanceof DoubleDictionary);
Assert.assertTrue(mmapDictionary instanceof DoubleDictionary);
break;
case FLOAT:
Assert.assertTrue(heapDictionary instanceof FloatDictionary);
Assert.assertTrue(mmapDictionary instanceof FloatDictionary);
break;
case LONG:
Assert.assertTrue(heapDictionary instanceof LongDictionary);
Assert.assertTrue(mmapDictionary instanceof LongDictionary);
break;
case INT:
Assert.assertTrue(heapDictionary instanceof IntDictionary);
Assert.assertTrue(mmapDictionary instanceof IntDictionary);
break;
}
Assert.assertEquals(mmapDictionary.length(), heapDictionary.length());
for (int i = 0; i < heapDictionary.length(); i++) {
Assert.assertEquals(mmapDictionary.get(i), heapDictionary.get(i));
}
}
}
use of com.linkedin.pinot.core.segment.index.IndexSegmentImpl in project pinot by linkedin.
the class IntArraysTest method test1.
@Test
public void test1() throws Exception {
final IndexSegmentImpl heapSegment = (IndexSegmentImpl) ColumnarSegmentLoader.load(INDEX_DIR.listFiles()[0], ReadMode.heap);
final IndexSegmentImpl mmapSegment = (IndexSegmentImpl) ColumnarSegmentLoader.load(INDEX_DIR.listFiles()[0], ReadMode.mmap);
final Map<String, ColumnMetadata> metadataMap = ((SegmentMetadataImpl) heapSegment.getSegmentMetadata()).getColumnMetadataMap();
for (final String column : metadataMap.keySet()) {
final DataFileReader heapArray = heapSegment.getForwardIndexReaderFor(column);
final DataFileReader mmapArray = mmapSegment.getForwardIndexReaderFor(column);
if (metadataMap.get(column).isSingleValue()) {
final SingleColumnSingleValueReader svHeapReader = (SingleColumnSingleValueReader) heapArray;
final SingleColumnSingleValueReader mvMmapReader = (SingleColumnSingleValueReader) mmapArray;
for (int i = 0; i < metadataMap.get(column).getTotalDocs(); i++) {
Assert.assertEquals(mvMmapReader.getInt(i), svHeapReader.getInt(i));
}
} else {
final SingleColumnMultiValueReader svHeapReader = (SingleColumnMultiValueReader) heapArray;
final SingleColumnMultiValueReader mvMmapReader = (SingleColumnMultiValueReader) mmapArray;
for (int i = 0; i < metadataMap.get(column).getTotalDocs(); i++) {
final int[] i_1 = new int[1000];
final int[] j_i = new int[1000];
Assert.assertEquals(mvMmapReader.getIntArray(i, j_i), svHeapReader.getIntArray(i, i_1));
}
}
}
}
Aggregations