private long AssociateIdToObject(byte idType, byte idStatus, long objectPosition) { long idPosition = objectWriter.AssociateIdToObject(idType, idStatus, currentBlockIdPosition , nextId, objectPosition, false); nextId = provider.GetObjectOID(nextId.GetObjectId() + 1, 0); return(idPosition); }
public virtual int CompareTo(object @object) { if (@object == null || !(@object is NeoDatis.Odb.Impl.Core.Oid.OdbClassOID)) { return(-1000); } NeoDatis.Odb.OID otherOid = (NeoDatis.Odb.OID)@object; return((int)(oid - otherOid.GetObjectId())); }
/// <exception cref="System.Exception"></exception> public virtual void TestGetObjectId() { DeleteBase("extb"); NeoDatis.Odb.ODB odb = null; odb = Open("extb"); NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function("Test Function" ); NeoDatis.Odb.OID oid = odb.Store(f); NeoDatis.Odb.ExternalOID extOid = odb.Ext().GetObjectExternalOID(f); AssertEquals(oid.GetObjectId(), extOid.GetObjectId()); AssertEquals(odb.Ext().GetDatabaseId(), extOid.GetDatabaseId()); odb.Close(); odb = Open("extb"); // Getting object via external oid NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)odb .GetObjectFromId(extOid); NeoDatis.Odb.OID lastOid = odb.GetObjectId(f2); AssertEquals(oid, lastOid); AssertEquals(f.GetName(), f2.GetName()); odb.Close(); }
/// <param name="objectWriter">The object writer</param> /// <param name="objectReader">The object reader</param> /// <param name="currentBlockIdPosition">The position of the current block</param> /// <param name="currentBlockIdNumber">The number of the current block</param> /// <param name="currentMaxId">Maximum Database id</param> public DefaultIdManager(NeoDatis.Odb.Core.Layers.Layer3.IObjectWriter objectWriter , NeoDatis.Odb.Core.Layers.Layer3.IObjectReader objectReader, long currentBlockIdPosition , int currentBlockIdNumber, NeoDatis.Odb.OID currentMaxId) { this.provider = NeoDatis.Odb.OdbConfiguration.GetCoreProvider(); this.objectWriter = objectWriter; this.objectReader = objectReader; this.session = objectWriter.GetSession(); this.currentBlockIdPosition = currentBlockIdPosition; this.currentBlockIdNumber = currentBlockIdNumber; this.maxId = provider.GetObjectOID((long)currentBlockIdNumber * NeoDatis.Odb.OdbConfiguration .GetNB_IDS_PER_BLOCK(), 0); this.nextId = provider.GetObjectOID(currentMaxId.GetObjectId() + 1, 0); lastIds = new NeoDatis.Odb.OID[IdBufferSize]; for (int i = 0; i < IdBufferSize; i++) { lastIds[i] = NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant.NullObjectId; } lastIdPositions = new long[IdBufferSize]; lastIdIndex = 0; }
/// <summary>Gets an id for an object (instance)</summary> /// <param name="objectPosition">the object position (instance)</param> /// <param name="idType">The type id : object,class, unknown</param> /// <param name="label">A label for debug</param> /// <returns>The id</returns> internal virtual NeoDatis.Odb.OID GetNextId(long objectPosition, byte idType, byte idStatus, string label) { lock (this) { if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId)) { NeoDatis.Tool.DLogger.Debug(" Start of " + label + " for object with position " + objectPosition); } if (MustShift()) { ShiftBlock(); } // Keep the current id NeoDatis.Odb.OID currentNextId = nextId; if (idType == NeoDatis.Odb.Core.Layers.Layer3.IDTypes.Class) { // If its a class, build a class OID instead. currentNextId = provider.GetClassOID(currentNextId.GetObjectId()); } // Compute the new index to be used to store id and its position in the lastIds and lastIdPositions array int currentIndex = (lastIdIndex + 1) % IdBufferSize; // Stores the id lastIds[currentIndex] = currentNextId; // really associate id to the object position long idPosition = AssociateIdToObject(idType, idStatus, objectPosition); // Store the id position lastIdPositions[currentIndex] = idPosition; if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId)) { NeoDatis.Tool.DLogger.Debug(" End of " + label + " for object with position " + idPosition + " : returning " + currentNextId); } // Update the id buffer index lastIdIndex = currentIndex; return(currentNextId); } }
public ExternalObjectOID(NeoDatis.Odb.OID oid, NeoDatis.Odb.DatabaseId databaseId ) : base(oid.GetObjectId()) { this.databaseId = databaseId; }