public virtual IReadBuffer Buffer(IReadBuffer buffer)
        {
            IReadBuffer temp = _buffer;

            _buffer = buffer;
            return(temp);
        }
Exemple #2
0
        private static DateTimeOffset ReadFrom(IReadBuffer buffer)
        {
            long ticks         = buffer.ReadLong();
            long timeSpanTicks = buffer.ReadLong();

            return(new DateTimeOffset(ticks, new TimeSpan(timeSpanTicks)));
        }
Exemple #3
0
        private static Guid ReadFrom(IReadBuffer buffer)
        {
            var guidBytes = new byte[GuidSize];

            buffer.ReadBytes(guidBytes);
            return(new Guid(guidBytes));
        }
Exemple #4
0
        protected static ValueTask <T> ReadPending <T>(IReadBuffer <T> buffer, CancellationToken token = default)
        {
            ValueTask <T> result = buffer.ReadAsync(token);

            result.IsCompleted.Should().BeFalse();
            return(result);
        }
Exemple #5
0
        protected static void Read <T>(IReadBuffer <T> buffer, T expected)
        {
            ValueTask <T> result = buffer.ReadAsync(CancellationToken.None);

            result.IsCompletedSuccessfully.Should().BeTrue();
            result.Result.Should().Be(expected);
        }
Exemple #6
0
        public void Resize(IReadBuffer buffer, int newElements, int newByteStride = -1, IntPtr?newData = null)
        {
            MyRenderProxy.Assert(newElements > 0);
            MyRenderProxy.Assert(newByteStride > 0 || newByteStride == -1);

            ResizeInternal(buffer as MyReadBuffer, newElements, newByteStride, newData);
        }
Exemple #7
0
 public Worker(IReadBuffer readBuffer, IBlockDictionary writeBuffer, IStatistics stats, ISettings settings)
 {
     this.writeDictionary = writeBuffer;
     this.stats           = stats;
     this.settings        = settings;
     this.readBuffer      = readBuffer;
 }
		public virtual void ReadTypeInfo(Transaction trans, IReadBuffer buffer, ArrayInfo
			 info, int classID)
		{
			BitMap4 typeInfoBitmap = new BitMap4(buffer.ReadByte());
			info.Primitive(typeInfoBitmap.IsTrue(0));
			info.Nullable(typeInfoBitmap.IsTrue(1));
		}
Exemple #9
0
        public override string Read(IReadBuffer buffer, int length)
        {
            var bytes = new byte[length];

            buffer.ReadBytes(bytes);
            return(Decode(bytes, 0, bytes.Length));
        }
Exemple #10
0
 public IReadBuffer <byte> GetBinaryReadBuffer(int size)
 {
     if (m_binaryReadBuffer == null)
     {
         m_binaryReadBuffer = this.CreateBinaryReadBuffer(size);
     }
     return(m_binaryReadBuffer);
 }
Exemple #11
0
 public IReadBuffer <char> GetTextualReadBuffer(int size)
 {
     if (m_textualReadBuffer == null)
     {
         m_textualReadBuffer = this.CreateTextualReadBuffer(size);
     }
     return(m_textualReadBuffer);
 }
Exemple #12
0
 public _IClosure4_318(QCandidate _enclosing, ITypeHandler4 arrayElementHandler, IReadBuffer
                       buffer, QCandidates candidates)
 {
     this._enclosing          = _enclosing;
     this.arrayElementHandler = arrayElementHandler;
     this.buffer     = buffer;
     this.candidates = candidates;
 }
Exemple #13
0
        private void PrepareReader(out IReadBuffer readBuffer, out IReader sut)
        {
            var settings = kernel.Get <ISettings>();

            settings.Mode = System.IO.Compression.CompressionMode.Compress;
            readBuffer    = new ReadBuffer(settings, kernel.Get <IBlockQueue>(), kernel.Get <IBlockQueue>(), 0);
            sut           = new Reader(kernel.Get <IStatistics>(), settings, readBuffer);
        }
		protected override void SeekSecondaryOffset(IReadBuffer buffer, ITypeHandler4 typeHandler
			)
		{
			if (Handlers4.HandlesPrimitiveArray(typeHandler))
			{
				buffer.Seek(buffer.ReadInt());
			}
		}
Exemple #15
0
        public virtual void ReadTypeInfo(Transaction trans, IReadBuffer buffer, ArrayInfo
                                         info, int classID)
        {
            BitMap4 typeInfoBitmap = new BitMap4(buffer.ReadByte());

            info.Primitive(typeInfoBitmap.IsTrue(0));
            info.Nullable(typeInfoBitmap.IsTrue(1));
        }
Exemple #16
0
 protected override void SeekSecondaryOffset(IReadBuffer buffer, ITypeHandler4 typeHandler
                                             )
 {
     if (Handlers4.HandlesPrimitiveArray(typeHandler))
     {
         buffer.Seek(buffer.ReadInt());
     }
 }
Exemple #17
0
 public virtual string Read(IReadBuffer buffer, int length)
 {
     char[] chars = new char[length];
     for (int ii = 0; ii < length; ii++)
     {
         chars[ii] = (char)(buffer.ReadByte() & unchecked ((int)(0xff)));
     }
     return(new string(chars, 0, length));
 }
Exemple #18
0
 public virtual object DoWithSlotIndirection(IReadBuffer buffer, ITypeHandler4 typeHandler
     , IClosure4 closure)
 {
     if (!IsIndirectedWithinSlot(typeHandler))
     {
         return closure.Run();
     }
     return DoWithSlotIndirection(buffer, closure);
 }
Exemple #19
0
 public virtual object DoWithSlotIndirection(IReadBuffer buffer, ITypeHandler4 typeHandler
                                             , IClosure4 closure)
 {
     if (!IsIndirectedWithinSlot(typeHandler))
     {
         return(closure.Run());
     }
     return(DoWithSlotIndirection(buffer, closure));
 }
		public virtual string Read(IReadBuffer buffer, int length)
		{
			char[] chars = new char[length];
			for (int ii = 0; ii < length; ii++)
			{
				chars[ii] = (char)(buffer.ReadByte() & unchecked((int)(0xff)));
			}
			return new string(chars, 0, length);
		}
 private int ReducedCountForNullBitMap(ArrayInfo info, IReadBuffer context)
 {
     if (!HasNullBitmap(info))
     {
         return(0);
     }
     return(ReducedCountForNullBitMap(info.ElementCount(), ReadNullBitmap(context, info
                                                                          .ElementCount())));
 }
		public virtual string ReadLengthAndString(IReadBuffer buffer)
		{
			int length = buffer.ReadInt();
			if (length == 0)
			{
				return string.Empty;
			}
			return Read(buffer, length);
		}
Exemple #23
0
 public override string Read(IReadBuffer buffer, int length)
 {
     var chars = new char[length];
     for (var ii = 0; ii < length; ii++)
     {
         chars[ii] = (char) ((buffer.ReadByte() & unchecked(0xff)) | ((buffer.ReadByte
             () & unchecked(0xff)) << 8));
     }
     return new string(chars, 0, length);
 }
Exemple #24
0
        private KeyValueHandlerPair ReadKeyValueTypeHandlers(IReadBuffer buffer, IContext
                                                             context)
        {
            buffer.ReadInt();
            buffer.ReadInt();
            ITypeHandler4 untypedHandler = (ITypeHandler4)Container(context).Handlers.OpenTypeHandler
                                               ();

            return(new KeyValueHandlerPair(untypedHandler, untypedHandler));
        }
 private QueryingReadContext(Transaction transaction, QCandidates candidates, int
                             handlerVersion, IReadBuffer buffer, int collectionID, IdObjectCollector collector
                             ) : base(transaction, buffer)
 {
     _candidates      = candidates;
     _activationDepth = new LegacyActivationDepth(0);
     _collectionID    = collectionID;
     _handlerVersion  = handlerVersion;
     _collector       = collector;
 }
Exemple #26
0
        public virtual string ReadLengthAndString(IReadBuffer buffer)
        {
            var length = buffer.ReadInt();

            if (length == 0)
            {
                return(string.Empty);
            }
            return(Read(buffer, length));
        }
		private QueryingReadContext(Transaction transaction, QCandidates candidates, int 
			handlerVersion, IReadBuffer buffer, int collectionID, IdObjectCollector collector
			) : base(transaction, buffer)
		{
			_candidates = candidates;
			_activationDepth = new LegacyActivationDepth(0);
			_collectionID = collectionID;
			_handlerVersion = handlerVersion;
			_collector = collector;
		}
Exemple #28
0
 public static void ReadEnd(IReadBuffer buffer)
 {
     if (Deploy.debug && Deploy.brackets)
     {
         if (buffer.ReadByte() != Const4.Yapend)
         {
             throw new Exception("Debug.readEnd() YAPEND expected");
         }
     }
 }
 private void ReadDimensions(ArrayInfo info, IReadBuffer buffer, int dimensionCount
     )
 {
     var dim = new int[dimensionCount];
     for (var i = 0; i < dim.Length; i++)
     {
         dim[i] = buffer.ReadInt();
     }
     ((MultidimensionalArrayInfo) info).Dimensions(dim);
     info.ElementCount(ElementCount(dim));
 }
Exemple #30
0
        protected static void ReadFailed <T, TException>(IReadBuffer <T> buffer, CancellationToken token = default)
            where TException : Exception
        {
            ValueTask <T> result = buffer.ReadAsync(token);

            result.IsCompleted.Should().BeTrue();
            result.IsCompletedSuccessfully.Should().BeFalse();
            Action act = () => _ = result.Result;

            act.Should().Throw <TException>();
        }
Exemple #31
0
 private void ReadDimensions(ArrayInfo info, IReadBuffer buffer, int dimensionCount
                             )
 {
     int[] dim = new int[dimensionCount];
     for (int i = 0; i < dim.Length; i++)
     {
         dim[i] = buffer.ReadInt();
     }
     ((MultidimensionalArrayInfo)info).Dimensions(dim);
     info.ElementCount(ElementCount(dim));
 }
Exemple #32
0
 private void ReadArrayCandidates(ITypeHandler4 typeHandler, IReadBuffer buffer, ITypeHandler4
     arrayElementHandler, QCandidates candidates)
 {
     if (!Handlers4.IsCascading(arrayElementHandler))
     {
         return;
     }
     SlotFormat slotFormat = SlotFormat.ForHandlerVersion(_handlerVersion);
     slotFormat.DoWithSlotIndirection(buffer, typeHandler, new _IClosure4_318(this, arrayElementHandler
         , buffer, candidates));
 }
Exemple #33
0
        public override string Read(IReadBuffer buffer, int length)
        {
            var chars = new char[length];

            for (var ii = 0; ii < length; ii++)
            {
                chars[ii] = (char)((buffer.ReadByte() & unchecked (0xff)) | ((buffer.ReadByte
                                                                                  () & unchecked (0xff)) << 8));
            }
            return(new string(chars, 0, length));
        }
        protected virtual object ReadCreate(Transaction trans, IReadBuffer buffer, ArrayInfo
                                            info)
        {
            ReadInfo(trans, buffer, info);
            IReflectClass clazz = NewInstanceReflectClass(trans.Reflector(), info);

            if (clazz == null)
            {
                return(null);
            }
            return(NewInstance(ArrayReflector(Container(trans)), info, clazz));
        }
Exemple #35
0
        private static ITypeHandler4 ReadElementTypeHandler(IReadBuffer buffer, IContext context)
        {
            int elementTypeId = buffer.ReadInt();

            if (elementTypeId == 0)
            {
                return(OpenTypeHandlerFrom(context));
            }

            ITypeHandler4 elementHandler = Container(context).TypeHandlerForClassMetadataID(elementTypeId);

            return(elementHandler ?? OpenTypeHandlerFrom(context));
        }
Exemple #36
0
 public static long ReadLong(IReadBuffer buffer)
 {
     long ret = 0;
     if (Deploy.debug && Deploy.debugLong)
     {
         ret = long.Parse(new LatinStringIO().Read(buffer, Const4.LongBytes).Trim());
     }
     for (var i = 0; i < Const4.LongBytes; i++)
     {
         ret = (ret << 8) + (buffer.ReadByte() & unchecked(0xff));
     }
     return ret;
 }
Exemple #37
0
        public static long ReadLong(IReadBuffer buffer)
        {
            long ret = 0;

            if (Deploy.debug && Deploy.debugLong)
            {
                ret = long.Parse(new LatinStringIO().Read(buffer, Const4.LongBytes).Trim());
            }
            for (var i = 0; i < Const4.LongBytes; i++)
            {
                ret = (ret << 8) + (buffer.ReadByte() & unchecked (0xff));
            }
            return(ret);
        }
Exemple #38
0
		public virtual object DoWithSlotIndirection(IReadBuffer buffer, IClosure4 closure
			)
		{
			int payLoadOffset = buffer.ReadInt();
			buffer.ReadInt();
			// length, not used
			int savedOffset = buffer.Offset();
			object res = null;
			if (payLoadOffset != 0)
			{
				buffer.Seek(payLoadOffset);
				res = closure.Run();
			}
			buffer.Seek(savedOffset);
			return res;
		}
Exemple #39
0
 internal PersistentChannelReader(IChannelReader <T> reader, bool singleReader)
 {
     this.reader = reader;
     if (singleReader)
     {
         readLock = default;
         buffer   = new SingleReaderBuffer();
     }
     else
     {
         readLock = AsyncLock.Exclusive();
         buffer   = new MultipleReadersBuffer();
     }
     fileOptions = new FileCreationOptions(FileMode.Open, FileAccess.Read, FileShare.ReadWrite, FileOptions.Asynchronous | FileOptions.SequentialScan);
     cursor      = new ChannelCursor(reader.Location, StateFileName);
 }
Exemple #40
0
        protected override void WithContent(AbstractBufferContext context, IRunnable runnable
                                            )
        {
            int address = context.ReadInt();
            int length  = context.ReadInt();

            if (address == 0)
            {
                return;
            }
            IReadBuffer     temp             = context.Buffer();
            ByteArrayBuffer indirectedBuffer = Container(context).DecryptedBufferByAddress(address
                                                                                           , length);

            context.Buffer(indirectedBuffer);
            runnable.Run();
            context.Buffer(temp);
        }
		protected virtual void ReadInfo(Transaction trans, IReadBuffer buffer, ArrayInfo 
			info)
		{
			int classID = buffer.ReadInt();
			if (IsPreVersion0Format(classID))
			{
				throw new UnsupportedOldFormatException();
			}
			else
			{
				_versionHelper.ReadTypeInfo(trans, buffer, info, classID);
				ReflectClassFromElementsEntry(Container(trans), info, classID);
				ReadDimensions(info, buffer);
			}
			if (Debug4.ExceedsMaximumArrayEntries(info.ElementCount(), _usePrimitiveClassReflector
				))
			{
				info.ElementCount(0);
			}
		}
Exemple #42
0
			public _CollectIdContext_203(QueryingReadContext readContext, Transaction baseArg1
				, IdObjectCollector baseArg2, ObjectHeader baseArg3, IReadBuffer baseArg4) : base
				(baseArg1, baseArg2, baseArg3, baseArg4)
			{
				this.readContext = readContext;
			}
Exemple #43
0
		/// <param name="buffer"></param>
		/// <param name="typeHandler"></param>
		protected virtual void SeekSecondaryOffset(IReadBuffer buffer, ITypeHandler4 typeHandler
			)
		{
		}
Exemple #44
0
 public static string ReadString(IContext context, IReadBuffer buffer)
 {
     var str = ReadStringNoDebug(context, buffer);
     return str;
 }
Exemple #45
0
 public static string ReadStringNoDebug(IContext context, IReadBuffer buffer)
 {
     return Intern(context, StringIo(context).ReadLengthAndString(buffer));
 }
		public override string Read(IReadBuffer buffer, int length)
		{
			byte[] bytes = new byte[length];
			buffer.ReadBytes(bytes);
			return Decode(bytes, 0, bytes.Length);
		}
		private static Guid ReadFrom(IReadBuffer buffer)
		{
			byte[] guidBytes = new byte[GuidSize];
			buffer.ReadBytes(guidBytes);
			return new Guid(guidBytes);
		}
        private static ITypeHandler4 ReadElementTypeHandler(IReadBuffer buffer, IContext context)
        {
            int elementHandlerId = buffer.ReadInt();
            if (elementHandlerId == 0) return OpenTypeHandlerFrom(context);

            ITypeHandler4 elementHandler = Container(context).TypeHandlerForClassMetadataID(elementHandlerId);
            return elementHandler ?? OpenTypeHandlerFrom(context);
        }
Exemple #49
0
		protected AbstractReadContext(Transaction transaction, IReadBuffer buffer) : base
			(transaction, buffer)
		{
		}
Exemple #50
0
 public _IClosure4_318(QCandidate _enclosing, ITypeHandler4 arrayElementHandler, IReadBuffer
     buffer, QCandidates candidates)
 {
     this._enclosing = _enclosing;
     this.arrayElementHandler = arrayElementHandler;
     this.buffer = buffer;
     this.candidates = candidates;
 }
Exemple #51
0
 private void ReadArrayCandidates(ITypeHandler4 typeHandler, IReadBuffer buffer, ITypeHandler4
     arrayElementHandler, QCandidates candidates)
 {
     if (!Handlers4.IsCascading(arrayElementHandler))
     {
         return;
     }
     var slotFormat = SlotFormat.ForHandlerVersion(_handlerVersion);
     slotFormat.DoWithSlotIndirection(buffer, typeHandler, new _IClosure4_318(this, arrayElementHandler
         , buffer, candidates));
 }
		private int ReducedCountForNullBitMap(ArrayInfo info, IReadBuffer context)
		{
			if (!HasNullBitmap(info))
			{
				return 0;
			}
			return ReducedCountForNullBitMap(info.ElementCount(), ReadNullBitmap(context, info
				.ElementCount()));
		}
		// do nothing, the byte for additional type information was added after format 3
		public override void ReadTypeInfo(Transaction trans, IReadBuffer buffer, ArrayInfo
			 info, int classID)
		{
		}
Exemple #54
0
 public static void ReadBegin(IReadBuffer buffer, byte identifier)
 {
 }
Exemple #55
0
 public static void ReadEnd(IReadBuffer buffer)
 {
     if (Deploy.debug && Deploy.brackets)
     {
         if (buffer.ReadByte() != Const4.Yapend)
         {
             throw new Exception("Debug.readEnd() YAPEND expected");
         }
     }
 }
		protected virtual void ReadDimensions(ArrayInfo info, IReadBuffer buffer)
		{
			info.ElementCount(buffer.ReadInt());
		}
		protected virtual object ReadCreate(Transaction trans, IReadBuffer buffer, ArrayInfo
			 info)
		{
			ReadInfo(trans, buffer, info);
			IReflectClass clazz = NewInstanceReflectClass(trans.Reflector(), info);
			if (clazz == null)
			{
				return null;
			}
			return NewInstance(ArrayReflector(Container(trans)), info, clazz);
		}
		protected virtual BitMap4 ReadNullBitmap(IReadBuffer context, int length)
		{
			return context.ReadBitMap(length);
		}
		public ObjectIdContextImpl(Transaction transaction, IReadBuffer buffer, ObjectHeader
			 objectHeader, int id) : base(transaction, buffer, objectHeader)
		{
			_id = id;
		}
Exemple #60
0
		private KeyValueHandlerPair ReadKeyValueTypeHandlers(IReadBuffer buffer, IContext
			 context)
		{
			buffer.ReadInt();
			buffer.ReadInt();
			ITypeHandler4 untypedHandler = (ITypeHandler4)Container(context).Handlers.OpenTypeHandler
				();
			return new KeyValueHandlerPair(untypedHandler, untypedHandler);
		}