Search in sources :

Example 1 with ListDocumentsPagedResponse

use of com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse in project beam by apache.

the class FirestoreTestingHelper method listDocumentIds.

Stream<String> listDocumentIds(String collectionPath) {
    int index = collectionPath.lastIndexOf('/');
    String parent = collectionPath.substring(0, index);
    String collectionId = collectionPath.substring(index + 1);
    ListDocumentsRequest ldr = ListDocumentsRequest.newBuilder().setParent(parent).setCollectionId(collectionId).setShowMissing(true).build();
    // LOGGER.debug("ldr = {}", ldr);
    ListDocumentsPagedResponse response = rpc.listDocumentsPagedCallable().call(ldr);
    return StreamSupport.stream(response.iteratePages().spliterator(), false).flatMap(page -> page.getResponse().getDocumentsList().stream()).map(Document::getName).filter(s -> !s.isEmpty());
}
Also used : ListDocumentsRequest(com.google.firestore.v1.ListDocumentsRequest) ListDocumentsPagedResponse(com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse)

Aggregations

ListDocumentsPagedResponse (com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse)1 ListDocumentsRequest (com.google.firestore.v1.ListDocumentsRequest)1