public bool TrySetValue(StorageKey sk, short missSize, BinaryDataListRow value)
        {

            _levelZeroCache[sk] = value;

            return true;
        }
        public List<int> DistinctGetRows(StorageKey sk, IIndexIterator keys, List<int> colIdx)
        {

            List<IndexBasedBinaryDataListRow> rows = new List<IndexBasedBinaryDataListRow>();

            // avoid blank rows ;)
            while(keys.HasMore())
            {
                // fetch a fixed segment at a time ;)
                var idx = keys.FetchNextIndex();

                StorageKey tmpKey = new StorageKey(sk.UID, idx + sk.UniqueKey);

                var tmp = _levelZeroCache[tmpKey];

                if(tmp != null)
                {
                    rows.Add(new IndexBasedBinaryDataListRow { Row = tmp, Index = idx });
                }
                else
                {
                    throw new Exception(string.Format("Critical error. No value in storage for index {0}", idx));
                }
            }

            var indexBasedBinaryDataListRowEqualityComparer = new BinaryDataListRowEqualityComparer(colIdx);

            // fetch row indexes ;)
            IEnumerable<int> indexBasedBinaryDataListRows = rows.Distinct(indexBasedBinaryDataListRowEqualityComparer).Select(c => c.Index);

            return indexBasedBinaryDataListRows.ToList();

        }
        public bool TryGetValue(StorageKey key, short missSize, out BinaryDataListRow value)
        {
            value = _levelZeroCache[key] ?? new BinaryDataListRow(missSize);

            return true;
        }
Example #4
0
        /// <summary>
        /// Generates the key.
        /// </summary>
        /// <returns></returns>
        private InternalFederatedTO GenerateFederatedKey(int idx)
        {
            InternalFederatedTO result = new InternalFederatedTO();

            // we need two keys ;)
            var firstKey = _keyToAliasMap.Keys.FirstOrDefault();
            ICollection<string> entry1Columns = null;

            // fetch alias key first ;)
            if(firstKey != null)
            {
                var magicKey = _keyToAliasMap[firstKey];

                var sk1 = new StorageKey(magicKey.MasterKeyID, idx + magicKey.MasterKey);
                entry1Columns = _keyToAliasMap.Keys;
                result.ParentKey = new FederatedStorageKey { TheKey = sk1, ImpactedColumns = entry1Columns };

                // set master entry for the federation ;)
                result.MasterEntry = magicKey.MasterEntry;
            }

            // now create the child key
            var sk2 = new StorageKey(DataListKey, idx + GenerateKeyPrefix(Namespace, DataListKey));

            result.ChildKey = new FederatedStorageKey { TheKey = sk2, ImpactedColumns = FilterColumns(entry1Columns) };

            return result;
        }
Example #5
0
        public List<int> GetDistinctRows(List<string> filterCols)
        {
            var filterColIndexes = new List<int>();
            var tmpThis = this;
            filterCols.ForEach(filterCol => filterColIndexes.Add(tmpThis.InternalFetchColumnIndex(filterCol)));

            // TODO : Hi-jack lookup

            StorageKey sk = new StorageKey(DataListKey, GenerateKeyPrefix(Namespace, DataListKey));

            var distinctBinaryDataListRows = _itemStorage.DistinctGetRows(sk, Keys, filterColIndexes);
            return distinctBinaryDataListRows;
        }
Example #6
0
        public IDictionary<int, IList<IBinaryDataListItem>> FetchSortData()
        {
            IDictionary<int, IList<IBinaryDataListItem>> result = new Dictionary<int, IList<IBinaryDataListItem>>(Count);
            IIndexIterator ii = Keys;
            if(IsRecordset)
            {
                short colCnt = (short)Columns.Count;

                while(ii.HasMore())
                {
                    // TODO : What if they are in different locations?

                    IList<IBinaryDataListItem> tmp = new List<IBinaryDataListItem>(Columns.Count);
                    BinaryDataListRow row;
                    int next = ii.FetchNextIndex();

                    // Hi-jack lookup

                    StorageKey sk = new StorageKey(DataListKey, next + GenerateKeyPrefix(Namespace, DataListKey));

                    if(_itemStorage.TryGetValue(sk, colCnt, out row))
                    {
                        for(int i = 0; i < Columns.Count; i++)
                        {
                            tmp.Add(new BinaryDataListItem(row.FetchValue(i, colCnt), Namespace, Columns[i].ColumnName, next));
                        }

                        result[next] = tmp;
                    }
                }
            }

            return result;
        }
Example #7
0
        /// <summary>
        /// Applies the sort action.
        /// </summary>
        public void ApplySortAction(IDictionary<int, IList<IBinaryDataListItem>> payload)
        {
            // Apply IDic back into my object ;)
            foreach(int i in payload.Keys)
            {
                // TODO : What if they are in different locations?

                StorageKey sk = new StorageKey(DataListKey, i + GenerateKeyPrefix(Namespace, DataListKey));

                BinaryDataListRow row;

                short colCnt = (short)Columns.Count;

                if(_itemStorage.TryGetValue(sk, colCnt, out row))
                {
                    IList<IBinaryDataListItem> cols;
                    if(payload.TryGetValue(i, out cols))
                    {
                        foreach(IBinaryDataListItem c in cols)
                        {
                            int idx = InternalFetchColumnIndex(c.FieldName);
                            string theValue;
                            try
                            {
                                theValue = c.TheValue;
                            }
                            catch(Exception)
                            {
                                theValue = null;
                            }
                            row.UpdateValue(theValue, idx, colCnt);
                        }

                        _itemStorage.TrySetValue(sk, colCnt, row);
                    }
                }
            }
        }