private void WriteIds(ByteArrayBuffer buffer, IList ids)
		{
			buffer.WriteInt(ids.Count);
			for (IEnumerator idIter = ids.GetEnumerator(); idIter.MoveNext(); )
			{
				int id = ((int)idIter.Current);
				buffer.WriteInt(id);
			}
		}
Ejemplo n.º 2
0
		public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object
			 obj)
		{
			Slot slot = (Slot)obj;
			writer.WriteInt(slot.Address());
			writer.WriteInt(slot.Length());
		}
		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.º 4
0
 public override void WriteThis(Transaction trans, ByteArrayBuffer writer)
 {
     writer.WriteInt(Size());
     for (int i = 0; i < _ints.Length; i++)
     {
         writer.WriteInt(_ints[i]);
     }
 }
Ejemplo n.º 5
0
		public override void WriteThis(Transaction trans, ByteArrayBuffer writer)
		{
			writer.WriteInt(Size());
			for (int i = 0; i < _ints.Length; i++)
			{
				writer.WriteInt(_ints[i]);
			}
		}
Ejemplo n.º 6
0
 public static void Write(ByteArrayBuffer buffer, Db4objects.Db4o.Internal.TreeInt
                          tree, int size)
 {
     if (tree == null)
     {
         buffer.WriteInt(0);
         return;
     }
     buffer.WriteInt(size);
     tree.Traverse(new _IVisitor4_97(buffer));
 }
Ejemplo n.º 7
0
		public virtual void Write(Transaction trans, ClassMetadata clazz, ByteArrayBuffer
			 writer)
		{
			writer.WriteShortString(trans, clazz.NameToWrite());
			int 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));
		}
 public virtual void WritePointer(int id, Slot slot)
 {
     if (DTrace.enabled)
     {
         DTrace.WritePointer.Log(id);
         DTrace.WritePointer.LogLength(slot);
     }
     _pointerIo.Seek(0);
     _pointerIo.WriteInt(slot.Address());
     _pointerIo.WriteInt(slot.Length());
     WriteBytes(_pointerIo, id, 0);
 }
Ejemplo n.º 9
0
 public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object
                                     obj)
 {
     writer.WriteInt(((CommitTimestampSupport.TimestampEntry)obj).ParentID());
     writer.WriteLong(((CommitTimestampSupport.TimestampEntry)obj).GetCommitTimestamp(
                          ));
 }
		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.º 11
0
		public override void Write(ByteArrayBuffer a_writer)
		{
			a_writer.WriteInt(_key);
			if (_object == null)
			{
				a_writer.WriteInt(0);
			}
			else
			{
				if (_object is TreeInt)
				{
					TreeInt.Write(a_writer, (TreeInt)_object);
				}
				else
				{
					((IReadWriteable)_object).Write(a_writer);
				}
			}
		}
Ejemplo n.º 12
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);
 }
Ejemplo n.º 13
0
 public override void Write(ByteArrayBuffer a_writer)
 {
     a_writer.WriteInt(_key);
     if (_object == null)
     {
         a_writer.WriteInt(0);
     }
     else
     {
         if (_object is TreeInt)
         {
             Write(a_writer, (TreeInt)_object);
         }
         else
         {
             ((IReadWriteable)_object).Write(a_writer);
         }
     }
 }
        public override void WriteThis(Transaction trans, ByteArrayBuffer buffer)
        {
            buffer.WriteInt(_classes.Size());
            IEnumerator i = _classes.GetEnumerator();

            while (i.MoveNext())
            {
                buffer.WriteIDOf(trans, i.Current);
            }
        }
		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);
			}
		}
        private int CopyUnindexedId(bool doRegister)
        {
            int orig = _source.ReadInt();

            // TODO: There is no test case for the zero case
            if (orig == 0)
            {
                _target.WriteInt(0);
                return(0);
            }
            int mapped = -1;

            try
            {
                mapped = _services.StrictMappedID(orig);
            }
            catch (MappingNotFoundException)
            {
                mapped = _services.TargetNewId();
                _services.MapIDs(orig, mapped, false);
                if (doRegister)
                {
                    _services.RegisterUnindexed(orig);
                }
            }
            _target.WriteInt(mapped);
            return(mapped);
        }
        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.º 18
0
		public static void WriteInt(int a_int, ByteArrayBuffer a_bytes)
		{
			a_bytes.WriteInt(a_int);
		}
Ejemplo n.º 19
0
		private void WriteObjectClassID(ByteArrayBuffer reader, int id)
		{
			reader.WriteInt(-id);
		}
Ejemplo n.º 20
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.º 21
0
		public override void Write(ByteArrayBuffer buffer)
		{
			buffer.WriteInt(_key);
			buffer.WriteInt(_slot.Address());
			buffer.WriteInt(_slot.Length());
		}
Ejemplo n.º 22
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.º 23
0
		public virtual void Write(ByteArrayBuffer buffer)
		{
			buffer.WriteInt(_key);
		}
Ejemplo n.º 24
0
 public virtual void Write(ByteArrayBuffer buffer)
 {
     buffer.WriteInt(_key);
 }
Ejemplo n.º 25
0
		public virtual void WriteObjectClassID(ByteArrayBuffer buffer, int id)
		{
			buffer.WriteInt(-id);
		}
Ejemplo n.º 26
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.º 27
0
 public virtual void Write(ByteArrayBuffer buffer)
 {
     buffer.WriteInt(_id);
     buffer.WriteInt(Length());
     buffer.Append(_bytes);
 }
		public override void WriteThis(Transaction trans, ByteArrayBuffer buffer)
		{
			buffer.WriteInt(_classes.Size());
			IEnumerator i = _classes.GetEnumerator();
			while (i.MoveNext())
			{
				buffer.WriteIDOf(trans, i.Current);
			}
		}
Ejemplo n.º 29
0
		public virtual void Write(ByteArrayBuffer buffer)
		{
			buffer.WriteInt(_id);
			buffer.WriteInt(_address);
			buffer.WriteInt(_length);
		}
			public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object
				 obj)
			{
				writer.WriteInt(((CommitTimestampSupport.TimestampEntry)obj).ParentID());
				writer.WriteLong(((CommitTimestampSupport.TimestampEntry)obj).GetCommitTimestamp(
					));
			}
Ejemplo n.º 31
0
 public virtual void WriteOwnID(Transaction trans, ByteArrayBuffer writer)
 {
     Write(trans);
     writer.WriteInt(GetID());
 }
		public virtual void Write(ByteArrayBuffer buffer)
		{
			buffer.WriteInt(PersistentGeneratorValue());
		}
Ejemplo n.º 33
0
 public virtual void WriteInt(int i)
 {
     PrepareWrite();
     _delegate.WriteInt(i);
 }
		public override void ApplySlotChanges(IVisitable slotChangeTree, int slotChangeCount
			, Slot reservedSlot)
		{
			if (slotChangeCount < 1)
			{
				return;
			}
			IRunnable commitHook = _container.CommitHook();
			FlushDatabaseFile();
			EnsureLogAndLock();
			int length = TransactionLogSlotLength(slotChangeCount);
			ByteArrayBuffer 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.º 35
0
		public override void Write(ByteArrayBuffer writer)
		{
			if (SlotModified())
			{
				writer.WriteInt(_key);
				writer.WriteInt(_newSlot.Address());
				writer.WriteInt(_newSlot.Length());
			}
		}
Ejemplo n.º 36
0
		public virtual void WriteOwnID(Transaction trans, ByteArrayBuffer writer)
		{
			Write(trans);
			writer.WriteInt(GetID());
		}
Ejemplo n.º 37
0
		public virtual void Write(ByteArrayBuffer buffer)
		{
			buffer.WriteInt(_id);
			buffer.WriteInt(Length());
			buffer.Append(_bytes);
		}
Ejemplo n.º 38
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.º 39
0
		protected virtual void WriteIndex(Transaction trans, ClassMetadata clazz, ByteArrayBuffer
			 writer)
		{
			int indexID = clazz.Index().Write(trans);
			writer.WriteInt(IndexIDForWriting(indexID));
		}
Ejemplo n.º 40
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.º 41
0
		public static void Write(ByteArrayBuffer buffer, Db4objects.Db4o.Internal.TreeInt
			 tree, int size)
		{
			if (tree == null)
			{
				buffer.WriteInt(0);
				return;
			}
			buffer.WriteInt(size);
			tree.Traverse(new _IVisitor4_97(buffer));
		}
Ejemplo n.º 42
0
 public void WriteInt(int value)
 {
     _source.IncrementOffset(Const4.IntLength);
     _target.WriteInt(value);
 }