com.neeve.rog.log
Interface RogLogQueryEngine

All Superinterfaces:
IdxFieldResolver<RogLog.Entry>, QueryEngine<Long,RogLog.Entry>

public interface RogLogQueryEngine
extends QueryEngine<Long,RogLog.Entry>

The 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:

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.

EntryMetadataAddressCustomerOrderOrderRequest
RogLog.EntryMetadatanullCustomer(uuid=2)nullnullnull
RogLog.EntryAddress(uuid=1)nullnullnullnull
RogLog.EntrynullnullnullOrder1null
RogLog.EntrynullCustomer(uuid=2)nullnullnull
RogLog.EntrynullnullnullnullOrderRequest(uuid=1)

Column Selection

Each of these columns can be selected in a select clause as is:
 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.


Nested Class Summary
static interface RogLogQueryEngine.RogLogField<T>
          Defines an IdxField for a RogLogQueryEngine
 
Nested classes/interfaces inherited from interface com.neeve.query.QueryEngine
QueryEngine.BackgroundIndexingPolicy
 
Method Summary
 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.
 
Methods inherited from interface com.neeve.query.QueryEngine
addRepository, close, createIndex, createIndex, createIndex, dropIndex, dropIndex, execute, executeStatement, getFetchRatioThreshold, getIndexedFields, removeRepository, setAutoIndexing, setAutoIndexLimit, setBackgroundIndexingPolicy, setDefaultIndexing, setDefaultPackage, setFetchRatioThreshold, setQueryStatGeneration, setSortAreaInMemoryCardinality, waitForBackgroundIndexing
 

Method Detail

execute

RogLogResultSet execute(String xsql)
Description copied from interface: QueryEngine
Executes an xpql query against this QueryEngine.

Specified by:
execute in interface QueryEngine<Long,RogLog.Entry>
Parameters:
xsql - The SELECT statement to execute.
Returns:
the QueryResult.

createQuery

RogLogQuery createQuery(String xsql)
Description copied from interface: QueryEngine
Creates a Query corresponding to the provided SELECT statement.

Specified by:
createQuery in interface QueryEngine<Long,RogLog.Entry>
Parameters:
xsql - The query string

createQuery

RogLogQuery createQuery()
Description copied from interface: QueryEngine
Creates an empty Query that can be executed against this QueryEngine.

Specified by:
createQuery in interface QueryEngine<Long,RogLog.Entry>
Returns:
A new Query.

execute

RogLogResultSet execute(RogLogQuery query)
Executes the given log query against the logs added to this RogLogQueryEngine.

Parameters:
query - The query to execute.
Returns:
The RogLogResultSet results.

getField

<T> RogLogQueryEngine.RogLogField<T> getField(String objectTypeName,
                                              String fieldPath)
Resolves a field for the given objectTypeName and field path. The objectTypeName can be:

Specified by:
getField in interface IdxFieldResolver<RogLog.Entry>
Parameters:
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
Returns:
The resolved field.

getField

<T> RogLogQueryEngine.RogLogField<T> getField(Class<?> objectType,
                                              String fieldPath)
Resolves a field for the given objectType and field path. The objectType can be:

Specified by:
getField in interface IdxFieldResolver<RogLog.Entry>
Parameters:
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
Returns:
The resolved field.

getField

<T> RogLogQueryEngine.RogLogField<T> getField(Class<?> objectType,
                                              String fieldPath,
                                              Class<T> fieldType,
                                              Class<?>... pathTypes)
Gets a field for the given objectType and field path. The objectType can be:

Specified by:
getField in interface IdxFieldResolver<RogLog.Entry>
Parameters:
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.
Returns:
The resolved field.

getField

<T> RogLogQueryEngine.RogLogField<T> getField(String columnDefinition)
                                          throws QueryException,
                                                 QueryParseException
Parses a field using the query engine's parser.

Specified by:
getField in interface QueryEngine<Long,RogLog.Entry>
Parameters:
columnDefinition - A field.
Returns:
The resolved field
Throws:
QueryParseException - if the columnDefinition can't be parsed as a valid column name
QueryException - if there is an error resolving the field

registerFactory

void registerFactory(Class<?> factoryClass)
Registers a type factory for use in resolving fields. A 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;

Parameters:
factoryClass - The factory to add.

getRepositories

Collection<RogLogRepository> getRepositories()
Gets this QueryEngine's current RogLogRepositorys. The returned Collection should be considered immutable.

Specified by:
getRepositories in interface QueryEngine<Long,RogLog.Entry>
Returns:
this QueryEngine's current QueryRepositorys.

enableTypeInference

void enableTypeInference(boolean enable)
Indicate whether the fields of a given query should be used to filter the log entries by Entry.object.class.

Parameters:
enable - Whether to enable or disable type inferencing.

enableStaticFields

void enableStaticFields(boolean enable)
Indicate whether well-known fields such as Entry.timestamp may be implemented via a static field. A value of false yields reflection-based fields.

Parameters:
enable - Whether to enable or disable static fields.

addTransactionLogForQuery

RogLogRepository addTransactionLogForQuery(File transactionLogFile,
                                           String alias)
                                           throws OdsException,
                                                  Exception
Adds a transaction log as a repository for this query engine.

Parameters:
transactionLogFile - The transaction log file.
alias - The alias which can be used to identify this log in queries.
Returns:
The opened transaction log repository.
Throws:
OdsException - If there is an error opening the transaction log file.
Exception


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.