Container for the parameters to the Scan operation.

The Scan operation returns one or more items and item attributes by accessing every item in the table. To have Amazon DynamoDB return fewer items, you can provide a ScanFilter .

If the total number of scanned items exceeds the maximum data set size limit of 1 MB, the scan stops and results are returned to the user with a LastEvaluatedKey to continue the scan in a subsequent operation. The results also include the number of items exceeding the limit. A scan can result in no table data meeting the filter criteria.

The result set is eventually consistent.

Inheritance: Amazon.Runtime.AmazonWebServiceRequest
コード例 #1
2
ファイル: CRUD.cs プロジェクト: fonnylasmana/Health
        public List<Dictionary<string,AttributeValue>> getAllItems(string ConnectionString, string tableName)
        {

            Connection c = new Connection();
            var client = c.ConnectAmazonDynamoDB(ConnectionString);
            var request = new ScanRequest
            {
                TableName = tableName,
            };

            var response = client.Scan(request);
            var result = response.Items;
            return result;
        }
コード例 #2
1
ファイル: CRUD.cs プロジェクト: fonnylasmana/Health
        public List<Dictionary<string, AttributeValue>> getItemContain(string ConnectionString, string tableName, string inputparam, string columnName)
        {

            Connection c = new Connection();
            var client = c.ConnectAmazonDynamoDB(ConnectionString);

            var table = Table.LoadTable(client, tableName);


            // Define scan conditions
            Dictionary<string, Condition> conditions = new Dictionary<string, Condition>();

            // Title attribute should contain the string "Adventures"
            Condition titleCondition = new Condition();
            titleCondition.ComparisonOperator = "BEGINS_WITH";
            titleCondition.AttributeValueList.Add(new AttributeValue { S = inputparam });
            conditions[columnName] = titleCondition;


            var request = new ScanRequest
            {
                TableName = tableName,
                ScanFilter = conditions
            };

            var response = client.Scan(request);
            var result = response.Items;
            return result;
        }
コード例 #3
1
        public void InstantiateIn(System.Web.UI.Control container)
        {
            AmazonDynamoDBClient client = new AmazonDynamoDBClient();
            // string tableName = "Attendee";
            var request = new ScanRequest
            {
                TableName = "QuizQuestion",

            };
            var response = client.Scan(request);
            List<QuestionData> questionDataList = new List<QuestionData>();
            foreach (Dictionary<string, AttributeValue> item in response.ScanResult.Items)
            {
                // Process the result.

                QuestionData question = new QuestionData();
                if (item.ContainsKey("options"))
                {
                        foreach (var itemNew in item["options"].M)
                        {
                            Label link = new Label();
                            link.ID = "linkmodel";
                            container.Controls.Add(link);
                            link.Text = itemNew.Value.S;
                            //Label value = questionData.FindControl("options") as Label;
                            ////testM = itemNew.Key.ToString();
                            //value.Text = itemNew.Value.S;
                        }
                }

            }
        }
コード例 #4
0
        internal static Amazon.DynamoDBv2.Model.ScanRequest CreateScanRequest <T>(Innovt.Cloud.Table.ScanRequest request)
        {
            var scanRequest = new Amazon.DynamoDBv2.Model.ScanRequest()
            {
                IndexName                 = request.IndexName,
                TableName                 = GetTableName <T>(),
                ConsistentRead            = request.IndexName == null,
                FilterExpression          = request.FilterExpression,
                ProjectionExpression      = request.AttributesToGet,
                ExclusiveStartKey         = PaginationTokenToDictionary(request.Page),
                ExpressionAttributeValues = CreateExpressionAttributeValues(request.Filter, string.Join(',', request.FilterExpression))
            };

            if (request.PageSize.HasValue)
            {
                scanRequest.Limit = request.PageSize == 0 ? 1 : request.PageSize.Value;
            }

            return(scanRequest);
        }
コード例 #5
0
ファイル: CRUD.cs プロジェクト: fonnylasmana/Health
        public List<Dictionary<string, AttributeValue>> getItem(string ConnectionString, string tableName, string inputparam, string expressionText, string columnName)
        {

            Connection c = new Connection();
            var client = c.ConnectAmazonDynamoDB(ConnectionString);

            var table = Table.LoadTable(client, tableName);

            var request = new ScanRequest
            {
                TableName = tableName,
                ExpressionAttributeValues = new Dictionary<string, AttributeValue> {
                        {expressionText, new AttributeValue { S = inputparam}}
                    },
                FilterExpression = columnName + "=" + expressionText
            };

            var response = client.Scan(request);
            var result = response.Items;
            return result;
        }
コード例 #6
0
 /// <summary>
 /// The <i>Scan</i> operation returns one or more items and item attributes by accessing
 /// every item in a table or a secondary index. To have DynamoDB return fewer items, you
 /// can provide a <i>ScanFilter</i> operation.
 /// 
 ///  
 /// <para>
 /// If the total number of scanned items exceeds the maximum data set size limit of 1
 /// MB, the scan stops and results are returned to the user as a <i>LastEvaluatedKey</i>
 /// value to continue the scan in a subsequent operation. The results also include the
 /// number of items exceeding the limit. A scan can result in no table data meeting the
 /// filter criteria. 
 /// </para>
 ///  
 /// <para>
 /// The result set is eventually consistent. 
 /// </para>
 ///  
 /// <para>
 /// By default, <i>Scan</i> operations proceed sequentially; however, for faster performance
 /// on a large table or secondary index, applications can request a parallel <i>Scan</i>
 /// operation by providing the <i>Segment</i> and <i>TotalSegments</i> parameters. For
 /// more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#QueryAndScanParallelScan">Parallel
 /// Scan</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table containing the requested items; or, if you provide <code>IndexName</code>, the name of the table to which that index belongs.</param>
 /// <param name="attributesToGet"><important>This is a legacy parameter, for backward compatibility. New applications should use <i>ProjectionExpression</i> instead. Do not combine legacy parameters and expression parameters in a single API call; otherwise, DynamoDB will return a <i>ValidationException</i> exception. This parameter allows you to retrieve attributes of type List or Map; however, it cannot retrieve individual elements within a List or a Map.</important> The names of one or more attributes to retrieve. If no attribute names are provided, then all attributes will be returned. If any of the requested attributes are not found, they will not appear in the result. Note that <i>AttributesToGet</i> has no effect on provisioned throughput consumption. DynamoDB determines capacity units consumed based on item size, not on the amount of data that is returned to an application.</param>
 /// 
 /// <returns>The response from the Scan service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException">
 /// The request rate is too high, or the request is too large, for the available throughput
 /// to accommodate. The AWS SDKs automatically retry requests that receive this exception;
 /// therefore, your request will eventually succeed, unless the request is too large or
 /// your retry queue is too large to finish. Reduce the frequency of requests by using
 /// the strategies listed in <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#APIRetries">Error
 /// Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
 /// The operation tried to access a nonexistent table or index. The resource might not
 /// be specified correctly, or its status might not be <code>ACTIVE</code>.
 /// </exception>
 public ScanResponse Scan(string tableName, List<string> attributesToGet)
 {
     var request = new ScanRequest();
     request.TableName = tableName;
     request.AttributesToGet = attributesToGet;
     return Scan(request);
 }
コード例 #7
0
        /// <summary>
        /// <para>The <i>Scan</i> operation returns one or more items and item attributes by accessing every item in the table. To have DynamoDB return
        /// fewer items, you can provide a <i>ScanFilter</i> .</para> <para>If the total number of scanned items exceeds the maximum data set size limit
        /// of 1 MB, the scan stops and results are returned to the user with a <i>LastEvaluatedKey</i> to continue the scan in a subsequent operation.
        /// The results also include the number of items exceeding the limit. A scan can result in no table data meeting the filter criteria. </para>
        /// <para>The result set is eventually consistent. </para> <para>By default, <i>Scan</i> operations proceed sequentially; however, for faster
        /// performance on large tables, applications can request a parallel <i>Scan</i> by specifying the <i>Segment</i> and <i>TotalSegments</i>
        /// parameters. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#QueryAndScanParallelScan">Parallel Scan</a> in the
        /// Amazon DynamoDB Developer Guide.</para>
        /// </summary>
        /// 
        /// <param name="scanRequest">Container for the necessary parameters to execute the Scan service method on AmazonDynamoDBv2.</param>
        /// 
        /// <returns>The response from the Scan service method, as returned by AmazonDynamoDBv2.</returns>
        /// 
        /// <exception cref="T:Amazon.DynamoDBv2.Model.ResourceNotFoundException" />
        /// <exception cref="T:Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException" />
        /// <exception cref="T:Amazon.DynamoDBv2.Model.InternalServerErrorException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<ScanResponse> ScanAsync(ScanRequest scanRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ScanRequestMarshaller();
            var unmarshaller = ScanResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, ScanRequest, ScanResponse>(scanRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
コード例 #8
0
ファイル: Search.cs プロジェクト: rguarino4/aws-sdk-net
        private List<Document> GetNextSetHelper(bool isAsync)
        {
            List<Document> ret = new List<Document>();

            if (!IsDone)
            {
                switch (SearchMethod)
                {
                    case SearchType.Scan:
                        ScanRequest scanReq = new ScanRequest
                        {
                            ExclusiveStartKey = NextKey,
                            Limit = Limit,
                            TableName = TableName,
                            AttributesToGet = AttributesToGet,
                            ScanFilter = Filter,
                            Select = EnumToStringMapper.Convert(Select)
                        };

                        if (this.TotalSegments != 0)
                        {
                            scanReq.TotalSegments = this.TotalSegments;
                            scanReq.Segment = this.Segment;
                        }

                        scanReq.BeforeRequestEvent += isAsync ?
                            new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerAsync) :
                            new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerSync);

                        ScanResult scanResult = SourceTable.DDBClient.Scan(scanReq).ScanResult;
                        foreach (var item in scanResult.Items)
                        {
                            Document doc = Document.FromAttributeMap(item);
                            ret.Add(doc);
                            if (CollectResults)
                            {
                                Matches.Add(doc);
                            }
                        }
                        NextKey = scanResult.LastEvaluatedKey;
                        if (NextKey == null)
                        {
                            IsDone = true;
                        }
                        return ret;
                    case SearchType.Query:
                        QueryRequest queryReq = new QueryRequest
                        {
                            ConsistentRead = IsConsistentRead,
                            ExclusiveStartKey = NextKey,
                            Limit = Limit,
                            ScanIndexForward = !IsBackwardSearch,
                            TableName = TableName,
                            AttributesToGet = AttributesToGet,
                            KeyConditions = Filter,
                            IndexName = IndexName,
                            Select = EnumToStringMapper.Convert(Select)
                        };
                        queryReq.BeforeRequestEvent += isAsync ?
                            new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerAsync) :
                            new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerSync);

                        QueryResult queryResult = SourceTable.DDBClient.Query(queryReq).QueryResult;
                        foreach (var item in queryResult.Items)
                        {
                            Document doc = Document.FromAttributeMap(item);
                            ret.Add(doc);
                            if (CollectResults)
                            {
                                Matches.Add(doc);
                            }
                        }
                        NextKey = queryResult.LastEvaluatedKey;
                        if (NextKey == null)
                        {
                            IsDone = true;
                        }
                        return ret;
                    default:
                        throw new InvalidOperationException("Unknown Search Method");
                }
            }

            return ret;
        }
コード例 #9
0
ファイル: Search.cs プロジェクト: yridesconix/aws-sdk-net
        private int GetCount()
        {
            if (IsDone && CollectResults)
            {
                return Matches.Count;
            }
            else
            {
                if (count != -1)
                {
                    return count;
                }
                else
                {
                    switch (SearchMethod)
                    {
                        case SearchType.Scan:
                            ScanRequest scanReq = new ScanRequest
                            {
                                TableName = TableName,
                                Select = EnumMapper.Convert(SelectValues.Count),
                                ExclusiveStartKey = NextKey,
                                ScanFilter = Filter.ToConditions(SourceTable.Conversion),
                            };
                            if (this.FilterExpression != null && this.FilterExpression.IsSet)
                            {
                                this.FilterExpression.ApplyExpression(scanReq, SourceTable.Conversion);
                            }
                            if (scanReq.ScanFilter != null && scanReq.ScanFilter.Count > 1)
                                scanReq.ConditionalOperator = EnumMapper.Convert(ConditionalOperator);

                            if (this.TotalSegments != 0)
                            {
                                scanReq.TotalSegments = this.TotalSegments;
                                scanReq.Segment = this.Segment;
                            }
                            scanReq.BeforeRequestEvent += SourceTable.UserAgentRequestEventHandlerSync;

                            ScanResult scanResult = SourceTable.DDBClient.Scan(scanReq);
                            count = Matches.Count + scanResult.Count;
                            return count;
                        case SearchType.Query:
                            QueryRequest queryReq = new QueryRequest
                            {
                                TableName = TableName,
                                ConsistentRead = IsConsistentRead,
                                Select = EnumMapper.Convert(SelectValues.Count),
                                ExclusiveStartKey = NextKey,
                                ScanIndexForward = !IsBackwardSearch,
                                IndexName = IndexName
                            };

                            if (this.FilterExpression != null && this.FilterExpression.IsSet)
                            {
                                this.FilterExpression.ApplyExpression(queryReq, SourceTable.Conversion);
                            }

                            Dictionary<string, Condition> keyConditions, filterConditions;
                            SplitQueryFilter(Filter, SourceTable, queryReq.IndexName, out keyConditions, out filterConditions);
                            queryReq.KeyConditions = keyConditions;
                            queryReq.QueryFilter = filterConditions;

                            if (queryReq.QueryFilter != null && queryReq.QueryFilter.Count > 1)
                                queryReq.ConditionalOperator = EnumMapper.Convert(ConditionalOperator);

                            queryReq.BeforeRequestEvent += SourceTable.UserAgentRequestEventHandlerSync;

                            QueryResult queryResult = SourceTable.DDBClient.Query(queryReq);
                            count = Matches.Count + queryResult.Count;
                            return count;
                        default:
                            throw new InvalidOperationException("Unknown Search Method");
                    }
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Initiates the asynchronous execution of the Scan operation.
        /// <seealso cref="Amazon.DynamoDBv2.IAmazonDynamoDB"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the Scan operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<ScanResponse> ScanAsync(ScanRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ScanRequestMarshaller();
            var unmarshaller = ScanResponseUnmarshaller.Instance;

            return InvokeAsync<ScanRequest,ScanResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
コード例 #11
0
 /// <summary>
 /// <para>The <i>Scan</i> operation returns one or more items and item attributes by accessing every item in the table. To have Amazon DynamoDB
 /// return fewer items, you can provide a <i>ScanFilter</i> .</para> <para>If the total number of scanned items exceeds the maximum data set
 /// size limit of 1 MB, the scan stops and results are returned to the user with a <i>LastEvaluatedKey</i> to continue the scan in a subsequent
 /// operation. The results also include the number of items exceeding the limit. A scan can result in no table data meeting the filter criteria.
 /// </para> <para>The result set is eventually consistent. </para> <para>By default, <i>Scan</i> operations proceed sequentially; however, for
 /// faster performance on large tables, applications can perform a parallel <i>Scan</i> by specifying the <i>Segment</i> and
 /// <i>TotalSegments</i> parameters. For more information, see Parallel Scan in the <i>Amazon DynamoDB Developer Guide</i> .</para>
 /// </summary>
 /// 
 /// <param name="scanRequest">Container for the necessary parameters to execute the Scan service method on AmazonDynamoDBv2.</param>
 /// 
 /// <returns>The response from the Scan service method, as returned by AmazonDynamoDBv2.</returns>
 /// 
 /// <exception cref="ResourceNotFoundException"/>
 /// <exception cref="ProvisionedThroughputExceededException"/>
 /// <exception cref="InternalServerErrorException"/>
 public ScanResponse Scan(ScanRequest scanRequest)
 {
     IAsyncResult asyncResult = invokeScan(scanRequest, null, null, true);
     return EndScan(asyncResult);
 }
コード例 #12
0
 internal ScanPaginator(IAmazonDynamoDB client, ScanRequest request)
 {
     this._client  = client;
     this._request = request;
 }
コード例 #13
0
 /// <summary>
 /// The <i>Scan</i> operation returns one or more items and item attributes by accessing
 /// every item in a table or a secondary index. To have DynamoDB return fewer items, you
 /// can provide a <i>ScanFilter</i> operation.
 /// 
 ///  
 /// <para>
 /// If the total number of scanned items exceeds the maximum data set size limit of 1
 /// MB, the scan stops and results are returned to the user as a <i>LastEvaluatedKey</i>
 /// value to continue the scan in a subsequent operation. The results also include the
 /// number of items exceeding the limit. A scan can result in no table data meeting the
 /// filter criteria. 
 /// </para>
 ///  
 /// <para>
 /// The result set is eventually consistent. 
 /// </para>
 ///  
 /// <para>
 /// By default, <i>Scan</i> operations proceed sequentially; however, for faster performance
 /// on a large table or secondary index, applications can request a parallel <i>Scan</i>
 /// operation by providing the <i>Segment</i> and <i>TotalSegments</i> parameters. For
 /// more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#QueryAndScanParallelScan">Parallel
 /// Scan</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table containing the requested items; or, if you provide <code>IndexName</code>, the name of the table to which that index belongs.</param>
 /// <param name="scanFilter"><important> This is a legacy parameter, for backward compatibility. New applications should use <i>FilterExpression</i> instead. Do not combine legacy parameters and expression parameters in a single API call; otherwise, DynamoDB will return a <i>ValidationException</i> exception. </important> A condition that evaluates the scan results and returns only the desired values. <note>This parameter does not support attributes of type List or Map.</note> If you specify more than one condition in the <i>ScanFilter</i> map, then by default all of the conditions must evaluate to true. In other words, the conditions are ANDed together. (You can use the <i>ConditionalOperator</i> parameter to OR the conditions instead. If you do this, then at least one of the conditions must evaluate to true, rather than all of them.) Each <i>ScanFilter</i> element consists of an attribute name to compare, along with the following: <ul> <li> <i>AttributeValueList</i> - One or more values to evaluate against the supplied attribute. The number of values in the list depends on the operator specified in <i>ComparisonOperator</i> . For type Number, value comparisons are numeric. String value comparisons for greater than, equals, or less than are based on ASCII character code values. For example, <code>a</code> is greater than <code>A</code>, and <code>a</code> is greater than <code>B</code>. For a list of code values, see <a href="http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters">http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters</a>. For Binary, DynamoDB treats each byte of the binary data as unsigned when it compares binary values. For information on specifying data types in JSON, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataFormat.html">JSON Data Format</a> in the <i>Amazon DynamoDB Developer Guide</i>. </li> <li> <i>ComparisonOperator</i> - A comparator for evaluating attributes. For example, equals, greater than, less than, etc. The following comparison operators are available: <code>EQ | NE | LE | LT | GE | GT | NOT_NULL | NULL | CONTAINS | NOT_CONTAINS | BEGINS_WITH | IN | BETWEEN</code> For complete descriptions of all comparison operators, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html">Condition</a>. </li> </ul></param>
 /// 
 /// <returns>The response from the Scan service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException">
 /// The request rate is too high, or the request is too large, for the available throughput
 /// to accommodate. The AWS SDKs automatically retry requests that receive this exception;
 /// therefore, your request will eventually succeed, unless the request is too large or
 /// your retry queue is too large to finish. Reduce the frequency of requests by using
 /// the strategies listed in <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#APIRetries">Error
 /// Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
 /// The operation tried to access a nonexistent table or index. The resource might not
 /// be specified correctly, or its status might not be <code>ACTIVE</code>.
 /// </exception>
 public ScanResponse Scan(string tableName, Dictionary<string, Condition> scanFilter)
 {
     var request = new ScanRequest();
     request.TableName = tableName;
     request.ScanFilter = scanFilter;
     return Scan(request);
 }
コード例 #14
0
 IAsyncResult invokeScan(ScanRequest scanRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new ScanRequestMarshaller().Marshall(scanRequest);
     var unmarshaller = ScanResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
コード例 #15
0
        public void Get_all_items_with_AWSSDK()
        {
            db.PutItem(new Todo { Id = 1, Content = "TODO 1", Order = 1 });

            var request = new ScanRequest
            {
                TableName = "Todo",
                Limit = 1000,
            };

            var allTodos = new List<Todo>();
            ScanResponse response = null;
            do
            {
                if (response != null)
                    request.ExclusiveStartKey = response.LastEvaluatedKey;

                response = awsDb.Scan(request);

                foreach (var item in response.Items)
                {
                    var todo = new Todo
                    {
                        Id = Convert.ToInt64(item["Id"].N),
                        Content = item["Content"].S,
                        Order = Convert.ToInt32(item["Order"].N),
                        Done = item["Done"].BOOL,
                    };
                    allTodos.Add(todo);
                }

            } while (response.LastEvaluatedKey != null && response.LastEvaluatedKey.Count > 0);

            allTodos.PrintDump();
        }
コード例 #16
0
        /// <summary>
        /// Initiates the asynchronous execution of the Scan operation.
        /// <seealso cref="Amazon.DynamoDBv2.IAmazonDynamoDB.Scan"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the Scan operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
		public async Task<ScanResponse> ScanAsync(ScanRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ScanRequestMarshaller();
            var unmarshaller = ScanResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, ScanRequest, ScanResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
コード例 #17
0
        public void SearchSamples()
        {
            RemoveTables();
            CreateLSITable();
            TableUtils.WaitUntilTableActive("SampleTable", TestClient);

            {
                // Create items to put into first table
                Dictionary<string, AttributeValue> item1 = new Dictionary<string, AttributeValue>();
                item1["Author"] = new AttributeValue { S = "Mark Twain" };
                item1["Title"] = new AttributeValue { S = "A Connecticut Yankee in King Arthur's Court" };
                item1["Pages"] = new AttributeValue { N = "575" };
                Dictionary<string, AttributeValue> item2 = new Dictionary<string, AttributeValue>();
                item2["Author"] = new AttributeValue { S = "Booker Taliaferro Washington" };
                item2["Title"] = new AttributeValue { S = "My Larger Education" };
                item2["Pages"] = new AttributeValue { N = "313" };
                item2["Year"] = new AttributeValue { N = "1911" };

                // Construct write-request for first table
                List<WriteRequest> sampleTableItems = new List<WriteRequest>();
                sampleTableItems.Add(new WriteRequest
                {
                    PutRequest = new PutRequest { Item = item1 }
                });
                sampleTableItems.Add(new WriteRequest
                {
                    PutRequest = new PutRequest { Item = item2 }
                });
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();
                client.BatchWriteItem(new BatchWriteItemRequest
                {
                    RequestItems = new Dictionary<string, List<WriteRequest>>
                    {
                        { "SampleTable", sampleTableItems }
                    }
                });

                PutSample();
            }


            {
                #region Query Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define item hash-key to be string value "Mark Twain"
                AttributeValue hashKey = new AttributeValue { S = "Mark Twain" };

                // Define query condition to search for range-keys that begin with the string "The Adventures"
                Condition condition = new Condition
                {
                    ComparisonOperator = "BEGINS_WITH",
                    AttributeValueList = new List<AttributeValue>
                    {
                        new AttributeValue { S = "The Adventures" }
                    }
                };

                // Create the key conditions from hashKey and condition
                Dictionary<string, Condition> keyConditions = new Dictionary<string, Condition>
                {
                    // Hash key condition. ComparisonOperator must be "EQ".
                    { 
                        "Author",
                        new Condition
                        {
                            ComparisonOperator = "EQ",
                            AttributeValueList = new List<AttributeValue> { hashKey }
                        }
                    },
                    // Range key condition
                    {
                        "Title",
                        condition
                    }
                };

                // Define marker variable
                Dictionary<string, AttributeValue> startKey = null;

                do
                {
                    // Create Query request
                    QueryRequest request = new QueryRequest
                    {
                        TableName = "SampleTable",
                        ExclusiveStartKey = startKey,
                        KeyConditions = keyConditions
                    };

                    // Issue request
                    var result = client.Query(request);

                    // View all returned items
                    List<Dictionary<string, AttributeValue>> items = result.Items;
                    foreach (Dictionary<string, AttributeValue> item in items)
                    {
                        Console.WriteLine("Item:");
                        foreach (var keyValuePair in item)
                        {
                            Console.WriteLine("{0} : S={1}, N={2}, SS=[{3}], NS=[{4}]",
                                keyValuePair.Key,
                                keyValuePair.Value.S,
                                keyValuePair.Value.N,
                                string.Join(", ", keyValuePair.Value.SS ?? new List<string>()),
                                string.Join(", ", keyValuePair.Value.NS ?? new List<string>()));
                        }
                    }

                    // Set marker variable
                    startKey = result.LastEvaluatedKey;
                } while (startKey != null && startKey.Count > 0);

                #endregion
            }

            {
                #region Query Local Secondary Index Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define item hash-key to be string value "Mark Twain"
                AttributeValue hashKey = new AttributeValue { S = "Mark Twain" };

                // Define query condition to search for range-keys ("Year", in "YearsIndex") that are less than 1900
                Condition condition = new Condition
                {
                    ComparisonOperator = "LT",
                    AttributeValueList = new List<AttributeValue>
                    {
                        new AttributeValue { N = "1900" }
                    }
                };

                // Create the key conditions from hashKey and condition
                Dictionary<string, Condition> keyConditions = new Dictionary<string, Condition>
                {
                    // Hash key condition. ComparisonOperator must be "EQ".
                    { 
                        "Author",
                        new Condition
                        {
                            ComparisonOperator = "EQ",
                            AttributeValueList = new List<AttributeValue> { hashKey }
                        }
                    },
                    // Range key condition
                    {
                        "Year", // Reference the correct range key when using indexes
                        condition
                    }
                };

                // Define marker variable
                Dictionary<string, AttributeValue> startKey = null;

                do
                {
                    // Create Query request
                    QueryRequest request = new QueryRequest
                    {
                        TableName = "SampleTable",
                        ExclusiveStartKey = startKey,
                        KeyConditions = keyConditions,
                        IndexName = "YearsIndex" // Specify the index to query against
                    };

                    // Issue request
                    var result = client.Query(request);

                    // View all returned items
                    List<Dictionary<string, AttributeValue>> items = result.Items;
                    foreach (Dictionary<string, AttributeValue> item in items)
                    {
                        Console.WriteLine("Item:");
                        foreach (var keyValuePair in item)
                        {
                            Console.WriteLine("{0} : S={1}, N={2}, SS=[{3}], NS=[{4}]",
                                keyValuePair.Key,
                                keyValuePair.Value.S,
                                keyValuePair.Value.N,
                                string.Join(", ", keyValuePair.Value.SS ?? new List<string>()),
                                string.Join(", ", keyValuePair.Value.NS ?? new List<string>()));
                        }
                    }

                    // Set marker variable
                    startKey = result.LastEvaluatedKey;
                } while (startKey != null && startKey.Count > 0);

                #endregion
            }

            {
                #region Scan Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define scan conditions
                Dictionary<string, Condition> conditions = new Dictionary<string, Condition>();

                // Title attribute should contain the string "Adventures"
                Condition titleCondition = new Condition();
                titleCondition.ComparisonOperator = ComparisonOperator.CONTAINS;
                titleCondition.AttributeValueList.Add(new AttributeValue { S = "Adventures" });
                conditions["Title"] = titleCondition;

                // Pages attributes must be greater-than the numeric value "200"
                Condition pagesCondition = new Condition();
                pagesCondition.ComparisonOperator = ComparisonOperator.GT;;
                pagesCondition.AttributeValueList.Add(new AttributeValue { N = "200" });
                conditions["Pages"] = pagesCondition;


                // Define marker variable
                Dictionary<string, AttributeValue> startKey = null;

                do
                {
                    // Create Scan request
                    ScanRequest request = new ScanRequest
                    {
                        TableName = "SampleTable",
                        ExclusiveStartKey = startKey,
                        ScanFilter = conditions
                    };

                    // Issue request
                    ScanResult result = client.Scan(request);

                    // View all returned items
                    List<Dictionary<string, AttributeValue>> items = result.Items;
                    foreach (Dictionary<string, AttributeValue> item in items)
                    {
                        Console.WriteLine("Item:");
                        foreach (var keyValuePair in item)
                        {
                            Console.WriteLine("{0} : S={1}, N={2}, SS=[{3}], NS=[{4}]",
                                keyValuePair.Key,
                                keyValuePair.Value.S,
                                keyValuePair.Value.N,
                                string.Join(", ", keyValuePair.Value.SS ?? new List<string>()),
                                string.Join(", ", keyValuePair.Value.NS ?? new List<string>()));
                        }
                    }

                    // Set marker variable
                    startKey = result.LastEvaluatedKey;
                } while (startKey != null && startKey.Count > 0);

                #endregion
            }

            {
                // Create lots of items to put into first table
                var table = Amazon.DynamoDBv2.DocumentModel.Table.LoadTable(TestClient, "SampleTable");
                var batchWrite = table.CreateBatchWrite();
                for (int i = 0; i < 100; i++)
                {
                    var document = new Amazon.DynamoDBv2.DocumentModel.Document();
                    document["Author"] = "FakeAuthor" + i;
                    document["Title"] = "Book" + i;
                    document["Pages"] = (180 + i);
                    document["Year"] = 1900 + i;
                    batchWrite.AddDocumentToPut(document);
                }
                batchWrite.Execute();
            }


            {
                #region Parallel Scan Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define scan conditions
                Dictionary<string, Condition> conditions = new Dictionary<string, Condition>();

                // Pages attributes must be greater-than the numeric value "200"
                Condition pagesCondition = new Condition();
                pagesCondition.ComparisonOperator = ComparisonOperator.GT;
                pagesCondition.AttributeValueList.Add(new AttributeValue { N = "200" });
                conditions["Pages"] = pagesCondition;

                // Setup 10 simultaneous threads, each thread calling Scan operation
                // with its own segment value.
                int totalSegments = 10;
                Parallel.For(0, totalSegments, segment =>
                {
                    // Define marker variable
                    Dictionary<string, AttributeValue> startKey = null;

                    do
                    {
                        // Create Scan request
                        ScanRequest request = new ScanRequest
                        {
                            TableName = "SampleTable",
                            ExclusiveStartKey = startKey,
                            ScanFilter = conditions,
                            // Total segments to split the table into
                            TotalSegments = totalSegments,
                            // Current segment to scan
                            Segment = segment
                        };

                        // Issue request
                        var result = client.Scan(request);

                        // Write returned items to file
                        string path = string.Format("ParallelScan-{0}-of-{1}.txt", totalSegments, segment);
                        List<Dictionary<string, AttributeValue>> items = result.Items;
                        using (Stream stream = File.OpenWrite(path))
                        using (StreamWriter writer = new StreamWriter(stream))
                        {
                            foreach (Dictionary<string, AttributeValue> item in items)
                            {
                                writer.WriteLine("Item:");
                                foreach (var keyValuePair in item)
                                {
                                    writer.WriteLine("{0} : S={1}, N={2}, SS=[{3}], NS=[{4}]",
                                        keyValuePair.Key,
                                        keyValuePair.Value.S,
                                        keyValuePair.Value.N,
                                        string.Join(", ", keyValuePair.Value.SS ?? new List<string>()),
                                        string.Join(", ", keyValuePair.Value.NS ?? new List<string>()));
                                }
                            }
                        }

                        // Set marker variable
                        startKey = result.LastEvaluatedKey;
                    } while (startKey != null && startKey.Count > 0);
                });

                #endregion
            }

        }
コード例 #18
0
 /// <summary>
 /// Initiates the asynchronous execution of the Scan operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the Scan operation on AmazonDynamoDBClient.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public void ScanAsync(ScanRequest request, AmazonServiceCallback<ScanRequest, ScanResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new ScanRequestMarshaller();
     var unmarshaller = ScanResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<ScanRequest,ScanResponse> responseObject 
                     = new AmazonServiceResult<ScanRequest,ScanResponse>((ScanRequest)req, (ScanResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<ScanRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
コード例 #19
0
 /// <summary>
 /// The <i>Scan</i> operation returns one or more items and item attributes by accessing
 /// every item in a table or a secondary index. To have DynamoDB return fewer items, you
 /// can provide a <i>ScanFilter</i> operation.
 /// 
 ///  
 /// <para>
 /// If the total number of scanned items exceeds the maximum data set size limit of 1
 /// MB, the scan stops and results are returned to the user as a <i>LastEvaluatedKey</i>
 /// value to continue the scan in a subsequent operation. The results also include the
 /// number of items exceeding the limit. A scan can result in no table data meeting the
 /// filter criteria. 
 /// </para>
 ///  
 /// <para>
 /// The result set is eventually consistent. 
 /// </para>
 ///  
 /// <para>
 /// By default, <i>Scan</i> operations proceed sequentially; however, for faster performance
 /// on a large table or secondary index, applications can request a parallel <i>Scan</i>
 /// operation by providing the <i>Segment</i> and <i>TotalSegments</i> parameters. For
 /// more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#QueryAndScanParallelScan">Parallel
 /// Scan</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table containing the requested items; or, if you provide <code>IndexName</code>, the name of the table to which that index belongs.</param>
 /// <param name="attributesToGet"><important>There is a newer parameter available. Use <i>ProjectionExpression</i> instead. Note that if you use <i>AttributesToGet</i> and <i>ProjectionExpression</i> at the same time, DynamoDB will return a <i>ValidationException</i> exception. This parameter allows you to retrieve attributes of type List or Map; however, it cannot retrieve individual elements within a List or a Map.</important> The names of one or more attributes to retrieve. If no attribute names are provided, then all attributes will be returned. If any of the requested attributes are not found, they will not appear in the result. Note that <i>AttributesToGet</i> has no effect on provisioned throughput consumption. DynamoDB determines capacity units consumed based on item size, not on the amount of data that is returned to an application.</param>
 /// <param name="scanFilter"><important> There is a newer parameter available. Use <i>FilterExpression</i> instead. Note that if you use <i>ScanFilter</i> and <i>FilterExpression</i> at the same time, DynamoDB will return a <i>ValidationException</i> exception. </important> A condition that evaluates the scan results and returns only the desired values. <note>This parameter does not support attributes of type List or Map.</note> If you specify more than one condition in the <i>ScanFilter</i> map, then by default all of the conditions must evaluate to true. In other words, the conditions are ANDed together. (You can use the <i>ConditionalOperator</i> parameter to OR the conditions instead. If you do this, then at least one of the conditions must evaluate to true, rather than all of them.) Each <i>ScanFilter</i> element consists of an attribute name to compare, along with the following: <ul> <li> <i>AttributeValueList</i> - One or more values to evaluate against the supplied attribute. The number of values in the list depends on the operator specified in <i>ComparisonOperator</i> . For type Number, value comparisons are numeric. String value comparisons for greater than, equals, or less than are based on ASCII character code values. For example, <code>a</code> is greater than <code>A</code>, and <code>a</code> is greater than <code>B</code>. For a list of code values, see <a href="http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters">http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters</a>. For Binary, DynamoDB treats each byte of the binary data as unsigned when it compares binary values. For information on specifying data types in JSON, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataFormat.html">JSON Data Format</a> in the <i>Amazon DynamoDB Developer Guide</i>. </li> <li> <i>ComparisonOperator</i> - A comparator for evaluating attributes. For example, equals, greater than, less than, etc. The following comparison operators are available: <code>EQ | NE | LE | LT | GE | GT | NOT_NULL | NULL | CONTAINS | NOT_CONTAINS | BEGINS_WITH | IN | BETWEEN</code> For complete descriptions of all comparison operators, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html">Condition</a>. </li> </ul></param>
 /// 
 /// <returns>The response from the Scan service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException">
 /// The request rate is too high, or the request is too large, for the available throughput
 /// to accommodate. The AWS SDKs automatically retry requests that receive this exception;
 /// therefore, your request will eventually succeed, unless the request is too large or
 /// your retry queue is too large to finish. Reduce the frequency of requests by using
 /// the strategies listed in <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#APIRetries">Error
 /// Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
 /// The operation tried to access a nonexistent table or index. The resource might not
 /// be specified correctly, or its status might not be <code>ACTIVE</code>.
 /// </exception>
 public void ScanAsync(string tableName, List<string> attributesToGet, Dictionary<string, Condition> scanFilter, AmazonServiceCallback<ScanRequest, ScanResponse> callback, AsyncOptions options = null)
 {
     var request = new ScanRequest();
     request.TableName = tableName;
     request.AttributesToGet = attributesToGet;
     request.ScanFilter = scanFilter;
     ScanAsync(request, callback, options);
 }
コード例 #20
0
 /// <summary>
 /// The <i>Scan</i> operation returns one or more items and item attributes by accessing
 /// every item in a table or a secondary index. To have DynamoDB return fewer items, you
 /// can provide a <i>ScanFilter</i> operation.
 /// 
 ///  
 /// <para>
 /// If the total number of scanned items exceeds the maximum data set size limit of 1
 /// MB, the scan stops and results are returned to the user as a <i>LastEvaluatedKey</i>
 /// value to continue the scan in a subsequent operation. The results also include the
 /// number of items exceeding the limit. A scan can result in no table data meeting the
 /// filter criteria. 
 /// </para>
 ///  
 /// <para>
 /// The result set is eventually consistent. 
 /// </para>
 ///  
 /// <para>
 /// By default, <i>Scan</i> operations proceed sequentially; however, for faster performance
 /// on a large table or secondary index, applications can request a parallel <i>Scan</i>
 /// operation by providing the <i>Segment</i> and <i>TotalSegments</i> parameters. For
 /// more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#QueryAndScanParallelScan">Parallel
 /// Scan</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table containing the requested items; or, if you provide <code>IndexName</code>, the name of the table to which that index belongs.</param>
 /// <param name="attributesToGet"><important>This is a legacy parameter, for backward compatibility. New applications should use <i>ProjectionExpression</i> instead. Do not combine legacy parameters and expression parameters in a single API call; otherwise, DynamoDB will return a <i>ValidationException</i> exception. This parameter allows you to retrieve attributes of type List or Map; however, it cannot retrieve individual elements within a List or a Map.</important> The names of one or more attributes to retrieve. If no attribute names are provided, then all attributes will be returned. If any of the requested attributes are not found, they will not appear in the result. Note that <i>AttributesToGet</i> has no effect on provisioned throughput consumption. DynamoDB determines capacity units consumed based on item size, not on the amount of data that is returned to an application.</param>
 /// <param name="scanFilter"><important> This is a legacy parameter, for backward compatibility. New applications should use <i>FilterExpression</i> instead. Do not combine legacy parameters and expression parameters in a single API call; otherwise, DynamoDB will return a <i>ValidationException</i> exception. </important> A condition that evaluates the scan results and returns only the desired values. <note>This parameter does not support attributes of type List or Map.</note> If you specify more than one condition in the <i>ScanFilter</i> map, then by default all of the conditions must evaluate to true. In other words, the conditions are ANDed together. (You can use the <i>ConditionalOperator</i> parameter to OR the conditions instead. If you do this, then at least one of the conditions must evaluate to true, rather than all of them.) Each <i>ScanFilter</i> element consists of an attribute name to compare, along with the following: <ul> <li> <i>AttributeValueList</i> - One or more values to evaluate against the supplied attribute. The number of values in the list depends on the operator specified in <i>ComparisonOperator</i> . For type Number, value comparisons are numeric. String value comparisons for greater than, equals, or less than are based on ASCII character code values. For example, <code>a</code> is greater than <code>A</code>, and <code>a</code> is greater than <code>B</code>. For a list of code values, see <a href="http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters">http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters</a>. For Binary, DynamoDB treats each byte of the binary data as unsigned when it compares binary values. For information on specifying data types in JSON, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataFormat.html">JSON Data Format</a> in the <i>Amazon DynamoDB Developer Guide</i>. </li> <li> <i>ComparisonOperator</i> - A comparator for evaluating attributes. For example, equals, greater than, less than, etc. The following comparison operators are available: <code>EQ | NE | LE | LT | GE | GT | NOT_NULL | NULL | CONTAINS | NOT_CONTAINS | BEGINS_WITH | IN | BETWEEN</code> For complete descriptions of all comparison operators, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html">Condition</a>. </li> </ul></param>
 /// 
 /// <returns>The response from the Scan service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException">
 /// The request rate is too high, or the request is too large, for the available throughput
 /// to accommodate. The AWS SDKs automatically retry requests that receive this exception;
 /// therefore, your request will eventually succeed, unless the request is too large or
 /// your retry queue is too large to finish. Reduce the frequency of requests by using
 /// the strategies listed in <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#APIRetries">Error
 /// Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
 /// The operation tried to access a nonexistent table or index. The resource might not
 /// be specified correctly, or its status might not be <code>ACTIVE</code>.
 /// </exception>
 public ScanResponse Scan(string tableName, List<string> attributesToGet, Dictionary<string, Condition> scanFilter)
 {
     var request = new ScanRequest();
     request.TableName = tableName;
     request.AttributesToGet = attributesToGet;
     request.ScanFilter = scanFilter;
     return Scan(request);
 }
コード例 #21
0
ファイル: DataHelper.cs プロジェクト: EchoPan/BreadcrumbAPI
        public List<Dictionary<string, object>> GetPinWithUserIDs(List<string> userIDs, double since, int takeCnt)
        {
            List<Dictionary<string, object>> retval = new List<Dictionary<string, object>>();
            Dictionary<string, object> tmpObject = null;

            var config = new AmazonDynamoDBConfig();
            config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"];
            client = new AmazonDynamoDBClient(config);
            List<AttributeValue> users = new List<AttributeValue>();
            foreach (string item in userIDs)
            {
                users.Add(new AttributeValue() { S = item });
            }
            try
            {
                ScanRequest sreq = new ScanRequest()
                {
                    TableName = "Pin",
                    ScanFilter = new Dictionary<string, Condition>()
                    {
                        {   "Owner",
                            new Condition
                            {
                                ComparisonOperator = ComparisonOperator.IN,
                                AttributeValueList = users
                            }
                        },
                        {
                            "PinDate",
                            new Condition()
                            {
                                ComparisonOperator = ComparisonOperator.LT,
                                AttributeValueList = new List<AttributeValue> { new AttributeValue { N = since.ToString() } }
                            }
                        }
                    }
                };

                var response = client.Scan(sreq);
                foreach (var item in response.Items)
                {
                    tmpObject = new Dictionary<string, object>();
                    tmpObject.Add("Title", item["Title"].S);
                    tmpObject.Add("Owner", item["Owner"].S);
                    tmpObject.Add("OwnerName", item["UserName"].S);
                    tmpObject.Add("OwnerHeadshot", item["HeadshotURL"].S);
                    tmpObject.Add("Latitude", item["Latitude"].S);
                    tmpObject.Add("Longitude", item["Longitude"].S);
                    tmpObject.Add("PinDate", Convert.ToDouble(item["PinDate"].N));
                    tmpObject.Add("Images", item["Images"].SS);
                    retval.Add(tmpObject);
                }
                retval = retval.OrderByDescending(a => a["PinDate"]).ToList<Dictionary<string, object>>();
            }
            catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); }
            catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
            catch (Exception e) { Console.WriteLine(e.Message); }

            return retval;
        }
コード例 #22
0
 /// <summary>
 /// Initiates the asynchronous execution of the Scan operation.
 /// <seealso cref="Amazon.DynamoDBv2.AmazonDynamoDB.Scan"/>
 /// </summary>
 /// 
 /// <param name="scanRequest">Container for the necessary parameters to execute the Scan operation on AmazonDynamoDBv2.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// 
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndScan
 ///         operation.</returns>
 public IAsyncResult BeginScan(ScanRequest scanRequest, AsyncCallback callback, object state)
 {
     return invokeScan(scanRequest, callback, state, false);
 }
コード例 #23
0
		internal ScanResponse Scan(ScanRequest request)
        {
            var task = ScanAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
コード例 #24
0
 /// <summary>
 /// Paginator for Scan operation
 ///</summary>
 public IScanPaginator Scan(ScanRequest request)
 {
     return(new ScanPaginator(this.client, request));
 }
コード例 #25
0
ファイル: Expression.cs プロジェクト: rajdotnet/aws-sdk-net
 internal void ApplyExpression(ScanRequest request, DynamoDBEntryConversion conversion)
 {
     request.FilterExpression = this.ExpressionStatement;
     request.ExpressionAttributeNames = new Dictionary<string, string>(this.ExpressionAttributeNames);
     request.ExpressionAttributeValues = ConvertToAttributeValues(this.ExpressionAttributeValues, conversion);
 }
コード例 #26
0
ファイル: Search.cs プロジェクト: yridesconix/aws-sdk-net
        internal List<Document> GetNextSetHelper(bool isAsync)
        {
            List<Document> ret = new List<Document>();

            if (!IsDone)
            {
                switch (SearchMethod)
                {
                    case SearchType.Scan:
                        ScanRequest scanReq = new ScanRequest
                        {
                            ExclusiveStartKey = NextKey,
                            Limit = Limit,
                            TableName = TableName,
                            AttributesToGet = AttributesToGet,
                            ScanFilter = Filter.ToConditions(SourceTable.Conversion),
                            Select = EnumMapper.Convert(Select),
                        };
                        if (this.FilterExpression != null && this.FilterExpression.IsSet)
                            this.FilterExpression.ApplyExpression(scanReq, SourceTable.Conversion);
                        if (scanReq.ScanFilter != null && scanReq.ScanFilter.Count > 1)
                            scanReq.ConditionalOperator = EnumMapper.Convert(ConditionalOperator);
                        Common.ConvertAttributesToGetToProjectionExpression(scanReq);

                        if (this.TotalSegments != 0)
                        {
                            scanReq.TotalSegments = this.TotalSegments;
                            scanReq.Segment = this.Segment;
                        }

                        scanReq.BeforeRequestEvent += isAsync ?
                            new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerAsync) :
                            new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerSync);

                        ScanResult scanResult = SourceTable.DDBClient.Scan(scanReq);
                        foreach (var item in scanResult.Items)
                        {
                            Document doc = Document.FromAttributeMap(item);
                            ret.Add(doc);
                            if (CollectResults)
                            {
                            Matches.Add(doc);
                        }
                        }
                        NextKey = scanResult.LastEvaluatedKey;
                        if (NextKey == null || NextKey.Count == 0)
                        {
                            IsDone = true;
                        }
                        return ret;
                    case SearchType.Query:
                        QueryRequest queryReq = new QueryRequest
                        {
                            TableName = TableName,
                            ConsistentRead = IsConsistentRead,
                            Select = EnumMapper.Convert(Select),
                            ExclusiveStartKey = NextKey,
                            Limit = Limit,
                            ScanIndexForward = !IsBackwardSearch,
                            AttributesToGet = AttributesToGet,
                            IndexName = IndexName,
                        };

                        if (this.FilterExpression != null && this.FilterExpression.IsSet)
                        {
                            this.FilterExpression.ApplyExpression(queryReq, SourceTable.Conversion);
                        }

                        Dictionary<string, Condition> keyConditions, filterConditions;
                        SplitQueryFilter(Filter, SourceTable, queryReq.IndexName, out keyConditions, out filterConditions);
                        queryReq.KeyConditions = keyConditions;
                        queryReq.QueryFilter = filterConditions;
                        Common.ConvertAttributesToGetToProjectionExpression(queryReq);

                        if (queryReq.QueryFilter != null && queryReq.QueryFilter.Count > 1)
                            queryReq.ConditionalOperator = EnumMapper.Convert(ConditionalOperator);

                        queryReq.BeforeRequestEvent += isAsync ?
                            new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerAsync) :
                            new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerSync);

                        QueryResult queryResult = SourceTable.DDBClient.Query(queryReq);
                        foreach (var item in queryResult.Items)
                        {
                            Document doc = Document.FromAttributeMap(item);
                            ret.Add(doc);
                            if (CollectResults)
                            {
                                Matches.Add(doc);
                            }
                        }
                        NextKey = queryResult.LastEvaluatedKey;
                        if (NextKey == null || NextKey.Count == 0)
                        {
                            IsDone = true;
                        }
                        return ret;
                    default:
                        throw new InvalidOperationException("Unknown Search Method");
                }
            }

            return ret;
        }
コード例 #27
0
        /// <summary>
        /// Initiates the asynchronous execution of the Scan operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the Scan operation on AmazonDynamoDBClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndScan
        ///         operation.</returns>
        public IAsyncResult BeginScan(ScanRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new ScanRequestMarshaller();
            var unmarshaller = ScanResponseUnmarshaller.Instance;

            return BeginInvoke<ScanRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
コード例 #28
0
        internal ScanResponse Scan(ScanRequest request)
        {
            var marshaller = new ScanRequestMarshaller();
            var unmarshaller = ScanResponseUnmarshaller.Instance;

            return Invoke<ScanRequest,ScanResponse>(request, marshaller, unmarshaller);
        }
コード例 #29
0
 private void FindProductsForPriceLessThanZeroHelper(Dictionary<string,AttributeValue> lastKeyEvaluated)
 {
     var request = new ScanRequest
     {
         TableName = "ProductCatalog",
         Limit = 2,
         ExclusiveStartKey = lastKeyEvaluated,
         ExpressionAttributeValues = new Dictionary<string,AttributeValue> {
                 {":val", new AttributeValue { N = "0" }}
         },
         FilterExpression = "Price < :val",
         
         ProjectionExpression = "Id, Title, Price"
     };
     
     _client.ScanAsync(request,(result)=>{
         foreach (Dictionary<string, AttributeValue> item
                  in result.Response.Items)
         {
                 resultText.text =("\nScanThreadTableUsePaging - printing.....");
                 PrintItem(item);
         }
         lastKeyEvaluated = result.Response.LastEvaluatedKey;
         if(lastKeyEvaluated != null && lastKeyEvaluated.Count != 0)
         {
             FindProductsForPriceLessThanZeroHelper(lastKeyEvaluated);
         }
     });
 }
コード例 #30
0
ファイル: Search.cs プロジェクト: rguarino4/aws-sdk-net
        private int GetCount()
        {
            if (IsDone && CollectResults)
            {
                return Matches.Count;
            }
            else
            {
                if (count != -1)
                {
                    return count;
                }
                else
                {
                    switch (SearchMethod)
                    {
                        case SearchType.Scan:
                            ScanRequest scanReq = new ScanRequest
                            {
                                TableName = TableName,
                                Select = EnumToStringMapper.Convert(SelectValues.Count),
                                ExclusiveStartKey = NextKey,
                                ScanFilter = Filter,
                            };

                            if (this.TotalSegments != 0)
                            {
                                scanReq.TotalSegments = this.TotalSegments;
                                scanReq.Segment = this.Segment;
                            }
                            scanReq.BeforeRequestEvent += SourceTable.UserAgentRequestEventHandlerSync;

                            ScanResult scanResult = SourceTable.DDBClient.Scan(scanReq).ScanResult;
                            count = Matches.Count + scanResult.Count;
                            return count;
                        case SearchType.Query:
                            QueryRequest queryReq = new QueryRequest
                            {
                                TableName = TableName,
                                ConsistentRead = IsConsistentRead,
                                Select = EnumToStringMapper.Convert(SelectValues.Count),
                                ExclusiveStartKey = NextKey,
                                ScanIndexForward = !IsBackwardSearch,
                                KeyConditions = Filter,
                                IndexName = IndexName
                            };
                            queryReq.BeforeRequestEvent += SourceTable.UserAgentRequestEventHandlerSync;

                            QueryResult queryResult = SourceTable.DDBClient.Query(queryReq).QueryResult;
                            count = Matches.Count + queryResult.Count;
                            return count;
                        default:
                            throw new InvalidOperationException("Unknown Search Method");
                    }
                }
            }
        }
コード例 #31
0
 /// <summary>
 /// The <i>Scan</i> operation returns one or more items and item attributes by accessing
 /// every item in a table or a secondary index. To have DynamoDB return fewer items, you
 /// can provide a <i>ScanFilter</i> operation.
 /// 
 ///  
 /// <para>
 /// If the total number of scanned items exceeds the maximum data set size limit of 1
 /// MB, the scan stops and results are returned to the user as a <i>LastEvaluatedKey</i>
 /// value to continue the scan in a subsequent operation. The results also include the
 /// number of items exceeding the limit. A scan can result in no table data meeting the
 /// filter criteria. 
 /// </para>
 ///  
 /// <para>
 /// By default, <i>Scan</i> operations proceed sequentially; however, for faster performance
 /// on a large table or secondary index, applications can request a parallel <i>Scan</i>
 /// operation by providing the <i>Segment</i> and <i>TotalSegments</i> parameters. For
 /// more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#QueryAndScanParallelScan">Parallel
 /// Scan</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 ///  
 /// <para>
 /// By default, <i>Scan</i> uses eventually consistent reads when acessing the data in
 /// the table or local secondary index. However, you can use strongly consistent reads
 /// instead by setting the <i>ConsistentRead</i> parameter to <i>true</i>.
 /// </para>
 /// </summary>
 /// <param name="tableName">The name of the table containing the requested items; or, if you provide <code>IndexName</code>, the name of the table to which that index belongs.</param>
 /// <param name="attributesToGet"><important>This is a legacy parameter, for backward compatibility. New applications should use <i>ProjectionExpression</i> instead. Do not combine legacy parameters and expression parameters in a single API call; otherwise, DynamoDB will return a <i>ValidationException</i> exception. This parameter allows you to retrieve attributes of type List or Map; however, it cannot retrieve individual elements within a List or a Map.</important> The names of one or more attributes to retrieve. If no attribute names are provided, then all attributes will be returned. If any of the requested attributes are not found, they will not appear in the result. Note that <i>AttributesToGet</i> has no effect on provisioned throughput consumption. DynamoDB determines capacity units consumed based on item size, not on the amount of data that is returned to an application.</param>
 /// <param name="scanFilter"><important> This is a legacy parameter, for backward compatibility. New applications should use <i>FilterExpression</i> instead. Do not combine legacy parameters and expression parameters in a single API call; otherwise, DynamoDB will return a <i>ValidationException</i> exception. </important> A condition that evaluates the scan results and returns only the desired values. <note>This parameter does not support attributes of type List or Map.</note> If you specify more than one condition in the <i>ScanFilter</i> map, then by default all of the conditions must evaluate to true. In other words, the conditions are ANDed together. (You can use the <i>ConditionalOperator</i> parameter to OR the conditions instead. If you do this, then at least one of the conditions must evaluate to true, rather than all of them.) Each <i>ScanFilter</i> element consists of an attribute name to compare, along with the following: <ul> <li> <i>AttributeValueList</i> - One or more values to evaluate against the supplied attribute. The number of values in the list depends on the operator specified in <i>ComparisonOperator</i> . For type Number, value comparisons are numeric. String value comparisons for greater than, equals, or less than are based on ASCII character code values. For example, <code>a</code> is greater than <code>A</code>, and <code>a</code> is greater than <code>B</code>. For a list of code values, see <a href="http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters">http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters</a>. For Binary, DynamoDB treats each byte of the binary data as unsigned when it compares binary values. For information on specifying data types in JSON, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataFormat.html">JSON Data Format</a> in the <i>Amazon DynamoDB Developer Guide</i>. </li> <li> <i>ComparisonOperator</i> - A comparator for evaluating attributes. For example, equals, greater than, less than, etc. The following comparison operators are available: <code>EQ | NE | LE | LT | GE | GT | NOT_NULL | NULL | CONTAINS | NOT_CONTAINS | BEGINS_WITH | IN | BETWEEN</code> For complete descriptions of all comparison operators, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html">Condition</a>. </li> </ul></param>
 /// <param name="cancellationToken">
 ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
 /// </param>
 /// 
 /// <returns>The response from the Scan service method, as returned by DynamoDB.</returns>
 /// <exception cref="Amazon.DynamoDBv2.Model.InternalServerErrorException">
 /// An error occurred on the server side.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException">
 /// Your request rate is too high. The AWS SDKs for DynamoDB automatically retry requests
 /// that receive this exception. Your request is eventually successful, unless your retry
 /// queue is too large to finish. Reduce the frequency of requests and use exponential
 /// backoff. For more information, go to <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#APIRetries">Error
 /// Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </exception>
 /// <exception cref="Amazon.DynamoDBv2.Model.ResourceNotFoundException">
 /// The operation tried to access a nonexistent table or index. The resource might not
 /// be specified correctly, or its status might not be <code>ACTIVE</code>.
 /// </exception>
 public Task<ScanResponse> ScanAsync(string tableName, List<string> attributesToGet, Dictionary<string, Condition> scanFilter, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new ScanRequest();
     request.TableName = tableName;
     request.AttributesToGet = attributesToGet;
     request.ScanFilter = scanFilter;
     return ScanAsync(request, cancellationToken);
 }
コード例 #32
0
	private void FindAllStickers(Dictionary<string,AttributeValue> lastKeyEvaluated)
	{
		var request = new ScanRequest
		{
			TableName = "CaptainCillianStickers",
			ExclusiveStartKey = lastKeyEvaluated
		};

		_client.ScanAsync(request,(result)=>{
			foreach (Dictionary<string, AttributeValue> item
				in result.Response.Items)
			{
				// New sticker found, add info to new sticker object
				addItem(item);
			}
			lastKeyEvaluated = result.Response.LastEvaluatedKey;
			if(lastKeyEvaluated != null && lastKeyEvaluated.Count != 0)
			{
				FindAllStickers(lastKeyEvaluated);
			} else {
				retrievedAllFromDatabase = true;
			}
		});
	}
コード例 #33
0
		internal ScanResponse Scan(ScanRequest request)
        {
            var task = ScanAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }