Class RowBasedIndexedTable<RowType>
- java.lang.Object
-
- org.apache.druid.segment.join.table.RowBasedIndexedTable<RowType>
-
- All Implemented Interfaces:
Closeable,AutoCloseable,IndexedTable,ReferenceCountedObject
public class RowBasedIndexedTable<RowType> extends Object implements IndexedTable
An IndexedTable composed of a List-based table and Map-based indexes. The implementation is agnostic to the specific row type; it uses aRowAdapterto work with any sort of object. The class allows passing in a cache key. If the key is non-null, results of any join on this table can be cached. That cache becomes invalidated if this key changes. Creators of this class can pass in a non-null cache key if its possible to construct a small identifier - that must change when contents of this indexed table chances - May remain unchanged when contents of this indexed table How the cache key is constructed itself, depends on how the RowBasedIndexedTable is being built.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.druid.segment.join.table.IndexedTable
IndexedTable.Index, IndexedTable.Reader
-
-
Constructor Summary
Constructors Constructor Description RowBasedIndexedTable(List<RowType> table, RowAdapter<RowType> rowAdapter, RowSignature rowSignature, Set<String> keyColumns, String version)RowBasedIndexedTable(List<RowType> table, RowAdapter<RowType> rowAdapter, RowSignature rowSignature, Set<String> keyColumns, String version, byte[] cacheKey)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<Closeable>acquireReferences()This method is expected to increment a reference count and provide aCloseablethat decrements the reference count when closed.voidclose()IndexedTable.IndexcolumnIndex(int column)Returns the index for a particular column.IndexedTable.ReadercolumnReader(int column)Returns a reader for a particular column.byte[]computeCacheKey()Computes abyte[]key for the table that can be used for computing cache keys for join operations.booleanisCacheable()Returns whether this indexed table can be cached for the join operationsSet<String>keyColumns()Returns the columns of this table that have indexes.intnumRows()Returns the number of rows in this table.RowSignaturerowSignature()Returns the signature of this table, which includes all key columns (as well as other columns that can be selected, but are not keys).Stringversion()Returns the version of this table, used to compare against when loading a new version of the table-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.segment.join.table.IndexedTable
makeColumnSelectorFactory
-
-
-
-
Constructor Detail
-
RowBasedIndexedTable
public RowBasedIndexedTable(List<RowType> table, RowAdapter<RowType> rowAdapter, RowSignature rowSignature, Set<String> keyColumns, String version)
-
RowBasedIndexedTable
public RowBasedIndexedTable(List<RowType> table, RowAdapter<RowType> rowAdapter, RowSignature rowSignature, Set<String> keyColumns, String version, @Nullable byte[] cacheKey)
-
-
Method Detail
-
version
public String version()
Description copied from interface:IndexedTableReturns the version of this table, used to compare against when loading a new version of the table- Specified by:
versionin interfaceIndexedTable
-
keyColumns
public Set<String> keyColumns()
Description copied from interface:IndexedTableReturns the columns of this table that have indexes.- Specified by:
keyColumnsin interfaceIndexedTable
-
rowSignature
public RowSignature rowSignature()
Description copied from interface:IndexedTableReturns the signature of this table, which includes all key columns (as well as other columns that can be selected, but are not keys).- Specified by:
rowSignaturein interfaceIndexedTable
-
columnIndex
public IndexedTable.Index columnIndex(int column)
Description copied from interface:IndexedTableReturns the index for a particular column. The provided column number must be that column's position inIndexedTable.rowSignature().- Specified by:
columnIndexin interfaceIndexedTable
-
columnReader
public IndexedTable.Reader columnReader(int column)
Description copied from interface:IndexedTableReturns a reader for a particular column. The provided column number must be that column's position inIndexedTable.rowSignature(). Don't forget to close yourIndexedTable.Readerwhen finished reading, to clean up any resources.- Specified by:
columnReaderin interfaceIndexedTable
-
computeCacheKey
public byte[] computeCacheKey()
Description copied from interface:IndexedTableComputes abyte[]key for the table that can be used for computing cache keys for join operations. seeJoinableFactory.computeJoinCacheKey(org.apache.druid.query.DataSource, org.apache.druid.segment.join.JoinConditionAnalysis)- Specified by:
computeCacheKeyin interfaceIndexedTable- Returns:
- the byte array for cache key
-
isCacheable
public boolean isCacheable()
Description copied from interface:IndexedTableReturns whether this indexed table can be cached for the join operations- Specified by:
isCacheablein interfaceIndexedTable
-
numRows
public int numRows()
Description copied from interface:IndexedTableReturns the number of rows in this table. It must not change over time, since it is used for things like algorithm selection and reporting of cardinality metadata.- Specified by:
numRowsin interfaceIndexedTable
-
acquireReferences
public Optional<Closeable> acquireReferences()
Description copied from interface:ReferenceCountedObjectThis method is expected to increment a reference count and provide aCloseablethat decrements the reference count when closed. This is likely just a wrapper aroundReferenceCountingCloseableObject.incrementReferenceAndDecrementOnceCloseable(), but may also include any other associated references which should be incremented when this method is called, and decremented/released by the closeable. IMPORTANT NOTE: to fulfill the contract of this method, implementors must return a closeable to indicate that the reference can be acquired, even if there is nothing to close. Implementors should avoid allowing this method or theCloseableit creates to throw exceptions. For callers: if this method returns non-empty, IT MUST BE CLOSED, else reference counts can potentially leak.- Specified by:
acquireReferencesin interfaceReferenceCountedObject
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-