Package org.apache.druid.segment.join
Interface Joinable
-
- All Superinterfaces:
ReferenceCountedObject
- All Known Implementing Classes:
IndexedTableJoinable,LookupJoinable
public interface Joinable extends ReferenceCountedObject
Represents something that can be the right-hand side of a join. This class's most important method ismakeJoinMatcher(org.apache.druid.segment.ColumnSelectorFactory, org.apache.druid.segment.join.JoinConditionAnalysis, boolean, boolean, org.apache.druid.java.util.common.io.Closer). Its main user isHashJoinEngine.makeJoinCursor(org.apache.druid.segment.Cursor, org.apache.druid.segment.join.JoinableClause, boolean, org.apache.druid.java.util.common.io.Closer).
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classJoinable.ColumnValuesWithUniqueFlag
-
Field Summary
Fields Modifier and Type Field Description static intCARDINALITY_UNKNOWN
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description List<String>getAvailableColumns()Returns the list of columns that this Joinable offers.intgetCardinality(String columnName)Returns the cardinality of "columnName", orCARDINALITY_UNKNOWNif not known.ColumnCapabilitiesgetColumnCapabilities(String columnName)Returns capabilities for one of this Joinable's columns.Optional<InDimFilter.ValuesSet>getCorrelatedColumnValues(String searchColumnName, String searchColumnValue, String retrievalColumnName, long maxCorrelationSetSize, boolean allowNonKeyColumnSearch)Searches a column from this Joinable for a particular value, finds rows that match, and returns values of a second column for those rows.Joinable.ColumnValuesWithUniqueFlaggetMatchableColumnValues(String columnName, boolean includeNull, int maxNumValues)Returns all matchable values from a particular column along with a flag to tell if they are all unique in the column.JoinMatchermakeJoinMatcher(ColumnSelectorFactory leftColumnSelectorFactory, JoinConditionAnalysis condition, boolean remainderNeeded, boolean descending, Closer closer)Creates a JoinMatcher that can be used to implement a join onto this Joinable.-
Methods inherited from interface org.apache.druid.segment.ReferenceCountedObject
acquireReferences
-
-
-
-
Field Detail
-
CARDINALITY_UNKNOWN
static final int CARDINALITY_UNKNOWN
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAvailableColumns
List<String> getAvailableColumns()
Returns the list of columns that this Joinable offers.
-
getCardinality
int getCardinality(String columnName)
Returns the cardinality of "columnName", orCARDINALITY_UNKNOWNif not known. May be used at query time to trigger optimizations. If notCARDINALITY_UNKNOWN, this must match the cardinality of selectors returned by theColumnSelectorFactory.makeDimensionSelector(org.apache.druid.query.dimension.DimensionSpec)method of this joinable'sJoinMatcher.getColumnSelectorFactory().
-
getColumnCapabilities
@Nullable ColumnCapabilities getColumnCapabilities(String columnName)
Returns capabilities for one of this Joinable's columns.- Parameters:
columnName- column name- Returns:
- capabilities, or null if the columnName is not one of this Joinable's columns
-
makeJoinMatcher
JoinMatcher makeJoinMatcher(ColumnSelectorFactory leftColumnSelectorFactory, JoinConditionAnalysis condition, boolean remainderNeeded, boolean descending, Closer closer)
Creates a JoinMatcher that can be used to implement a join onto this Joinable.- Parameters:
leftColumnSelectorFactory- column selector factory that allows access to the left-hand side of the joincondition- join condition for the matcherremainderNeeded- whether or notJoinMatcher.matchRemainder()will ever be called on the matcher. If we know it will not, additional optimizations are often possible.descending- true if join cursor is iterated in descending ordercloser- closer that will run after join cursor has completed to clean up any per query resources the joinable uses- Returns:
- the matcher
-
getMatchableColumnValues
Joinable.ColumnValuesWithUniqueFlag getMatchableColumnValues(String columnName, boolean includeNull, int maxNumValues)
Returns all matchable values from a particular column along with a flag to tell if they are all unique in the column. If the matchable values are greater than "maxNumValues" or if the column doesn't exists or doesn't supports this operation, returns an object with empty set for column values and false for uniqueness flag. The uniqueness flag will only be true if we've collected all matchable values in the column and found that they're all unique. In all other cases it will be false. The returned set may be passed toInDimFilter. For efficiency, implementations should prefer creating the returned set withnew TreeSet<String>(Comparators.naturalNullsFirst()}. This avoids a copy in the filter's constructor.- Parameters:
columnName- name of the columnincludeNull- whether null should be considered a matchable value. If true, this method returns all values that are present in the column. If false, this method returns all non-null values.maxNumValues- maximum number of values to return. If exceeded, returns an empty set with the "allUnique" flag set to false.
-
getCorrelatedColumnValues
Optional<InDimFilter.ValuesSet> getCorrelatedColumnValues(String searchColumnName, String searchColumnValue, String retrievalColumnName, long maxCorrelationSetSize, boolean allowNonKeyColumnSearch)
Searches a column from this Joinable for a particular value, finds rows that match, and returns values of a second column for those rows. The returned set may be passed toInDimFilter. For efficiency, implementations should prefer creating the returned set withnew TreeSet<String>(Comparators.naturalNullsFirst()}. This avoids a copy in the filter's constructor.- Parameters:
searchColumnName- Name of the search column. This is the column that is being used in the filtersearchColumnValue- Target value of the search column. This is the value that is being filtered on.retrievalColumnName- The column to retrieve values from. This is the column that is being joined against.maxCorrelationSetSize- Maximum number of values to retrieve. If we detect that more values would be returned than this limit, return absent.allowNonKeyColumnSearch- If true, allow searchs on non-key columns. If this is false, a search on a non-key column returns absent.- Returns:
- The set of correlated column values. If we cannot determine correlated values, return absent. In case either the search or retrieval column names are not found, this will return absent.
-
-