Package org.teiid.translator.mongodb
Class MongoDBExecutionFactory
- java.lang.Object
-
- org.teiid.translator.ExecutionFactory<ConnectionFactory,MongoDBConnection>
-
- org.teiid.translator.mongodb.MongoDBExecutionFactory
-
@Translator(name="mongodb", description="MongoDB Translator, reads and writes the data to MongoDB") public class MongoDBExecutionFactory extends ExecutionFactory<ConnectionFactory,MongoDBConnection>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.teiid.translator.ExecutionFactory
ExecutionFactory.Format, ExecutionFactory.NullOrder, ExecutionFactory.SupportedJoinCriteria, ExecutionFactory.TransactionSupport
-
-
Field Summary
Fields Modifier and Type Field Description static StringAVOID_PROJECTIONstatic VersionFOUR_0static StringFUNC_GEO_INTERSECTSstatic StringFUNC_GEO_NEARstatic StringFUNC_GEO_NEAR_SPHEREstatic StringFUNC_GEO_POLYGON_INTERSECTSstatic StringFUNC_GEO_POLYGON_WITHINstatic StringFUNC_GEO_WITHINprotected Map<String,FunctionModifier>functionModifiersstatic String[]GEOSPATIAL_FUNCTIONSstatic VersionTHREE_0static VersionTWO_4static VersionTWO_6-
Fields inherited from class org.teiid.translator.ExecutionFactory
DEFAULT_MAX_FROM_GROUPS, DEFAULT_MAX_IN_CRITERIA_SIZE, DEFAULT_MAX_PROJECTED_COLUMNS
-
-
Constructor Summary
Constructors Constructor Description MongoDBExecutionFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectconvertToMongoType(Object value, com.mongodb.DB mongoDB, String fqn)Mongodb only supports certain data types, Teiid need to serialize them in other compatible formats, and convert them back while reading them.ProcedureExecutioncreateDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection)ProcedureExecutioncreateProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection)ResultSetExecutioncreateResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection)UpdateExecutioncreateUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection)StringgetDatabaseVersion()List<String>getDefaultSupportedFunctions()Map<String,FunctionModifier>getFunctionModifiers()MetadataProcessor<MongoDBConnection>getMetadataProcessor()Get a MetadataProcessor for the translator to read the metadata.com.mongodb.AggregationOptionsgetOptions(int batchSize)List<String>getSupportedFunctions()Get list of all supported function names.ExecutionFactory.TransactionSupportgetTransactionSupport()voidinitCapabilities(MongoDBConnection connection)Will be called byExecutionFactory.start()with a null connection if a source connection is notExecutionFactory.isSourceRequiredForCapabilities()booleanisSourceRequiredForCapabilities()If true, theExecutionFactory.initCapabilities(Object)method will be consulted prior to determining the capabilitiesvoidregisterFunctionModifier(String name, FunctionModifier modifier)ObjectretrieveValue(Object value, Class<?> expectedClass, com.mongodb.DB mongoDB, String fqn, String colName)voidsetDatabaseVersion(String version)Sets the database version.voidsetDatabaseVersion(Version version)voidsetSupportsAggregatesCount(boolean value)voidsetUseDisk(boolean useDisk)voidstart()Initialize the connector with supplied configurationbooleansupportsAggregatesAvg()Support indicates connector can accept the AVG aggregate functionbooleansupportsAggregatesCount()Support indicates connector can accept the COUNT aggregate functionbooleansupportsAggregatesCountStar()Support indicates connector can accept the COUNT(*) aggregate functionbooleansupportsAggregatesMax()Support indicates connector can accept the MAX aggregate functionbooleansupportsAggregatesMin()Support indicates connector can accept the MIN aggregate functionbooleansupportsAggregatesSum()Support indicates connector can accept the SUM aggregate functionbooleansupportsBulkUpdate()Whether the source supports updates with multiple value setsbooleansupportsCompareCriteriaEquals()Support indicates connector accepts criteria of form (element = constant)booleansupportsCompareCriteriaOrdered()Support indicates connector accepts criteria of form (element <=|>= constant)
The query engine will may pushdown queries containing < or > if NOT is also supported.booleansupportsGroupBy()Whether the source supports an explicit GROUP BY clausebooleansupportsHaving()Whether the source supports the HAVING clausebooleansupportsInCriteria()Support indicates connector accepts criteria of form (element IN set)booleansupportsIsNullCriteria()Support indicates connector accepts criteria of form (element IS NULL)booleansupportsLikeCriteria()Support indicates connector accepts criteria of form (element LIKE constant)booleansupportsLikeRegex()booleansupportsNotCriteria()Support indicates connector accepts logical criteria NOTbooleansupportsOnlyLiteralComparison()booleansupportsOrCriteria()Support indicates connector accepts logical criteria connected by ORbooleansupportsOrderByUnrelated()Support indicates connector accepts ORDER BY clause with columns not from the selectbooleansupportsRowLimit()Gets whether the connector can limit the number of rows returned by a query.booleansupportsRowOffset()Gets whether the connector supports a SQL clause (similar to the LIMIT with an offset) that can return result sets that start in the middle of the resulting rows returned by a querybooleansupportsSelectExpression()Support indicates connector can accept expressions other than element symbols in the SELECT clause.booleansupportsSelfJoins()Support indicates connector can accept self-joins where a group is joined to itself with aliases.booleanuseAnsiJoin()Whether the source prefers to use ANSI style joins.booleanuseDisk()-
Methods inherited from class org.teiid.translator.ExecutionFactory
addPushDownFunction, areLobsUsableAfterClose, closeConnection, createExecution, getCacheDirective, getCollationLocale, getConnection, getConnection, getDefaultNullOrder, getDirectQueryProcedureName, getExcludedCommonTableExpressionName, getInstance, getLanguageFactory, getMaxDependentInPredicates, getMaxFromGroups, getMaxInCriteriaSize, getMaxProjectedColumns, getMetadata, getNativeQueryProcedureName, getPushDownFunctions, getRequiredLikeEscape, getSupportedJoinCriteria, getTypeFacility, isCopyLobs, isForkable, isImmutable, isSourceRequired, isSourceRequiredForMetadata, isThreadBound, requiresCriteria, returnsSingleUpdateCount, setCollationLocale, setCopyLobs, setDirectQueryProcedureName, setExcludedCommonTableExpressionName, setImmutable, setMaxDependentInPredicates, setMaxInCriteriaSize, setNativeQueryProcedureName, setRequiresCriteria, setSourceRequired, setSourceRequiredForMetadata, setSupportedJoinCriteria, setSupportsDirectQueryProcedure, setSupportsFullOuterJoins, setSupportsInnerJoins, setSupportsNativeQueries, setSupportsOrderBy, setSupportsOuterJoins, setSupportsSelectDistinct, setThreadBound, setTransactionSupport, supportsAdvancedOlapOperations, supportsAggregatesCountBig, supportsAggregatesDistinct, supportsAggregatesEnhancedNumeric, supportsAliasedTable, supportsArrayAgg, supportsArrayType, supportsBatchedUpdates, supportsCommonTableExpressions, supportsCompareCriteriaOrderedExclusive, supportsConvert, supportsCorrelatedSubqueries, supportsCorrelatedSubqueryLimit, supportsDependentJoins, supportsDirectQueryProcedure, supportsElementaryOlapOperations, supportsExcept, supportsExistsCriteria, supportsFormatLiteral, supportsFullDependentJoins, supportsFullOuterJoins, supportsFunctionsInGroupBy, supportsGeographyType, supportsGroupByMultipleDistinctAggregates, supportsGroupByRollup, supportsInCriteriaSubquery, supportsInlineViews, supportsInnerJoins, supportsInsertWithQueryExpression, supportsIntersect, supportsIsDistinctCriteria, supportsLateralJoin, supportsLateralJoinCondition, supportsLikeCriteriaEscapeCharacter, supportsListAgg, supportsMultipleOpenExecutions, supportsNativeQueries, supportsOnlyCorrelatedSubqueries, supportsOnlyFormatLiterals, supportsOnlyLateralJoinProcedure, supportsOnlyRelationshipStyleJoins, supportsOnlySingleTableGroupBy, supportsOnlyTimestampAddLiteral, supportsOrderBy, supportsOrderByNullOrdering, supportsOrderByWithExtendedGrouping, supportsOuterJoins, supportsPartialFiltering, supportsProcedureParameterExpression, supportsProcedureTable, supportsQuantifiedCompareCriteriaAll, supportsQuantifiedCompareCriteriaSome, supportsRecursiveCommonTableExpressions, supportsScalarSubqueries, supportsScalarSubqueryProjection, supportsSearchedCaseExpressions, supportsSelectDistinct, supportsSelectExpressionArrayType, supportsSelectWithoutFrom, supportsSetQueryLimitOffset, supportsSetQueryOrderBy, supportsSimilarTo, supportsStringAgg, supportsSubqueryCommonTableExpressions, supportsSubqueryInOn, supportsUnions, supportsUpsert, supportsWindowDistinctAggregates, supportsWindowFrameClause, supportsWindowFunctionCumeDist, supportsWindowFunctionNthValue, supportsWindowFunctionNtile, supportsWindowFunctionPercentRank, supportsWindowOrderByWithAggregates, useBindingsForDependentJoin
-
-
-
-
Field Detail
-
TWO_4
public static final Version TWO_4
-
TWO_6
public static final Version TWO_6
-
THREE_0
public static final Version THREE_0
-
FOUR_0
public static final Version FOUR_0
-
FUNC_GEO_WITHIN
public static final String FUNC_GEO_WITHIN
- See Also:
- Constant Field Values
-
FUNC_GEO_INTERSECTS
public static final String FUNC_GEO_INTERSECTS
- See Also:
- Constant Field Values
-
FUNC_GEO_NEAR
public static final String FUNC_GEO_NEAR
- See Also:
- Constant Field Values
-
FUNC_GEO_NEAR_SPHERE
public static final String FUNC_GEO_NEAR_SPHERE
- See Also:
- Constant Field Values
-
FUNC_GEO_POLYGON_WITHIN
public static final String FUNC_GEO_POLYGON_WITHIN
- See Also:
- Constant Field Values
-
FUNC_GEO_POLYGON_INTERSECTS
public static final String FUNC_GEO_POLYGON_INTERSECTS
- See Also:
- Constant Field Values
-
GEOSPATIAL_FUNCTIONS
public static final String[] GEOSPATIAL_FUNCTIONS
-
AVOID_PROJECTION
public static final String AVOID_PROJECTION
- See Also:
- Constant Field Values
-
functionModifiers
protected Map<String,FunctionModifier> functionModifiers
-
-
Method Detail
-
start
public void start() throws TranslatorExceptionDescription copied from class:ExecutionFactoryInitialize the connector with supplied configuration- Overrides:
startin classExecutionFactory<ConnectionFactory,MongoDBConnection>- Throws:
TranslatorException
-
getDatabaseVersion
@TranslatorProperty(display="Database Version", description="Database Version") public String getDatabaseVersion()
-
useDisk
@TranslatorProperty(display="Use Disk", description="Use disk for aggregation processing in MongoDB", advanced=true) public boolean useDisk()
-
setUseDisk
public void setUseDisk(boolean useDisk)
-
setDatabaseVersion
public void setDatabaseVersion(String version)
Sets the database version. See alsogetVersion()- Parameters:
version-
-
setDatabaseVersion
public void setDatabaseVersion(Version version)
-
getMetadataProcessor
public MetadataProcessor<MongoDBConnection> getMetadataProcessor()
Description copied from class:ExecutionFactoryGet a MetadataProcessor for the translator to read the metadata. Typically this will return a new instance.- Overrides:
getMetadataProcessorin classExecutionFactory<ConnectionFactory,MongoDBConnection>- Returns:
-
registerFunctionModifier
public void registerFunctionModifier(String name, FunctionModifier modifier)
-
getFunctionModifiers
public Map<String,FunctionModifier> getFunctionModifiers()
-
createResultSetExecution
public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection) throws TranslatorException
- Overrides:
createResultSetExecutionin classExecutionFactory<ConnectionFactory,MongoDBConnection>- Throws:
TranslatorException
-
createProcedureExecution
public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection) throws TranslatorException
- Overrides:
createProcedureExecutionin classExecutionFactory<ConnectionFactory,MongoDBConnection>- Throws:
TranslatorException
-
createUpdateExecution
public UpdateExecution createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection) throws TranslatorException
- Overrides:
createUpdateExecutionin classExecutionFactory<ConnectionFactory,MongoDBConnection>- Throws:
TranslatorException
-
createDirectExecution
public ProcedureExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection) throws TranslatorException
- Overrides:
createDirectExecutionin classExecutionFactory<ConnectionFactory,MongoDBConnection>- Throws:
TranslatorException
-
useAnsiJoin
public boolean useAnsiJoin()
Description copied from class:ExecutionFactoryWhether the source prefers to use ANSI style joins.- Overrides:
useAnsiJoinin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsSelfJoins
public boolean supportsSelfJoins()
Description copied from class:ExecutionFactorySupport indicates connector can accept self-joins where a group is joined to itself with aliases. Connector must also supportExecutionFactory.supportsAliasedTable().- Overrides:
supportsSelfJoinsin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsCompareCriteriaEquals
public boolean supportsCompareCriteriaEquals()
Description copied from class:ExecutionFactorySupport indicates connector accepts criteria of form (element = constant)- Overrides:
supportsCompareCriteriaEqualsin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsCompareCriteriaOrdered
public boolean supportsCompareCriteriaOrdered()
Description copied from class:ExecutionFactorySupport indicates connector accepts criteria of form (element <=|>= constant)
The query engine will may pushdown queries containing < or > if NOT is also supported.- Overrides:
supportsCompareCriteriaOrderedin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsLikeCriteria
public boolean supportsLikeCriteria()
Description copied from class:ExecutionFactorySupport indicates connector accepts criteria of form (element LIKE constant)- Overrides:
supportsLikeCriteriain classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsOrCriteria
public boolean supportsOrCriteria()
Description copied from class:ExecutionFactorySupport indicates connector accepts logical criteria connected by OR- Overrides:
supportsOrCriteriain classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsOrderByUnrelated
public boolean supportsOrderByUnrelated()
Description copied from class:ExecutionFactorySupport indicates connector accepts ORDER BY clause with columns not from the select- Overrides:
supportsOrderByUnrelatedin classExecutionFactory<ConnectionFactory,MongoDBConnection>- Returns:
-
supportsGroupBy
public boolean supportsGroupBy()
Description copied from class:ExecutionFactoryWhether the source supports an explicit GROUP BY clause- Overrides:
supportsGroupByin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsHaving
public boolean supportsHaving()
Description copied from class:ExecutionFactoryWhether the source supports the HAVING clause- Overrides:
supportsHavingin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsAggregatesSum
public boolean supportsAggregatesSum()
Description copied from class:ExecutionFactorySupport indicates connector can accept the SUM aggregate function- Overrides:
supportsAggregatesSumin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsAggregatesAvg
public boolean supportsAggregatesAvg()
Description copied from class:ExecutionFactorySupport indicates connector can accept the AVG aggregate function- Overrides:
supportsAggregatesAvgin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsAggregatesMin
public boolean supportsAggregatesMin()
Description copied from class:ExecutionFactorySupport indicates connector can accept the MIN aggregate function- Overrides:
supportsAggregatesMinin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsAggregatesMax
public boolean supportsAggregatesMax()
Description copied from class:ExecutionFactorySupport indicates connector can accept the MAX aggregate function- Overrides:
supportsAggregatesMaxin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
setSupportsAggregatesCount
public void setSupportsAggregatesCount(boolean value)
-
supportsAggregatesCount
@TranslatorProperty(display="Supports Count(expr)", description="Supports Aggregate function count with expression", advanced=true) public boolean supportsAggregatesCount()
Description copied from class:ExecutionFactorySupport indicates connector can accept the COUNT aggregate function- Overrides:
supportsAggregatesCountin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsAggregatesCountStar
public boolean supportsAggregatesCountStar()
Description copied from class:ExecutionFactorySupport indicates connector can accept the COUNT(*) aggregate function- Overrides:
supportsAggregatesCountStarin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
getSupportedFunctions
public List<String> getSupportedFunctions()
Description copied from class:ExecutionFactoryGet list of all supported function names. Arithmetic functions have names like "+".- Overrides:
getSupportedFunctionsin classExecutionFactory<ConnectionFactory,MongoDBConnection>- See Also:
for a listing of system pushdown functions. Note that not all system functions are listed as some functions will use a common name such as CONCAT vs. the || operator, and other functions will be rewritten and not pushed down, such as SPACE. Note: User defined functions should be specified fully qualified.
-
supportsInCriteria
public boolean supportsInCriteria()
Description copied from class:ExecutionFactorySupport indicates connector accepts criteria of form (element IN set)- Overrides:
supportsInCriteriain classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsNotCriteria
public boolean supportsNotCriteria()
Description copied from class:ExecutionFactorySupport indicates connector accepts logical criteria NOT- Overrides:
supportsNotCriteriain classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsRowLimit
public boolean supportsRowLimit()
Description copied from class:ExecutionFactoryGets whether the connector can limit the number of rows returned by a query.- Overrides:
supportsRowLimitin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsIsNullCriteria
public boolean supportsIsNullCriteria()
Description copied from class:ExecutionFactorySupport indicates connector accepts criteria of form (element IS NULL)- Overrides:
supportsIsNullCriteriain classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsRowOffset
public boolean supportsRowOffset()
Description copied from class:ExecutionFactoryGets whether the connector supports a SQL clause (similar to the LIMIT with an offset) that can return result sets that start in the middle of the resulting rows returned by a query- Overrides:
supportsRowOffsetin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsBulkUpdate
public boolean supportsBulkUpdate()
Description copied from class:ExecutionFactoryWhether the source supports updates with multiple value sets- Overrides:
supportsBulkUpdatein classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsLikeRegex
public boolean supportsLikeRegex()
- Overrides:
supportsLikeRegexin classExecutionFactory<ConnectionFactory,MongoDBConnection>- Returns:
- true if the LIKE_REGEX predicate is supported
-
supportsSelectExpression
public boolean supportsSelectExpression()
Description copied from class:ExecutionFactorySupport indicates connector can accept expressions other than element symbols in the SELECT clause. Specific supports for the expression type are still checked.- Overrides:
supportsSelectExpressionin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsOnlyLiteralComparison
public boolean supportsOnlyLiteralComparison()
- Overrides:
supportsOnlyLiteralComparisonin classExecutionFactory<ConnectionFactory,MongoDBConnection>- Returns:
- true if only Literal comparisons (equality, ordered, like, etc.) are supported for non-join conditions.
-
retrieveValue
public Object retrieveValue(Object value, Class<?> expectedClass, com.mongodb.DB mongoDB, String fqn, String colName) throws TranslatorException
- Throws:
TranslatorException
-
convertToMongoType
public Object convertToMongoType(Object value, com.mongodb.DB mongoDB, String fqn) throws TranslatorException
Mongodb only supports certain data types, Teiid need to serialize them in other compatible formats, and convert them back while reading them.- Parameters:
value-- Returns:
- Throws:
TranslatorException
-
getOptions
public com.mongodb.AggregationOptions getOptions(int batchSize)
-
isSourceRequiredForCapabilities
public boolean isSourceRequiredForCapabilities()
Description copied from class:ExecutionFactoryIf true, theExecutionFactory.initCapabilities(Object)method will be consulted prior to determining the capabilities- Overrides:
isSourceRequiredForCapabilitiesin classExecutionFactory<ConnectionFactory,MongoDBConnection>- Returns:
-
getTransactionSupport
public ExecutionFactory.TransactionSupport getTransactionSupport()
- Overrides:
getTransactionSupportin classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
initCapabilities
public void initCapabilities(MongoDBConnection connection) throws TranslatorException
Description copied from class:ExecutionFactoryWill be called byExecutionFactory.start()with a null connection if a source connection is notExecutionFactory.isSourceRequiredForCapabilities()- Overrides:
initCapabilitiesin classExecutionFactory<ConnectionFactory,MongoDBConnection>- Throws:
TranslatorException
-
-