示例#1
0
        public override async Task <IQueryStream <TElement> > ExecuteQueryStreamedAsync <TElement>(TableQuery <TElement> query, TableRequestOptions requestOptions = null, OperationContext operationContext = null)
        {
            // Philosophically, maybe this proxy-making belongs on the host
            // side, but that would require a second custom wrapper because we
            // still need the custom wrapper on the caller side to do the
            // different event types.
            IQueryStream <TElement> remoteStream = await nonannotatableCallProxy.ExecuteQueryStreamedAsync(
                query, requestOptions, operationContext);

            return(new QueryStreamPSharpProxy <TElement>(
                       PSharpRealProxy.MakeTransparentProxy(callerMachineId, hostMachineId, remoteStream,
                                                            null, () => new TableNonannotatableCallEvent())));
        }
示例#2
0
        public override async Task <IQueryStream <TElement> > ExecuteQueryStreamedAsync <TElement>(TableQuery <TElement> query, TableRequestOptions requestOptions = null, OperationContext operationContext = null)
        {
            //Trace.TraceInformation("{0} calling {1}.ExecuteQueryStreamedAsync({2})", callerMachineId, debugName, BetterComparer.ToString(query));
            // Philosophically, maybe this proxy-making belongs on the host
            // side, but that would require a second custom wrapper because we
            // still need the custom wrapper on the caller side to do the
            // different event types.
            IQueryStream <TElement> remoteStream = await plainEventProxy.ExecuteQueryStreamedAsync(
                query, requestOptions, operationContext);

            return(new QueryStreamPSharpProxy <TElement>(
                       PSharpRealProxy.MakeTransparentProxy(callerMachineId, hostMachineId, remoteStream,
                                                            string.Format("<{0} QueryStream>", debugName), () => new GenericDispatchableEvent())));
        }
示例#3
0
        Task WalkTableInParallel(IChainTable2 table, TableRequestOptions requestOptions, OperationContext operationContext,
                                 Func <MTableEntity, Task <IQueryStream <MTableEntity> > > rowCallbackAsync)
        {
            return(Task.WhenAll(Enumerable.Range(0, 16).Select(hexNumber => Task.Run(async() =>
            {
                var query = new TableQuery <MTableEntity>();

                if (hexNumber == 0)
                {
                    query.FilterString = TableQuery.GenerateFilterCondition(
                        "PartitionKey",
                        QueryComparisons.LessThanOrEqual,
                        (hexNumber + 1).ToString("x"));
                }
                else if (hexNumber == 15)
                {
                    query.FilterString = TableQuery.GenerateFilterCondition(
                        "PartitionKey",
                        QueryComparisons.GreaterThanOrEqual,
                        hexNumber.ToString("x"));
                }
                else
                {
                    query.FilterString = TableQuery.CombineFilters(
                        TableQuery.GenerateFilterCondition(
                            "PartitionKey",
                            QueryComparisons.GreaterThanOrEqual,
                            hexNumber.ToString("x")),
                        TableOperators.And,
                        TableQuery.GenerateFilterCondition(
                            "PartitionKey",
                            QueryComparisons.LessThanOrEqual,
                            (hexNumber + 1).ToString("x")));
                }

                try
                {
                    IQueryStream <MTableEntity> tableStream = await table.ExecuteQueryStreamedAsync(
                        query, requestOptions, operationContext);

                    MTableEntity entity;
                    while ((entity = await tableStream.ReadRowAsync()) != null)
                    {
                        IQueryStream <MTableEntity> newTableStream = await rowCallbackAsync(entity);
                        if (newTableStream != null)
                        {
                            tableStream = newTableStream;
                        }
                    }
                }
                catch (Exception e)
                {
                    while (e is AggregateException)
                    {
                        e = ((AggregateException)(e)).InnerException;
                    }

                    if (!(e is StorageException && ((StorageException)e).RequestInformation.HttpStatusCode == 404))
                    {
                        throw;
                    }
                }
            }))));
        }