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(); }
protected override void WriteBuffer(ByteArrayBuffer buffer, bool shuttingDown) { base.WriteBuffer(buffer, shuttingDown); var systemData = SystemData(); buffer.WriteInt(systemData.IdToTimestampIndexId()); buffer.WriteInt(systemData.TimestampToIdIndexId()); }
public static SerializedGraph Read(ByteArrayBuffer buffer ) { var id = buffer.ReadInt(); var length = buffer.ReadInt(); return new SerializedGraph(id, buffer.ReadBytes(length)); }
public UnmarshallingContext(Transaction transaction, ByteArrayBuffer buffer, ObjectReference @ref, int addToIDTree, bool checkIDTree) : base(transaction, buffer, null, @ref ) { _addToIDTree = addToIDTree; _checkIDTree = checkIDTree; }
// _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); }
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; }
public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer writer, object obj) { var slot = (Slot) obj; writer.WriteInt(slot.Address()); writer.WriteInt(slot.Length()); }
private byte[] ReadName(LatinStringIO sio, ByteArrayBuffer reader) { var nameBytes = sio.Bytes(reader); reader.IncrementOffset(nameBytes.Length); nameBytes = Platform4.UpdateClassName(nameBytes); return nameBytes; }
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()); }
public MultipartReader(string contentType, MultipartReaderDelegate delegate_) { this.contentType = contentType; this.delegate_ = delegate_; this.buffer = new ByteArrayBuffer(1024); this.state = MultipartReader.MultipartReaderState.kAtStart; ParseContentType(); }
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; }
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; }
protected override void ReadBuffer(ByteArrayBuffer buffer, bool versionsAreConsistent ) { base.ReadBuffer(buffer, versionsAreConsistent); var systemData = SystemData(); systemData.IdToTimestampIndexId(buffer.ReadInt()); systemData.TimestampToIdIndexId(buffer.ReadInt()); }
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)); } }
public override object ReadDouble(ByteArrayBuffer buffer) { var value = UnmarshalDouble(buffer); if (double.IsNaN(value)) { return null; } return value; }
public override object ReadLong(ByteArrayBuffer buffer) { var value = buffer.ReadLong(); if (value == long.MaxValue) { return null; } return value; }
public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer a_writer, object a_object) { if (a_object == null) { a_object = PrimitiveNull(); } Write(a_object, a_writer); }
public override object ReadFloat(ByteArrayBuffer bytes) { var value = UnmarshallFloat(bytes); if (float.IsNaN(value)) { return null; } return value; }
public override object ReadShort(ByteArrayBuffer buffer) { var value = UnmarshallShort(buffer); if (value == short.MaxValue) { return null; } return value; }
public override object ReadInteger(ByteArrayBuffer bytes) { var value = bytes.ReadInt(); if (value == int.MaxValue) { return null; } return value; }
protected virtual void ReadWriteSlotChanges(ByteArrayBuffer buffer) { var slotChanges = new LockedTree(); slotChanges.Read(buffer, new SlotChange(0)); if (WriteSlots(new _IVisitable_65(slotChanges))) { FlushDatabaseFile(); } }
public override DateTime ReadDate(ByteArrayBuffer bytes) { var value = bytes.ReadLong(); if (value == long.MaxValue) { return MarshallingConstants0.NullDate; } return new DateTime(value); }
protected override void ReadIndex(ObjectContainerBase stream, ClassMetadata clazz , ByteArrayBuffer reader) { var indexID = reader.ReadInt(); if (indexID == 0) { return; } clazz.Index().Read(stream, indexID); }
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); }
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()); }
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)); }
public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer buffer) { try { return Read1(buffer); } catch (CorruptionException) { } return null; }
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); }
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; }
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); }
public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer buffer, object mapping) { ((IdSlotMapping)mapping).Write(buffer); }
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(); }
public virtual void DebugPrependNextWrite(ByteArrayBuffer prepend) { }
public override void Write(object a_object, ByteArrayBuffer a_bytes) { WriteInt(Sharpen.Runtime.FloatToIntBits(((float)a_object)), a_bytes); }
public override void SkipMarshallerInfo(ByteArrayBuffer reader) { }
public DelegateReleaseBuffer(ByteArrayBuffer buffer, int offset, int capacity) : base(buffer._byteArray, offset, capacity) { _parentBuffer = buffer; }
public override void Write(object a_object, ByteArrayBuffer a_bytes) { a_bytes.WriteByte(((byte)a_object)); }
public virtual ObjectHeader SourceObjectHeader(ByteArrayBuffer buffer) { return(new ObjectHeader(_sourceDb, buffer)); }
/// <exception cref="System.IO.IOException"></exception> private static void WriteBytes(ByteArrayBuffer b, OutputStream @out) { @out.Write(b.Buffer(), 0, b.Length()); }
public static Db4objects.Db4o.Internal.Marshall.ObjectHeader ScrollBufferToContent (LocalObjectContainer container, ByteArrayBuffer buffer) { return(new Db4objects.Db4o.Internal.Marshall.ObjectHeader(container, buffer)); }
public virtual void TargetWriteBytes(ByteArrayBuffer reader, int address) { _targetDb.WriteBytes(reader, address, 0); }
public override void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect , ByteArrayBuffer writer) { writer.WriteByte(aspect.AspectType()._id); base.Write(trans, clazz, aspect, writer); }
protected override RawFieldSpec ReadSpec(AspectType aspectType, ObjectContainerBase stream, ByteArrayBuffer reader) { return(base.ReadSpec(AspectType.ForByte(reader.ReadByte()), stream, reader)); }
public static double UnmarshalDouble(ByteArrayBuffer buffer) { return(Platform4.LongToDouble(buffer.ReadLong())); }
object IIndexable4.ReadIndexEntry(IContext context, ByteArrayBuffer reader) { return(ReadFrom(reader)); }
/// <exception cref="System.IO.IOException"></exception> private static void WriteBytes(string s, Encoding charset, OutputStream @out) { ByteArrayBuffer b = Encode(charset, s); WriteBytes(b, @out); }
void IIndexable4.WriteIndexEntry(IContext context, ByteArrayBuffer writer, object obj) { Write(writer, (DateTimeOffset)obj); }
/// <exception cref="System.IO.IOException"></exception> private static void WriteBytes(string s, OutputStream @out) { ByteArrayBuffer b = Encode(MIME.DefaultCharset, s); WriteBytes(b, @out); }
internal override object Read1(ByteArrayBuffer a_bytes) { var ret = a_bytes.ReadByte(); return(ret); }
protected void AppendSlotChanges(ByteArrayBuffer writer, IVisitable slotChangeVisitable ) { slotChangeVisitable.Accept(new _IVisitor4_30(writer)); }
internal override object Read1(ByteArrayBuffer a_bytes) { return(PrimitiveMarshaller().ReadFloat(a_bytes)); }
public _IVisitor4_30(ByteArrayBuffer writer) { this.writer = writer; }
public override void WriteObjectClassID(ByteArrayBuffer buffer, int id) { buffer.WriteInt(id); }
public void WriteShort(Transaction trans, string str, ByteArrayBuffer buffer) { StringIo(trans.Container()).WriteLengthAndString(buffer, str); }
public override ObjectHeaderAttributes ReadHeaderAttributes(ByteArrayBuffer reader ) { return(null); }
public _IPreparedComparison_229(StringHandler _enclosing, IContext context, ByteArrayBuffer sourceBuffer) { this._enclosing = _enclosing; this.context = context; this.sourceBuffer = sourceBuffer; }
private int ReadParentID(IContext context, ByteArrayBuffer a_reader) { return((int)_parentIdHandler.ReadIndexEntry(context, a_reader)); }
public int CompareTo(object target) { ByteArrayBuffer targetBuffer = this._enclosing.Val(target, context); return(this._enclosing.Compare(sourceBuffer, targetBuffer)); }
public virtual object ReadIndexEntry(IContext context, ByteArrayBuffer buffer) { return(IdSlotMapping.Read(buffer)); }
public static float UnmarshallFloat(ByteArrayBuffer buffer) { return(Sharpen.Runtime.IntBitsToFloat(buffer.ReadInt())); }