Search in sources :

Example 21 with Datastore

use of com.google.datastore.v1.client.Datastore in project beam by apache.

the class DatastoreV1 method isValidKey.

/**
   * Returns true if a Cloud Datastore key is complete. A key is complete if its last element
   * has either an id or a name.
   */
static boolean isValidKey(Key key) {
    List<PathElement> elementList = key.getPathList();
    if (elementList.isEmpty()) {
        return false;
    }
    PathElement lastElement = elementList.get(elementList.size() - 1);
    return (lastElement.getId() != 0 || !lastElement.getName().isEmpty());
}
Also used : PathElement(com.google.datastore.v1.Key.PathElement)

Aggregations

Test (org.junit.Test)11 Entity (com.google.datastore.v1.Entity)5 Query (com.google.datastore.v1.Query)5 Key (com.google.datastore.v1.Key)4 LookupRequest (com.google.datastore.v1.LookupRequest)4 RunQueryRequest (com.google.datastore.v1.RunQueryRequest)4 Datastore (com.google.datastore.v1.client.Datastore)4 RunQueryResponse (com.google.datastore.v1.RunQueryResponse)3 DatastoreHelper.makeKey (com.google.datastore.v1.client.DatastoreHelper.makeKey)3 DeleteEntity (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteEntity)3 DeleteKey (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteKey)3 DatastoreV1.isValidKey (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.isValidKey)3 GqlQuery (com.google.datastore.v1.GqlQuery)2 ReadOptions (com.google.datastore.v1.ReadOptions)2 DatastoreException (com.google.datastore.v1.client.DatastoreException)2 DatastoreOptions (com.google.datastore.v1.client.DatastoreOptions)2 ByteString (com.google.protobuf.ByteString)2 Status (com.yahoo.ycsb.Status)2 StringByteIterator (com.yahoo.ycsb.StringByteIterator)2 Credential (com.google.api.client.auth.oauth2.Credential)1