Package uk.gov.gchq.gaffer.store
Class Store
- java.lang.Object
-
- uk.gov.gchq.gaffer.store.Store
-
- Direct Known Subclasses:
AccumuloStore
,FederatedStore
,FederatedStore
,MapStore
,ProxyStore
public abstract class Store extends Object
AStore
backs a Graph and is responsible for storing theElement
s and handlingOperation
s.Operation
s and their correspondingOperationHandler
s are registered in a map and used to handle provided operations - allowing different store implementations to handle the same operations in their own store specific way. Optional functionality can be added to store implementations defined by theStoreTrait
s.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addOperationChainOptimisers(List<OperationChainOptimiser> newOpChainOptimisers)
<OP extends Output<O>,O>
voidaddOperationHandler(Class<? extends Output<O>> opClass, OutputOperationHandler<OP,O> handler)
void
addOperationHandler(Class<? extends Operation> opClass, OperationHandler handler)
Context
createContext(User user)
static Store
createStore(String graphId, byte[] schema, Properties storeProperties)
static Store
createStore(String graphId, Schema schema, StoreProperties storeProperties)
<O> O
execute(Output<O> operation, Context context)
Executes a given operation and returns the result.void
execute(Operation operation, Context context)
Executes a given operation and returns the result.JobDetail
executeJob(Job job, Context context)
JobDetail
executeJob(Operation operation, Context context)
Executes a given operation job and returns the job detail.List<Cache<?,?>>
getCaches()
String
getCreatedTime()
Gets this Store's creation timestamp forGetGraphCreatedTime
operation.String
getGraphId()
GraphLibrary
getGraphLibrary()
JobTracker
getJobTracker()
Set<Class<? extends Operation>>
getNextOperations(Class<? extends Operation> operation)
List<OperationChainOptimiser>
getOperationChainOptimisers()
OperationChainValidator
getOperationChainValidator()
OperationHandler<Operation>
getOperationHandler(Class<? extends Operation> opClass)
Schema
getOriginalSchema()
Get the Store's originalSchema
.StoreProperties
getProperties()
Get this Store'sStoreProperties
.Schema
getSchema()
Get this Store's internalSchema
.Set<Class<? extends Operation>>
getSupportedOperations()
Object
handleOperation(Operation operation, Context context)
void
initialise(String graphId, Schema schema, StoreProperties properties)
boolean
isSupported(Class<? extends Operation> operationClass)
void
optimiseSchema()
Element
populateElement(Element lazyElement)
Ensures all identifier and property values are populated on an element by triggering getters on the element for all identifier and properties in theSchema
forcing a lazy element to load all of its values.void
runAsync(Runnable runnable)
void
setGraphLibrary(GraphLibrary library)
void
setOriginalSchema(Schema originalSchema)
Set the Store's originalSchema
.void
updateJsonSerialiser()
static void
updateJsonSerialiser(StoreProperties storeProperties)
void
validateSchemas()
-
-
-
Constructor Detail
-
Store
public Store()
-
Store
public Store(Boolean addCoreOpHandlers)
-
-
Method Detail
-
createStore
public static Store createStore(String graphId, byte[] schema, Properties storeProperties)
-
createStore
public static Store createStore(String graphId, Schema schema, StoreProperties storeProperties)
-
initialise
public void initialise(String graphId, Schema schema, StoreProperties properties) throws StoreException
- Throws:
StoreException
-
getCreatedTime
public String getCreatedTime()
Gets this Store's creation timestamp forGetGraphCreatedTime
operation.- Returns:
- the Store's creation timestamp.
-
updateJsonSerialiser
public static void updateJsonSerialiser(StoreProperties storeProperties)
-
updateJsonSerialiser
public void updateJsonSerialiser()
-
execute
public void execute(Operation operation, Context context) throws OperationException
Executes a given operation and returns the result.- Parameters:
operation
- the operation to execute.context
- the context executing the operation- Throws:
OperationException
- thrown by the operation handler if the operation fails.
-
execute
public <O> O execute(Output<O> operation, Context context) throws OperationException
Executes a given operation and returns the result.- Type Parameters:
O
- the output type of the operation- Parameters:
operation
- the operation to execute.context
- the context executing the operation- Returns:
- the result of executing the operation
- Throws:
OperationException
- thrown by the operation handler if the operation fails.
-
executeJob
public JobDetail executeJob(Operation operation, Context context) throws OperationException
Executes a given operation job and returns the job detail.- Parameters:
operation
- the operation to execute.context
- the context executing the job.- Returns:
- the job detail.
- Throws:
OperationException
- thrown if jobs are not configured.
-
executeJob
public JobDetail executeJob(Job job, Context context) throws OperationException
- Parameters:
job
- the job to execute.context
- the context executing the job.- Returns:
- the job detail.
- Throws:
OperationException
- thrown if there is an error running the job.
-
runAsync
public void runAsync(Runnable runnable)
-
getJobTracker
public JobTracker getJobTracker()
-
isSupported
public boolean isSupported(Class<? extends Operation> operationClass)
- Parameters:
operationClass
- the operation class to check- Returns:
- true if the provided operation is supported.
-
getSupportedOperations
public Set<Class<? extends Operation>> getSupportedOperations()
- Returns:
- a collection of all the supported
Operation
s.
-
getNextOperations
public Set<Class<? extends Operation>> getNextOperations(Class<? extends Operation> operation)
-
populateElement
public Element populateElement(Element lazyElement)
Ensures all identifier and property values are populated on an element by triggering getters on the element for all identifier and properties in theSchema
forcing a lazy element to load all of its values.- Parameters:
lazyElement
- the lazy element- Returns:
- the fully populated unwrapped element
-
getGraphId
public String getGraphId()
-
getSchema
public Schema getSchema()
Get this Store's internalSchema
.This is optimised and will usually differ from the original schema used to create the store initially.
-
setOriginalSchema
public void setOriginalSchema(Schema originalSchema)
Set the Store's originalSchema
.This is used to keep an (unoptimised, unchanged) copy of the original schema used to create the store initially.
- Parameters:
originalSchema
- theSchema
to be set as the original schema used to create this store
-
getOriginalSchema
public Schema getOriginalSchema()
Get the Store's originalSchema
.- Returns:
- the
Schema
used to create this store, null if not set
-
getProperties
public StoreProperties getProperties()
Get this Store'sStoreProperties
.- Returns:
- the instance of
StoreProperties
, this may contain details such as database connection details.
-
getGraphLibrary
public GraphLibrary getGraphLibrary()
-
setGraphLibrary
public void setGraphLibrary(GraphLibrary library)
-
optimiseSchema
public void optimiseSchema()
-
validateSchemas
public void validateSchemas()
-
getOperationChainValidator
public OperationChainValidator getOperationChainValidator()
-
addOperationChainOptimisers
public void addOperationChainOptimisers(List<OperationChainOptimiser> newOpChainOptimisers)
-
getOperationChainOptimisers
public List<OperationChainOptimiser> getOperationChainOptimisers()
-
addOperationHandler
public void addOperationHandler(Class<? extends Operation> opClass, OperationHandler handler)
-
addOperationHandler
public <OP extends Output<O>,O> void addOperationHandler(Class<? extends Output<O>> opClass, OutputOperationHandler<OP,O> handler)
-
getOperationHandler
public OperationHandler<Operation> getOperationHandler(Class<? extends Operation> opClass)
-
handleOperation
public Object handleOperation(Operation operation, Context context) throws OperationException
- Throws:
OperationException
-
-