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
AStorebacks a Graph and is responsible for storing theElements and handlingOperations.Operations and their correspondingOperationHandlers 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 theStoreTraits.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOperationChainOptimisers(List<OperationChainOptimiser> newOpChainOptimisers)<OP extends Output<O>,O>
voidaddOperationHandler(Class<? extends Output<O>> opClass, OutputOperationHandler<OP,O> handler)voidaddOperationHandler(Class<? extends Operation> opClass, OperationHandler handler)ContextcreateContext(User user)static StorecreateStore(String graphId, byte[] schema, Properties storeProperties)static StorecreateStore(String graphId, Schema schema, StoreProperties storeProperties)<O> Oexecute(Output<O> operation, Context context)Executes a given operation and returns the result.voidexecute(Operation operation, Context context)Executes a given operation and returns the result.JobDetailexecuteJob(Job job, Context context)JobDetailexecuteJob(Operation operation, Context context)Executes a given operation job and returns the job detail.List<Cache<?,?>>getCaches()StringgetCreatedTime()Gets this Store's creation timestamp forGetGraphCreatedTimeoperation.StringgetGraphId()GraphLibrarygetGraphLibrary()JobTrackergetJobTracker()Set<Class<? extends Operation>>getNextOperations(Class<? extends Operation> operation)List<OperationChainOptimiser>getOperationChainOptimisers()OperationChainValidatorgetOperationChainValidator()OperationHandler<Operation>getOperationHandler(Class<? extends Operation> opClass)SchemagetOriginalSchema()Get the Store's originalSchema.StorePropertiesgetProperties()Get this Store'sStoreProperties.SchemagetSchema()Get this Store's internalSchema.Set<Class<? extends Operation>>getSupportedOperations()ObjecthandleOperation(Operation operation, Context context)voidinitialise(String graphId, Schema schema, StoreProperties properties)booleanisSupported(Class<? extends Operation> operationClass)voidoptimiseSchema()ElementpopulateElement(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 theSchemaforcing a lazy element to load all of its values.voidrunAsync(Runnable runnable)voidsetGraphLibrary(GraphLibrary library)voidsetOriginalSchema(Schema originalSchema)Set the Store's originalSchema.voidupdateJsonSerialiser()static voidupdateJsonSerialiser(StoreProperties storeProperties)voidvalidateSchemas()
-
-
-
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 forGetGraphCreatedTimeoperation.- 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
Operations.
-
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 theSchemaforcing 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- theSchemato be set as the original schema used to create this store
-
getOriginalSchema
public Schema getOriginalSchema()
Get the Store's originalSchema.- Returns:
- the
Schemaused 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
-
-