Class OffHeapBitmapInvertedIndexCreator
- java.lang.Object
-
- org.apache.pinot.segment.local.segment.creator.impl.inv.OffHeapBitmapInvertedIndexCreator
-
- All Implemented Interfaces:
Closeable,AutoCloseable,DictionaryBasedInvertedIndexCreator,InvertedIndexCreator,IndexCreator
public final class OffHeapBitmapInvertedIndexCreator extends Object implements DictionaryBasedInvertedIndexCreator
Implementation ofDictionaryBasedInvertedIndexCreatorthat uses off-heap memory.We use 2 passes to create the inverted index.
- In the first pass (adding values phase), when add() method is called, store the dictIds into the forward index value buffer (for multi-valued column also store number of values for each docId into forward index length buffer). We also compute the inverted index length for each dictId while adding values.
-
In the second pass (processing values phase), when seal() method is called, all the dictIds should already been
added. We first reorder the values into the inverted index buffers by going over the dictIds in forward index
value buffer (for multi-valued column we also need forward index length buffer to get the docId for each dictId).
Once we have the inverted index buffers, we simply go over them and create the bitmap for each dictId and serialize them into a file.
Based on the number of values we need to store, we use direct memory or MMap file to allocate the buffer.
-
-
Constructor Summary
Constructors Constructor Description OffHeapBitmapInvertedIndexCreator(File indexDir, String columnName, boolean singleValue, int cardinality, int numDocs, int numValues, String extension)OffHeapBitmapInvertedIndexCreator(File indexDir, FieldSpec fieldSpec, int cardinality, int numDocs, int numValues)OffHeapBitmapInvertedIndexCreator(File indexDir, FieldSpec fieldSpec, int cardinality, int numDocs, int numValues, String extension)Like callingOffHeapBitmapInvertedIndexCreator(File, String, boolean, int, int, int, String)with the column name and single value specified by the givenFieldSpec.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int dictId)voidadd(int[] dictIds, int length)voidadd(it.unimi.dsi.fastutil.ints.IntIterator dictIds)voidclose()static FilegetDefaultFile(File indexDir, String columnName, String extension)voidseal()voidseal(FileChannel channel)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.pinot.segment.spi.index.creator.DictionaryBasedInvertedIndexCreator
add, add
-
-
-
-
Constructor Detail
-
OffHeapBitmapInvertedIndexCreator
public OffHeapBitmapInvertedIndexCreator(File indexDir, FieldSpec fieldSpec, int cardinality, int numDocs, int numValues) throws IOException
-
OffHeapBitmapInvertedIndexCreator
public OffHeapBitmapInvertedIndexCreator(File indexDir, FieldSpec fieldSpec, int cardinality, int numDocs, int numValues, String extension) throws IOException
Like callingOffHeapBitmapInvertedIndexCreator(File, String, boolean, int, int, int, String)with the column name and single value specified by the givenFieldSpec.
-
OffHeapBitmapInvertedIndexCreator
public OffHeapBitmapInvertedIndexCreator(File indexDir, String columnName, boolean singleValue, int cardinality, int numDocs, int numValues, String extension) throws IOException
- Parameters:
indexDir- The directory where the index will be created.columnName- The name of the column being indexed.singleValue- True iff the column is single value.cardinality- How many different values the column has.numDocs- How many documents are expected.numValues- How many values the index will have. This should be equal to numDocs in single value columns, but may be higher in multivalued columns.extension- The suffix added to the file. Although is called extension, it behaves likeFiles.createTempFile(String, String, FileAttribute[])suffix parameter.- Throws:
IOException
-
-
Method Detail
-
getDefaultFile
public static File getDefaultFile(File indexDir, String columnName, String extension)
-
add
public void add(int dictId)
- Specified by:
addin interfaceDictionaryBasedInvertedIndexCreator
-
add
public void add(it.unimi.dsi.fastutil.ints.IntIterator dictIds)
-
add
public void add(int[] dictIds, int length)- Specified by:
addin interfaceDictionaryBasedInvertedIndexCreator
-
seal
public void seal() throws IOException- Specified by:
sealin interfaceIndexCreator- Specified by:
sealin interfaceInvertedIndexCreator- Throws:
IOException
-
seal
public void seal(FileChannel channel) throws IOException
- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-