public interface RogLogQueryEngine extends QueryEngine<Long,RogLog.Entry>
RogLogQueryEngine provides query access to a set of RogLog files. It provides SQL-like query syntax for performing queries.
To understand how we query logs we first want to look at the structure of a log. A log is comprised of series of RogLog.Entry object. Each RogLog.Entry
is composed of:
IRogMetadata including things like transactionId, object id (a UUID), etc which is accessed via RogLog.Entry.getMetadata()
null for removes) accessed via RogLog.Entry.getObject()
RogLog.Entry.getEntryType()
To facility querying in a familiar SQL like manner, we map this structure to a single logical table with one row per RogLog.Entry in the log.
Each row is composed of RogLog.Entry fields, Metadata and a column for each Entity and/pr Message type present in the recovery log.
For example, in a state replication log we might have objects such as Customer, Address and Order and OrderRequest.
We would then have 6 columns in the table which represents this log and any given row of the table will contain the RogLog.Entry fields and Metadata for the log Entry
and will have exactly one Entity or Message type column populated, e.g.
| Entry | Metadata | Address | Customer | Order | OrderRequest | |
|---|---|---|---|---|---|---|
RogLog.Entry | Metadata | null | Customer(uuid=2) | null | null | null |
RogLog.Entry | Address(uuid=1) | null | null | null | null | |
RogLog.Entry | null | null | null | Order1 | null | |
RogLog.Entry | null | Customer(uuid=2) | null | null | null | |
RogLog.Entry | null | null | null | null | OrderRequest(uuid=1) |
SELECT Entry, Metadata, Order FROM "myLog" where Entry.type = 'Put'and you would get back a
RogLogResultSet with three object column that holds the RogLog.Entry, IRogMetadata and Customer
But you can also select individual fields of each of the columns by specifying their bean paths:
SELECT Entry.type, Metadata.messageSequenceNumber, Customer.customerId FROM "myLog" where Metadata.txnId = '2'which would return 3 columns with the
RogLog.Entry.Type and sequence number and customerId of the entries in transaction 2.| Modifier and Type | Interface and Description |
|---|---|
static interface |
RogLogQueryEngine.RogLogField<T>
Defines an
IdxField for a RogLogQueryEngine |
QueryEngine.BackgroundIndexingPolicy| Modifier and Type | Method and Description |
|---|---|
RogLogRepository |
addTransactionLogForQuery(File transactionLogFile,
String alias)
Adds a transaction log as a repository for this query engine.
|
RogLogQuery |
createQuery()
Creates an empty
Query that can be executed against this QueryEngine. |
RogLogQuery |
createQuery(String xsql)
Creates a
Query corresponding to the provided SELECT statement. |
void |
enableStaticFields(boolean enable)
Indicate whether well-known fields such as Entry.timestamp may be implemented via
a static field.
|
void |
enableTypeInference(boolean enable)
Indicate whether the fields of a given query should be used to filter the log entries by
Entry.object.class.
|
RogLogResultSet |
execute(RogLogQuery query)
Executes the given log query against the logs added to this
RogLogQueryEngine. |
RogLogResultSet |
execute(String xsql)
Executes an xpql query against this
QueryEngine. |
<T> RogLogQueryEngine.RogLogField<T> |
getField(Class<?> objectType,
String fieldPath)
Resolves a field for the given objectType and field path.
|
<T> RogLogQueryEngine.RogLogField<T> |
getField(Class<?> objectType,
String fieldPath,
Class<T> fieldType,
Class<?>... pathTypes)
Gets a field for the given objectType and field path.
|
<T> RogLogQueryEngine.RogLogField<T> |
getField(String columnDefinition)
Parses a field using the query engine's parser.
|
<T> RogLogQueryEngine.RogLogField<T> |
getField(String objectTypeName,
String fieldPath)
Resolves a field for the given objectTypeName and field path.
|
Collection<RogLogRepository> |
getRepositories()
Gets this
QueryEngine's current RogLogRepositorys. |
void |
registerFactory(Class<?> factoryClass)
Registers a type factory for use in resolving fields.
|
addRepository, close, createIndex, createIndex, createIndex, dropIndex, dropIndex, execute, executeStatement, getFetchRatioThreshold, getIndexedFields, getNonUniqueIndex, getUniqueIndex, removeRepository, setAutoIndexing, setAutoIndexLimit, setBackgroundIndexingPolicy, setDefaultIndexing, setDefaultPackage, setFetchRatioThreshold, setQueryStatGeneration, setSortAreaInMemoryCardinality, waitForBackgroundIndexingRogLogResultSet execute(String xsql)
QueryEngineQueryEngine.execute in interface QueryEngine<Long,RogLog.Entry>xsql - The SELECT statement to execute.QueryResult.RogLogQuery createQuery(String xsql)
QueryEngineQuery corresponding to the provided SELECT statement.createQuery in interface QueryEngine<Long,RogLog.Entry>xsql - The query stringRogLogQuery createQuery()
QueryEngineQuery that can be executed against this QueryEngine.createQuery in interface QueryEngine<Long,RogLog.Entry>Query.RogLogResultSet execute(RogLogQuery query)
RogLogQueryEngine.query - The query to execute.RogLogResultSet results.<T> RogLogQueryEngine.RogLogField<T> getField(String objectTypeName, String fieldPath)
RogLog.Entry itself
IRogNode e.g. the Message or Entity class, that was logged in which
case the field path is relative to that object.
getField in interface IdxFieldResolver<RogLog.Entry>objectTypeName - The classname of the object. If not fully qualified an attempt will be made
to find the field in the engine's registered factories.fieldPath - The bean path of the field. If null then the field will refer to the
object itself<T> RogLogQueryEngine.RogLogField<T> getField(Class<?> objectType, String fieldPath)
RogLog.Entry meaning the field path is relative the the RogLog.Entry itself
IRogMetadata meaning that the field path is relative to the node's metadata
IRogNode e.g. the Message or Entity class, that was logged in which
case the field path is relative to that object.
getField in interface IdxFieldResolver<RogLog.Entry>objectType - The object whose field should be identified.fieldPath - The bean path of the field. If null then the field will refer to the
object itself<T> RogLogQueryEngine.RogLogField<T> getField(Class<?> objectType, String fieldPath, Class<T> fieldType, Class<?>... pathTypes)
RogLog.Entry meaning the field path is relative the the RogLog.Entry itself
IRogMetadata meaning that the field path is relative to the node's metadata
IRogNode e.g. the Message or Entity class, that was logged in which
case the field path is relative to that object.
getField in interface IdxFieldResolver<RogLog.Entry>objectType - The object whose field should be identified.fieldPath - The bean path of the field. If null then the field will refer to the
object itself.fieldType - Indicates the type of the field refered to by the field path.pathTypes - For cases where types in the field path are ambiguous, this allows
specifying specific types for the intermediate paths. Specifying path types is not generally
necessary unless there are ambiguous types in the field path such as Object or if the
intent is to specify a specific type for an type in the field path that is polymorphic.<T> RogLogQueryEngine.RogLogField<T> getField(String columnDefinition) throws QueryException, QueryParseException
getField in interface QueryEngine<Long,RogLog.Entry>columnDefinition - A field.QueryParseException - if the columnDefinition can't be parsed as a valid column nameQueryException - if there is an error resolving the fieldvoid registerFactory(Class<?> factoryClass)
RogLogRepository's
factories will be added to the factory when it is added to the engine. This method
is provided to allow for cases where fields need to be resolved prior to adding
a RogLogRepository to the RogLogQueryEngine;factoryClass - The factory to add.Collection<RogLogRepository> getRepositories()
QueryEngine's current RogLogRepositorys. The returned
Collection should be considered immutable.getRepositories in interface QueryEngine<Long,RogLog.Entry>QueryEngine's current QueryRepositorys.void enableTypeInference(boolean enable)
enable - Whether to enable or disable type inferencing.void enableStaticFields(boolean enable)
enable - Whether to enable or disable static fields.RogLogRepository addTransactionLogForQuery(File transactionLogFile, String alias) throws OdsException, Exception
transactionLogFile - The transaction log file.alias - The alias which can be used to identify this log in queries.OdsException - If there is an error opening the transaction log file.Exception - If there is an error addint the transaction log for query.Copyright © 2019 Neeve Research, LLC. All Rights Reserved.