當前位置: 首頁>>代碼示例>>Java>>正文


Java SqlQuerySpec類代碼示例

本文整理匯總了Java中com.microsoft.azure.documentdb.SqlQuerySpec的典型用法代碼示例。如果您正苦於以下問題:Java SqlQuerySpec類的具體用法?Java SqlQuerySpec怎麽用?Java SqlQuerySpec使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SqlQuerySpec類屬於com.microsoft.azure.documentdb包,在下文中一共展示了SqlQuerySpec類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: GetDatabase

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
public static Database GetDatabase(DocumentClient client, String databaseId) {
    BackoffExponentialRetryPolicy retryPolicy = new BackoffExponentialRetryPolicy();
    QueryIterable<Database> dbIterable = client.queryDatabases(
            new SqlQuerySpec("SELECT * FROM root r WHERE [email protected]",
                    new SqlParameterCollection(new SqlParameter("@id", databaseId))),
            null).getQueryIterable();
    
    List<Database> databases = null;
    while(retryPolicy.shouldRetry()){
        try {
            databases = dbIterable.toList();
            break;
        } catch (Exception e) {
            retryPolicy.errorOccured(e);
        }
    }
    
    if(databases.size() == 0) {
        return null;
    }
    
    return databases.get(0);
}
 
開發者ID:Azure,項目名稱:azure-documentdb-hadoop,代碼行數:24,代碼來源:DocumentDBConnectorUtil.java

示例2: cleanUpGeneratedDatabases

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
private void cleanUpGeneratedDatabases() throws DocumentClientException {
    LOGGER.info("cleanup databases invoked");

    String[] allDatabaseIds = { DATABASE_ID };

    for (String id : allDatabaseIds) {
        try {
            List<FeedResponsePage<Database>> feedResponsePages = asyncClient
                    .queryDatabases(new SqlQuerySpec("SELECT * FROM root r WHERE [email protected]",
                            new SqlParameterCollection(new SqlParameter("@id", id))), null).toList().toBlocking().single();
            
            
            if (!feedResponsePages.get(0).getResults().isEmpty()) {
                Database res = feedResponsePages.get(0).getResults().get(0);
                LOGGER.info("deleting a database " + feedResponsePages.get(0));
                asyncClient.deleteDatabase(res.getSelfLink(), null).toBlocking().single();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:23,代碼來源:DatabaseAndCollectionCreationAsyncAPITest.java

示例3: cleanUpGeneratedDatabases

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
private void cleanUpGeneratedDatabases() throws DocumentClientException {
    LOGGER.info("cleanup databases invoked");

    String[] allDatabaseIds = { DATABASE_ID };

    for (String id : allDatabaseIds) {
        try {
            List<FeedResponsePage<Database>> feedResponsePages = asyncClient
                    .queryDatabases(new SqlQuerySpec("SELECT * FROM root r WHERE [email protected]",
                            new SqlParameterCollection(new SqlParameter("@id", id))), null)
                    .toList().toBlocking().single();

            if (!feedResponsePages.get(0).getResults().isEmpty()) {
                Database res = feedResponsePages.get(0).getResults().get(0);
                LOGGER.info("deleting a database " + feedResponsePages.get(0));
                asyncClient.deleteDatabase(res.getSelfLink(), null).toBlocking().single();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:23,代碼來源:DocumentQueryAsyncAPITest.java

示例4: groupByInMemory_MoreDetail

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
/**
 * This does the same thing as {@link #groupByInMemory_MoreDetail()} but with pedagogical details
 * @throws Exception
 */
@Test
public void groupByInMemory_MoreDetail() throws Exception {

    int requestPageSize = 3;
    FeedOptions options = new FeedOptions();
    options.setPageSize(requestPageSize);


    Observable<Document> documentsObservable = asyncClient
            .queryDocuments(createdCollection.getSelfLink(),
                    new SqlQuerySpec("SELECT * FROM root r WHERE [email protected]_id",
                            new SqlParameterCollection(new SqlParameter("@site_id", "ABC"))),
                    options)
            .flatMap(page -> Observable.from(page.getResults()));

    final LocalDateTime now = LocalDateTime.now();

    Observable<GroupedObservable<Integer, Document>> groupedByPayerIdObservable = documentsObservable
            .filter(doc -> Math.abs(now.getSecond() - doc.getInt("created_time")) <= 90)
            .groupBy(doc -> doc.getInt("payer_id"));

    Observable<List<Document>> docsGroupedAsList = groupedByPayerIdObservable.flatMap(grouped -> {
        Observable<List<Document>> list = grouped.toList();
        return list;
    });

    List<List<Document>> resultsGroupedAsLists = docsGroupedAsList.toList().toBlocking().single();

    for(List<Document> resultsForEachPayer : resultsGroupedAsLists) {
        System.out.println("documents with payer_id : " + resultsForEachPayer.get(0).getInt("payer_id") + " are " + resultsForEachPayer);
    }
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:37,代碼來源:InMemoryGroupbyTest.java

示例5: GetDocumentCollection

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
/**
 * Gets an output collection with the passed name ( if the collection already exists return it, otherwise create new one
 * @param client The DocumentClient instance.
 * @param databaseSelfLink the self link of the passed database.
 * @param collectionId The id of the output collection.
 */
public static DocumentCollection GetDocumentCollection(DocumentClient client, String databaseSelfLink, String collectionId) {
    BackoffExponentialRetryPolicy retryPolicy = new BackoffExponentialRetryPolicy();
    QueryIterable<DocumentCollection> collIterable = client.queryCollections(
            databaseSelfLink,
            new SqlQuerySpec("SELECT * FROM root r WHERE [email protected]",
                    new SqlParameterCollection(new SqlParameter("@id", collectionId))),
            null).getQueryIterable();
    
    List<DocumentCollection> collections = null;
    while(retryPolicy.shouldRetry()){
        try {
            collections = collIterable.toList();
            break;
        } catch (Exception e) {
            retryPolicy.errorOccured(e);
        }
    }
    
    if(collections.size() == 0) {
        return null;
    }
    
    return collections.get(0);
}
 
開發者ID:Azure,項目名稱:azure-documentdb-hadoop,代碼行數:31,代碼來源:DocumentDBConnectorUtil.java

示例6: getDatabase

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
public static Database getDatabase(DocumentClient client, String databaseId) {
    FeedResponse<Database> feedResponsePages = client
            .queryDatabases(new SqlQuerySpec("SELECT * FROM root r WHERE [email protected]",
                    new SqlParameterCollection(new SqlParameter("@id", databaseId))), null);
    Iterator<Database> it = feedResponsePages.getQueryIterator();
    if (it == null || !it.hasNext()) {
        throw new RuntimeException("cannot find database " + databaseId);
    }
    return it.next();
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:11,代碼來源:DocDBUtils.java

示例7: getCollection

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
public static DocumentCollection getCollection(DocumentClient client, String databaseLink, String collectionId) {
    FeedResponse<DocumentCollection> feedResponsePages = client
            .queryCollections(databaseLink, new SqlQuerySpec("SELECT * FROM root r WHERE [email protected]",
                    new SqlParameterCollection(new SqlParameter("@id", collectionId))), null);
    Iterator<DocumentCollection> it = feedResponsePages.getQueryIterator();
    if (it == null || !it.hasNext()) {
        throw new RuntimeException("cannot find collection " + collectionId);
    }
    return it.next();
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:11,代碼來源:DocDBUtils.java

示例8: groupByInMemory

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
/**
 * If you want to understand the steps in more details see {@link #groupByInMemory_MoreDetail()}
 * @throws Exception
 */
@Test
public void groupByInMemory() throws Exception {

    // if you want to understand the steps in more details see groupByInMemoryMoreDetail()

    int requestPageSize = 3;
    FeedOptions options = new FeedOptions();
    options.setPageSize(requestPageSize);

    Observable<Document> documentsObservable = asyncClient
            .queryDocuments(createdCollection.getSelfLink(),
                    new SqlQuerySpec("SELECT * FROM root r WHERE [email protected]_id",
                            new SqlParameterCollection(new SqlParameter("@site_id", "ABC"))),
                    options)
            .flatMap(page -> Observable.from(page.getResults()));

    final LocalDateTime now = LocalDateTime.now();

    List<List<Document>> resultsGroupedAsLists = documentsObservable
            .filter(doc -> Math.abs(now.getSecond() - doc.getInt("created_time")) <= 90)
            .groupBy(doc -> doc.getInt("payer_id")).flatMap(grouped -> grouped.toList())
            .toList()
            .toBlocking()
            .single();

    for(List<Document> resultsForEachPayer :resultsGroupedAsLists) {
        System.out.println("documents with payer_id : " + resultsForEachPayer.get(0).getInt("payer_id") + " are " + resultsForEachPayer);
    }
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:34,代碼來源:InMemoryGroupbyTest.java

示例9: queryDatabases

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
@Override
public Observable<FeedResponsePage<Database>> queryDatabases(final SqlQuerySpec querySpec, final FeedOptions options) {
    return this.createFeedResponsePageObservable(new ImplFunc<FeedResponse<Database>>() {
        @Override
        public FeedResponse<Database> invoke() throws Exception {
            return client.queryDatabases(querySpec, options);
        }
    });
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:10,代碼來源:RxWrapperDocumentClientImpl.java

示例10: queryCollections

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
@Override
public Observable<FeedResponsePage<DocumentCollection>> queryCollections(final String databaseLink, final
        SqlQuerySpec querySpec, final FeedOptions options) {
    return this.createFeedResponsePageObservable(new ImplFunc<FeedResponse<DocumentCollection>>() {
        @Override
        public FeedResponse<DocumentCollection> invoke() throws Exception {
            return client.queryCollections(databaseLink, querySpec, options);
        }
    });
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:11,代碼來源:RxWrapperDocumentClientImpl.java

示例11: queryDocuments

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
@Override
public Observable<FeedResponsePage<Document>> queryDocuments(final String collectionLink, final SqlQuerySpec querySpec, final
        FeedOptions options) {
    return this.createFeedResponsePageObservable(new ImplFunc<FeedResponse<Document>>() {
        @Override
        public FeedResponse<Document> invoke() throws Exception {
            return client.queryDocuments(collectionLink, querySpec, options);
        }
    });
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:11,代碼來源:RxWrapperDocumentClientImpl.java

示例12: queryStoredProcedures

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
@Override
public Observable<FeedResponsePage<StoredProcedure>> queryStoredProcedures(final String collectionLink, final
        SqlQuerySpec querySpec, final FeedOptions options) {
    return this.createFeedResponsePageObservable(new ImplFunc<FeedResponse<StoredProcedure>>() {
        @Override
        public FeedResponse<StoredProcedure> invoke() throws Exception {
            return client.queryStoredProcedures(collectionLink, querySpec, options);
        }
    });
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:11,代碼來源:RxWrapperDocumentClientImpl.java

示例13: queryTriggers

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
@Override
public Observable<FeedResponsePage<Trigger>> queryTriggers(final String collectionLink, final SqlQuerySpec querySpec, final
        FeedOptions options) {
    return this.createFeedResponsePageObservable(new ImplFunc<FeedResponse<Trigger>>() {
        @Override
        public FeedResponse<Trigger> invoke() throws Exception {
            return client.queryTriggers(collectionLink, querySpec, options);
        }
    });
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:11,代碼來源:RxWrapperDocumentClientImpl.java

示例14: queryUserDefinedFunctions

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
@Override
public Observable<FeedResponsePage<UserDefinedFunction>> queryUserDefinedFunctions(final String collectionLink, final
        SqlQuerySpec querySpec, final FeedOptions options) {
    return this.createFeedResponsePageObservable(new ImplFunc<FeedResponse<UserDefinedFunction>>() {
        @Override
        public FeedResponse<UserDefinedFunction> invoke() throws Exception {
            return client.queryUserDefinedFunctions(collectionLink, querySpec, options);
        }
    });
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:11,代碼來源:RxWrapperDocumentClientImpl.java

示例15: queryAttachments

import com.microsoft.azure.documentdb.SqlQuerySpec; //導入依賴的package包/類
@Override
public Observable<FeedResponsePage<Attachment>> queryAttachments(final String documentLink, final SqlQuerySpec querySpec, final
        FeedOptions options) {
    return this.createFeedResponsePageObservable(new ImplFunc<FeedResponse<Attachment>>() {
        @Override
        public FeedResponse<Attachment> invoke() throws Exception {
            return client.queryAttachments(documentLink, querySpec, options);
        }
    });
}
 
開發者ID:Azure,項目名稱:azure-documentdb-rxjava,代碼行數:11,代碼來源:RxWrapperDocumentClientImpl.java


注:本文中的com.microsoft.azure.documentdb.SqlQuerySpec類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。