|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.neodatis.odb.impl.core.transaction.Cache
public class Cache
A cache of object.
Cache objects by object, by position, by oids,...
Field Summary | |
---|---|
protected java.util.Map<java.lang.Object,ObjectInsertingInfo> |
insertingObjects
To resolve cyclic reference, keep track of objects being inserted |
protected java.lang.String |
name
|
protected static int |
nbCallsToGetObjectInfoHeaderFromObject
|
protected static int |
nbCallsToGetObjectInfoHeaderFromOid
|
protected static int |
nbCallsToGetObjectWithOid
|
protected static int |
nbObjectPositionByIds
|
protected static int |
nbObjects
|
protected static int |
nbOids
|
protected static int |
nbOih
|
protected static int |
nbTransactionOids
|
protected java.util.Map<OID,ObjectInfoHeader> |
objectInfoPointersCacheFromOid
Entry to get object info pointers (position,next object pos, previous object pos and class info pos) from the id |
protected java.util.Map<OID,IdInfo> |
objectPositionsByIds
To resolve the update of an id object position: When an object is full updated(the current object is being deleted and a new one os being created), the id remain the same but its position change. |
protected java.util.Map<java.lang.Object,OID> |
objects
object cache - used to know if object exist in the cache TODO use hashcode instead? |
protected java.util.Map<OID,java.lang.Object> |
oids
Entry to get an object from its oid |
protected java.util.Map<OID,java.lang.Object[]> |
readingObjectInfo
To resolve cyclic reference, keep track of objects being read |
protected ISession |
session
|
protected java.util.Map<OID,OID> |
unconnectedZoneOids
To keep track of the oid that have been created or modified in the current transaction |
protected boolean |
useCache
|
Constructor Summary | |
---|---|
Cache(ISession session,
java.lang.String name)
|
Method Summary | |
---|---|
void |
addObject(OID oid,
java.lang.Object object,
ObjectInfoHeader objectInfoHeader)
|
void |
addObjectInfo(ObjectInfoHeader objectInfoHeader)
Only adds the Object info - used for non committed objects |
void |
addOIDToUnconnectedZone(OID oid)
|
protected boolean |
checkHeaderPosition()
|
void |
clear(boolean setToNull)
|
void |
clearInsertingObjects()
|
void |
clearOnCommit()
|
void |
endInsertingObject(java.lang.Object object)
|
void |
endReadingObjectInfo(OID oid)
|
boolean |
existObject(java.lang.Object object)
|
int |
getNumberOfObjectHeader()
|
int |
getNumberOfObjects()
|
ObjectInfoHeader |
getObjectInfoHeaderFromObject(java.lang.Object object,
boolean throwExceptionIfNotFound)
|
ObjectInfoHeader |
getObjectInfoHeaderFromOid(OID oid,
boolean throwExceptionIfNotFound)
|
java.util.Map<OID,ObjectInfoHeader> |
getObjectInfoPointersCacheFromOid()
|
long |
getObjectPositionByOid(OID oid)
Returns the position or -1 if it is not is the cache or StorageEngineConstant.NULL_OBJECT_ID_ID if it has been marked as deleted |
java.util.Map<java.lang.Object,OID> |
getObjects()
|
java.lang.Object |
getObjectWithOid(OID oid)
|
OID |
getOid(java.lang.Object object,
boolean throwExceptionIfNotFound)
|
java.util.Map<OID,java.lang.Object> |
getOids()
|
NonNativeObjectInfo |
getReadingObjectInfoFromOid(OID oid)
|
OID |
idOfInsertingObject(java.lang.Object object)
|
protected void |
init(ISession session,
java.lang.String name)
|
int |
insertingLevelOf(java.lang.Object object)
|
boolean |
isDeleted(OID oid)
|
boolean |
isReadingObjectInfoWithOid(OID oid)
|
protected void |
manageFullCache()
|
void |
markIdAsDeleted(OID oid)
|
boolean |
objectWithIdIsInCommitedZone(OID oid)
|
void |
removeObject(java.lang.Object object)
|
void |
removeObjectWithOid(OID oid)
|
void |
savePositionOfObjectWithOid(OID oid,
long objectPosition)
To resolve uncommitted updates where the oid change and is not committed yet |
void |
setObjectInfoPointersCacheFromOid(java.util.Map<OID,ObjectInfoHeader> objectInfoPointersCacheFromOid)
|
void |
setObjects(java.util.Map<java.lang.Object,OID> objects)
|
void |
setOids(java.util.Map<OID,java.lang.Object> oids)
|
void |
startInsertingObjectWithOid(java.lang.Object object,
OID oid,
NonNativeObjectInfo nnoi)
|
void |
startReadingObjectInfoWithOid(OID oid,
NonNativeObjectInfo objectInfo)
To resolve cyclic reference, keep track of objects being read The read count is used to store how many times the object has been recursively read |
java.lang.String |
toCompleteString()
|
java.lang.String |
toString()
|
void |
updateIdOfInsertingObject(java.lang.Object object,
OID oid)
|
static java.lang.String |
usage()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static int nbObjects
protected static int nbOids
protected static int nbOih
protected static int nbTransactionOids
protected static int nbObjectPositionByIds
protected static int nbCallsToGetObjectInfoHeaderFromOid
protected static int nbCallsToGetObjectInfoHeaderFromObject
protected static int nbCallsToGetObjectWithOid
protected java.util.Map<java.lang.Object,OID> objects
protected java.util.Map<OID,java.lang.Object> oids
protected java.util.Map<java.lang.Object,ObjectInsertingInfo> insertingObjects
protected java.util.Map<OID,java.lang.Object[]> readingObjectInfo
protected java.util.Map<OID,IdInfo> objectPositionsByIds
To resolve the update of an id object position: When an object is full updated(the current object is being deleted and a new one os being created), the id remain the same but its position change. But the update is done in transaction, so it is not flushed until the commit happens So after the update when i need the position to make the old object a pointer, i have no way to get the right position. To resolve this, i keep a cache of ids where i keep the non commited value
protected java.util.Map<OID,OID> unconnectedZoneOids
protected ISession session
protected java.lang.String name
protected java.util.Map<OID,ObjectInfoHeader> objectInfoPointersCacheFromOid
protected boolean useCache
Constructor Detail |
---|
public Cache(ISession session, java.lang.String name)
Method Detail |
---|
protected void init(ISession session, java.lang.String name)
public void addObject(OID oid, java.lang.Object object, ObjectInfoHeader objectInfoHeader)
addObject
in interface ICache
public void addObjectInfo(ObjectInfoHeader objectInfoHeader)
addObjectInfo
in interface ICache
protected void manageFullCache()
public void startInsertingObjectWithOid(java.lang.Object object, OID oid, NonNativeObjectInfo nnoi)
startInsertingObjectWithOid
in interface ICache
public void updateIdOfInsertingObject(java.lang.Object object, OID oid)
updateIdOfInsertingObject
in interface ICache
public void endInsertingObject(java.lang.Object object)
endInsertingObject
in interface ICache
public void removeObjectWithOid(OID oid)
removeObjectWithOid
in interface ICache
public void removeObject(java.lang.Object object)
removeObject
in interface ICache
public boolean existObject(java.lang.Object object)
existObject
in interface ICache
public java.lang.Object getObjectWithOid(OID oid)
getObjectWithOid
in interface ICache
public ObjectInfoHeader getObjectInfoHeaderFromObject(java.lang.Object object, boolean throwExceptionIfNotFound)
getObjectInfoHeaderFromObject
in interface ICache
public ObjectInfoHeader getObjectInfoHeaderFromOid(OID oid, boolean throwExceptionIfNotFound)
getObjectInfoHeaderFromOid
in interface ICache
public OID getOid(java.lang.Object object, boolean throwExceptionIfNotFound)
getOid
in interface ICache
public void savePositionOfObjectWithOid(OID oid, long objectPosition)
ICache
savePositionOfObjectWithOid
in interface ICache
public void markIdAsDeleted(OID oid)
markIdAsDeleted
in interface ICache
public boolean isDeleted(OID oid)
isDeleted
in interface ICache
public long getObjectPositionByOid(OID oid)
getObjectPositionByOid
in interface ICache
public void clearOnCommit()
clearOnCommit
in interface ICache
public void clear(boolean setToNull)
clear
in interface ICache
public void clearInsertingObjects()
clearInsertingObjects
in interface ICache
public java.lang.String toString()
toString
in interface ICache
toString
in class java.lang.Object
public java.lang.String toCompleteString()
toCompleteString
in interface ICache
public int getNumberOfObjects()
getNumberOfObjects
in interface ICache
public int getNumberOfObjectHeader()
getNumberOfObjectHeader
in interface ICache
public OID idOfInsertingObject(java.lang.Object object)
idOfInsertingObject
in interface ICache
public int insertingLevelOf(java.lang.Object object)
insertingLevelOf
in interface ICache
public boolean isReadingObjectInfoWithOid(OID oid)
isReadingObjectInfoWithOid
in interface ICache
public NonNativeObjectInfo getReadingObjectInfoFromOid(OID oid)
getReadingObjectInfoFromOid
in interface ICache
public void startReadingObjectInfoWithOid(OID oid, NonNativeObjectInfo objectInfo)
ICache
startReadingObjectInfoWithOid
in interface ICache
oid
- The Object OIDobjectInfo
- The object info (not fully set) that is being readpublic void endReadingObjectInfo(OID oid)
endReadingObjectInfo
in interface ICache
public java.util.Map<OID,java.lang.Object> getOids()
getOids
in interface ICache
public void setOids(java.util.Map<OID,java.lang.Object> oids)
public java.util.Map<OID,ObjectInfoHeader> getObjectInfoPointersCacheFromOid()
getObjectInfoPointersCacheFromOid
in interface ICache
public void setObjectInfoPointersCacheFromOid(java.util.Map<OID,ObjectInfoHeader> objectInfoPointersCacheFromOid)
public java.util.Map<java.lang.Object,OID> getObjects()
getObjects
in interface ICache
public void setObjects(java.util.Map<java.lang.Object,OID> objects)
public boolean objectWithIdIsInCommitedZone(OID oid)
objectWithIdIsInCommitedZone
in interface ICache
public void addOIDToUnconnectedZone(OID oid)
addOIDToUnconnectedZone
in interface ICache
public static java.lang.String usage()
protected boolean checkHeaderPosition()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |