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 String
AVOID_PROJECTION
static Version
FOUR_0
static String
FUNC_GEO_INTERSECTS
static String
FUNC_GEO_NEAR
static String
FUNC_GEO_NEAR_SPHERE
static String
FUNC_GEO_POLYGON_INTERSECTS
static String
FUNC_GEO_POLYGON_WITHIN
static String
FUNC_GEO_WITHIN
protected Map<String,FunctionModifier>
functionModifiers
static String[]
GEOSPATIAL_FUNCTIONS
static Version
THREE_0
static Version
TWO_4
static Version
TWO_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 Object
convertToMongoType(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.ProcedureExecution
createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection)
ProcedureExecution
createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection)
ResultSetExecution
createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection)
UpdateExecution
createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection)
String
getDatabaseVersion()
List<String>
getDefaultSupportedFunctions()
Map<String,FunctionModifier>
getFunctionModifiers()
MetadataProcessor<MongoDBConnection>
getMetadataProcessor()
Get a MetadataProcessor for the translator to read the metadata.com.mongodb.AggregationOptions
getOptions(int batchSize)
List<String>
getSupportedFunctions()
Get list of all supported function names.ExecutionFactory.TransactionSupport
getTransactionSupport()
void
initCapabilities(MongoDBConnection connection)
Will be called byExecutionFactory.start()
with a null connection if a source connection is notExecutionFactory.isSourceRequiredForCapabilities()
boolean
isSourceRequiredForCapabilities()
If true, theExecutionFactory.initCapabilities(Object)
method will be consulted prior to determining the capabilitiesvoid
registerFunctionModifier(String name, FunctionModifier modifier)
Object
retrieveValue(Object value, Class<?> expectedClass, com.mongodb.DB mongoDB, String fqn, String colName)
void
setDatabaseVersion(String version)
Sets the database version.void
setDatabaseVersion(Version version)
void
setSupportsAggregatesCount(boolean value)
void
setUseDisk(boolean useDisk)
void
start()
Initialize the connector with supplied configurationboolean
supportsAggregatesAvg()
Support indicates connector can accept the AVG aggregate functionboolean
supportsAggregatesCount()
Support indicates connector can accept the COUNT aggregate functionboolean
supportsAggregatesCountStar()
Support indicates connector can accept the COUNT(*) aggregate functionboolean
supportsAggregatesMax()
Support indicates connector can accept the MAX aggregate functionboolean
supportsAggregatesMin()
Support indicates connector can accept the MIN aggregate functionboolean
supportsAggregatesSum()
Support indicates connector can accept the SUM aggregate functionboolean
supportsBulkUpdate()
Whether the source supports updates with multiple value setsboolean
supportsCompareCriteriaEquals()
Support indicates connector accepts criteria of form (element = constant)boolean
supportsCompareCriteriaOrdered()
Support indicates connector accepts criteria of form (element <=|>= constant)
The query engine will may pushdown queries containing < or > if NOT is also supported.boolean
supportsGroupBy()
Whether the source supports an explicit GROUP BY clauseboolean
supportsHaving()
Whether the source supports the HAVING clauseboolean
supportsInCriteria()
Support indicates connector accepts criteria of form (element IN set)boolean
supportsIsNullCriteria()
Support indicates connector accepts criteria of form (element IS NULL)boolean
supportsLikeCriteria()
Support indicates connector accepts criteria of form (element LIKE constant)boolean
supportsLikeRegex()
boolean
supportsNotCriteria()
Support indicates connector accepts logical criteria NOTboolean
supportsOnlyLiteralComparison()
boolean
supportsOrCriteria()
Support indicates connector accepts logical criteria connected by ORboolean
supportsOrderByUnrelated()
Support indicates connector accepts ORDER BY clause with columns not from the selectboolean
supportsRowLimit()
Gets whether the connector can limit the number of rows returned by a query.boolean
supportsRowOffset()
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 queryboolean
supportsSelectExpression()
Support indicates connector can accept expressions other than element symbols in the SELECT clause.boolean
supportsSelfJoins()
Support indicates connector can accept self-joins where a group is joined to itself with aliases.boolean
useAnsiJoin()
Whether the source prefers to use ANSI style joins.boolean
useDisk()
-
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 TranslatorException
Description copied from class:ExecutionFactory
Initialize the connector with supplied configuration- Overrides:
start
in 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:ExecutionFactory
Get a MetadataProcessor for the translator to read the metadata. Typically this will return a new instance.- Overrides:
getMetadataProcessor
in 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:
createResultSetExecution
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
- Throws:
TranslatorException
-
createProcedureExecution
public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection) throws TranslatorException
- Overrides:
createProcedureExecution
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
- Throws:
TranslatorException
-
createUpdateExecution
public UpdateExecution createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection) throws TranslatorException
- Overrides:
createUpdateExecution
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
- Throws:
TranslatorException
-
createDirectExecution
public ProcedureExecution createDirectExecution(List<Argument> arguments, Command command, ExecutionContext executionContext, RuntimeMetadata metadata, MongoDBConnection connection) throws TranslatorException
- Overrides:
createDirectExecution
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
- Throws:
TranslatorException
-
useAnsiJoin
public boolean useAnsiJoin()
Description copied from class:ExecutionFactory
Whether the source prefers to use ANSI style joins.- Overrides:
useAnsiJoin
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsSelfJoins
public boolean supportsSelfJoins()
Description copied from class:ExecutionFactory
Support indicates connector can accept self-joins where a group is joined to itself with aliases. Connector must also supportExecutionFactory.supportsAliasedTable()
.- Overrides:
supportsSelfJoins
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsCompareCriteriaEquals
public boolean supportsCompareCriteriaEquals()
Description copied from class:ExecutionFactory
Support indicates connector accepts criteria of form (element = constant)- Overrides:
supportsCompareCriteriaEquals
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsCompareCriteriaOrdered
public boolean supportsCompareCriteriaOrdered()
Description copied from class:ExecutionFactory
Support indicates connector accepts criteria of form (element <=|>= constant)
The query engine will may pushdown queries containing < or > if NOT is also supported.- Overrides:
supportsCompareCriteriaOrdered
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsLikeCriteria
public boolean supportsLikeCriteria()
Description copied from class:ExecutionFactory
Support indicates connector accepts criteria of form (element LIKE constant)- Overrides:
supportsLikeCriteria
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsOrCriteria
public boolean supportsOrCriteria()
Description copied from class:ExecutionFactory
Support indicates connector accepts logical criteria connected by OR- Overrides:
supportsOrCriteria
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsOrderByUnrelated
public boolean supportsOrderByUnrelated()
Description copied from class:ExecutionFactory
Support indicates connector accepts ORDER BY clause with columns not from the select- Overrides:
supportsOrderByUnrelated
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
- Returns:
-
supportsGroupBy
public boolean supportsGroupBy()
Description copied from class:ExecutionFactory
Whether the source supports an explicit GROUP BY clause- Overrides:
supportsGroupBy
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsHaving
public boolean supportsHaving()
Description copied from class:ExecutionFactory
Whether the source supports the HAVING clause- Overrides:
supportsHaving
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsAggregatesSum
public boolean supportsAggregatesSum()
Description copied from class:ExecutionFactory
Support indicates connector can accept the SUM aggregate function- Overrides:
supportsAggregatesSum
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsAggregatesAvg
public boolean supportsAggregatesAvg()
Description copied from class:ExecutionFactory
Support indicates connector can accept the AVG aggregate function- Overrides:
supportsAggregatesAvg
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsAggregatesMin
public boolean supportsAggregatesMin()
Description copied from class:ExecutionFactory
Support indicates connector can accept the MIN aggregate function- Overrides:
supportsAggregatesMin
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsAggregatesMax
public boolean supportsAggregatesMax()
Description copied from class:ExecutionFactory
Support indicates connector can accept the MAX aggregate function- Overrides:
supportsAggregatesMax
in 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:ExecutionFactory
Support indicates connector can accept the COUNT aggregate function- Overrides:
supportsAggregatesCount
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsAggregatesCountStar
public boolean supportsAggregatesCountStar()
Description copied from class:ExecutionFactory
Support indicates connector can accept the COUNT(*) aggregate function- Overrides:
supportsAggregatesCountStar
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
getSupportedFunctions
public List<String> getSupportedFunctions()
Description copied from class:ExecutionFactory
Get list of all supported function names. Arithmetic functions have names like "+".- Overrides:
getSupportedFunctions
in 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:ExecutionFactory
Support indicates connector accepts criteria of form (element IN set)- Overrides:
supportsInCriteria
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsNotCriteria
public boolean supportsNotCriteria()
Description copied from class:ExecutionFactory
Support indicates connector accepts logical criteria NOT- Overrides:
supportsNotCriteria
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsRowLimit
public boolean supportsRowLimit()
Description copied from class:ExecutionFactory
Gets whether the connector can limit the number of rows returned by a query.- Overrides:
supportsRowLimit
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsIsNullCriteria
public boolean supportsIsNullCriteria()
Description copied from class:ExecutionFactory
Support indicates connector accepts criteria of form (element IS NULL)- Overrides:
supportsIsNullCriteria
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsRowOffset
public boolean supportsRowOffset()
Description copied from class:ExecutionFactory
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 query- Overrides:
supportsRowOffset
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsBulkUpdate
public boolean supportsBulkUpdate()
Description copied from class:ExecutionFactory
Whether the source supports updates with multiple value sets- Overrides:
supportsBulkUpdate
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsLikeRegex
public boolean supportsLikeRegex()
- Overrides:
supportsLikeRegex
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
- Returns:
- true if the LIKE_REGEX predicate is supported
-
supportsSelectExpression
public boolean supportsSelectExpression()
Description copied from class:ExecutionFactory
Support indicates connector can accept expressions other than element symbols in the SELECT clause. Specific supports for the expression type are still checked.- Overrides:
supportsSelectExpression
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
supportsOnlyLiteralComparison
public boolean supportsOnlyLiteralComparison()
- Overrides:
supportsOnlyLiteralComparison
in 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:ExecutionFactory
If true, theExecutionFactory.initCapabilities(Object)
method will be consulted prior to determining the capabilities- Overrides:
isSourceRequiredForCapabilities
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
- Returns:
-
getTransactionSupport
public ExecutionFactory.TransactionSupport getTransactionSupport()
- Overrides:
getTransactionSupport
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
-
initCapabilities
public void initCapabilities(MongoDBConnection connection) throws TranslatorException
Description copied from class:ExecutionFactory
Will be called byExecutionFactory.start()
with a null connection if a source connection is notExecutionFactory.isSourceRequiredForCapabilities()
- Overrides:
initCapabilities
in classExecutionFactory<ConnectionFactory,MongoDBConnection>
- Throws:
TranslatorException
-
-