Ejemplo n.º 1
0
 protected override void WriteBuffer(ByteArrayBuffer buffer, bool shuttingDown)
 {
     base.WriteBuffer(buffer, shuttingDown);
     var systemData = SystemData();
     buffer.WriteInt(systemData.IdToTimestampIndexId());
     buffer.WriteInt(systemData.TimestampToIdIndexId());
 }
Ejemplo n.º 2
0
 public override void WriteThis(Transaction trans, ByteArrayBuffer a_writer)
 {
     a_writer.WriteByte(BtreeVersion);
     a_writer.WriteInt(_size);
     a_writer.WriteInt(NodeSize());
     a_writer.WriteIDOf(trans, _root);
 }
Ejemplo n.º 3
0
 public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object
     obj)
 {
     var slot = (Slot) obj;
     writer.WriteInt(slot.Address());
     writer.WriteInt(slot.Length());
 }
        public override void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount
                                              , Slot reservedSlot)
        {
            if (slotChangeCount < 1)
            {
                return;
            }
            var commitHook = _container.CommitHook();

            FlushDatabaseFile();
            EnsureLogAndLock();
            var length    = TransactionLogSlotLength(slotChangeCount);
            var logBuffer = new ByteArrayBuffer(length);

            logBuffer.WriteInt(length);
            logBuffer.WriteInt(slotChangeCount);
            AppendSlotChanges(logBuffer, slotChangeTree);
            Write(_logFile, logBuffer);
            _logFile.Sync();
            WriteToLockFile(LockInt);
            WriteSlots(slotChangeTree);
            commitHook.Run();
            FlushDatabaseFile();
            WriteToLockFile(0);
        }
Ejemplo n.º 5
0
        public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object
                                            obj)
        {
            Slot slot = (Slot)obj;

            writer.WriteInt(slot.Address());
            writer.WriteInt(slot.Length());
        }
Ejemplo n.º 6
0
        protected override void WriteBuffer(ByteArrayBuffer buffer, bool shuttingDown)
        {
            base.WriteBuffer(buffer, shuttingDown);
            SystemData systemData = SystemData();

            buffer.WriteInt(systemData.IdToTimestampIndexId());
            buffer.WriteInt(systemData.TimestampToIdIndexId());
        }
Ejemplo n.º 7
0
        private void WriteToLockFile(int lockSignal)
        {
            ByteArrayBuffer lockBuffer = NewLockFileBuffer();

            lockBuffer.WriteInt(lockSignal);
            lockBuffer.WriteInt(lockSignal);
            Write(_lockFile, lockBuffer);
            _lockFile.Sync();
        }
Ejemplo n.º 8
0
 public override void Write(ByteArrayBuffer writer)
 {
     if (SlotModified())
     {
         writer.WriteInt(_key);
         writer.WriteInt(_newSlot.Address());
         writer.WriteInt(_newSlot.Length());
     }
 }
Ejemplo n.º 9
0
 private void WriteIds(ByteArrayBuffer buffer, IList ids)
 {
     buffer.WriteInt(ids.Count);
     for (var idIter = ids.GetEnumerator(); idIter.MoveNext();)
     {
         var id = ((int)idIter.Current);
         buffer.WriteInt(id);
     }
 }
 public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer a_writer, object
                                     a_object)
 {
     if (a_object == null)
     {
         a_writer.WriteInt(0);
         return;
     }
     a_writer.WriteInt(((int)a_object));
 }
 private void WriteSlot(ByteArrayBuffer buffer, Slot slot, bool writeZero)
 {
     if (writeZero || slot == null)
     {
         buffer.WriteInt(0);
         buffer.WriteInt(0);
         return;
     }
     buffer.WriteInt(slot.Address());
     buffer.WriteInt(slot.Length());
 }
Ejemplo n.º 12
0
 public virtual void Write(Transaction trans, ClassMetadata clazz, ByteArrayBuffer
     writer)
 {
     writer.WriteShortString(trans, clazz.NameToWrite());
     var intFormerlyKnownAsMetaClassID = 0;
     writer.WriteInt(intFormerlyKnownAsMetaClassID);
     writer.WriteIDOf(trans, clazz._ancestor);
     WriteIndex(trans, clazz, writer);
     writer.WriteInt(clazz.DeclaredAspectCount());
     clazz.TraverseDeclaredAspects(new _IProcedure4_39(this, trans, clazz, writer));
 }
Ejemplo n.º 13
0
        public override void WriteThis(Transaction trans, ByteArrayBuffer buffer)
        {
            int      count       = 0;
            int      startOffset = buffer._offset;
            IContext context     = trans.Context();

            buffer.IncrementOffset(CountLeafAnd3LinkLength);
            if (_isLeaf)
            {
                for (int i = 0; i < _count; i++)
                {
                    object obj = InternalKey(trans, i);
                    if (obj != No4.Instance)
                    {
                        count++;
                        KeyHandler().WriteIndexEntry(context, buffer, obj);
                    }
                }
            }
            else
            {
                for (int i = 0; i < _count; i++)
                {
                    if (ChildCanSupplyFirstKey(i))
                    {
                        Db4objects.Db4o.Internal.Btree.BTreeNode child = (Db4objects.Db4o.Internal.Btree.BTreeNode
                                                                          )_children[i];
                        object childKey = child.FirstKey(trans);
                        if (childKey != No4.Instance)
                        {
                            count++;
                            KeyHandler().WriteIndexEntry(context, buffer, childKey);
                            buffer.WriteIDOf(trans, child);
                        }
                    }
                    else
                    {
                        count++;
                        KeyHandler().WriteIndexEntry(context, buffer, Key(i));
                        buffer.WriteIDOf(trans, _children[i]);
                    }
                }
            }
            int endOffset = buffer._offset;

            buffer._offset = startOffset;
            buffer.WriteInt(count);
            buffer.WriteByte(_isLeaf ? (byte)1 : (byte)0);
            buffer.WriteInt(_parentID);
            buffer.WriteInt(_previousID);
            buffer.WriteInt(_nextID);
            buffer._offset = endOffset;
        }
Ejemplo n.º 14
0
        public virtual void Write(Transaction trans, ClassMetadata clazz, ByteArrayBuffer
                                  writer)
        {
            writer.WriteShortString(trans, clazz.NameToWrite());
            var intFormerlyKnownAsMetaClassID = 0;

            writer.WriteInt(intFormerlyKnownAsMetaClassID);
            writer.WriteIDOf(trans, clazz._ancestor);
            WriteIndex(trans, clazz, writer);
            writer.WriteInt(clazz.DeclaredAspectCount());
            clazz.TraverseDeclaredAspects(new _IProcedure4_39(this, trans, clazz, writer));
        }
Ejemplo n.º 15
0
        private void WriteThis(Slot reservedSlot)
        {
            // We need a little dance here to keep filling free slots
            // with X bytes. The FreespaceManager would do it immediately
            // upon the free call, but then our CrashSimulatingTestCase
            // fails because we have the Xses in the file before flushing.
            Slot xByteSlot  = null;
            int  slotLength = SlotLength();

            if (reservedSlot.Length() >= slotLength)
            {
                _slot        = reservedSlot;
                reservedSlot = null;
            }
            else
            {
                _slot = AllocateSlot(true, slotLength);
            }
            ByteArrayBuffer buffer = new ByteArrayBuffer(_slot.Length());

            buffer.WriteInt(_childId);
            _idGenerator.Write(buffer);
            TreeInt.Write(buffer, _ids);
            _container.WriteBytes(buffer, _slot.Address(), 0);
            _container.SystemData().IdSystemSlot(_slot);
            IRunnable commitHook = _container.CommitHook();

            _container.SyncFiles(commitHook);
            FreeSlot(reservedSlot);
        }
Ejemplo n.º 16
0
        protected virtual void WriteIndex(Transaction trans, ClassMetadata clazz, ByteArrayBuffer
                                          writer)
        {
            var indexID = clazz.Index().Write(trans);

            writer.WriteInt(IndexIDForWriting(indexID));
        }
        protected virtual void WriteBuffer(ByteArrayBuffer buffer, bool shuttingDown)
        {
            SystemData systemData = SystemData();

            WriteSlot(buffer, systemData.IdSystemSlot(), false);
            WriteSlot(buffer, systemData.InMemoryFreespaceSlot(), !shuttingDown);
            buffer.WriteInt(systemData.BTreeFreespaceId());
            buffer.WriteInt(systemData.ConverterVersion());
            buffer.WriteInt(systemData.UuidIndexId());
            Db4oDatabase identity = systemData.Identity();

            buffer.WriteInt(identity == null ? 0 : identity.GetID(_container.SystemTransaction
                                                                      ()));
            buffer.WriteLong(systemData.LastTimeStampID());
            buffer.WriteByte(systemData.FreespaceSystem());
        }
Ejemplo n.º 18
0
        public override void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect
                                   , ByteArrayBuffer writer)
        {
            writer.WriteShortString(trans, aspect.GetName());
            if (!(aspect is FieldMetadata))
            {
                return;
            }
            var field = (FieldMetadata)aspect;

            field.Alive();
            if (field.IsVirtual())
            {
                return;
            }
            var handler = field.GetHandler();

            if (handler is StandardReferenceTypeHandler)
            {
                // TODO: ensure there is a test case, to make this happen
                if (((StandardReferenceTypeHandler)handler).ClassMetadata().GetID() == 0)
                {
                    trans.Container().NeedsUpdate(clazz);
                }
            }
            writer.WriteInt(field.FieldTypeID());
            var bitmap = new BitMap4(3);

            bitmap.Set(0, field.IsPrimitive());
            bitmap.Set(1, Handlers4.HandlesArray(handler));
            bitmap.Set(2, Handlers4.HandlesMultidimensionalArray(handler));
            // keep the order
            writer.WriteByte(bitmap.GetByte(0));
        }
Ejemplo n.º 19
0
            private void WriteIntAt(ByteArrayBuffer target, int offset, int value)
            {
                int currentOffset = target.Offset();

                target.Seek(offset);
                target.WriteInt(value);
                target.Seek(currentOffset);
            }
Ejemplo n.º 20
0
        public void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object obj)
        {
            var indexEntry = obj as IndexEntry;

            if (indexEntry == null)
            {
                indexEntry = new IndexEntry(ClassMetadataIdFor(context, obj), Convert.ToInt64(obj));
            }
            writer.WriteInt(indexEntry.ClassMetadataId);
            writer.WriteLong(indexEntry.EnumValue);
        }
        public virtual ByteArrayBuffer Marshall(LocalTransaction transaction, IIntIterator4
                                                ids, int count)
        {
            ByteArrayBuffer buffer = new ByteArrayBuffer(Const4.IntLength + count * Const4.IntLength
                                                         );
            int sizeOffset = buffer.Offset();

            buffer.WriteInt(0);
            int written = 0;

            while (count > 0 && ids.MoveNext())
            {
                buffer.WriteInt(ids.CurrentInt());
                ++written;
                --count;
            }
            buffer.Seek(sizeOffset);
            buffer.WriteInt(written);
            return(buffer);
        }
Ejemplo n.º 22
0
        private static byte[] BytesToSendFor(string message)
        {
            var io = new LatinStringIO();
            var marshalledStringLength = io.Length(message);
            var buffer = new ByteArrayBuffer(marshalledStringLength + Const4.IntLength);

            buffer.WriteInt(marshalledStringLength);

            io.WriteLengthAndString(buffer, message);
            buffer.Seek(0);
            return(buffer.ReadBytes(buffer.Length()));
        }
Ejemplo n.º 23
0
        public virtual ByteArrayBuffer ToWriteBuffer(Pointer4 pointer)
        {
            ByteArrayBuffer buffer = new ByteArrayBuffer(pointer.Length());

            _writeBuffer.MergeChildren(this, pointer.Address(), WriteBufferOffset());
            WriteObjectClassID(buffer, ClassMetadata().GetID());
            buffer.WriteByte(HandlerRegistry.HandlerVersion);
            buffer.WriteInt(AspectCount());
            buffer.WriteBitMap(_nullBitMap);
            _writeBuffer.TransferContentTo(buffer);
            return(buffer);
        }
Ejemplo n.º 24
0
 private void WriteIdSlotPairsTo(IList slots, ByteArrayBuffer buffer)
 {
     buffer.WriteInt(slots.Count);
     for (IEnumerator idSlotPairIter = slots.GetEnumerator(); idSlotPairIter.MoveNext(
              );)
     {
         Pair idSlotPair = ((Pair)idSlotPairIter.Current);
         int  id         = (((int)idSlotPair.first));
         Slot slot       = ((Slot)idSlotPair.second);
         if (Slot.IsNull(slot))
         {
             buffer.WriteInt(id);
             buffer.WriteInt(0);
             continue;
         }
         ByteArrayBuffer slotBuffer = _transaction.LocalContainer().ReadBufferBySlot(slot);
         buffer.WriteInt(id);
         buffer.WriteInt(slot.Length());
         buffer.WriteBytes(slotBuffer._buffer);
     }
 }
Ejemplo n.º 25
0
 public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object
                                     entry)
 {
     if (entry == null)
     {
         writer.WriteInt(0);
         writer.WriteInt(0);
         return;
     }
     if (entry is StatefulBuffer)
     {
         StatefulBuffer entryAsWriter = (StatefulBuffer)entry;
         writer.WriteInt(entryAsWriter.GetAddress());
         writer.WriteInt(entryAsWriter.Length());
         return;
     }
     if (entry is Slot)
     {
         Slot s = (Slot)entry;
         writer.WriteInt(s.Address());
         writer.WriteInt(s.Length());
         return;
     }
     throw new ArgumentException();
 }
Ejemplo n.º 26
0
        private void DefragmentWriteMappedClassId(IDefragmentContext context, ArrayInfo info
                                                  , int classIdOffset)
        {
            ByteArrayBuffer targetBuffer  = context.TargetBuffer();
            int             currentOffset = targetBuffer.Offset();

            targetBuffer.Seek(classIdOffset);
            int classID            = ClassIDFromInfo(Container(context), info);
            int mappedID           = context.MappedID(classID);
            int marshalledMappedId = ClassIdToMarshalledClassId(mappedID, info.Primitive());

            targetBuffer.WriteInt(marshalledMappedId);
            targetBuffer.Seek(currentOffset);
        }
Ejemplo n.º 27
0
        public void Test()
        {
            int[] ints = new int[] {
                int.MinValue,
                -1,
                0,
                1,
                int.MaxValue
            };
            int             bufferLength = Const4.IntLength * ints.Length;
            ByteArrayBuffer buffer       = new ByteArrayBuffer(bufferLength);

            for (int i = 0; i < ints.Length; i++)
            {
                buffer.WriteInt(ints[i]);
            }
            long checkSum = CRC32.CheckSum(buffer._buffer, 0, buffer._buffer.Length);

            _expectedJavaOutput = checkSum.ToString();
            RunTest();
        }
Ejemplo n.º 28
0
        public Msg ReplyFromServer()
        {
            lock (ContainerLock())
            {
                try
                {
                    // Since every new Client reads the class
                    // collection from the file, we have to
                    // make sure, it has been written.
                    Container().ClassCollection().Write(Transaction());
                }
                catch (Exception)
                {
                }
            }
            MsgD message = Msg.GetClasses.GetWriterForLength(Transaction(), Const4.IntLength
                                                             + 1);
            ByteArrayBuffer writer = message.PayLoad();

            writer.WriteInt(Container().ClassCollection().GetID());
            writer.WriteByte(Container().StringIO().EncodingByte());
            return(message);
        }
Ejemplo n.º 29
0
 public override void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount
     , Slot reservedSlot)
 {
     if (slotChangeCount < 1)
     {
         return;
     }
     var commitHook = _container.CommitHook();
     FlushDatabaseFile();
     EnsureLogAndLock();
     var length = TransactionLogSlotLength(slotChangeCount);
     var logBuffer = new ByteArrayBuffer(length);
     logBuffer.WriteInt(length);
     logBuffer.WriteInt(slotChangeCount);
     AppendSlotChanges(logBuffer, slotChangeTree);
     Write(_logFile, logBuffer);
     _logFile.Sync();
     WriteToLockFile(LockInt);
     WriteSlots(slotChangeTree);
     commitHook.Run();
     FlushDatabaseFile();
     WriteToLockFile(0);
 }
Ejemplo n.º 30
0
 public virtual void Write(ByteArrayBuffer buffer)
 {
     buffer.WriteInt(_id);
     buffer.WriteInt(_address);
     buffer.WriteInt(_length);
 }
Ejemplo n.º 31
0
 public virtual void Write(ByteArrayBuffer buffer)
 {
     buffer.WriteInt(_id);
     buffer.WriteInt(Length());
     buffer.Append(_bytes);
 }
Ejemplo n.º 32
0
 public override void WriteThis(Transaction trans, ByteArrayBuffer a_writer)
 {
     a_writer.WriteByte(BtreeVersion);
     a_writer.WriteInt(_size);
     a_writer.WriteInt(NodeSize());
     a_writer.WriteIDOf(trans, _root);
 }
Ejemplo n.º 33
0
 protected virtual void WriteBuffer(ByteArrayBuffer buffer, bool shuttingDown)
 {
     var systemData = SystemData();
     WriteSlot(buffer, systemData.IdSystemSlot(), false);
     WriteSlot(buffer, systemData.InMemoryFreespaceSlot(), !shuttingDown);
     buffer.WriteInt(systemData.BTreeFreespaceId());
     buffer.WriteInt(systemData.ConverterVersion());
     buffer.WriteInt(systemData.UuidIndexId());
     var identity = systemData.Identity();
     buffer.WriteInt(identity == null
         ? 0
         : identity.GetID(_container.SystemTransaction
             ()));
     buffer.WriteLong(systemData.LastTimeStampID());
     buffer.WriteByte(systemData.FreespaceSystem());
 }
Ejemplo n.º 34
0
 private void WriteThis(Slot reservedSlot)
 {
     // We need a little dance here to keep filling free slots
     // with X bytes. The FreespaceManager would do it immediately
     // upon the free call, but then our CrashSimulatingTestCase
     // fails because we have the Xses in the file before flushing.
     Slot xByteSlot = null;
     var slotLength = SlotLength();
     if (reservedSlot.Length() >= slotLength)
     {
         _slot = reservedSlot;
         reservedSlot = null;
     }
     else
     {
         _slot = AllocateSlot(true, slotLength);
     }
     var buffer = new ByteArrayBuffer(_slot.Length());
     buffer.WriteInt(_childId);
     _idGenerator.Write(buffer);
     TreeInt.Write(buffer, _ids);
     _container.WriteBytes(buffer, _slot.Address(), 0);
     _container.SystemData().IdSystemSlot(_slot);
     var commitHook = _container.CommitHook();
     _container.SyncFiles(commitHook);
     FreeSlot(reservedSlot);
 }
Ejemplo n.º 35
0
 public static void WriteInt(int a_int, ByteArrayBuffer a_bytes)
 {
     a_bytes.WriteInt(a_int);
 }
Ejemplo n.º 36
0
 public virtual void Write(ByteArrayBuffer buffer)
 {
     buffer.WriteInt(PersistentGeneratorValue());
 }
Ejemplo n.º 37
0
 private void WriteObjectClassID(ByteArrayBuffer reader, int id)
 {
     reader.WriteInt(-id);
 }
Ejemplo n.º 38
0
 public override void Write(ByteArrayBuffer writer)
 {
     if (SlotModified())
     {
         writer.WriteInt(_key);
         writer.WriteInt(_newSlot.Address());
         writer.WriteInt(_newSlot.Length());
     }
 }
Ejemplo n.º 39
0
 public override void Write(ByteArrayBuffer buffer)
 {
     buffer.WriteInt(_key);
     buffer.WriteInt(_slot.Address());
     buffer.WriteInt(_slot.Length());
 }
Ejemplo n.º 40
0
 public virtual void Write(ByteArrayBuffer buffer)
 {
     buffer.WriteInt(_id);
     buffer.WriteInt(_address);
     buffer.WriteInt(_length);
 }
Ejemplo n.º 41
0
 public virtual void WriteObjectClassID(ByteArrayBuffer buffer, int id)
 {
     buffer.WriteInt(-id);
 }
Ejemplo n.º 42
0
 public virtual void WriteObjectClassID(ByteArrayBuffer buffer, int id)
 {
     buffer.WriteInt(-id);
 }
Ejemplo n.º 43
0
 public override void Write(ByteArrayBuffer buffer)
 {
     buffer.WriteInt(_key);
     buffer.WriteInt(_slot.Address());
     buffer.WriteInt(_slot.Length());
 }
Ejemplo n.º 44
0
 public override void Write(ByteArrayBuffer a_writer)
 {
     // byte order: size, address
     a_writer.WriteInt(_key);
     a_writer.WriteInt(_peer._key);
 }
Ejemplo n.º 45
0
 public override void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect
     , ByteArrayBuffer writer)
 {
     writer.WriteShortString(trans, aspect.GetName());
     if (!(aspect is FieldMetadata))
     {
         return;
     }
     var field = (FieldMetadata) aspect;
     field.Alive();
     if (field.IsVirtual())
     {
         return;
     }
     var handler = field.GetHandler();
     if (handler is StandardReferenceTypeHandler)
     {
         // TODO: ensure there is a test case, to make this happen 
         if (((StandardReferenceTypeHandler) handler).ClassMetadata().GetID() == 0)
         {
             trans.Container().NeedsUpdate(clazz);
         }
     }
     writer.WriteInt(field.FieldTypeID());
     var bitmap = new BitMap4(3);
     bitmap.Set(0, field.IsPrimitive());
     bitmap.Set(1, Handlers4.HandlesArray(handler));
     bitmap.Set(2, Handlers4.HandlesMultidimensionalArray(handler));
     // keep the order
     writer.WriteByte(bitmap.GetByte(0));
 }
 public virtual void Write(ByteArrayBuffer buffer)
 {
     buffer.WriteInt(PersistentGeneratorValue());
 }
Ejemplo n.º 47
0
 public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object
     entry)
 {
     if (entry == null)
     {
         writer.WriteInt(0);
         writer.WriteInt(0);
         return;
     }
     if (entry is StatefulBuffer)
     {
         var entryAsWriter = (StatefulBuffer) entry;
         writer.WriteInt(entryAsWriter.GetAddress());
         writer.WriteInt(entryAsWriter.Length());
         return;
     }
     if (entry is Slot)
     {
         var s = (Slot) entry;
         writer.WriteInt(s.Address());
         writer.WriteInt(s.Length());
         return;
     }
     throw new ArgumentException();
 }
Ejemplo n.º 48
0
 public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer a_writer, object
     a_object)
 {
     if (a_object == null)
     {
         a_writer.WriteInt(0);
         return;
     }
     a_writer.WriteInt(((int) a_object));
 }
Ejemplo n.º 49
0
 public static void WriteInt(int a_int, ByteArrayBuffer a_bytes)
 {
     a_bytes.WriteInt(a_int);
 }
Ejemplo n.º 50
0
 protected virtual void WriteIndex(Transaction trans, ClassMetadata clazz, ByteArrayBuffer
     writer)
 {
     var indexID = clazz.Index().Write(trans);
     writer.WriteInt(IndexIDForWriting(indexID));
 }
Ejemplo n.º 51
0
 public virtual ByteArrayBuffer ToWriteBuffer(Pointer4 pointer)
 {
     var buffer = new ByteArrayBuffer(pointer.Length());
     _writeBuffer.MergeChildren(this, pointer.Address(), WriteBufferOffset());
     WriteObjectClassID(buffer, ClassMetadata().GetID());
     buffer.WriteByte(HandlerRegistry.HandlerVersion);
     buffer.WriteInt(AspectCount());
     buffer.WriteBitMap(_nullBitMap);
     _writeBuffer.TransferContentTo(buffer);
     return buffer;
 }
Ejemplo n.º 52
0
 public override void WriteThis(Transaction trans, ByteArrayBuffer buffer)
 {
     var count = 0;
     var startOffset = buffer._offset;
     var context = trans.Context();
     buffer.IncrementOffset(CountLeafAnd3LinkLength);
     if (_isLeaf)
     {
         for (var i = 0; i < _count; i++)
         {
             var obj = InternalKey(trans, i);
             if (obj != No4.Instance)
             {
                 count++;
                 KeyHandler().WriteIndexEntry(context, buffer, obj);
             }
         }
     }
     else
     {
         for (var i = 0; i < _count; i++)
         {
             if (ChildCanSupplyFirstKey(i))
             {
                 var child = (BTreeNode
                     ) _children[i];
                 var childKey = child.FirstKey(trans);
                 if (childKey != No4.Instance)
                 {
                     count++;
                     KeyHandler().WriteIndexEntry(context, buffer, childKey);
                     buffer.WriteIDOf(trans, child);
                 }
             }
             else
             {
                 count++;
                 KeyHandler().WriteIndexEntry(context, buffer, Key(i));
                 buffer.WriteIDOf(trans, _children[i]);
             }
         }
     }
     var endOffset = buffer._offset;
     buffer._offset = startOffset;
     buffer.WriteInt(count);
     buffer.WriteByte(_isLeaf ? (byte) 1 : (byte) 0);
     buffer.WriteInt(_parentID);
     buffer.WriteInt(_previousID);
     buffer.WriteInt(_nextID);
     buffer._offset = endOffset;
 }
Ejemplo n.º 53
0
 private void WriteSlot(ByteArrayBuffer buffer, Slot slot, bool writeZero)
 {
     if (writeZero || slot == null)
     {
         buffer.WriteInt(0);
         buffer.WriteInt(0);
         return;
     }
     buffer.WriteInt(slot.Address());
     buffer.WriteInt(slot.Length());
 }
Ejemplo n.º 54
0
 public override void WriteObjectClassID(ByteArrayBuffer buffer, int id)
 {
     buffer.WriteInt(id);
 }