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; }
/// <summary> /// Initiates the asynchronous execution of the Scan operation. /// <seealso cref="Amazon.DynamoDB.AmazonDynamoDB.Scan"/> /// </summary> /// /// <param name="scanRequest">Container for the necessary parameters to execute the Scan operation on AmazonDynamoDB.</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); }
/// <summary> /// <para>Retrieves one or more items and its attributes by performing a full scan of a table.</para> <para>Provide a <c>ScanFilter</c> to get /// more specific results.</para> /// </summary> /// /// <param name="scanRequest">Container for the necessary parameters to execute the Scan service method on AmazonDynamoDB.</param> /// /// <returns>The response from the Scan service method, as returned by AmazonDynamoDB.</returns> /// /// <exception cref="ProvisionedThroughputExceededException"/> /// <exception cref="InternalServerErrorException"/> /// <exception cref="ResourceNotFoundException"/> public ScanResponse Scan(ScanRequest scanRequest) { IAsyncResult asyncResult = invokeScan(scanRequest, null, null, true); return EndScan(asyncResult); }
/// <summary> /// <para> The Scan operation returns one or more items and its attributes by performing a full scan of a table. Limit the returned results by /// specifying a filter. </para> /// </summary> /// /// <param name="scanRequest">Container for the necessary parameters to execute the Scan service method on AmazonDynamoDB.</param> /// /// <returns>The response from the Scan service method, as returned by AmazonDynamoDB.</returns> /// /// <exception cref="ProvisionedThroughputExceededException"/> /// <exception cref="InternalServerErrorException"/> /// <exception cref="ResourceNotFoundException"/> public ScanResponse Scan(ScanRequest scanRequest) { IRequest<ScanRequest> request = new ScanRequestMarshaller().Marshall(scanRequest); ScanResponse response = Invoke<ScanRequest, ScanResponse> (request, this.signer, ScanResponseUnmarshaller.GetInstance()); return response; }
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 }; scanReq.BeforeRequestEvent += isAsync ? new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerAsync) : new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerSync); if (AttributesToGet != null) scanReq.AttributesToGet = AttributesToGet; scanReq.ScanFilter = (ScanFilter)Filter; ScanResult scanResult = SourceTable.DDBClient.Scan(scanReq).ScanResult; foreach (var item in scanResult.Items) { Document doc = Document.FromAttributeMap(item); ret.Add(doc); Matches.Add(doc); } NextKey = scanResult.LastEvaluatedKey; if (NextKey == null) { IsDone = true; } return ret; case SearchType.Query: QueryRequest queryReq = new QueryRequest { ConsistentRead=IsConsistentRead, ExclusiveStartKey=NextKey, HashKeyValue=HashKey, Limit=Limit, ScanIndexForward=!IsBackwardSearch, TableName=TableName, }; if (Filter != null) queryReq.RangeKeyCondition = ((RangeFilter)Filter).Condition; queryReq.BeforeRequestEvent += isAsync ? new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerAsync) : new RequestEventHandler(SourceTable.UserAgentRequestEventHandlerSync); if (AttributesToGet != null) queryReq.AttributesToGet = AttributesToGet; QueryResult queryResult = SourceTable.DDBClient.Query(queryReq).QueryResult; foreach (var item in queryResult.Items) { Document doc = Document.FromAttributeMap(item); ret.Add(doc); Matches.Add(doc); } NextKey = queryResult.LastEvaluatedKey; if (NextKey == null) { IsDone = true; } return ret; default: throw new InvalidOperationException("Unknown Search Method"); } } return ret; }
private int GetCount() { if (IsDone) { return Matches.Count; } else { if (count != -1) { return count; } else { switch (SearchMethod) { case SearchType.Scan: ScanRequest scanReq = new ScanRequest { Count=true, ExclusiveStartKey=NextKey, TableName=TableName, }; scanReq.BeforeRequestEvent += SourceTable.UserAgentRequestEventHandlerSync; scanReq.ScanFilter = (ScanFilter)Filter; ScanResult scanResult = SourceTable.DDBClient.Scan(scanReq).ScanResult; count = Matches.Count + scanResult.Count; return count; case SearchType.Query: QueryRequest queryReq = new QueryRequest { ConsistentRead=IsConsistentRead, Count=true, ExclusiveStartKey=NextKey, HashKeyValue=HashKey, RangeKeyCondition = ((RangeFilter)Filter).Condition, ScanIndexForward=!IsBackwardSearch, TableName=TableName, }; 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"); } } } }
private int GetCount() { if (IsDone) { return Matches.Count; } else { if (count != -1) { return count; } else { switch (SearchMethod) { case SearchType.Scan: ScanRequest scanReq = new ScanRequest() .WithCount(true) .WithExclusiveStartKey(NextKey) .WithTableName(TableName) .WithBeforeRequestHandler(SourceTable.UserAgentRequestEventHandlerSync) as ScanRequest; scanReq.ScanFilter = (ScanFilter)Filter; ScanResult scanResult = SourceTable.DDBClient.Scan(scanReq).ScanResult; count = Matches.Count + scanResult.Count; return count; case SearchType.Query: QueryRequest queryReq = new QueryRequest() .WithConsistentRead(IsConsistentRead) .WithCount(true) .WithExclusiveStartKey(NextKey) .WithHashKeyValue(HashKey) .WithRangeKeyCondition(((RangeFilter)Filter).Condition) .WithScanIndexForward(!IsBackwardSearch) .WithTableName(TableName) .WithBeforeRequestHandler(SourceTable.UserAgentRequestEventHandlerSync) as QueryRequest; QueryResult queryResult = SourceTable.DDBClient.Query(queryReq).QueryResult; count = Matches.Count + queryResult.Count; return count; default: throw new InvalidOperationException("Unknown Search Method"); } } } }
/// <summary> /// Retrieves the next set (page) of results /// </summary> /// <returns>Next set of Documents matching the search parameters</returns> public List<Document> GetNextSet() { List<Document> ret = new List<Document>(); if (!IsDone) { switch (SearchMethod) { case SearchType.Scan: ScanRequest scanReq = new ScanRequest() .WithExclusiveStartKey(NextKey) .WithLimit(Limit) .WithTableName(TableName) .WithBeforeRequestHandler(SourceTable.UserAgentRequestEventHandler) as ScanRequest; if (AttributesToGet != null) scanReq.AttributesToGet = AttributesToGet; scanReq.ScanFilter = (ScanFilter)Filter; ScanResult scanResult = SourceTable.DDBClient.Scan(scanReq).ScanResult; foreach (var item in scanResult.Items) { Document doc = Document.FromAttributeMap(item); ret.Add(doc); Matches.Add(doc); } NextKey = scanResult.LastEvaluatedKey; if (NextKey == null) { IsDone = true; } return ret; case SearchType.Query: QueryRequest queryReq = new QueryRequest() .WithConsistentRead(IsConsistentRead) .WithExclusiveStartKey(NextKey) .WithHashKeyValue(HashKey) .WithLimit(Limit) .WithRangeKeyCondition(((RangeFilter)Filter).Condition) .WithScanIndexForward(!IsBackwardSearch) .WithTableName(TableName) .WithBeforeRequestHandler(SourceTable.UserAgentRequestEventHandler) as QueryRequest; if (AttributesToGet !=null) queryReq.AttributesToGet = AttributesToGet; QueryResult queryResult = SourceTable.DDBClient.Query(queryReq).QueryResult; foreach (var item in queryResult.Items) { Document doc = Document.FromAttributeMap(item); ret.Add(doc); Matches.Add(doc); } NextKey = queryResult.LastEvaluatedKey; if (NextKey == null) { IsDone = true; } return ret; default: throw new InvalidOperationException("Unknown Search Method"); } } return ret; }