/** * Executes a query in segmented mode with a {@link ResultContinuation} continuation token. * Executing a query with <code>executeSegmented</code> allows the query to be resumed after returning partial * results, using information returned by the server in the {@link ResultSegment} object. * <p> * This method will invoke a <a href="http://msdn.microsoft.com/en-us/library/azure/dd179421.aspx">Query * Entities</a> operation on the <a href="http://msdn.microsoft.com/en-us/library/azure/dd179423.aspx">Table Service * REST API</a> to query the table, using the Table service endpoint and storage account credentials of this * instance. * * @param query * A {@link TableQuery} instance specifying the table to query and the query parameters to use, * specialized for a type T implementing {@link TableEntity}. * @param continuationToken * A {@link ResultContinuation} object representing a continuation token from the server when the * operation returns a partial result. Specify <code>null</code> on the initial call. Call the * {@link ResultSegment#getContinuationToken()} method on the result to obtain the * {@link ResultContinuation} object to use in the next call to resume the query. * * @return * A {@link ResultSegment} specialized for type T of the results of executing the query. * * @throws StorageException * if a storage service error occurred during the operation. */ @DoesServiceRequest public <T extends TableEntity> ResultSegment<T> executeSegmented(final TableQuery<T> query, final ResultContinuation continuationToken) throws StorageException { return this.executeSegmented(query, continuationToken, null /* options */, null /* opContext */); }
public <R> ResultSegment<R> executeSegmented(final TableQuery<?> query, final EntityResolver<R> resolver, final ResultContinuation continuationToken) throws StorageException { return this.executeSegmented(query, resolver, continuationToken, null /* options */, null /* opContext */);
/** * Executes a query in segmented mode with a {@link ResultContinuation} continuation token. * Executing a query with <code>executeSegmented</code> allows the query to be resumed after returning partial * results, using information returned by the server in the {@link ResultSegment} object. * <p> * This method will invoke a <a href="http://msdn.microsoft.com/en-us/library/azure/dd179421.aspx">Query * Entities</a> operation on the <a href="http://msdn.microsoft.com/en-us/library/azure/dd179423.aspx">Table Service * REST API</a> to query the table, using the Table service endpoint and storage account credentials of this * instance. * * @param query * A {@link TableQuery} instance specifying the table to query and the query parameters to use, * specialized for a type T implementing {@link TableEntity}. * @param continuationToken * A {@link ResultContinuation} object representing a continuation token from the server when the * operation returns a partial result. Specify <code>null</code> on the initial call. Call the * {@link ResultSegment#getContinuationToken()} method on the result to obtain the * {@link ResultContinuation} object to use in the next call to resume the query. * * @return * A {@link ResultSegment} specialized for type T of the results of executing the query. * * @throws StorageException * if a storage service error occurred during the operation. */ @DoesServiceRequest public <T extends TableEntity> ResultSegment<T> executeSegmented(final TableQuery<T> query, final ResultContinuation continuationToken) throws StorageException { return this.executeSegmented(query, continuationToken, null /* options */, null /* opContext */); }
public <R> ResultSegment<R> executeSegmented(final TableQuery<?> query, final EntityResolver<R> resolver, final ResultContinuation continuationToken) throws StorageException { return this.executeSegmented(query, resolver, continuationToken, null /* options */, null /* opContext */);
private void testTableWithSelectOnMissingFields(TableRequestOptions options) throws StorageException { TableQuery<DynamicTableEntity> projectionQuery = TableQuery.from(DynamicTableEntity.class).where( "(PartitionKey eq 'javatables_batch_0') and (RowKey eq '000000')"); // A exists, F does not projectionQuery.select(new String[]{"A", "F"}); ResultSegment<DynamicTableEntity> seg = table.executeSegmented(projectionQuery, null, options, null); assertEquals(1, seg.getResults().size()); DynamicTableEntity ent = seg.getResults().get(0); assertEquals("foo_A", ent.getProperties().get("A").getValueAsString()); assertEquals(null, ent.getProperties().get("F").getValueAsString()); assertEquals(EdmType.STRING, ent.getProperties().get("F").getEdmType()); }
@Test public void testTableInvalidQuery() throws StorageException { TableRequestOptions options = new TableRequestOptions(); options.setTablePayloadFormat(TablePayloadFormat.Json); TableQuery<Class1> query = TableQuery.from(Class1.class).where( String.format("(PartitionKey ) and (RowKey ge '%s')", "000050")); try { table.executeSegmented(query, null, options, null); fail(); } catch (TableServiceException ex) { assertEquals(ex.getMessage(), "Bad Request"); assertTrue(ex.getExtendedErrorInformation().getErrorMessage() .startsWith("A binary operator with incompatible types was detected. Found operand types 'Edm.String' and 'Edm.Boolean' for operator kind 'And'.")); assertEquals(ex.getExtendedErrorInformation().getErrorCode(), "InvalidInput"); } }
private void testTableQueryWithSpecialChars(char charToTest, CloudTable table) throws StorageException, URISyntaxException { String partitionKey = "partition" + charToTest + "key"; String rowKey = "row" + charToTest + "key"; EmptyClass ref = new EmptyClass(); ref.setPartitionKey(partitionKey); ref.setRowKey(rowKey); table.execute(TableOperation.insert(ref)); String condition = TableQuery.generateFilterCondition(TableConstants.PARTITION_KEY, QueryComparisons.EQUAL, partitionKey); ResultSegment<EmptyClass> seg = table.executeSegmented(TableQuery.from(EmptyClass.class).where(condition), null); assertEquals(1, seg.getLength()); assertEquals(partitionKey, seg.getResults().get(0).getPartitionKey()); }
private void testTableQueryWithTake(TableRequestOptions options, boolean usePropertyResolver) throws StorageException { // Create entity to check against Class1 randEnt = TableTestHelper.generateRandomEntity(null); if (usePropertyResolver) { options.setPropertyResolver(randEnt); } final ResultSegment<Class1> result = table.executeSegmented( TableQuery.from(Class1.class).select(new String[] { "A", "C" }).take(25), null, options, null); int count = 0; // Validate results for (Class1 ent : result.getResults()) { count++; assertEquals(ent.getA(), randEnt.getA()); assertEquals(ent.getB(), null); assertEquals(ent.getC(), randEnt.getC()); assertEquals(ent.getD(), null); } assertEquals(count, 25); }