コード例 #1
0
 public override void CompleteInterruptedTransaction(int transactionId1, int transactionId2
     )
 {
     if (!File.Exists(LockFileName(_fileName)))
     {
         return;
     }
     if (!LockFileSignalsInterruptedTransaction())
     {
         return;
     }
     var buffer = new ByteArrayBuffer(Const4.IntLength);
     OpenLogFile();
     Read(_logFile, buffer);
     var length = buffer.ReadInt();
     if (length > 0)
     {
         buffer = new ByteArrayBuffer(length);
         Read(_logFile, buffer);
         buffer.IncrementOffset(Const4.IntLength);
         ReadWriteSlotChanges(buffer);
     }
     DeleteLockFile();
     CloseLogFile();
     DeleteLogFile();
 }
コード例 #2
0
 protected override void WriteBuffer(ByteArrayBuffer buffer, bool shuttingDown)
 {
     base.WriteBuffer(buffer, shuttingDown);
     var systemData = SystemData();
     buffer.WriteInt(systemData.IdToTimestampIndexId());
     buffer.WriteInt(systemData.TimestampToIdIndexId());
 }
コード例 #3
0
ファイル: SerializedGraph.cs プロジェクト: masroore/db4o
 public static SerializedGraph Read(ByteArrayBuffer buffer
     )
 {
     var id = buffer.ReadInt();
     var length = buffer.ReadInt();
     return new SerializedGraph(id, buffer.ReadBytes(length));
 }
コード例 #4
0
ファイル: UnmarshallingContext.cs プロジェクト: masroore/db4o
 public UnmarshallingContext(Transaction transaction, ByteArrayBuffer buffer, ObjectReference
     @ref, int addToIDTree, bool checkIDTree) : base(transaction, buffer, null, @ref
         )
 {
     _addToIDTree = addToIDTree;
     _checkIDTree = checkIDTree;
 }
コード例 #5
0
ファイル: IdSlotTree.cs プロジェクト: masroore/db4o
 // _key, _slot._address, _slot._length 
 public override object Read(ByteArrayBuffer buffer)
 {
     var id = buffer.ReadInt();
     var slot = new Slot
         (buffer.ReadInt(), buffer.ReadInt());
     return new IdSlotTree(id, slot);
 }
コード例 #6
0
 private static ByteArrayBuffer Encode(Encoding charset, string @string)
 {
     ByteBuffer encoded = charset.Encode(CharBuffer.Wrap(@string));
     ByteArrayBuffer bab = new ByteArrayBuffer(encoded.Remaining());
     bab.Append(((byte[])encoded.Array()), encoded.Position(), encoded.Remaining());
     return bab;
 }
コード例 #7
0
ファイル: SlotHandler.cs プロジェクト: masroore/db4o
 public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object
     obj)
 {
     var slot = (Slot) obj;
     writer.WriteInt(slot.Address());
     writer.WriteInt(slot.Length());
 }
コード例 #8
0
ファイル: ClassMarshaller.cs プロジェクト: masroore/db4o
 private byte[] ReadName(LatinStringIO sio, ByteArrayBuffer reader)
 {
     var nameBytes = sio.Bytes(reader);
     reader.IncrementOffset(nameBytes.Length);
     nameBytes = Platform4.UpdateClassName(nameBytes);
     return nameBytes;
 }
コード例 #9
0
ファイル: MappedIDPairHandler.cs プロジェクト: masroore/db4o
 public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer reader, object
     obj)
 {
     var mappedIDs = (MappedIDPair) obj;
     _origHandler.WriteIndexEntry(context, reader, mappedIDs.Orig());
     _mappedHandler.WriteIndexEntry(context, reader, mappedIDs.Mapped());
 }
コード例 #10
0
		public MultipartReader(string contentType, MultipartReaderDelegate delegate_)
		{
			this.contentType = contentType;
			this.delegate_ = delegate_;
			this.buffer = new ByteArrayBuffer(1024);
			this.state = MultipartReader.MultipartReaderState.kAtStart;
			ParseContentType();
		}
コード例 #11
0
ファイル: CharHandler.cs プロジェクト: masroore/db4o
 internal override object Read1(ByteArrayBuffer a_bytes)
 {
     var b1 = a_bytes.ReadByte();
     var b2 = a_bytes.ReadByte();
     var ret = (char) ((b1 & unchecked(0xff)) | ((b2 & unchecked(0xff))
                                                 << 8));
     return ret;
 }
コード例 #12
0
ファイル: LatinStringIO.cs プロジェクト: masroore/db4o
 public virtual byte[] Bytes(ByteArrayBuffer buffer)
 {
     var len = buffer.ReadInt();
     len = BytesPerChar()*len;
     var res = new byte[len];
     Array.Copy(buffer._buffer, buffer._offset, res, 0, len);
     return res;
 }
コード例 #13
0
 protected override void ReadBuffer(ByteArrayBuffer buffer, bool versionsAreConsistent
     )
 {
     base.ReadBuffer(buffer, versionsAreConsistent);
     var systemData = SystemData();
     systemData.IdToTimestampIndexId(buffer.ReadInt());
     systemData.TimestampToIdIndexId(buffer.ReadInt());
 }
コード例 #14
0
ファイル: ShortHandler.cs プロジェクト: masroore/db4o
 internal static void WriteShort(int a_short, ByteArrayBuffer a_bytes)
 {
     for (var i = 0; i < Const4.ShortBytes; i++)
     {
         a_bytes._buffer[a_bytes._offset++] = (byte) (a_short >> ((Const4.ShortBytes - 1 -
                                                                   i)*8));
     }
 }
コード例 #15
0
ファイル: PrimitiveMarshaller0.cs プロジェクト: masroore/db4o
 public override object ReadDouble(ByteArrayBuffer buffer)
 {
     var value = UnmarshalDouble(buffer);
     if (double.IsNaN(value))
     {
         return null;
     }
     return value;
 }
コード例 #16
0
ファイル: PrimitiveMarshaller0.cs プロジェクト: masroore/db4o
 public override object ReadLong(ByteArrayBuffer buffer)
 {
     var value = buffer.ReadLong();
     if (value == long.MaxValue)
     {
         return null;
     }
     return value;
 }
コード例 #17
0
ファイル: PrimitiveHandler.cs プロジェクト: masroore/db4o
 public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer a_writer, object
     a_object)
 {
     if (a_object == null)
     {
         a_object = PrimitiveNull();
     }
     Write(a_object, a_writer);
 }
コード例 #18
0
ファイル: PrimitiveMarshaller0.cs プロジェクト: masroore/db4o
 public override object ReadFloat(ByteArrayBuffer bytes)
 {
     var value = UnmarshallFloat(bytes);
     if (float.IsNaN(value))
     {
         return null;
     }
     return value;
 }
コード例 #19
0
ファイル: PrimitiveMarshaller0.cs プロジェクト: masroore/db4o
 public override object ReadShort(ByteArrayBuffer buffer)
 {
     var value = UnmarshallShort(buffer);
     if (value == short.MaxValue)
     {
         return null;
     }
     return value;
 }
コード例 #20
0
ファイル: PrimitiveMarshaller0.cs プロジェクト: masroore/db4o
 public override object ReadInteger(ByteArrayBuffer bytes)
 {
     var value = bytes.ReadInt();
     if (value == int.MaxValue)
     {
         return null;
     }
     return value;
 }
コード例 #21
0
 protected virtual void ReadWriteSlotChanges(ByteArrayBuffer buffer)
 {
     var slotChanges = new LockedTree();
     slotChanges.Read(buffer, new SlotChange(0));
     if (WriteSlots(new _IVisitable_65(slotChanges)))
     {
         FlushDatabaseFile();
     }
 }
コード例 #22
0
ファイル: PrimitiveMarshaller0.cs プロジェクト: masroore/db4o
 public override DateTime ReadDate(ByteArrayBuffer bytes)
 {
     var value = bytes.ReadLong();
     if (value == long.MaxValue)
     {
         return MarshallingConstants0.NullDate;
     }
     return new DateTime(value);
 }
コード例 #23
0
ファイル: ClassMarshaller2.cs プロジェクト: masroore/db4o
 protected override void ReadIndex(ObjectContainerBase stream, ClassMetadata clazz
     , ByteArrayBuffer reader)
 {
     var indexID = reader.ReadInt();
     if (indexID == 0)
     {
         return;
     }
     clazz.Index().Read(stream, indexID);
 }
コード例 #24
0
ファイル: DateHandlerBase.cs プロジェクト: masroore/db4o
 public override void Write(object a_object, ByteArrayBuffer a_bytes)
 {
     // TODO: This is a temporary fix to prevent exceptions with
     // Marshaller.LEGACY.  
     if (a_object == null)
     {
         a_object = new DateTime(0);
     }
     a_bytes.WriteLong(((DateTime) a_object).Ticks);
 }
コード例 #25
0
 public virtual void ReadThis(ByteArrayBuffer buffer)
 {
     SystemData().ConverterVersion(buffer.ReadInt());
     SystemData().FreespaceSystem(buffer.ReadByte());
     buffer.ReadInt();
     // was BTreeFreespaceId, converted to slot, can no longer be used
     SystemData().IdentityId(buffer.ReadInt());
     SystemData().LastTimeStampID(buffer.ReadLong());
     SystemData().UuidIndexId(buffer.ReadInt());
 }
コード例 #26
0
ファイル: ClassMarshaller.cs プロジェクト: masroore/db4o
 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));
 }
コード例 #27
0
ファイル: PrimitiveHandler.cs プロジェクト: masroore/db4o
 public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer buffer)
 {
     try
     {
         return Read1(buffer);
     }
     catch (CorruptionException)
     {
     }
     return null;
 }
コード例 #28
0
ファイル: FieldIndexKeyHandler.cs プロジェクト: masroore/db4o
 public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer a_reader)
 {
     // TODO: could read int directly here with a_reader.readInt()
     var parentID = ReadParentID(context, a_reader);
     var objPart = _valueHandler.ReadIndexEntry(context, a_reader);
     if (parentID < 0)
     {
         objPart = null;
         parentID = -parentID;
     }
     return new FieldIndexKeyImpl(parentID, objPart);
 }
コード例 #29
0
ファイル: BTreePointer.cs プロジェクト: masroore/db4o
 public BTreePointer(Transaction transaction, ByteArrayBuffer nodeReader, BTreeNode
     node, int index)
 {
     if (transaction == null || node == null)
     {
         throw new ArgumentNullException();
     }
     _transaction = transaction;
     _nodeReader = nodeReader;
     _node = node;
     _index = index;
 }
コード例 #30
0
ファイル: ClassMarshaller.cs プロジェクト: masroore/db4o
 public virtual RawClassSpec ReadSpec(Transaction trans, ByteArrayBuffer reader)
 {
     var nameBytes = ReadName(trans, reader);
     var className = trans.Container().StringIO().Read(nameBytes);
     ReadMetaClassID(reader);
     // skip
     var ancestorID = reader.ReadInt();
     reader.IncrementOffset(Const4.IntLength);
     // index ID
     var numFields = reader.ReadInt();
     return new RawClassSpec(className, ancestorID, numFields);
 }
コード例 #31
0
 public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer buffer, object
                                     mapping)
 {
     ((IdSlotMapping)mapping).Write(buffer);
 }
コード例 #32
0
        public void GetMore_should_use_same_session(
            [Values(false, true)] bool async)
        {
            var mockChannelSource     = new Mock <IChannelSource>();
            var channelSource         = mockChannelSource.Object;
            var mockChannel           = new Mock <IChannelHandle>();
            var channel               = mockChannel.Object;
            var mockSession           = new Mock <ICoreSessionHandle>();
            var session               = mockSession.Object;
            var databaseNamespace     = new DatabaseNamespace("database");
            var collectionNamespace   = new CollectionNamespace(databaseNamespace, "collection");
            var cursorId              = 1;
            var subject               = CreateSubject(collectionNamespace: collectionNamespace, cursorId: cursorId, channelSource: Optional.Create(channelSource));
            var cancellationToken     = new CancellationTokenSource().Token;
            var connectionDescription = CreateConnectionDescriptionSupportingSession();

            mockChannelSource.SetupGet(m => m.Session).Returns(session);
            mockChannel.SetupGet(m => m.ConnectionDescription).Returns(connectionDescription);
            var nextBatchBytes = new byte[] { 5, 0, 0, 0, 0 };
            var nextBatchSlice = new ByteArrayBuffer(nextBatchBytes, isReadOnly: true);
            var secondBatch    = new BsonDocument
            {
                { "cursor", new BsonDocument
                  {
                      { "id", 0 },
                      { "nextBatch", new RawBsonArray(nextBatchSlice) }
                  } }
            };

            subject.MoveNext(cancellationToken); // skip empty first batch
            var sameSessionWasUsed = false;

            if (async)
            {
                mockChannelSource.Setup(m => m.GetChannelAsync(cancellationToken)).Returns(Task.FromResult(channel));
                mockChannel
                .Setup(m => m.CommandAsync(
                           session,
                           null,
                           databaseNamespace,
                           It.IsAny <BsonDocument>(),
                           null,
                           NoOpElementNameValidator.Instance,
                           null,
                           null,
                           CommandResponseHandling.Return,
                           It.IsAny <IBsonSerializer <BsonDocument> >(),
                           It.IsAny <MessageEncoderSettings>(),
                           cancellationToken))
                .Callback(() => sameSessionWasUsed = true)
                .Returns(Task.FromResult(secondBatch));

                subject.MoveNextAsync(cancellationToken).GetAwaiter().GetResult();
            }
            else
            {
                mockChannelSource.Setup(m => m.GetChannel(cancellationToken)).Returns(channel);
                mockChannel
                .Setup(m => m.Command(
                           session,
                           null,
                           databaseNamespace,
                           It.IsAny <BsonDocument>(),
                           null,
                           NoOpElementNameValidator.Instance,
                           null,
                           null,
                           CommandResponseHandling.Return,
                           It.IsAny <IBsonSerializer <BsonDocument> >(),
                           It.IsAny <MessageEncoderSettings>(),
                           cancellationToken))
                .Callback(() => sameSessionWasUsed = true)
                .Returns(secondBatch);

                subject.MoveNext(cancellationToken);
            }

            sameSessionWasUsed.Should().BeTrue();
        }
コード例 #33
0
ファイル: MarshallingContext.cs プロジェクト: danfma/db4o-net
 public virtual void DebugPrependNextWrite(ByteArrayBuffer prepend)
 {
 }
コード例 #34
0
 public override void Write(object a_object, ByteArrayBuffer a_bytes)
 {
     WriteInt(Sharpen.Runtime.FloatToIntBits(((float)a_object)), a_bytes);
 }
コード例 #35
0
 public override void SkipMarshallerInfo(ByteArrayBuffer reader)
 {
 }
コード例 #36
0
 public DelegateReleaseBuffer(ByteArrayBuffer buffer, int offset, int capacity)
     : base(buffer._byteArray, offset, capacity)
 {
     _parentBuffer = buffer;
 }
コード例 #37
0
ファイル: ByteHandler.cs プロジェクト: pondyond/db4o
 public override void Write(object a_object, ByteArrayBuffer a_bytes)
 {
     a_bytes.WriteByte(((byte)a_object));
 }
コード例 #38
0
 public virtual ObjectHeader SourceObjectHeader(ByteArrayBuffer buffer)
 {
     return(new ObjectHeader(_sourceDb, buffer));
 }
コード例 #39
0
 /// <exception cref="System.IO.IOException"></exception>
 private static void WriteBytes(ByteArrayBuffer b, OutputStream @out)
 {
     @out.Write(b.Buffer(), 0, b.Length());
 }
コード例 #40
0
 public static Db4objects.Db4o.Internal.Marshall.ObjectHeader ScrollBufferToContent
     (LocalObjectContainer container, ByteArrayBuffer buffer)
 {
     return(new Db4objects.Db4o.Internal.Marshall.ObjectHeader(container, buffer));
 }
コード例 #41
0
 public virtual void TargetWriteBytes(ByteArrayBuffer reader, int address)
 {
     _targetDb.WriteBytes(reader, address, 0);
 }
コード例 #42
0
 public override void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect
                            , ByteArrayBuffer writer)
 {
     writer.WriteByte(aspect.AspectType()._id);
     base.Write(trans, clazz, aspect, writer);
 }
コード例 #43
0
 protected override RawFieldSpec ReadSpec(AspectType aspectType, ObjectContainerBase
                                          stream, ByteArrayBuffer reader)
 {
     return(base.ReadSpec(AspectType.ForByte(reader.ReadByte()), stream, reader));
 }
コード例 #44
0
 public static double UnmarshalDouble(ByteArrayBuffer buffer)
 {
     return(Platform4.LongToDouble(buffer.ReadLong()));
 }
コード例 #45
0
 object IIndexable4.ReadIndexEntry(IContext context, ByteArrayBuffer reader)
 {
     return(ReadFrom(reader));
 }
コード例 #46
0
        /// <exception cref="System.IO.IOException"></exception>
        private static void WriteBytes(string s, Encoding charset, OutputStream @out)
        {
            ByteArrayBuffer b = Encode(charset, s);

            WriteBytes(b, @out);
        }
コード例 #47
0
 void IIndexable4.WriteIndexEntry(IContext context, ByteArrayBuffer writer, object obj)
 {
     Write(writer, (DateTimeOffset)obj);
 }
コード例 #48
0
        /// <exception cref="System.IO.IOException"></exception>
        private static void WriteBytes(string s, OutputStream @out)
        {
            ByteArrayBuffer b = Encode(MIME.DefaultCharset, s);

            WriteBytes(b, @out);
        }
コード例 #49
0
ファイル: ByteHandler.cs プロジェクト: pondyond/db4o
        internal override object Read1(ByteArrayBuffer a_bytes)
        {
            var ret = a_bytes.ReadByte();

            return(ret);
        }
コード例 #50
0
 protected void AppendSlotChanges(ByteArrayBuffer writer, IVisitable slotChangeVisitable
                                  )
 {
     slotChangeVisitable.Accept(new _IVisitor4_30(writer));
 }
コード例 #51
0
 internal override object Read1(ByteArrayBuffer a_bytes)
 {
     return(PrimitiveMarshaller().ReadFloat(a_bytes));
 }
コード例 #52
0
 public _IVisitor4_30(ByteArrayBuffer writer)
 {
     this.writer = writer;
 }
コード例 #53
0
 public override void WriteObjectClassID(ByteArrayBuffer buffer, int id)
 {
     buffer.WriteInt(id);
 }
コード例 #54
0
 public void WriteShort(Transaction trans, string str, ByteArrayBuffer buffer)
 {
     StringIo(trans.Container()).WriteLengthAndString(buffer, str);
 }
コード例 #55
0
 public override ObjectHeaderAttributes ReadHeaderAttributes(ByteArrayBuffer reader
                                                             )
 {
     return(null);
 }
コード例 #56
0
 public _IPreparedComparison_229(StringHandler _enclosing, IContext context, ByteArrayBuffer
                                 sourceBuffer)
 {
     this._enclosing   = _enclosing;
     this.context      = context;
     this.sourceBuffer = sourceBuffer;
 }
コード例 #57
0
 private int ReadParentID(IContext context, ByteArrayBuffer a_reader)
 {
     return((int)_parentIdHandler.ReadIndexEntry(context, a_reader));
 }
コード例 #58
0
            public int CompareTo(object target)
            {
                ByteArrayBuffer targetBuffer = this._enclosing.Val(target, context);

                return(this._enclosing.Compare(sourceBuffer, targetBuffer));
            }
コード例 #59
0
 public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer buffer)
 {
     return(IdSlotMapping.Read(buffer));
 }
コード例 #60
0
 public static float UnmarshallFloat(ByteArrayBuffer buffer)
 {
     return(Sharpen.Runtime.IntBitsToFloat(buffer.ReadInt()));
 }