Пример #1
0
        private List <InnerData> ReadMetaDataUsingSelect(TCommand script, int countElements, bool isfirstAsk,
                                                         ref object lastId,
                                                         Func <MetaData, bool> isMine, ref bool isAllDataRead)
        {
            var list          = new List <InnerData>();
            var idDescription = PrepareKeyDescription(countElements, isfirstAsk, lastId);
            SelectSearchResult result;

            int count = 0;

            var select = new SelectDescriptionForGeneric <TCommand>(idDescription, script, countElements,
                                                                    new List <FieldDescription>());
            var ret = SelectRead(select, out result);

            while (!ret.IsError)
            {
                bool exit = false;
                foreach (var searchData in result.Data)
                {
                    var meta = _metaDataCommandCreator.ReadMetaFromSearchData(searchData);
                    var data = _userCommandCreator.ReadObjectFromSearchData(searchData.Fields);
                    meta.Hash = _hashCalculater.CalculateHashFromValue(data);

                    if (isMine(meta))
                    {
                        var innerData = new InnerData(new Transaction(meta.Hash, ""))
                        {
                            Data     = _hashCalculater.SerializeValue(data),
                            MetaData = meta
                        };

                        list.Add(innerData);
                        count++;
                    }

                    lastId = meta.Id;

                    if (count == countElements)
                    {
                        exit = true;
                        break;
                    }
                }

                if (result.IsAllDataRead || exit)
                {
                    break;
                }

                idDescription = PrepareKeyDescription(countElements, false, lastId);
                select        = new SelectDescriptionForGeneric <TCommand>(idDescription, script, count,
                                                                           new List <FieldDescription>());
                ret = SelectRead(select, out result);
            }

            isAllDataRead = result.IsAllDataRead;

            return(list);
        }
Пример #2
0
        public UserTransaction Create(object key, object value)
        {
            var hash = _hashFromValue
                ? _hashCalculater.CalculateHashFromValue(value)
                : _hashCalculater.CalculateHashFromKey(key);

            var transaction = _distributor.CreateTransaction(hash);

            transaction.OperationName = OperationName.Create;
            transaction.OperationType = OperationType.Async;

            if (!transaction.IsError)
            {
                CompleteTransaction(key, value, transaction);
                PerfCounters.ProxyCounters.Instance.CreateCount.Increment();
            }

            return(transaction.UserTransaction);
        }