/// <exception cref="Db4objects.Db4o.Internal.FieldIndexException"></exception> public override void AddFieldIndex(ObjectIdContextImpl context) { LocalTransaction transaction = (LocalTransaction)context.Transaction(); LocalObjectContainer localContainer = (LocalObjectContainer)transaction.Container (); Slot oldSlot = transaction.IdSystem().CommittedSlot(context.ObjectId()); int savedOffset = context.Offset(); int db4oDatabaseIdentityID = context.ReadInt(); long uuid = context.ReadLong(); context.Seek(savedOffset); bool isnew = (oldSlot.IsNull()); if ((uuid == 0 || db4oDatabaseIdentityID == 0) && context.ObjectId() > 0 && !isnew) { UUIDFieldMetadata.DatabaseIdentityIDAndUUID identityAndUUID = ReadDatabaseIdentityIDAndUUID (localContainer, context.ClassMetadata(), oldSlot, false); db4oDatabaseIdentityID = identityAndUUID.databaseIdentityID; uuid = identityAndUUID.uuid; } if (db4oDatabaseIdentityID == 0) { db4oDatabaseIdentityID = localContainer.Identity().GetID(transaction); } if (uuid == 0) { uuid = localContainer.GenerateTimeStampId(); } StatefulBuffer writer = (StatefulBuffer)context.Buffer(); writer.WriteInt(db4oDatabaseIdentityID); writer.WriteLong(uuid); if (isnew) { AddIndexEntry(writer, uuid); } }
/// <exception cref="Db4objects.Db4o.Internal.FieldIndexException"></exception> public virtual void AddFieldIndex(ObjectIdContextImpl context) { if (!HasIndex()) { IncrementOffset(context, context); return; } try { AddIndexEntry(context.Transaction(), context.ObjectId(), ReadIndexEntry(context)); } catch (CorruptionException exc) { throw new FieldIndexException(exc, this); } }
protected override void ProcessAspect(ClassAspect aspect, int currentSlot, bool isNull ) { if (aspect is FieldMetadata) { var field = (FieldMetadata)aspect; if (isNull) { field.AddIndexEntry(context.Transaction(), context.ObjectId(), null); } else { field.AddFieldIndex(context); } } else { aspect.IncrementOffset(context.Buffer(), context); } }