Container for the parameters to the BatchGetItem operation.

The BatchGetItem operation returns the attributes of one or more items from one or more tables. You identify requested items by primary key.

A single operation can retrieve up to 1 MB of data, which can comprise as many as 100 items. BatchGetItem will return a partial result if the response size limit is exceeded, the table's provisioned throughput is exceeded, or an internal processing failure occurs. If a partial result is returned, the operation returns a value for UnprocessedKeys . You can use this value to retry the operation starting with the next item to get.

For example, if you ask to retrieve 100 items, but each individual item is 50 KB in size, the system returns 20 items (1 MB) and an appropriate UnprocessedKeys value so you can get the next page of results. If desired, your application can include its own logic to assemble the pages of results into one dataset.

If no items can be processed because of insufficient provisioned throughput on each of the tables involved in the request, BatchGetItem throws ProvisionedThroughputExceededException .

By default, BatchGetItem performs eventually consistent reads on every table in the request. If you want strongly consistent reads instead, you can set ConsistentRead to true for any or all tables.

In order to minimize response latency, BatchGetItem fetches items in parallel.

When designing your application, keep in mind that Amazon DynamoDB does not return attributes in any particular order. To help parse the response by item, include the primary key values for the items in your request in the AttributesToGet parameter.

If a requested item does not exist, it is not returned in the result. Requests for nonexistent items consume the minimum read capacity units according to the type of read. For more information, see Capacity Units Calculations in the Amazon DynamoDB Developer Guide.

Inheritance: AmazonDynamoDBv2Request
コード例 #1
0
        /// <summary>
        /// Will return null if no records were found, gets everything from the FAQ table
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, string> GetFaqQuestions()
        {
            Dictionary <string, string> result = null;

            try
            {
                // Make sure this DB client gets cleaned up, fastest route is the using statement
                // TODO: Lets get these keys encrypted and in the web config or the database(Maybe BCrypt?)
                using (AmazonDynamoDBClient amazonDynamoDBClient = new AmazonDynamoDBClient("AKIAINS26T6JVAGVNZ2A", "qolTppubmJ5XWBl1UtHE42HPs7lULGgF2t8okG0J", RegionEndpoint.USEast1))
                {
                    Amazon.DynamoDBv2.Model.BatchGetItemRequest itemRequest = new Amazon.DynamoDBv2.Model.BatchGetItemRequest();

                    // Apparently you can't rename tables in Dynamo so I have to re-write the table and copy the data. Not top priority for getting inital APP done
                    Table FaqTable = Table.LoadTable(amazonDynamoDBClient, Tables.MyFaqQuetsions.ToString());

                    ScanFilter scanFilter = new ScanFilter();
                    scanFilter.AddCondition("MyFaqQuestions_pk", ScanOperator.GreaterThan, 0); // Lets grab all the rows since we know there will never be too many to do so

                    Search search = FaqTable.Scan(scanFilter);

                    List <Document> documents = search.GetRemaining();

                    if (documents != null)
                    {
                        result = new Dictionary <string, string>();
                        foreach (Document document in documents)
                        {
                            string answer = document.Values.ToList()[0].AsString();

                            string question = document.Values.ToList()[2].AsString();

                            List <string> names = document.GetAttributeNames();

                            result.Add(question, answer);

                            //if(names != null)
                            //{
                            //    foreach(string name in names)
                            //    {
                            //        DynamoDBEntry storedValue;

                            //        if (document.TryGetValue(name, out storedValue))
                            //        {
                            //            result.Add(name, storedValue);
                            //        }
                            //    }
                            //}
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // TODO: Pass this exception back up to the BLL to be handled, maybe implement a retry count first?
                throw ex;
            }

            return(result);
        }
コード例 #2
0
 /// <summary>
 /// Paginator for BatchGetItem operation
 ///</summary>
 public IBatchGetItemPaginator BatchGetItem(BatchGetItemRequest request)
 {
     return(new BatchGetItemPaginator(this.client, request));
 }
コード例 #3
0
 IAsyncResult invokeBatchGetItem(BatchGetItemRequest batchGetItemRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new BatchGetItemRequestMarshaller().Marshall(batchGetItemRequest);
     var unmarshaller = BatchGetItemResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
コード例 #4
0
 /// <summary>
 /// Initiates the asynchronous execution of the BatchGetItem operation.
 /// <seealso cref="Amazon.DynamoDBv2.AmazonDynamoDB.BatchGetItem"/>
 /// </summary>
 /// 
 /// <param name="batchGetItemRequest">Container for the necessary parameters to execute the BatchGetItem 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 EndBatchGetItem
 ///         operation.</returns>
 public IAsyncResult BeginBatchGetItem(BatchGetItemRequest batchGetItemRequest, AsyncCallback callback, object state)
 {
     return invokeBatchGetItem(batchGetItemRequest, callback, state, false);
 }
コード例 #5
0
 /// <summary>
 /// <para>The <i>BatchGetItem</i> operation returns the attributes of one or more items from one or more tables. You identify requested items by
 /// primary key.</para> <para>A single operation can retrieve up to 1 MB of data, which can comprise as many as 100 items. <i>BatchGetItem</i>
 /// will return a partial result if the response size limit is exceeded, the table's provisioned throughput is exceeded, or an internal
 /// processing failure occurs. If a partial result is returned, the operation returns a value for <i>UnprocessedKeys</i> . You can use this
 /// value to retry the operation starting with the next item to get.</para> <para>For example, if you ask to retrieve 100 items, but each
 /// individual item is 50 KB in size, the system returns 20 items (1 MB) and an appropriate <i>UnprocessedKeys</i> value so you can get the next
 /// page of results. If desired, your application can include its own logic to assemble the pages of results into one dataset.</para> <para>If
 /// no items can be processed because of insufficient provisioned throughput on each of the tables involved in the request, <i>BatchGetItem</i>
 /// throws <i>ProvisionedThroughputExceededException</i> . </para> <para>By default, <i>BatchGetItem</i> performs eventually consistent reads on
 /// every table in the request. If you want strongly consistent reads instead, you can set <i>ConsistentRead</i> to <c>true</c> for any or all
 /// tables.</para> <para>In order to minimize response latency, <i>BatchGetItem</i> fetches items in parallel.</para> <para>When designing your
 /// application, keep in mind that Amazon DynamoDB does not return attributes in any particular order. To help parse the response by item,
 /// include the primary key values for the items in your request in the <i>AttributesToGet</i> parameter.</para> <para>If a requested item does
 /// not exist, it is not returned in the result. Requests for nonexistent items consume the minimum read capacity units according to the type of
 /// read. For more information, see Capacity Units Calculations in the <i>Amazon DynamoDB Developer Guide</i> .</para>
 /// </summary>
 /// 
 /// <param name="batchGetItemRequest">Container for the necessary parameters to execute the BatchGetItem service method on
 ///          AmazonDynamoDBv2.</param>
 /// 
 /// <returns>The response from the BatchGetItem service method, as returned by AmazonDynamoDBv2.</returns>
 /// 
 /// <exception cref="ResourceNotFoundException"/>
 /// <exception cref="ProvisionedThroughputExceededException"/>
 /// <exception cref="InternalServerErrorException"/>
 public BatchGetItemResponse BatchGetItem(BatchGetItemRequest batchGetItemRequest)
 {
     IAsyncResult asyncResult = invokeBatchGetItem(batchGetItemRequest, null, null, true);
     return EndBatchGetItem(asyncResult);
 }
コード例 #6
0
 /// <summary>
 /// The <i>BatchGetItem</i> operation returns the attributes of one or more items from
 /// one or more tables. You identify requested items by primary key.
 /// 
 ///  
 /// <para>
 /// A single operation can retrieve up to 16 MB of data, which can contain as many as
 /// 100 items. <i>BatchGetItem</i> will return a partial result if the response size limit
 /// is exceeded, the table's provisioned throughput is exceeded, or an internal processing
 /// failure occurs. If a partial result is returned, the operation returns a value for
 /// <i>UnprocessedKeys</i>. You can use this value to retry the operation starting with
 /// the next item to get.
 /// </para>
 ///  
 /// <para>
 /// For example, if you ask to retrieve 100 items, but each individual item is 300 KB
 /// in size, the system returns 52 items (so as not to exceed the 16 MB limit). It also
 /// returns an appropriate <i>UnprocessedKeys</i> value so you can get the next page of
 /// results. If desired, your application can include its own logic to assemble the pages
 /// of results into one data set.
 /// </para>
 ///  
 /// <para>
 /// If <i>none</i> of the items can be processed due to insufficient provisioned throughput
 /// on all of the tables in the request, then <i>BatchGetItem</i> will return a <i>ProvisionedThroughputExceededException</i>.
 /// If <i>at least one</i> of the items is successfully processed, then <i>BatchGetItem</i>
 /// completes successfully, while returning the keys of the unread items in <i>UnprocessedKeys</i>.
 /// </para>
 ///  <important> 
 /// <para>
 /// If DynamoDB returns any unprocessed items, you should retry the batch operation on
 /// those items. However, <i>we strongly recommend that you use an exponential backoff
 /// algorithm</i>. If you retry the batch operation immediately, the underlying read or
 /// write requests can still fail due to throttling on the individual tables. If you delay
 /// the batch operation using exponential backoff, the individual requests in the batch
 /// are much more likely to succeed.
 /// </para>
 ///  
 /// <para>
 /// For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#BatchOperations">Batch
 /// Operations and Error Handling</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 ///  </important> 
 /// <para>
 /// By default, <i>BatchGetItem</i> performs eventually consistent reads on every table
 /// in the request. If you want strongly consistent reads instead, you can set <i>ConsistentRead</i>
 /// to <code>true</code> for any or all tables.
 /// </para>
 ///  
 /// <para>
 /// In order to minimize response latency, <i>BatchGetItem</i> retrieves items in parallel.
 /// </para>
 ///  
 /// <para>
 /// When designing your application, keep in mind that DynamoDB does not return attributes
 /// in any particular order. To help parse the response by item, include the primary key
 /// values for the items in your request in the <i>AttributesToGet</i> parameter.
 /// </para>
 ///  
 /// <para>
 /// If a requested item does not exist, it is not returned in the result. Requests for
 /// nonexistent items consume the minimum read capacity units according to the type of
 /// read. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#CapacityUnitCalculations">Capacity
 /// Units Calculations</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 /// </summary>
 /// <param name="requestItems">A map of one or more table names and, for each table, a map that describes one or more items to retrieve from that table. Each table name can be used only once per <i>BatchGetItem</i> request. Each element in the map of items to retrieve consists of the following: <ul> <li> <i>ConsistentRead</i> - If <code>true</code>, a strongly consistent read is used; if <code>false</code> (the default), an eventually consistent read is used. </li> <li>  <i>ExpressionAttributeNames</i> - One or more substitution tokens for attribute names in the <i>ProjectionExpression</i> parameter. The following are some use cases for using <i>ExpressionAttributeNames</i>: <ul> <li> To access an attribute whose name conflicts with a DynamoDB reserved word. </li> <li> To create a placeholder for repeating occurrences of an attribute name in an expression. </li> <li> To prevent special characters in an attribute name from being misinterpreted in an expression. </li> </ul> Use the <b>#</b> character in an expression to dereference an attribute name. For example, consider the following attribute name: <ul><li><code>Percentile</code></li></ul> The name of this attribute conflicts with a reserved word, so it cannot be used directly in an expression. (For the complete list of reserved words, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html">Reserved Words</a> in the <i>Amazon DynamoDB Developer Guide</i>). To work around this, you could specify the following for <i>ExpressionAttributeNames</i>: <ul><li><code>{"#P":"Percentile"}</code></li></ul> You could then use this substitution in an expression, as in this example: <ul><li><code>#P = :val</code></li></ul> <note> Tokens that begin with the <b>:</b> character are <i>expression attribute values</i>, which are placeholders for the actual value at runtime.</note> For more information on expression attribute names, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html">Accessing Item Attributes</a> in the <i>Amazon DynamoDB Developer Guide</i>. </li> <li> <i>Keys</i> - An array of primary key attribute values that define specific items in the table. For each primary key, you must provide <i>all</i> of the key attributes. For example, with a hash type primary key, you only need to provide the hash attribute. For a hash-and-range type primary key, you must provide <i>both</i> the hash attribute and the range attribute. </li> <li> <i>ProjectionExpression</i> - A string that identifies one or more attributes to retrieve from the table. These attributes can include scalars, sets, or elements of a JSON document. The attributes in the expression must be separated by commas. If no attribute names are specified, then all attributes will be returned. If any of the requested attributes are not found, they will not appear in the result. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html">Accessing Item Attributes</a> in the <i>Amazon DynamoDB Developer Guide</i>. </li> <li>  <i>AttributesToGet</i> -  <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. </li> </ul></param>
 /// 
 /// <returns>The response from the BatchGetItem 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 BatchGetItemResponse BatchGetItem(Dictionary<string, KeysAndAttributes> requestItems)
 {
     var request = new BatchGetItemRequest();
     request.RequestItems = requestItems;
     return BatchGetItem(request);
 }
コード例 #7
0
 /// <summary>
 /// Initiates the asynchronous execution of the BatchGetItem operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the BatchGetItem 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 BatchGetItemAsync(BatchGetItemRequest request, AmazonServiceCallback<BatchGetItemRequest, BatchGetItemResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new BatchGetItemRequestMarshaller();
     var unmarshaller = BatchGetItemResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<BatchGetItemRequest,BatchGetItemResponse> responseObject 
                     = new AmazonServiceResult<BatchGetItemRequest,BatchGetItemResponse>((BatchGetItemRequest)req, (BatchGetItemResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<BatchGetItemRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
コード例 #8
0
        /// <summary>
        /// Initiates the asynchronous execution of the BatchGetItem operation.
        /// <seealso cref="Amazon.DynamoDBv2.IAmazonDynamoDB"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the BatchGetItem 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<BatchGetItemResponse> BatchGetItemAsync(BatchGetItemRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new BatchGetItemRequestMarshaller();
            var unmarshaller = BatchGetItemResponseUnmarshaller.Instance;

            return InvokeAsync<BatchGetItemRequest,BatchGetItemResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
コード例 #9
0
        /// <summary>
        /// <para>The <i>BatchGetItem</i> operation returns the attributes of one or more items from one or more tables. You identify requested items by
        /// primary key.</para> <para>A single operation can retrieve up to 1 MB of data, which can contain as many as 100 items. <i>BatchGetItem</i>
        /// will return a partial result if the response size limit is exceeded, the table's provisioned throughput is exceeded, or an internal
        /// processing failure occurs. If a partial result is returned, the operation returns a value for <i>UnprocessedKeys</i> . You can use this
        /// value to retry the operation starting with the next item to get.</para> <para>For example, if you ask to retrieve 100 items, but each
        /// individual item is 50 KB in size, the system returns 20 items (1 MB) and an appropriate <i>UnprocessedKeys</i> value so you can get the next
        /// page of results. If desired, your application can include its own logic to assemble the pages of results into one dataset.</para> <para>If
        /// <i>none</i> of the items can be processed due to insufficient provisioned throughput on all of the tables in the request, then
        /// <i>BatchGetItem</i> will throw a <i>ProvisionedThroughputExceededException</i> . If <i>at least one</i> of the items is successfully
        /// processed, then <i>BatchGetItem</i> completes successfully, while returning the keys of the unread items in <i>UnprocessedKeys</i> .</para>
        /// <para>By default, <i>BatchGetItem</i> performs eventually consistent reads on every table in the request. If you want strongly consistent
        /// reads instead, you can set <i>ConsistentRead</i> to <c>true</c> for any or all tables.</para> <para>In order to minimize response latency,
        /// <i>BatchGetItem</i> retrieves items in parallel.</para> <para>When designing your application, keep in mind that DynamoDB does not return
        /// attributes in any particular order. To help parse the response by item, include the primary key values for the items in your request in the
        /// <i>AttributesToGet</i> parameter.</para> <para>If a requested item does not exist, it is not returned in the result. Requests for
        /// nonexistent items consume the minimum read capacity units according to the type of read. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#CapacityUnitCalculations">Capacity Units
        /// Calculations</a> in the Amazon DynamoDB Developer Guide.</para>
        /// </summary>
        /// 
        /// <param name="batchGetItemRequest">Container for the necessary parameters to execute the BatchGetItem service method on
        /// AmazonDynamoDBv2.</param>
        /// 
        /// <returns>The response from the BatchGetItem 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<BatchGetItemResponse> BatchGetItemAsync(BatchGetItemRequest batchGetItemRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new BatchGetItemRequestMarshaller();
            var unmarshaller = BatchGetItemResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, BatchGetItemRequest, BatchGetItemResponse>(batchGetItemRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
コード例 #10
0
		internal BatchGetItemResponse BatchGetItem(BatchGetItemRequest request)
        {
            var task = BatchGetItemAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
コード例 #11
0
 /// <summary>
 /// The <i>BatchGetItem</i> operation returns the attributes of one or more items from
 /// one or more tables. You identify requested items by primary key.
 /// 
 ///  
 /// <para>
 /// A single operation can retrieve up to 16 MB of data, which can contain as many as
 /// 100 items. <i>BatchGetItem</i> will return a partial result if the response size limit
 /// is exceeded, the table's provisioned throughput is exceeded, or an internal processing
 /// failure occurs. If a partial result is returned, the operation returns a value for
 /// <i>UnprocessedKeys</i>. You can use this value to retry the operation starting with
 /// the next item to get.
 /// </para>
 ///  <important>
 /// <para>
 /// If you request more than 100 items <i>BatchGetItem</i> will return a <i>ValidationException</i>
 /// with the message "Too many items requested for the BatchGetItem call".
 /// </para>
 /// </important> 
 /// <para>
 /// For example, if you ask to retrieve 100 items, but each individual item is 300 KB
 /// in size, the system returns 52 items (so as not to exceed the 16 MB limit). It also
 /// returns an appropriate <i>UnprocessedKeys</i> value so you can get the next page of
 /// results. If desired, your application can include its own logic to assemble the pages
 /// of results into one data set.
 /// </para>
 ///  
 /// <para>
 /// If <i>none</i> of the items can be processed due to insufficient provisioned throughput
 /// on all of the tables in the request, then <i>BatchGetItem</i> will return a <i>ProvisionedThroughputExceededException</i>.
 /// If <i>at least one</i> of the items is successfully processed, then <i>BatchGetItem</i>
 /// completes successfully, while returning the keys of the unread items in <i>UnprocessedKeys</i>.
 /// </para>
 ///  <important> 
 /// <para>
 /// If DynamoDB returns any unprocessed items, you should retry the batch operation on
 /// those items. However, <i>we strongly recommend that you use an exponential backoff
 /// algorithm</i>. If you retry the batch operation immediately, the underlying read or
 /// write requests can still fail due to throttling on the individual tables. If you delay
 /// the batch operation using exponential backoff, the individual requests in the batch
 /// are much more likely to succeed.
 /// </para>
 ///  
 /// <para>
 /// For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#BatchOperations">Batch
 /// Operations and Error Handling</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 ///  </important> 
 /// <para>
 /// By default, <i>BatchGetItem</i> performs eventually consistent reads on every table
 /// in the request. If you want strongly consistent reads instead, you can set <i>ConsistentRead</i>
 /// to <code>true</code> for any or all tables.
 /// </para>
 ///  
 /// <para>
 /// In order to minimize response latency, <i>BatchGetItem</i> retrieves items in parallel.
 /// </para>
 ///  
 /// <para>
 /// When designing your application, keep in mind that DynamoDB does not return attributes
 /// in any particular order. To help parse the response by item, include the primary key
 /// values for the items in your request in the <i>AttributesToGet</i> parameter.
 /// </para>
 ///  
 /// <para>
 /// If a requested item does not exist, it is not returned in the result. Requests for
 /// nonexistent items consume the minimum read capacity units according to the type of
 /// read. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#CapacityUnitCalculations">Capacity
 /// Units Calculations</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 /// </summary>
 /// <param name="requestItems">A map of one or more table names and, for each table, a map that describes one or more items to retrieve from that table. Each table name can be used only once per <i>BatchGetItem</i> request. Each element in the map of items to retrieve consists of the following: <ul> <li> <i>ConsistentRead</i> - If <code>true</code>, a strongly consistent read is used; if <code>false</code> (the default), an eventually consistent read is used. </li> <li>  <i>ExpressionAttributeNames</i> - One or more substitution tokens for attribute names in the <i>ProjectionExpression</i> parameter. The following are some use cases for using <i>ExpressionAttributeNames</i>: <ul> <li> To access an attribute whose name conflicts with a DynamoDB reserved word. </li> <li> To create a placeholder for repeating occurrences of an attribute name in an expression. </li> <li> To prevent special characters in an attribute name from being misinterpreted in an expression. </li> </ul> Use the <b>#</b> character in an expression to dereference an attribute name. For example, consider the following attribute name: <ul><li><code>Percentile</code></li></ul> The name of this attribute conflicts with a reserved word, so it cannot be used directly in an expression. (For the complete list of reserved words, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html">Reserved Words</a> in the <i>Amazon DynamoDB Developer Guide</i>). To work around this, you could specify the following for <i>ExpressionAttributeNames</i>: <ul><li><code>{"#P":"Percentile"}</code></li></ul> You could then use this substitution in an expression, as in this example: <ul><li><code>#P = :val</code></li></ul> <note>Tokens that begin with the <b>:</b> character are <i>expression attribute values</i>, which are placeholders for the actual value at runtime.</note> For more information on expression attribute names, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html">Accessing Item Attributes</a> in the <i>Amazon DynamoDB Developer Guide</i>. </li> <li> <i>Keys</i> - An array of primary key attribute values that define specific items in the table. For each primary key, you must provide <i>all</i> of the key attributes. For example, with a hash type primary key, you only need to provide the hash attribute. For a hash-and-range type primary key, you must provide <i>both</i> the hash attribute and the range attribute. </li> <li> <i>ProjectionExpression</i> - A string that identifies one or more attributes to retrieve from the table. These attributes can include scalars, sets, or elements of a JSON document. The attributes in the expression must be separated by commas. If no attribute names are specified, then all attributes will be returned. If any of the requested attributes are not found, they will not appear in the result. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html">Accessing Item Attributes</a> in the <i>Amazon DynamoDB Developer Guide</i>. </li> <li>  <i>AttributesToGet</i> -  <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. </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 BatchGetItem 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<BatchGetItemResponse> BatchGetItemAsync(Dictionary<string, KeysAndAttributes> requestItems, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new BatchGetItemRequest();
     request.RequestItems = requestItems;
     return BatchGetItemAsync(request, cancellationToken);
 }
コード例 #12
0
        /// <summary>
        /// Initiates the asynchronous execution of the BatchGetItem operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the BatchGetItem 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 EndBatchGetItem
        ///         operation.</returns>
        public IAsyncResult BeginBatchGetItem(BatchGetItemRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new BatchGetItemRequestMarshaller();
            var unmarshaller = BatchGetItemResponseUnmarshaller.Instance;

            return BeginInvoke<BatchGetItemRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
コード例 #13
0
		internal BatchGetItemResponse BatchGetItem(BatchGetItemRequest request)
        {
            var task = BatchGetItemAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
コード例 #14
0
        /// <summary>
        /// Initiates the asynchronous execution of the BatchGetItem operation.
        /// <seealso cref="Amazon.DynamoDBv2.IAmazonDynamoDB.BatchGetItem"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the BatchGetItem 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<BatchGetItemResponse> BatchGetItemAsync(BatchGetItemRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new BatchGetItemRequestMarshaller();
            var unmarshaller = BatchGetItemResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, BatchGetItemRequest, BatchGetItemResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
コード例 #15
0
        public void BatchSamples()
        {
            EnsureTables();

            {
                #region BatchGet Sample 1

                // Define attributes to get and keys to retrieve
                List<string> attributesToGet = new List<string> { "Author", "Title", "Year" };
                List<Dictionary<string, AttributeValue>> sampleTableKeys = new List<Dictionary<string, AttributeValue>>
                {
                    new Dictionary<string, AttributeValue>
                    {
                        { "Author", new AttributeValue { S = "Mark Twain" } },
                        { "Title", new AttributeValue { S = "The Adventures of Tom Sawyer" } }
                    },
                    new Dictionary<string, AttributeValue>
                    {
                        { "Author", new AttributeValue { S = "Mark Twain" } },
                        { "Title", new AttributeValue { S = "Adventures of Huckleberry Finn" } }
                    }
                };

                // Construct get-request for first table
                KeysAndAttributes sampleTableItems = new KeysAndAttributes
                {
                    AttributesToGet = attributesToGet,
                    Keys = sampleTableKeys
                };

                #endregion

                #region BatchGet Sample 2

                // Define keys to retrieve
                List<Dictionary<string, AttributeValue>> authorsTableKeys = new List<Dictionary<string, AttributeValue>>
                {
                    new Dictionary<string, AttributeValue>
                    {
                        { "Author", new AttributeValue { S = "Mark Twain" } },
                    },
                    new Dictionary<string, AttributeValue>
                    {
                        { "Author", new AttributeValue { S = "Booker Taliaferro Washington" } },
                    }
                };

                // Construct get-request for second table
                //  Skip setting AttributesToGet property to retrieve all attributes
                KeysAndAttributes authorsTableItems = new KeysAndAttributes
                {
                    Keys = authorsTableKeys,
                };

                #endregion

                #region BatchGet Sample 3

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

                // Construct table-keys mapping
                Dictionary<string, KeysAndAttributes> requestItems = new Dictionary<string, KeysAndAttributes>();
                requestItems["SampleTable"] = sampleTableItems;
                requestItems["AuthorsTable"] = authorsTableItems;

                // Construct request
                BatchGetItemRequest request = new BatchGetItemRequest
                {
                    RequestItems = requestItems
                };

                BatchGetItemResult result;
                do
                {
                    // Issue request and retrieve items
                    result = client.BatchGetItem(request);

                    // Iterate through responses
                    Dictionary<string, List<Dictionary<string, AttributeValue>>> responses = result.Responses;
                    foreach (string tableName in responses.Keys)
                    {
                        // Get items for each table
                        List<Dictionary<string, AttributeValue>> tableItems = responses[tableName];

                        // View items
                        foreach (Dictionary<string, AttributeValue> item in tableItems)
                        {
                            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>()));
                            }
                        }
                    }

                    // Some items may not have been retrieved!
                    //  Set RequestItems to the result's UnprocessedKeys and reissue request
                    request.RequestItems = result.UnprocessedKeys;

                } while (result.UnprocessedKeys.Count > 0);

                #endregion
            }


            {
                #region BatchWrite Sample 1

                // 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" };

                // Create key for item to delete from first table
                //  Hash-key of the target item is string value "Mark Twain"
                //  Range-key of the target item is string value "Tom Sawyer, Detective"
                Dictionary<string, AttributeValue> keyToDelete1 = new Dictionary<string, AttributeValue>
                {
                    { "Author", new AttributeValue { S = "Mark Twain" } },
                    { "Title", new AttributeValue { S = "Tom Sawyer, Detective" } }
                };

                // 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 }
                });
                sampleTableItems.Add(new WriteRequest
                {
                    DeleteRequest = new DeleteRequest { Key = keyToDelete1 }
                });

                #endregion

                #region BatchWrite Sample 2

                // Create key for item to delete from second table
                //  Hash-key of the target item is string value "Francis Scott Key Fitzgerald"
                Dictionary<string, AttributeValue> keyToDelete2 = new Dictionary<string, AttributeValue>
                {
                    { "Author", new AttributeValue { S = "Francis Scott Key Fitzgerald" } },
                };

                // Construct write-request for first table
                List<WriteRequest> authorsTableItems = new List<WriteRequest>();
                authorsTableItems.Add(new WriteRequest
                {
                    DeleteRequest = new DeleteRequest { Key = keyToDelete2 }
                });

                #endregion

                #region BatchWrite Sample 3

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

                // Construct table-keys mapping
                Dictionary<string, List<WriteRequest>> requestItems = new Dictionary<string, List<WriteRequest>>();
                requestItems["SampleTable"] = sampleTableItems;
                requestItems["AuthorsTable"] = authorsTableItems;

                BatchWriteItemRequest request = new BatchWriteItemRequest { RequestItems = requestItems };
                BatchWriteItemResult result;
                do
                {
                    // Issue request and retrieve items
                    result = client.BatchWriteItem(request);

                    // Some items may not have been processed!
                    //  Set RequestItems to the result's UnprocessedItems and reissue request
                    request.RequestItems = result.UnprocessedItems;

                } while (result.UnprocessedItems.Count > 0);

                #endregion
            }
        }
コード例 #16
0
 internal BatchGetItemPaginator(IAmazonDynamoDB client, BatchGetItemRequest request)
 {
     this._client  = client;
     this._request = request;
 }
コード例 #17
0
        internal BatchGetItemResponse BatchGetItem(BatchGetItemRequest request)
        {
            var marshaller = new BatchGetItemRequestMarshaller();
            var unmarshaller = BatchGetItemResponseUnmarshaller.Instance;

            return Invoke<BatchGetItemRequest,BatchGetItemResponse>(request, marshaller, unmarshaller);
        }
コード例 #18
0
        private Dictionary<string, List<Dictionary<string, AttributeValue>>> GetAttributeItems(bool isAsync)
        {
            var allItems = new Dictionary<string, List<Dictionary<string, AttributeValue>>>();
            if (Batches == null || Batches.Count == 0)
                return allItems;

            DocumentBatchGet firstBatch = this.Batches[0];
            BatchGetItemRequest request = new BatchGetItemRequest();
            request.BeforeRequestEvent += isAsync ?
                new RequestEventHandler(firstBatch.TargetTable.UserAgentRequestEventHandlerAsync) :
                new RequestEventHandler(firstBatch.TargetTable.UserAgentRequestEventHandlerSync);

            foreach (var batch in Batches)
            {
                if (batch.Keys != null && batch.Keys.Count > 0)
                {
                    if (request.RequestItems.ContainsKey(batch.TargetTable.TableName))
                    {
                        throw new InvalidOperationException("Multiple batches refer to the same table.");
                    }

                    request.RequestItems.Add(
                        batch.TargetTable.TableName,
                        new KeysAndAttributes
                        {
                            Keys = batch.Keys.Select((Key k) => k as Dictionary<string, AttributeValue>).ToList(),
                            AttributesToGet = batch.AttributesToGet,
                            ConsistentRead = batch.ConsistentRead
                        });
                }
            }
            var client = firstBatch.TargetTable.DDBClient;

            do
            {
                var batchGetItemResponse = client.BatchGetItem(request);
                var result = batchGetItemResponse.BatchGetItemResult;

                var responses = result.Responses;
                foreach (var response in responses)
                {
                    string tableName = response.Key;
                    List<Dictionary<string, AttributeValue>> items = response.Value;

                    List<Dictionary<string, AttributeValue>> fetchedItems;
                    if (!allItems.TryGetValue(tableName, out fetchedItems))
                    {
                        fetchedItems = new List<Dictionary<string, AttributeValue>>();
                        allItems[tableName] = fetchedItems;
                    }
                    fetchedItems.AddRange(items);
                }

                request.RequestItems = result.UnprocessedKeys;
            } while (request.RequestItems.Count > 0);

            return allItems;
        }
コード例 #19
0
 /// <summary>
 /// The <i>BatchGetItem</i> operation returns the attributes of one or more items from
 /// one or more tables. You identify requested items by primary key.
 /// 
 ///  
 /// <para>
 /// A single operation can retrieve up to 16 MB of data, which can contain as many as
 /// 100 items. <i>BatchGetItem</i> will return a partial result if the response size limit
 /// is exceeded, the table's provisioned throughput is exceeded, or an internal processing
 /// failure occurs. If a partial result is returned, the operation returns a value for
 /// <i>UnprocessedKeys</i>. You can use this value to retry the operation starting with
 /// the next item to get.
 /// </para>
 ///  
 /// <para>
 /// For example, if you ask to retrieve 100 items, but each individual item is 300 KB
 /// in size, the system returns 52 items (so as not to exceed the 16 MB limit). It also
 /// returns an appropriate <i>UnprocessedKeys</i> value so you can get the next page of
 /// results. If desired, your application can include its own logic to assemble the pages
 /// of results into one data set.
 /// </para>
 ///  
 /// <para>
 /// If <i>none</i> of the items can be processed due to insufficient provisioned throughput
 /// on all of the tables in the request, then <i>BatchGetItem</i> will return a <i>ProvisionedThroughputExceededException</i>.
 /// If <i>at least one</i> of the items is successfully processed, then <i>BatchGetItem</i>
 /// completes successfully, while returning the keys of the unread items in <i>UnprocessedKeys</i>.
 /// </para>
 ///  <important> 
 /// <para>
 /// If DynamoDB returns any unprocessed items, you should retry the batch operation on
 /// those items. However, <i>we strongly recommend that you use an exponential backoff
 /// algorithm</i>. If you retry the batch operation immediately, the underlying read or
 /// write requests can still fail due to throttling on the individual tables. If you delay
 /// the batch operation using exponential backoff, the individual requests in the batch
 /// are much more likely to succeed.
 /// </para>
 ///  
 /// <para>
 /// For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#BatchOperations">Batch
 /// Operations and Error Handling</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 ///  </important> 
 /// <para>
 /// By default, <i>BatchGetItem</i> performs eventually consistent reads on every table
 /// in the request. If you want strongly consistent reads instead, you can set <i>ConsistentRead</i>
 /// to <code>true</code> for any or all tables.
 /// </para>
 ///  
 /// <para>
 /// In order to minimize response latency, <i>BatchGetItem</i> retrieves items in parallel.
 /// </para>
 ///  
 /// <para>
 /// When designing your application, keep in mind that DynamoDB does not return attributes
 /// in any particular order. To help parse the response by item, include the primary key
 /// values for the items in your request in the <i>AttributesToGet</i> parameter.
 /// </para>
 ///  
 /// <para>
 /// If a requested item does not exist, it is not returned in the result. Requests for
 /// nonexistent items consume the minimum read capacity units according to the type of
 /// read. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#CapacityUnitCalculations">Capacity
 /// Units Calculations</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 /// </summary>
 /// <param name="requestItems">A map of one or more table names and, for each table, a map that describes one or more items to retrieve from that table. Each table name can be used only once per <i>BatchGetItem</i> request. Each element in the map of items to retrieve consists of the following: <ul> <li> <i>ConsistentRead</i> - If <code>true</code>, a strongly consistent read is used; if <code>false</code> (the default), an eventually consistent read is used. </li> <li>  <i>ExpressionAttributeNames</i> - One or more substitution tokens for attribute names in the <i>ProjectionExpression</i> parameter. The following are some use cases for using <i>ExpressionAttributeNames</i>: <ul> <li> To access an attribute whose name conflicts with a DynamoDB reserved word. </li> <li> To create a placeholder for repeating occurrences of an attribute name in an expression. </li> <li> To prevent special characters in an attribute name from being misinterpreted in an expression. </li> </ul> Use the <b>#</b> character in an expression to dereference an attribute name. For example, consider the following attribute name: <ul><li><code>Percentile</code></li></ul> The name of this attribute conflicts with a reserved word, so it cannot be used directly in an expression. (For the complete list of reserved words, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html">Reserved Words</a> in the <i>Amazon DynamoDB Developer Guide</i>). To work around this, you could specify the following for <i>ExpressionAttributeNames</i>: <ul><li><code>{"#P":"Percentile"}</code></li></ul> You could then use this substitution in an expression, as in this example: <ul><li><code>#P = :val</code></li></ul> <note> Tokens that begin with the <b>:</b> character are <i>expression attribute values</i>, which are placeholders for the actual value at runtime.</note> For more information on expression attribute names, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html">Accessing Item Attributes</a> in the <i>Amazon DynamoDB Developer Guide</i>. </li> <li> <i>Keys</i> - An array of primary key attribute values that define specific items in the table. For each primary key, you must provide <i>all</i> of the key attributes. For example, with a hash type primary key, you only need to provide the hash attribute. For a hash-and-range type primary key, you must provide <i>both</i> the hash attribute and the range attribute. </li> <li> <i>ProjectionExpression</i> - A string that identifies one or more attributes to retrieve from the table. These attributes can include scalars, sets, or elements of a JSON document. The attributes in the expression must be separated by commas. If no attribute names are specified, then all attributes will be returned. If any of the requested attributes are not found, they will not appear in the result. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html">Accessing Item Attributes</a> in the <i>Amazon DynamoDB Developer Guide</i>. </li> <li>  <i>AttributesToGet</i> -  <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. </li> </ul></param>
 /// <param name="returnConsumedCapacity">A property of BatchGetItemRequest used to execute the BatchGetItem service method.</param>
 /// 
 /// <returns>The response from the BatchGetItem 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 BatchGetItemResponse BatchGetItem(Dictionary<string, KeysAndAttributes> requestItems, ReturnConsumedCapacity returnConsumedCapacity)
 {
     var request = new BatchGetItemRequest();
     request.RequestItems = requestItems;
     request.ReturnConsumedCapacity = returnConsumedCapacity;
     return BatchGetItem(request);
 }
コード例 #20
0
 /// <summary>
 /// The <i>BatchGetItem</i> operation returns the attributes of one or more items from
 /// one or more tables. You identify requested items by primary key.
 /// 
 ///  
 /// <para>
 /// A single operation can retrieve up to 16 MB of data, which can contain as many as
 /// 100 items. <i>BatchGetItem</i> will return a partial result if the response size limit
 /// is exceeded, the table's provisioned throughput is exceeded, or an internal processing
 /// failure occurs. If a partial result is returned, the operation returns a value for
 /// <i>UnprocessedKeys</i>. You can use this value to retry the operation starting with
 /// the next item to get.
 /// </para>
 ///  
 /// <para>
 /// For example, if you ask to retrieve 100 items, but each individual item is 300 KB
 /// in size, the system returns 52 items (so as not to exceed the 16 MB limit). It also
 /// returns an appropriate <i>UnprocessedKeys</i> value so you can get the next page of
 /// results. If desired, your application can include its own logic to assemble the pages
 /// of results into one data set.
 /// </para>
 ///  
 /// <para>
 /// If <i>none</i> of the items can be processed due to insufficient provisioned throughput
 /// on all of the tables in the request, then <i>BatchGetItem</i> will return a <i>ProvisionedThroughputExceededException</i>.
 /// If <i>at least one</i> of the items is successfully processed, then <i>BatchGetItem</i>
 /// completes successfully, while returning the keys of the unread items in <i>UnprocessedKeys</i>.
 /// </para>
 ///  <important> 
 /// <para>
 /// If DynamoDB returns any unprocessed items, you should retry the batch operation on
 /// those items. However, <i>we strongly recommend that you use an exponential backoff
 /// algorithm</i>. If you retry the batch operation immediately, the underlying read or
 /// write requests can still fail due to throttling on the individual tables. If you delay
 /// the batch operation using exponential backoff, the individual requests in the batch
 /// are much more likely to succeed.
 /// </para>
 ///  
 /// <para>
 /// For more information, go to <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#BatchOperations">Batch
 /// Operations and Error Handling</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 ///  </important> 
 /// <para>
 /// By default, <i>BatchGetItem</i> performs eventually consistent reads on every table
 /// in the request. If you want strongly consistent reads instead, you can set <i>ConsistentRead</i>
 /// to <code>true</code> for any or all tables.
 /// </para>
 ///  
 /// <para>
 /// In order to minimize response latency, <i>BatchGetItem</i> retrieves items in parallel.
 /// </para>
 ///  
 /// <para>
 /// When designing your application, keep in mind that DynamoDB does not return attributes
 /// in any particular order. To help parse the response by item, include the primary key
 /// values for the items in your request in the <i>AttributesToGet</i> parameter.
 /// </para>
 ///  
 /// <para>
 /// If a requested item does not exist, it is not returned in the result. Requests for
 /// nonexistent items consume the minimum read capacity units according to the type of
 /// read. For more information, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#CapacityUnitCalculations">Capacity
 /// Units Calculations</a> in the <i>Amazon DynamoDB Developer Guide</i>.
 /// </para>
 /// </summary>
 /// <param name="requestItems">A map of one or more table names and, for each table, the corresponding primary keys for the items to retrieve. Each table name can be invoked only once. Each element in the map consists of the following: <ul> <li> <i>Keys</i> - An array of primary key attribute values that define specific items in the table. For each primary key, you must provide <i>all</i> of the key attributes. For example, with a hash type primary key, you only need to provide the hash attribute. For a hash-and-range type primary key, you must provide <i>both</i> the hash attribute and the range attribute. </li> <li> <i>AttributesToGet</i> - One or more attributes to be retrieved from the table. By default, all attributes are returned. If a specified attribute is not found, it does 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. </li> <li> <i>ConsistentRead</i> - If <code>true</code>, a strongly consistent read is used; if <code>false</code> (the default), an eventually consistent read is used. </li> </ul></param>
 /// 
 /// <returns>The response from the BatchGetItem 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 BatchGetItemAsync(Dictionary<string, KeysAndAttributes> requestItems, AmazonServiceCallback<BatchGetItemRequest, BatchGetItemResponse> callback, AsyncOptions options = null)
 {
     var request = new BatchGetItemRequest();
     request.RequestItems = requestItems;
     BatchGetItemAsync(request, callback, options);
 }