|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.intermine.dataloader.IntegrationWriterAbstractImpl
public abstract class IntegrationWriterAbstractImpl
Abstract implementation of ObjectStoreIntegrationWriter. To retain O/R mapping independence concrete subclasses should delegate writing to a mapping tool specific implementation of ObjectStoreWriter.
| Field Summary | |
|---|---|
protected BaseEquivalentObjectFetcher |
beof
|
protected IntPresentSet |
dbIdsStored
|
protected HintingFetcher |
eof
|
protected static int |
FROM_DB
|
protected IntToIntMap |
idMap
|
protected int |
idMapOps
|
protected boolean |
ignoreDuplicates
|
protected Source |
lastSource
|
protected ObjectStoreWriter |
osw
|
protected java.util.Set<java.lang.String> |
seenBrokenOneToMany
|
protected static int |
SKELETON
|
protected static int |
SOURCE
|
protected long |
timeSpentRecursing
|
| Fields inherited from interface org.intermine.objectstore.ObjectStore |
|---|
SEQUENCE_IGNORE |
| Constructor Summary | |
|---|---|
IntegrationWriterAbstractImpl(ObjectStoreWriter osw)
Constructs a new instance of an IntegrationWriter |
|
| Method Summary | |
|---|---|
void |
abortTransaction()
Request that the ObjectStore aborts and closes the transaction, delegate to internal ObjectStoreWriter. |
void |
addAllToBag(ObjectStoreBag osb,
java.util.Collection<java.lang.Integer> coll)
Adds a collection of elements to an ObjectStoreBag, delegate to internal ObjectStoreWriter. |
void |
addToBag(ObjectStoreBag osb,
java.lang.Integer element)
Adds an element to an ObjectStoreBag, delegate to internal ObjectStoreWriter. |
void |
addToBagFromQuery(ObjectStoreBag osb,
Query query)
Adds elements to an ObjectStoreBag, delegate to internal ObjectStoreWriter. |
void |
addToCollection(java.lang.Integer hasId,
java.lang.Class<?> clazz,
java.lang.String fieldName,
java.lang.Integer hadId)
Add an object to another object's collection, delegate to internal ObjectStoreWriter. |
void |
assignMapping(java.lang.Integer source,
java.lang.Integer dest)
Puts a mapping into idMap. |
void |
batchCommitTransaction()
Request that the ObjectStoreWriter commits and closes the transaction and then opens a new one, without guaranteeing that the operation is finished before this method returns. |
void |
beginTransaction()
Request that the ObjectStore begins a transaction, delegate to internal ObjectStoreWriter. |
java.lang.Object |
cacheObjectById(java.lang.Integer id,
InterMineObject obj)
Places an entry into the objectstore getObjectById cache. |
void |
close()
Closes the connection associated with this ObjectStoreWriter |
void |
commitTransaction()
Request that the ObjectStore commits and closes the transaction, delegate to internal ObjectStoreWriter. |
protected void |
copyField(FastPathObject srcObj,
FastPathObject dest,
Source source,
Source skelSource,
FieldDescriptor field,
int type)
Copies the value of the field given from the source object into the destination object. |
int |
count(Query q,
java.util.Map<java.lang.Object,java.lang.Integer> sequence)
Counts the number of rows the query will produce |
Clob |
createClob()
Creates a new empty Clob that is valid for this ObjectStore. |
ObjectStoreBag |
createObjectStoreBag()
Returns a new empty ObjectStoreBag for this ObjectStore, delegate to internal ObjectStoreWriter. |
void |
delete(InterMineObject o)
Delete an object from this ObjectStore, delegate to internal ObjectStoreWriter. |
void |
delete(QueryClass qc,
Constraint c)
Deletes a set of objects from this ObjectStore. |
ResultsInfo |
estimate(Query q)
Explain a Query (give estimate for execution time and number of rows). |
Results |
execute(Query q)
Execute a Query on this ObjectStore |
Results |
execute(Query q,
int batchSize,
boolean optimise,
boolean explain,
boolean prefetch)
Execute a Query on this ObjectStore |
java.util.List<ResultsRow<java.lang.Object>> |
execute(Query q,
int start,
int limit,
boolean optimise,
boolean explain,
java.util.Map<java.lang.Object,java.lang.Integer> sequence)
Execute a Query on this ObjectStore, asking for a certain range of rows to be returned. |
SingletonResults |
executeSingleton(Query q)
Execute a Query on this ObjectStore, returning a SingletonResults |
SingletonResults |
executeSingleton(Query q,
int batchSize,
boolean optimise,
boolean explain,
boolean prefetch)
Execute a Query on this ObjectStore, returning a SingletonResults |
void |
flushObjectById()
Completely empties the getObjectById cache. |
BaseEquivalentObjectFetcher |
getBaseEof()
Returns the base equivalent object fetcher. |
java.util.Set<java.lang.Object> |
getComponentsForQuery(Query q)
Returns a Set of independent components that affect the results of the given Query. |
java.util.Set<InterMineObject> |
getEquivalentObjects(InterMineObject obj,
Source source)
Returns a Set of objects from the idMap or database that are equivalent to the given object, according to the primary keys defined by the given Source. |
int |
getMaxLimit()
Get the maximum LIMIT that can be used in an SQL query without throwing an ObjectStoreLimitReachedException |
int |
getMaxOffset()
Get the maximum range start index a that can be accessed in a Results object without throwing an ObjectStoreLimitReachedException |
long |
getMaxTime()
Get the maximum time a query may take before throwing an ObjectStoreQueryDurationException |
Model |
getModel()
Return the metadata associated with this ObjectStore |
ObjectStoreWriter |
getNewWriter()
Create an ObjectStoreWriter that writes into this ObjectStore. |
InterMineObject |
getObjectByExample(InterMineObject o,
java.util.Set<java.lang.String> fieldNames)
Return an object from the objectstore that has the fields mentioned in the list set to the same values as the fields in the provided example object. |
InterMineObject |
getObjectById(java.lang.Integer id)
Search database for object matching the given object id |
InterMineObject |
getObjectById(java.lang.Integer id,
java.lang.Class<? extends InterMineObject> clazz)
Search database for object matching the given object id and class |
java.util.List<InterMineObject> |
getObjectsByIds(java.util.Collection<java.lang.Integer> ids)
Get an objects from the ObjectStore that have the IDs in the ids colection |
ObjectStore |
getObjectStore()
Retrieve this Writer's ObjectStore. |
ObjectStoreWriter |
getObjectStoreWriter()
Returns the underlying ObjectStoreWriter. |
java.util.Map<java.lang.Object,java.lang.Integer> |
getSequence(java.util.Set<java.lang.Object> tables)
Return the sequence number representing the state of the ObjectStore. |
java.lang.Integer |
getSerial()
Gets an ID number which is unique in the database. |
void |
invalidateObjectById(java.lang.Integer id)
Removes an entry from the objectstore getObjectById cache. |
boolean |
isInTransaction()
Check whether the ObjectStore is performing a transaction, delegate to internal ObjectStoreWriter. |
boolean |
isMultiConnection()
Return whether or not this ObjectStore gives a performance improvement when multiple simultaneous are made. |
InterMineObject |
pilferObjectById(java.lang.Integer id)
Gets a object from the cache if it is present. |
void |
prefetchObjectById(java.lang.Integer id)
Prefetches an object into the objectstore getObjectById cache. |
void |
removeAllFromBag(ObjectStoreBag osb,
java.util.Collection<java.lang.Integer> coll)
Removes a collection of elements from an ObjectStoreBag, delegate to internal ObjectStoreWriter. |
void |
removeFromBag(ObjectStoreBag osb,
java.lang.Integer element)
Removes an element from an ObjectStoreBag, delegate to internal ObjectStoreWriter. |
void |
replaceClob(Clob clob,
java.lang.String text)
Replaces the contents of the given Clob with the given String. |
void |
reset()
Resets the IntegrationWriter, clearing the id map and the hints |
void |
setEof(HintingFetcher eof)
Sets the equivalent object fetcher. |
void |
setIgnoreDuplicates(boolean ignoreDuplicates)
Tell this IntegrationWriter whether to ignore duplicate objects from the same source. |
void |
store(FastPathObject o,
Source source,
Source skelSource)
Stores the given object in the objectstore. |
protected abstract InterMineObject |
store(FastPathObject o,
Source source,
Source skelSource,
int type)
Stores the given object in the objectstore. |
void |
store(java.lang.Object o)
Store an object in this ObjectStore, delegates to internal ObjectStoreWriter. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.intermine.dataloader.IntegrationWriter |
|---|
getMainSource, getSkeletonSource |
| Field Detail |
|---|
protected ObjectStoreWriter osw
protected static final int SKELETON
protected static final int FROM_DB
protected static final int SOURCE
protected IntToIntMap idMap
protected IntPresentSet dbIdsStored
protected int idMapOps
protected boolean ignoreDuplicates
protected HintingFetcher eof
protected BaseEquivalentObjectFetcher beof
protected Source lastSource
protected java.util.Set<java.lang.String> seenBrokenOneToMany
protected long timeSpentRecursing
| Constructor Detail |
|---|
public IntegrationWriterAbstractImpl(ObjectStoreWriter osw)
osw - an instance of an ObjectStoreWriter, which we can use to access the database| Method Detail |
|---|
public void reset()
public BaseEquivalentObjectFetcher getBaseEof()
public void setEof(HintingFetcher eof)
eof - a HintingFetcherpublic void setIgnoreDuplicates(boolean ignoreDuplicates)
setIgnoreDuplicates in interface IntegrationWriterignoreDuplicates - the value of ignoreDuplicatespublic ObjectStoreWriter getObjectStoreWriter()
public java.util.Set<InterMineObject> getEquivalentObjects(InterMineObject obj,
Source source)
throws ObjectStoreException
obj - the Object to look forsource - the data Source
ObjectStoreException - if an error occurs
public void store(FastPathObject o,
Source source,
Source skelSource)
throws ObjectStoreException
store in interface IntegrationWritero - the object to storesource - the data Source to which to attribute the dataskelSource - the data Source to which to attribute skeleton data
ObjectStoreException - if an error occurs in the underlying objectstore
protected abstract InterMineObject store(FastPathObject o,
Source source,
Source skelSource,
int type)
throws ObjectStoreException
o - the object to storesource - the data Source to which to attribute the dataskelSource - the data Source to which to attribute skeleton datatype - the type of action required, from SOURCE, SKELETON, or FROM_DB
ObjectStoreException - if an error occurs in the underlying objectstore
protected void copyField(FastPathObject srcObj,
FastPathObject dest,
Source source,
Source skelSource,
FieldDescriptor field,
int type)
throws java.lang.IllegalAccessException,
ObjectStoreException
srcObj - the source objectdest - the destination objectsource - the data Source to which to attribute the dataskelSource - the data Source to which to attribute skeleton datafield - the FieldDescriptor describing the field to copytype - the type of copy required - SOURCE for a full copy, SKELETON for a minimal copy
that guarantees limited recursion, and FROM_DB to indicate that the source object originated
from the destination database.
java.lang.IllegalAccessException - should never happen
ObjectStoreException - if an error occurs in the underlying objectstore
public void assignMapping(java.lang.Integer source,
java.lang.Integer dest)
throws ObjectStoreException
source - the ID of the object from the sourcedest - the ID of the object from the destination
ObjectStoreException - if an attempt is made to change an existing mapping
public InterMineObject getObjectById(java.lang.Integer id)
throws ObjectStoreException
getObjectById in interface ObjectStoreid - the object ID
ObjectStoreException - if an error occurs retieving the object
public InterMineObject getObjectById(java.lang.Integer id,
java.lang.Class<? extends InterMineObject> clazz)
throws ObjectStoreException
getObjectById in interface ObjectStoreid - the object IDclazz - a Class of the object
ObjectStoreException - if an error occurs retrieving the object
public java.util.List<InterMineObject> getObjectsByIds(java.util.Collection<java.lang.Integer> ids)
throws ObjectStoreException
getObjectsByIds in interface ObjectStoreids - the IDs of the objects to fetch
ObjectStoreException - if an error occurs during retrieval of the object
public void store(java.lang.Object o)
throws ObjectStoreException
store in interface ObjectStoreWritero - the object to store
ObjectStoreException - if an error occurs during storage of the object
public void addToCollection(java.lang.Integer hasId,
java.lang.Class<?> clazz,
java.lang.String fieldName,
java.lang.Integer hadId)
throws ObjectStoreException
addToCollection in interface ObjectStoreWriterhasId - the ID of the object that has the collectionclazz - the class of the objectfieldName - the name of the collectionhadId - the ID of the object to be placed in the collection
ObjectStoreException - if something goes wrong
public void delete(InterMineObject o)
throws ObjectStoreException
delete in interface ObjectStoreWritero - the object to delete
ObjectStoreException - if an error occurs during deletion of the object
public void delete(QueryClass qc,
Constraint c)
throws ObjectStoreException
delete in interface ObjectStoreWriterqc - a QueryClass for the class of objects to deletec - a Constraint based on the QueryClass to filter the objects to delete, or null to
delete all objects
ObjectStoreException - if an error occurs while deleting the objects
public ObjectStoreBag createObjectStoreBag()
throws ObjectStoreException
createObjectStoreBag in interface ObjectStoreObjectStoreException - if an error occurs fetching a new ID
public void addToBag(ObjectStoreBag osb,
java.lang.Integer element)
throws ObjectStoreException
addToBag in interface ObjectStoreWriterosb - an ObjectStoreBagelement - an Integer to add to the bag
ObjectStoreException - if an error occurs
public void addAllToBag(ObjectStoreBag osb,
java.util.Collection<java.lang.Integer> coll)
throws ObjectStoreException
addAllToBag in interface ObjectStoreWriterosb - an ObjectStoreBagcoll - a Collection of Integers
ObjectStoreException - if an error occurs
public void removeFromBag(ObjectStoreBag osb,
java.lang.Integer element)
throws ObjectStoreException
removeFromBag in interface ObjectStoreWriterosb - an ObjectStoreBagelement - an Integer to add to the bag
ObjectStoreException - if an error occurs
public void removeAllFromBag(ObjectStoreBag osb,
java.util.Collection<java.lang.Integer> coll)
throws ObjectStoreException
removeAllFromBag in interface ObjectStoreWriterosb - an ObjectStoreBagcoll - a Collection of Integers
ObjectStoreException - if an error occurs
public void addToBagFromQuery(ObjectStoreBag osb,
Query query)
throws ObjectStoreException
addToBagFromQuery in interface ObjectStoreWriterosb - an ObjectStoreBagquery - a Query
ObjectStoreException - if an error occurs
public Clob createClob()
throws ObjectStoreException
createClob in interface ObjectStoreObjectStoreException - if an error occurs fetching a new ID
public void replaceClob(Clob clob,
java.lang.String text)
throws ObjectStoreException
replaceClob in interface ObjectStoreWriterclob - the Clob to write totext - the text to write to the Clob
ObjectStoreException - if something goes wrong
public java.lang.Integer getSerial()
throws ObjectStoreException
getSerial in interface ObjectStoreObjectStoreException - if a problem occurs
public boolean isInTransaction()
throws ObjectStoreException
isInTransaction in interface ObjectStoreWriterObjectStoreException - if an error occurs the check
public void beginTransaction()
throws ObjectStoreException
beginTransaction in interface ObjectStoreWriterObjectStoreException - if a transaction is in progress, or is aborted
public void commitTransaction()
throws ObjectStoreException
commitTransaction in interface ObjectStoreWriterObjectStoreException - if a transaction is not in progress, or is aborted
public void abortTransaction()
throws ObjectStoreException
abortTransaction in interface ObjectStoreWriterObjectStoreException - if a transaction is not in progress
public void batchCommitTransaction()
throws ObjectStoreException
batchCommitTransaction in interface ObjectStoreWriterObjectStoreException - if an error occurspublic ObjectStore getObjectStore()
getObjectStore in interface ObjectStoreWriterpublic Results execute(Query q)
execute in interface ObjectStoreq - the Query to execute
public Results execute(Query q,
int batchSize,
boolean optimise,
boolean explain,
boolean prefetch)
execute in interface ObjectStoreq - the Query to executebatchSize - the batch size to initialise the Results object withoptimise - whether to optimise queriesexplain - whether to explain queriesprefetch - whether to use the PrefetchManager
public SingletonResults executeSingleton(Query q)
executeSingleton in interface ObjectStoreq - the Query to execute
public SingletonResults executeSingleton(Query q,
int batchSize,
boolean optimise,
boolean explain,
boolean prefetch)
executeSingleton in interface ObjectStoreq - the Query to executebatchSize - the batch size to initialise the Results object withoptimise - whether to optimise queriesexplain - whether to explain queriesprefetch - whether to use the PrefetchManager
public java.util.List<ResultsRow<java.lang.Object>> execute(Query q,
int start,
int limit,
boolean optimise,
boolean explain,
java.util.Map<java.lang.Object,java.lang.Integer> sequence)
throws ObjectStoreException
execute(Query q).
execute in interface ObjectStoreq - the Query to executestart - the start rowlimit - the maximum number of rows to returnoptimise - true if it is expected that optimising the query will improve performanceexplain - true if the ObjectStore should enforce maximum query running time constraintssequence - an object representing the state of the database corresponding to when the
action that resulted in this execute was started. This number must match the ObjectStore's
internal sequence number or a DataChangedException is thrown. The sequence number is
incremented each time the data in the objectstore is changed
ObjectStoreException - if an error occurs during the running of the Querypublic void prefetchObjectById(java.lang.Integer id)
This method is provided primarily to help speed up our data loader. The method may block until the prefetch has been completed. However, the prefetch can be done outside of any synchronised areas of code, allowing the time-critical synchronised areas of code to access the object from the cache.
prefetchObjectById in interface ObjectStoreid - the ID of the object to prefetchpublic void invalidateObjectById(java.lang.Integer id)
invalidateObjectById in interface ObjectStoreid - the ID of the object to invalidate
public java.lang.Object cacheObjectById(java.lang.Integer id,
InterMineObject obj)
cacheObjectById in interface ObjectStoreid - the ID of the objectobj - a fully populated object, as loaded from the database, or null to negatively
cache
public void flushObjectById()
flushObjectById in interface ObjectStorepublic InterMineObject pilferObjectById(java.lang.Integer id)
pilferObjectById in interface ObjectStoreid - the ID of the object
public ResultsInfo estimate(Query q)
throws ObjectStoreException
estimate in interface ObjectStoreq - the query to estimate rows for
ObjectStoreException - if an error occurs explaining the query
public int count(Query q,
java.util.Map<java.lang.Object,java.lang.Integer> sequence)
throws ObjectStoreException
count in interface ObjectStoreq - InterMine Query on which to count rowssequence - an object representing the state of the database corresponding to when the
action that resulted in this execute was started. This number must match the ObjectStore's
internal sequence number or a DataChangedException is thrown. The sequence number is
incremented each time the data in the objectstore is changed
ObjectStoreException - if an error occurs counting the querypublic Model getModel()
getModel in interface ObjectStore
public InterMineObject getObjectByExample(InterMineObject o,
java.util.Set<java.lang.String> fieldNames)
throws ObjectStoreException
getObjectByExample in interface ObjectStoreo - an example objectfieldNames - a Set of fieldnames
ObjectStoreException - if an underlying error occurs
public void close()
throws ObjectStoreException
close in interface ObjectStoreWriterObjectStoreException - if something goes wrongpublic boolean isMultiConnection()
isMultiConnection in interface ObjectStorepublic java.util.Set<java.lang.Object> getComponentsForQuery(Query q)
getComponentsForQuery in interface ObjectStoreq - a Query
public java.util.Map<java.lang.Object,java.lang.Integer> getSequence(java.util.Set<java.lang.Object> tables)
getSequence in interface ObjectStoretables - a Set of independent database components to get data for
public int getMaxLimit()
getMaxLimit in interface ObjectStorepublic int getMaxOffset()
getMaxOffset in interface ObjectStorepublic long getMaxTime()
getMaxTime in interface ObjectStorepublic ObjectStoreWriter getNewWriter()
getNewWriter in interface ObjectStore
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||