|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.neodatis.odb.impl.core.layers.layer3.engine.AbstractObjectWriter
public abstract class AbstractObjectWriter
Manage all IO writing
Field Summary | |
---|---|
protected IByteArrayConverter |
byteArrayConverter
|
IClassIntrospector |
classIntrospector
|
protected IObjectInfoComparator |
comparator
|
IFileSystemInterface |
fsi
|
protected IIdManager |
idManager
|
static java.lang.String |
LOG_ID
|
static java.lang.String |
LOG_ID_DEBUG
|
protected static int |
nbInPlaceUpdates
|
protected static int |
nbNormalUpdates
|
protected IObjectReader |
objectReader
|
protected IStorageEngine |
storageEngine
|
protected ITriggerManager |
triggerManager
To manage triggers |
Constructor Summary | |
---|---|
AbstractObjectWriter(IStorageEngine engine)
|
Method Summary | |
---|---|
ClassInfo |
addClass(ClassInfo newClassInfo,
boolean addDependentClasses)
|
ClassInfoList |
addClasses(ClassInfoList classInfoList)
|
void |
afterInit()
|
long |
associateIdToObject(byte idType,
byte idStatus,
long currentBlockIdPosition,
OID oid,
long objectPosition,
boolean writeInTransaction)
Associate an object OID to its position |
abstract IFileSystemInterface |
buildFSI()
|
void |
close()
|
void |
createEmptyDatabaseHeader(long creationDate,
java.lang.String user,
java.lang.String password)
Creates the header of the file |
OID |
delete(ObjectInfoHeader header)
|
java.lang.String |
depthToSpaces()
|
void |
encodeOid(OID oid,
byte[] bytes,
int offset)
|
void |
flush()
|
IFileSystemInterface |
getFsi()
|
IIdManager |
getIdManager()
|
static int |
getNbInPlaceUpdates()
|
static int |
getNbNormalUpdates()
|
protected ObjectInfoHeader |
getObjectInfoHeader(OID oid,
ICache cache)
|
abstract ISession |
getSession()
|
void |
init2()
The init2 method is the two phase init implementation The FileSystemInterface depends on the session creation which is done by subclasses after the ObjectWriter constructor So we can not execute the buildFSI in the constructor as it would result in a non initialized object reference (the session) |
OID |
insertNonNativeObject(OID oid,
NonNativeObjectInfo nnoi,
boolean isNewObject)
|
(package private) long |
internalStoreObject(NativeObjectInfo noi)
Store a meta representation of a native object(already as meta representation)in ODBFactory database. |
int |
manageIndexesForDelete(OID oid,
NonNativeObjectInfo nnoi)
Insert the object in the index |
int |
manageIndexesForInsert(OID oid,
NonNativeObjectInfo nnoi)
Insert the object in the index |
int |
manageIndexesForUpdate(OID oid,
NonNativeObjectInfo nnoi,
NonNativeObjectInfo oldMetaRepresentation)
|
protected void |
markAsAPointerTo(OID oid,
long currentPosition,
long newObjectPosition)
Writes a pointer block : A pointer block is like a goto. |
int |
markAsDeleted(long currentPosition,
OID oid,
boolean writeInTransaction)
Mark a block as deleted |
long |
markIdBlockAsFull(long blockPosition,
long nextBlockPosition,
boolean writeInTransaction)
Marks a block of type id as full, changes the status and the next block position |
ClassInfo |
persistClass(ClassInfo newClassInfo,
int lastClassInfoIndex,
boolean addClass,
boolean addDependentClasses)
Persist a single class info - This method is used by the XML Importer. |
static void |
resetNbUpdates()
|
long |
safeOverWriteAtomicNativeObject(long position,
AtomicNativeObjectInfo newAnoi,
boolean writeInTransaction)
|
static void |
setNbInPlaceUpdates(int nbInPlaceUpdates)
|
static void |
setNbNormalUpdates(int nbNormalUpdates)
|
void |
setTriggerManager(ITriggerManager triggerManager)
|
void |
storeFreeSpace(long currentPosition,
int blockSize)
|
OID |
storeObject(OID oid,
NonNativeObjectInfo nnoi)
Store a meta representation of an object(already as meta representation)in ODBFactory database. |
void |
updateClassInfo(ClassInfo classInfo,
boolean writeInTransaction)
|
void |
updateClassPositionForClassOIDWithPosition(long idPosition,
long objectPosition,
boolean writeInTransaction)
Udates the real class positon of the class OID |
protected void |
updateFirstInstanceFieldOfClassInfoWithId(OID classInfoId,
long firstInstancePosition)
Updates the first instance field of the class info into the database file |
void |
updateInstanceFieldsOfClassInfo(ClassInfo classInfo,
boolean writeInTransaction)
Updates the instance related field of the class info into the database file Updates the number of objects, the first object oid and the next class oid |
protected void |
updateLastInstanceFieldOfClassInfoWithId(OID classInfoId,
long lastInstancePosition)
Updates the last instance field of the class info into the database file |
protected void |
updateNbObjectsFieldOfClassInfo(OID classInfoId,
long nbObjects)
Updates the number of objects of the class info into the database file |
void |
updateNextObjectFieldOfObjectInfo(OID objectOID,
OID nextObjectOID,
boolean writeInTransaction)
Update next object oid field of the object at the specific position |
ObjectInfoHeader |
updateNextObjectPreviousPointersInCache(OID nextObjectOID,
OID previousObjectOID,
ICache cache)
|
OID |
updateNonNativeObjectInfo(NonNativeObjectInfo nnoi,
boolean forceUpdate)
Updates an object. |
OID |
updateObject(AbstractObjectInfo aoi,
boolean forceUpdate)
|
void |
updateObjectPositionForObjectOIDWithPosition(long idPosition,
long objectPosition,
boolean writeInTransaction)
Updates the real object position of the object OID |
void |
updateObjectReference(long positionWhereTheReferenceIsStored,
OID newOid,
boolean writeInTransaction)
Class User{ private String name; private Function function; } When an object of type User is stored, it stores a reference to its function object. |
void |
updatePreviousObjectFieldOfObjectInfo(OID objectOID,
OID previousObjectOID,
boolean writeInTransaction)
Updates the previous object position field of the object at objectPosition |
ObjectInfoHeader |
updatePreviousObjectNextPointersInCache(OID nextObjectOID,
OID previousObjectOID,
ICache cache)
|
void |
updateStatusForIdWithPosition(long idPosition,
byte newStatus,
boolean writeInTransaction)
|
long |
writeAtomicNativeObject(AtomicNativeObjectInfo anoi,
boolean writeInTransaction)
Writes a natibve attribute |
long |
writeAtomicNativeObject(AtomicNativeObjectInfo anoi,
boolean writeInTransaction,
int totalSpaceIfString)
|
void |
writeClassInfoBody(ClassInfo classInfo,
long position,
boolean writeInTransaction)
Write the class info body to the database file. |
void |
writeClassInfoHeader(ClassInfo classInfo,
long position,
boolean writeInTransaction)
Write the class info header to the database file |
long |
writeClassInfoIndexes(ClassInfo classInfo)
|
void |
writeDatabaseCharacterEncoding(boolean writeInTransaction)
Write the database characterEncoding |
DatabaseId |
writeDatabaseId(long creationDate,
boolean writeInTransaction)
|
void |
writeEncrytionFlag(boolean useEncryption,
boolean writeInTransaction)
Write the encryption flag : 0= no encryption, 1=with encryption |
long |
writeEnumNativeObject(EnumNativeObjectInfo anoi,
boolean writeInTransaction)
|
void |
writeFirstClassInfoOID(OID classInfoID,
boolean inTransaction)
Resets the position of the first class of the metamodel. |
long |
writeIdBlock(long position,
int idBlockSize,
byte blockStatus,
int blockNumber,
long previousBlockPosition,
boolean writeInTransaction)
Writes the header of a block of type ID - a block that contains ids of objects and classes |
void |
writeLastODBCloseStatus(boolean ok,
boolean writeInTransaction)
Write the status of the last odb close |
void |
writeLastTransactionId(TransactionId transactionId)
Write the current transaction Id, out of transaction |
protected void |
writeNativeObjectHeader(int odbTypeId,
boolean isNull,
byte blockType,
boolean writeDataInTransaction)
Write the header of a native attribute |
protected void |
writeNonNativeNullObjectHeader(OID classInfoId,
boolean writeInTransaction)
|
OID |
writeNonNativeObjectInfo(OID existingOid,
NonNativeObjectInfo objectInfo,
long position,
boolean writeDataInTransaction,
boolean isNewObject)
Write an object representation to database file |
OID |
writeNonNativeObjectInfoOld(OID existingOid,
NonNativeObjectInfo objectInfo,
long position,
boolean writeDataInTransaction,
boolean isNewObject)
|
protected void |
writeNullNativeObjectHeader(int OdbTypeId,
boolean writeInTransaction)
|
void |
writeNumberOfClasses(long number,
boolean writeInTransaction)
Write the number of classes in meta-model |
void |
writeOid(OID oid,
boolean writeInTransaction,
java.lang.String label,
int writeAction)
|
void |
writeReplicationFlag(boolean useReplication,
boolean writeInTransaction)
Write the replication flag : 0= No replication, 1= Use replication |
void |
writeUserAndPassword(java.lang.String user,
java.lang.String password,
boolean writeInTransaction)
|
void |
writeVersion(boolean writeInTransaction)
Write the version in the database file |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static int nbInPlaceUpdates
protected static int nbNormalUpdates
public static final java.lang.String LOG_ID
public static final java.lang.String LOG_ID_DEBUG
protected IStorageEngine storageEngine
protected IObjectReader objectReader
public IClassIntrospector classIntrospector
public IFileSystemInterface fsi
protected IIdManager idManager
protected ITriggerManager triggerManager
protected IByteArrayConverter byteArrayConverter
protected IObjectInfoComparator comparator
Constructor Detail |
---|
public AbstractObjectWriter(IStorageEngine engine)
Method Detail |
---|
public abstract ISession getSession()
getSession
in interface IObjectWriter
public abstract IFileSystemInterface buildFSI()
public void init2()
init2
in interface ITwoPhaseInit
public void afterInit()
afterInit
in interface IObjectWriter
public void createEmptyDatabaseHeader(long creationDate, java.lang.String user, java.lang.String password)
createEmptyDatabaseHeader
in interface IObjectWriter
creationDate
- The creation dateuser
- The userpassword
- The password @public void writeUserAndPassword(java.lang.String user, java.lang.String password, boolean writeInTransaction)
public void writeEncrytionFlag(boolean useEncryption, boolean writeInTransaction)
public void writeVersion(boolean writeInTransaction)
public DatabaseId writeDatabaseId(long creationDate, boolean writeInTransaction)
public void writeReplicationFlag(boolean useReplication, boolean writeInTransaction)
public void writeLastTransactionId(TransactionId transactionId)
writeLastTransactionId
in interface IObjectWriter
transactionId
- public void writeNumberOfClasses(long number, boolean writeInTransaction)
public void writeLastODBCloseStatus(boolean ok, boolean writeInTransaction)
writeLastODBCloseStatus
in interface IObjectWriter
public void writeDatabaseCharacterEncoding(boolean writeInTransaction)
public long writeIdBlock(long position, int idBlockSize, byte blockStatus, int blockNumber, long previousBlockPosition, boolean writeInTransaction)
writeIdBlock
in interface IObjectWriter
position
- Position at which the block must be written, if -1, take the
next available positionidBlockSize
- The block size in byteblockStatus
- The block statusblockNumber
- The number of the blockpreviousBlockPosition
- The position of the previous block of the same typewriteInTransaction
- To indicate if write must be done in transaction
public long markIdBlockAsFull(long blockPosition, long nextBlockPosition, boolean writeInTransaction)
markIdBlockAsFull
in interface IObjectWriter
blockPosition
- nextBlockPosition
- writeInTransaction
-
public long associateIdToObject(byte idType, byte idStatus, long currentBlockIdPosition, OID oid, long objectPosition, boolean writeInTransaction)
associateIdToObject
in interface IObjectWriter
idType
- The type : can be object or classidStatus
- The status of the OIDcurrentBlockIdPosition
- The current OID block positionoid
- The OIDobjectPosition
- The positionwriteInTransaction
- To indicate if write must be executed in transaction
public void updateObjectPositionForObjectOIDWithPosition(long idPosition, long objectPosition, boolean writeInTransaction)
updateObjectPositionForObjectOIDWithPosition
in interface IObjectWriter
idPosition
- The OID positionobjectPosition
- The real object positionwriteInTransactionTo
- indicate if write must be done in transaction @public void updateClassPositionForClassOIDWithPosition(long idPosition, long objectPosition, boolean writeInTransaction)
updateClassPositionForClassOIDWithPosition
in interface IObjectWriter
idPosition
- objectPosition
- writeInTransaction
- public void updateStatusForIdWithPosition(long idPosition, byte newStatus, boolean writeInTransaction)
updateStatusForIdWithPosition
in interface IObjectWriter
public ClassInfo persistClass(ClassInfo newClassInfo, int lastClassInfoIndex, boolean addClass, boolean addDependentClasses)
persistClass
in interface IObjectWriter
public ClassInfo addClass(ClassInfo newClassInfo, boolean addDependentClasses)
addClass
in interface IObjectWriter
public ClassInfoList addClasses(ClassInfoList classInfoList)
addClasses
in interface IObjectWriter
public void writeClassInfoHeader(ClassInfo classInfo, long position, boolean writeInTransaction)
IObjectWriter
writeClassInfoHeader
in interface IObjectWriter
classInfo
- The class info to be writtenposition
- The position at which it must be writtenwriteInTransaction
- true if the write must be done in transaction, false to write
directlypublic void encodeOid(OID oid, byte[] bytes, int offset)
public void writeOid(OID oid, boolean writeInTransaction, java.lang.String label, int writeAction)
public void writeClassInfoBody(ClassInfo classInfo, long position, boolean writeInTransaction)
classInfo
- position
- The positionwriteInTransaction
- public long writeClassInfoIndexes(ClassInfo classInfo)
public void updateClassInfo(ClassInfo classInfo, boolean writeInTransaction)
updateClassInfo
in interface IObjectWriter
public void writeFirstClassInfoOID(OID classInfoID, boolean inTransaction)
classInfoPosition
- public OID writeNonNativeObjectInfo(OID existingOid, NonNativeObjectInfo objectInfo, long position, boolean writeDataInTransaction, boolean isNewObject)
IObjectWriter
writeNonNativeObjectInfo
in interface IObjectWriter
existingOid
- The oid of the object, can be nullobjectInfo
- The Object meta representationposition
- The position where the object must be written, can be -1writeDataInTransaction
- To indicate if the write must be done in or out of transaction
public OID writeNonNativeObjectInfoOld(OID existingOid, NonNativeObjectInfo objectInfo, long position, boolean writeDataInTransaction, boolean isNewObject)
public int manageIndexesForInsert(OID oid, NonNativeObjectInfo nnoi)
manageIndexesForInsert
in interface IObjectWriter
oid
- The object idnnoi
- The object meta represenation
public int manageIndexesForDelete(OID oid, NonNativeObjectInfo nnoi)
manageIndexesForDelete
in interface IObjectWriter
oid
- The object idnnoi
- The object meta represenation
java.lang.Exception
public int manageIndexesForUpdate(OID oid, NonNativeObjectInfo nnoi, NonNativeObjectInfo oldMetaRepresentation)
manageIndexesForUpdate
in interface IObjectWriter
public OID insertNonNativeObject(OID oid, NonNativeObjectInfo nnoi, boolean isNewObject)
insertNonNativeObject
in interface IObjectWriter
oid
- The Oid of the object to be insertednnoi
- The object meta representation The object to be inserted in
the databaseisNewObject
- To indicate if object is new
public OID storeObject(OID oid, NonNativeObjectInfo nnoi)
oid
- The oid of the object to be inserted/updatesnnoi
- The meta representation of an object
long internalStoreObject(NativeObjectInfo noi)
nnoi
- The meta representation of an object
public OID updateObject(AbstractObjectInfo aoi, boolean forceUpdate)
public OID updateNonNativeObjectInfo(NonNativeObjectInfo nnoi, boolean forceUpdate)
Try to update in place. Only change what has changed. This is restricted to particular types (fixed size types). If in place update is not possible, then deletes the current object and creates a new at the end of the database file and updates OID object position. @param object The object to be updated @param forceUpdate when true, no verification is done to check if update must be done. @return The oid of the object, as a negative number @
updateNonNativeObjectInfo
in interface IObjectWriter
nnoi
- The meta representation of the object to be updatedforceUpdate
- when true, no verification is done to check if update must be done.
protected ObjectInfoHeader getObjectInfoHeader(OID oid, ICache cache)
public ObjectInfoHeader updateNextObjectPreviousPointersInCache(OID nextObjectOID, OID previousObjectOID, ICache cache)
public ObjectInfoHeader updatePreviousObjectNextPointersInCache(OID nextObjectOID, OID previousObjectOID, ICache cache)
public java.lang.String depthToSpaces()
protected void writeNullNativeObjectHeader(int OdbTypeId, boolean writeInTransaction)
protected void writeNonNativeNullObjectHeader(OID classInfoId, boolean writeInTransaction)
protected void writeNativeObjectHeader(int odbTypeId, boolean isNull, byte blockType, boolean writeDataInTransaction)
odbTypeId
- isNull
- writeDataInTransaction
- public long safeOverWriteAtomicNativeObject(long position, AtomicNativeObjectInfo newAnoi, boolean writeInTransaction) throws java.lang.NumberFormatException, java.io.IOException
java.lang.NumberFormatException
java.io.IOException
public long writeEnumNativeObject(EnumNativeObjectInfo anoi, boolean writeInTransaction)
public long writeAtomicNativeObject(AtomicNativeObjectInfo anoi, boolean writeInTransaction)
anoi
- writeInTransaction
- To specify if data must be written in the transaction or
directly to database file
java.lang.NumberFormatException
public long writeAtomicNativeObject(AtomicNativeObjectInfo anoi, boolean writeInTransaction, int totalSpaceIfString)
writeAtomicNativeObject
in interface IObjectWriter
public void updatePreviousObjectFieldOfObjectInfo(OID objectOID, OID previousObjectOID, boolean writeInTransaction)
updatePreviousObjectFieldOfObjectInfo
in interface IObjectWriter
objectOID
- previousObjectOID
- writeInTransaction
- public void updateNextObjectFieldOfObjectInfo(OID objectOID, OID nextObjectOID, boolean writeInTransaction)
updateNextObjectFieldOfObjectInfo
in interface IObjectWriter
objectOID
- nextObjectOID
- writeInTransaction
- public int markAsDeleted(long currentPosition, OID oid, boolean writeInTransaction)
markAsDeleted
in interface IObjectWriter
currentPosition
-
public void storeFreeSpace(long currentPosition, int blockSize)
protected void markAsAPointerTo(OID oid, long currentPosition, long newObjectPosition)
currentPosition
- newObjectPosition
- public void updateInstanceFieldsOfClassInfo(ClassInfo classInfo, boolean writeInTransaction)
updateInstanceFieldsOfClassInfo
in interface IObjectWriter
classInfo
- The class info to be updatedwriteInTransaction
- To specify if it must be part of a transaction @protected void updateLastInstanceFieldOfClassInfoWithId(OID classInfoId, long lastInstancePosition)
classInfoPosition
- The class info to be updatedlastInstancePosition
- The last instance position @protected void updateFirstInstanceFieldOfClassInfoWithId(OID classInfoId, long firstInstancePosition)
classInfoPosition
- The class info to be updatedfirstInstancePosition
- The first instance position @protected void updateNbObjectsFieldOfClassInfo(OID classInfoId, long nbObjects)
classInfoPosition
- The class info to be updatednbObjects
- The number of object @public void updateObjectReference(long positionWhereTheReferenceIsStored, OID newOid, boolean writeInTransaction)
Class User{ private String name; private Function function; } When an object of type User is stored, it stores a reference to its function object. If the function is set to another, the pointer to the function object must be changed. for example, it was pointing to a function at the position 1407, the 1407 value is stored while writing the USer object, let's say at the position 528. To make the user point to another function object (which exist at the position 1890) The position 528 must be updated to 1890.
positionWhereTheReferenceIsStored
- newOid
- public void flush()
flush
in interface IObjectWriter
public IIdManager getIdManager()
getIdManager
in interface IObjectWriter
public void close()
close
in interface IObjectWriter
public static int getNbInPlaceUpdates()
public static void setNbInPlaceUpdates(int nbInPlaceUpdates)
public static int getNbNormalUpdates()
public static void setNbNormalUpdates(int nbNormalUpdates)
public static void resetNbUpdates()
public IFileSystemInterface getFsi()
getFsi
in interface IObjectWriter
public OID delete(ObjectInfoHeader header)
delete
in interface IObjectWriter
public void setTriggerManager(ITriggerManager triggerManager)
setTriggerManager
in interface IObjectWriter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |