/// <summary>
        /// Copies an array from the given stream using the given accessor.
        /// </summary>
        /// <param name="accessor">The accessor to use.</param>
        /// <param name="stream">The stream to copy from.</param>
        internal virtual void CopyFrom(MappedAccessor <T> accessor, Stream stream)
        {
            long i       = 0;
            var  element = default(T);

            while (i < this.Length)
            {
                accessor.ReadFrom(stream, stream.Position, ref element);
                this[i] = element;
                i++;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates a memory mapped array based on existing data.
        /// </summary>
        public Array(MappedAccessor <T> accessor, int bufferSize, int cacheSize)
        {
            _accessors = new List <MappedAccessor <T> >();
            _accessors.Add(accessor);
            _accessorSize   = accessor.CapacityElements;
            _createAccessor = null;

            // create first accessor.
            _length = accessor.CapacityElements;

            _bufferSize              = bufferSize;
            _cachedBuffer            = null;
            _cachedBuffers           = new LRUCache <long, CachedBuffer>(cacheSize);
            _cachedBuffers.OnRemove += new LRUCache <long, CachedBuffer> .OnRemoveDelegate(buffer_OnRemove);
        }
Beispiel #3
0
 /// <summary>
 /// Creates a new index based on one fixed-size accessor.
 /// </summary>
 public Index(MappedAccessor <T> accessor)
 {
     _accessors = new System.Collections.Generic.List <MappedAccessor <T> >();
     _accessors.Add(accessor);
     _accessorBytesLost = new System.Collections.Generic.List <long>();
     _accessorBytesLost.Add(0);
     _accessorSize = accessor.Capacity;
     if (!accessor.ElementSizeFixed)
     { // use the size in bytes.
         _accessorSizeElements = _accessorSize;
     }
     else
     { // use the size in elements.
         _accessorSizeElements = accessor.CapacityElements;
     }
 }
Beispiel #4
0
 /// <summary>
 /// Creates a memory mapped array based on existing data.
 /// </summary>
 public Array(MappedAccessor <T> accessor, ArrayProfile profile)
     : this(accessor, profile.BufferSize, profile.CacheSize)
 {
 }
Beispiel #5
0
 /// <summary>
 /// Creates a memory mapped array based on existing data.
 /// </summary>
 public Array(MappedAccessor <T> accessor)
     : this(accessor, DefaultBufferSize, DefaultCacheSize)
 {
 }