public abstract class QueryPostprocessDataContext extends AbstractDataContext implements HasReadTypeConverters
Modifier and Type | Field and Description |
---|---|
static String |
INFORMATION_SCHEMA_NAME |
static String |
SYSTEM_PROPERTY_CREATE_DEFAULT_TABLE_ALIAS |
Constructor and Description |
---|
QueryPostprocessDataContext() |
QueryPostprocessDataContext(boolean singleTableDatastore) |
Modifier and Type | Method and Description |
---|---|
void |
addConverter(Column column,
TypeConverter<?,?> converter)
Adds a
TypeConverter to this DataContext's query engine (Query Postprocessor) for read operations. |
protected Number |
executeCountQuery(Table table,
List<FilterItem> whereItems,
boolean functionApproximationAllowed)
Executes a simple count query, if possible.
|
protected Row |
executePrimaryKeyLookupQuery(Table table,
List<SelectItem> selectItems,
Column primaryKeyColumn,
Object keyValue)
Executes a query which obtains a row by primary key (as defined by
Column.isPrimaryKey() ). |
DataSet |
executeQuery(Query query)
Executes a query against the DataContext.
|
protected String |
getDefaultSchemaName()
Gets the name of the default schema.
|
protected abstract Schema |
getMainSchema() |
protected abstract String |
getMainSchemaName() |
protected Schema |
getSchemaByNameInternal(String name)
Gets a specific schema from the non-abstract implementation.
|
protected List<String> |
getSchemaNamesInternal()
Gets schema names from the non-abstract implementation.
|
protected boolean |
isMainSchemaTable(Table table) |
protected boolean |
isScalarFunctionMaterialized(ScalarFunction function)
Determines if the subclass of this class can materialize
SelectItem s with the given
ScalarFunction . |
protected DataSet |
materializeFromItem(FromItem fromItem,
List<SelectItem> selectItems) |
protected abstract DataSet |
materializeMainSchemaTable(Table table,
List<Column> columns,
int maxRows)
Executes a simple one-table query against a table in the main schema of the subclasses of this class.
|
protected DataSet |
materializeMainSchemaTable(Table table,
List<Column> columns,
int firstRow,
int maxRows)
Executes a simple one-table query against a table in the main schema of the subclasses of this class.
|
protected DataSet |
materializeMainSchemaTable(Table table,
List<SelectItem> selectItems,
List<FilterItem> whereItems,
int firstRow,
int maxRows)
Execute a simple one-table query against a table in the main schema of the subclasses of this class.
|
protected DataSet |
materializeMainSchemaTableSelect(Table table,
List<SelectItem> selectItems,
int firstRow,
int maxRows)
Executes a simple one-table query against a table in the main schema of the subclasses of this class.
|
protected DataSet |
materializeTable(Table table,
List<SelectItem> selectItems,
List<FilterItem> whereItems,
int firstRow,
int maxRows) |
compileQuery, executeQuery, executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, isQualifiedPathDelim, onSchemaCacheRefreshed, parseQuery, query, refreshSchemas
public static final String SYSTEM_PROPERTY_CREATE_DEFAULT_TABLE_ALIAS
public static final String INFORMATION_SCHEMA_NAME
public QueryPostprocessDataContext()
public QueryPostprocessDataContext(boolean singleTableDatastore)
singleTableDatastore
- a flag that, if set to true, indicates that this DataContext contains just a single
table. This information will be used to optimize and provide convenience for the implementation. An
additional Table
of type TableType.ALIAS
with the name "default_table" will be
automatically added in addition to the single table. That again makes for convenient querying of the
single table using a predictable name/alias.public DataSet executeQuery(Query query)
DataContext
executeQuery
in interface DataContext
query
- the query object to executeDataSet
produced from executing the queryprotected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed)
table
- the table on which the count is requested.whereItems
- a (sometimes empty) list of WHERE items.functionApproximationAllowed
- whether approximation is allowed or not.protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn, Object keyValue)
Column.isPrimaryKey()
). This method is
provided to allow subclasses to optimize lookup queries since they are quite common and often a datastore can
retrieve the row using some specialized means which is much more performant than scanning all records manually.table
- the table on which the lookup is requested.selectItems
- the items to select from the lookup query.primaryKeyColumn
- the column that is the primary keykeyValue
- the primary key value that is specified in the lookup query.protected DataSet materializeFromItem(FromItem fromItem, List<SelectItem> selectItems)
protected DataSet materializeTable(Table table, List<SelectItem> selectItems, List<FilterItem> whereItems, int firstRow, int maxRows)
protected boolean isScalarFunctionMaterialized(ScalarFunction function)
SelectItem
s with the given
ScalarFunction
. Usually scalar functions are applied by MetaModel on the client side, but when possible
they can also be handled by e.g. materializeMainSchemaTable(Table, List, int, int)
and
materializeMainSchemaTable(Table, List, List, int, int)
in which case MetaModel will not evaluate it
client-side.function
- protected boolean isMainSchemaTable(Table table)
protected final List<String> getSchemaNamesInternal() throws MetaModelException
AbstractDataContext
AbstractDataContext.refreshSchemas()
method is called.getSchemaNamesInternal
in class AbstractDataContext
MetaModelException
protected String getDefaultSchemaName() throws MetaModelException
AbstractDataContext
getDefaultSchemaName
in class AbstractDataContext
MetaModelException
protected final Schema getSchemaByNameInternal(String name) throws MetaModelException
AbstractDataContext
AbstractDataContext.refreshSchemas()
method is called.getSchemaByNameInternal
in class AbstractDataContext
name
- the name of the schema to getMetaModelException
public void addConverter(Column column, TypeConverter<?,?> converter)
TypeConverter
to this DataContext's query engine (Query Postprocessor) for read operations. Note
that this method should NOT be invoked directly by consuming code. Rather use
Converters.addTypeConverter(DataContext, Column, TypeConverter)
to ensure conversion on both reads and
writes.addConverter
in interface HasReadTypeConverters
protected abstract Schema getMainSchema() throws MetaModelException
MetaModelException
protected abstract String getMainSchemaName() throws MetaModelException
MetaModelException
protected DataSet materializeMainSchemaTable(Table table, List<SelectItem> selectItems, List<FilterItem> whereItems, int firstRow, int maxRows)
materializeMainSchemaTable(Table, List, int, int)
and apply WHERE item
filtering afterwards.table
- selectItems
- whereItems
- firstRow
- maxRows
- protected DataSet materializeMainSchemaTableSelect(Table table, List<SelectItem> selectItems, int firstRow, int maxRows)
materializeMainSchemaTable(Table, List, int, int)
.table
- selectItems
- firstRow
- maxRows
- protected DataSet materializeMainSchemaTable(Table table, List<Column> columns, int firstRow, int maxRows)
materializeMainSchemaTable(Table, List, int)
and apply a
FirstRowDataSet
if necessary.table
- columns
- firstRow
- maxRows
- protected abstract DataSet materializeMainSchemaTable(Table table, List<Column> columns, int maxRows)
table
- the table to querycolumns
- the columns of the table to querymaxRows
- the maximum amount of rows needed or -1 if all rows are wanted.Copyright © 2007–2017 The Apache Software Foundation. All rights reserved.