Exemplo n.º 1
0
        private ClusteredArray <T> toClusteredArray(T[] plainArray)
        {
            ClusteredArray <T> cc = new ClusteredArray <T>(morphedLengthThreshold, plainArray.Length);

            cc.CopyFrom(plainArray, 0, 0, plainArray.Length);
            return(cc);
        }
Exemplo n.º 2
0
        public override ClusteredArray <byte> GetClusteredArray()
        {
            ClusteredArray <byte> clusterByteArray = new ClusteredArray <byte>(Length);

            clusterByteArray.CopyFrom(_data, 0, 0, Length);
            return(clusterByteArray);
        }
        public bool MoveNext()
        {
            if (_dataWithValue != null && _index < _chunkKeys.Count)
            {
                object key = _chunkKeys[_index++];
                if (_dataWithValue.ContainsKey(key))
                {
                    if (_getData)
                    {
                        _currentValue    = new ClusteredArray <object>(2);
                        _currentValue[0] = key;
                        _currentValue[1] = _dataWithValue[key];
                        return(true);
                    }
                    else
                    {
                        _currentValue    = new ClusteredArray <object>(1);
                        _currentValue[0] = key;
                        return(true);
                    }
                }
                else
                {
                    return(HasMoreData);
                }
            }

            return(HasMoreData);
        }
 public void Dispose()
 {
     _keyList       = null;
     _chunkKeys     = null;
     _currentValue  = null;
     _dataWithValue = null;
 }
Exemplo n.º 5
0
 public void Morph()
 {
     if (!isMorphed)
     {
         clusteredView = toClusteredArray(plainView);
         isMorphed     = true;
         plainView     = null;
     }
 }
Exemplo n.º 6
0
 public void DeMorph()
 {
     if (isMorphed)
     {
         plainView     = (T[])clusteredView;
         isMorphed     = false;
         clusteredView = null;
     }
 }
Exemplo n.º 7
0
 public void Deserialize(Runtime.Serialization.IO.CompactReader reader)
 {
     _columns = reader.ReadObject() as ColumnCollection;
     _objects = new ClusteredArray <object>(_columns.Count);
     for (int i = 0; i < _objects.Length; i++)
     {
         _objects[i] = reader.ReadObject();
     }
 }
Exemplo n.º 8
0
        private void Dispose(bool disposing)
        {
            Close();
            if (disposing)
            {
                GC.SuppressFinalize(this);
            }

            _currentRow = null;
        }
Exemplo n.º 9
0
        public bool Read()
        {
            if (_clientRecordSetEnumerator == null)
            {
                return(false);
            }
            bool next = _clientRecordSetEnumerator.MoveNext();

            if (next)
            {
                _currentRow = _clientRecordSetEnumerator.Current;
            }
            return(next);
        }
Exemplo n.º 10
0
 static Crc32()
 {
     Table = new ClusteredArray <int>(256);
     for (uint i = 0; i < 256; i++)
     {
         uint crc = i;
         for (uint j = 0; j < 8; j++)
         {
             crc = (crc >> 1) ^ (((crc & 1) == 1) ? 0xEDB88320u : 0);
         }
         //Note: table ordinal and value inverted to omit -1 start and end operation
         Table[~i & 0x0ff] = ~unchecked ((int)crc);
     }
 }
Exemplo n.º 11
0
        public void Alternate()
        {
            switch (isMorphed)
            {
            case true:
                plainView     = (T[])clusteredView;
                isMorphed     = false;
                clusteredView = null;
                break;

            case false:
                clusteredView = toClusteredArray(plainView);
                isMorphed     = true;
                plainView     = null;
                break;
            }
        }
Exemplo n.º 12
0
 public static void SerializeClusteredArray <T>(ClusteredArray <T> array, Runtime.Serialization.IO.CompactWriter writer)
 {
     if (array == null)
     {
         writer.Write(false);
         return;
     }
     else
     {
         writer.Write(true);
         writer.Write(array.Length);
         writer.Write(array.LengthThreshold);
         for (int i = 0; i < array.Length; i++)
         {
             writer.WriteObject(array[i]);
         }
     }
 }
Exemplo n.º 13
0
        public virtual void ResetPool()
        {
            lock (_operationLock)
            {
                Count    = _initialCapacity;
                Capacity = _initialCapacity;

                _pooledObjectStack = new ClusteredArray <T>(Capacity);

                for (int i = 0; i < Capacity; i++)
                {
                    var instance = _pooledObjectStack[i] = GetInstanceSafe();
                    instance.ResetLeasable();
                }

                _top           = Capacity;
                _hits          = 0;
                _misses        = 0;
                _totalRequests = 0;
            }
        }
Exemplo n.º 14
0
        public static ClusteredArray <T> DeserializeClusteredArray <T>(Runtime.Serialization.IO.CompactReader reader)
        {
            bool flag = reader.ReadBoolean();

            if (flag)
            {
                int length               = reader.ReadInt32();
                int threshold            = reader.ReadInt32();
                ClusteredArray <T> array = new ClusteredArray <T>(threshold, length);

                for (int i = 0; i < length; i++)
                {
                    array[i] = (T)reader.ReadObject();
                }

                return(array);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 15
0
 public Morphable(T[][] arr)
 {
     if (arr != null)
     {
         if (arr.Length > 1)
         {
             morphedLengthThreshold = arr[0].Length;
             clusteredView          = new ClusteredArray <T>(morphedLengthThreshold, arr[0].Length * arr.Length);
         }
         else
         {
             clusteredView          = new ClusteredArray <T>(arr[0].Length);
             morphedLengthThreshold = clusteredView.LengthThreshold;
         }
         int arrayposition = 0;
         foreach (T[] buffer in arr)
         {
             clusteredView.CopyFrom(buffer, 0, arrayposition, buffer.Length);
             arrayposition += buffer.Length;
         }
         isMorphed = true;
     }
 }
Exemplo n.º 16
0
        public override ClusteredArray <byte> GetClusteredArray()
        {
            ClusteredArray <byte> clusterByteArray = new ClusteredArray <byte>(Length);

            int nextIndex = 0;

            byte[] binarChunk = null;

            if (Length > 0)
            {
                for (int i = 0; i < _data.Count - 1; i++)
                {
                    binarChunk = (byte[])_data[i];
                    if (binarChunk != null)
                    {
                        clusterByteArray.CopyFrom(binarChunk, 0, nextIndex, binarChunk.Length);
                        nextIndex += binarChunk.Length;
                    }
                }
                clusterByteArray.CopyFrom((byte[])_data[_noOfChunks - 1], 0, nextIndex, _lastChunkSize);
            }
            return(clusterByteArray);
        }
Exemplo n.º 17
0
        public ClusteredMemoryStream(byte[] buffer, bool writable)
        {
            if (buffer == null) throw new ArgumentNullException("buffer", ResourceHelper.GetResourceString("ArgumentNull_Buffer"));
#if DEBUG
            Contract.EndContractBlock();
#endif
            _buffer = new ClusteredArray<byte>(buffer.Length);
            _buffer.CopyFrom(buffer, 0, 0, buffer.Length);
            _length = _capacity = buffer.Length;
            _writable = writable;
            _exposable = false;
            _origin = 0;
            _isOpen = true;
        }
Exemplo n.º 18
0
        public ClusteredMemoryStream(int capacity)
        {
            if (capacity < 0)
            {
                throw new ArgumentOutOfRangeException("capacity", ResourceHelper.GetResourceString("ArgumentOutOfRange_NegativeCapacity"));
            }
#if DEBUG
            Contract.EndContractBlock();
#endif
            _buffer = new ClusteredArray<byte>(capacity);
            _capacity = capacity;
            _expandable = true;
            _writable = true;
            _exposable = true;
            _origin = 0;      // Must be 0 for byte[]'s created by MemoryStream
            _isOpen = true;
        }
Exemplo n.º 19
0
 internal RecordRow(ColumnCollection columns)
 {
     _columns = columns;
     _objects = new ClusteredArray <object>(columns.Count);
 }
Exemplo n.º 20
0
        // Constructs a ArrayList with a given initial capacity. The list is
        // initially empty, but will have room for the given number of elements
        // before any reallocations are required.
        // 
        public ClusteredArrayList(int capacity)
        {
            if (capacity < 0) throw new ArgumentOutOfRangeException("capacity", ResourceHelper.GetResourceString("ArgumentOutOfRange_MustBeNonNegNum"));
#if DEBUG
            Contract.EndContractBlock();
#endif
            if (capacity == 0)
                _items = emptyArray;
            else
                _items = new ClusteredArray<object>(capacity);
        }
Exemplo n.º 21
0
        // Constructs a ArrayList, copying the contents of the given collection. The
        // size and capacity of the new list will both be equal to the size of the
        // given collection.
        // 
        public ClusteredArrayList(ICollection c)
        {
            if (c == null)
                throw new ArgumentNullException("c", ResourceHelper.GetResourceString("ArgumentNull_Collection"));
#if DEBUG
            Contract.EndContractBlock();
#endif
            int count = c.Count;
            if (count == 0)
            {
                _items = emptyArray;
            }
            else
            {
                _items = new ClusteredArray<object>(count);
                AddRange(c);
            }
        }
Exemplo n.º 22
0
 public Morphable(ClusteredArray <T> arr)
 {
     clusteredView          = arr;
     morphedLengthThreshold = arr.LengthThreshold;
     isMorphed = true;
 }
Exemplo n.º 23
0
 public ClusteredArrayList()
 {
     _items = emptyArray;
 }
Exemplo n.º 24
0
        //Changelog: Used ClusteredArray's internal CopyFrom method.
        public ClusteredMemoryStream(byte[] buffer, int index, int count, bool writable, bool publiclyVisible)
        {
            if (buffer == null)
                throw new ArgumentNullException("buffer", ResourceHelper.GetResourceString("ArgumentNull_Buffer"));
            if (index < 0)
                throw new ArgumentOutOfRangeException("index", ResourceHelper.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
            if (count < 0)
                throw new ArgumentOutOfRangeException("count", ResourceHelper.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
            if (buffer.Length - index < count)
                throw new ArgumentException(ResourceHelper.GetResourceString("Argument_InvalidOffLen"));
#if DEBUG
            Contract.EndContractBlock();
#endif
            _buffer = new ClusteredArray<byte>(buffer.Length);
            _buffer.CopyFrom(buffer, 0, 0, buffer.Length);
            _origin = _position = index;
            _length = _capacity = index + count;
            _writable = writable;
            _exposable = publiclyVisible;  // Can GetBuffer return the array?
            _expandable = false;
            _isOpen = true;
        }