public final class CsvDataContext extends QueryPostprocessDataContext implements UpdateableDataContext
INFORMATION_SCHEMA_NAME, SYSTEM_PROPERTY_CREATE_DEFAULT_TABLE_ALIAS
Constructor and Description |
---|
CsvDataContext(File file)
Constructs a CSV DataContext based on a file
|
CsvDataContext(File file,
CsvConfiguration configuration)
Constructs a CSV DataContext based on a file
The file provided can be either existing or non-existing.
|
CsvDataContext(InputStream inputStream,
CsvConfiguration configuration)
Constructs a CSV DataContext based on an
InputStream |
CsvDataContext(Resource resource,
CsvConfiguration configuration) |
CsvDataContext(URL url,
CsvConfiguration configuration)
Constructs a CSV DataContext based on a
URL |
Modifier and Type | Method and Description |
---|---|
protected com.opencsv.CSVReader |
createCsvReader(BufferedReader reader) |
protected com.opencsv.CSVReader |
createCsvReader(int skipLines) |
protected Number |
executeCountQuery(Table table,
List<FilterItem> whereItems,
boolean functionApproximationAllowed)
Executes a simple count query, if possible.
|
UpdateSummary |
executeUpdate(UpdateScript update)
Submits an
UpdateScript for execution on the DataContext . |
CsvConfiguration |
getConfiguration()
Gets the CSV configuration used
|
protected org.apache.metamodel.csv.CsvSchema |
getMainSchema() |
protected String |
getMainSchemaName() |
Resource |
getResource()
Gets the resource that is being read from.
|
protected boolean |
isWritable() |
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.
|
addConverter, executePrimaryKeyLookupQuery, executeQuery, getDefaultSchemaName, getSchemaByNameInternal, getSchemaNamesInternal, isMainSchemaTable, isScalarFunctionMaterialized, materializeFromItem, materializeMainSchemaTable, materializeMainSchemaTable, materializeMainSchemaTableSelect, materializeTable
compileQuery, executeQuery, executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, isQualifiedPathDelim, onSchemaCacheRefreshed, parseQuery, query, refreshSchemas
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compileQuery, executeQuery, executeQuery, executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, parseQuery, query, refreshSchemas
public CsvDataContext(File file, CsvConfiguration configuration)
file
- configuration
- public CsvDataContext(Resource resource, CsvConfiguration configuration)
public CsvDataContext(URL url, CsvConfiguration configuration)
URL
url
- configuration
- public CsvDataContext(File file)
file
- public CsvDataContext(InputStream inputStream, CsvConfiguration configuration)
InputStream
inputStream
- configuration
- public CsvConfiguration getConfiguration()
public Resource getResource()
protected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed)
QueryPostprocessDataContext
executeCountQuery
in class QueryPostprocessDataContext
table
- the table on which the count is requested.whereItems
- a (sometimes empty) list of WHERE items.functionApproximationAllowed
- whether approximation is allowed or not.public DataSet materializeMainSchemaTable(Table table, List<Column> columns, int maxRows)
QueryPostprocessDataContext
materializeMainSchemaTable
in class QueryPostprocessDataContext
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.protected com.opencsv.CSVReader createCsvReader(int skipLines)
protected com.opencsv.CSVReader createCsvReader(BufferedReader reader)
protected org.apache.metamodel.csv.CsvSchema getMainSchema() throws MetaModelException
getMainSchema
in class QueryPostprocessDataContext
MetaModelException
protected String getMainSchemaName()
getMainSchemaName
in class QueryPostprocessDataContext
protected boolean isWritable()
public UpdateSummary executeUpdate(UpdateScript update)
UpdateableDataContext
UpdateScript
for execution on the DataContext
.
Since implementations of the DataContext
vary quite a lot, there
is no golden rule as to how an update script will be executed. But the
implementors should strive towards handling an UpdateScript
as a
single transactional change to the data store.executeUpdate
in interface UpdateableDataContext
update
- the update script to executeCopyright © 2007–2021 The Apache Software Foundation. All rights reserved.