use of org.jpl7.Query in project beam by apache.
the class V1TestUtil method deleteAllEntities.
/**
* Delete all entities with the given ancestor.
*/
static void deleteAllEntities(V1TestOptions options, String project, String ancestor) throws Exception {
Datastore datastore = getDatastore(options, project);
Query query = V1TestUtil.makeAncestorKindQuery(options.getKind(), options.getNamespace(), ancestor);
V1TestReader reader = new V1TestReader(datastore, query, options.getNamespace());
V1TestWriter writer = new V1TestWriter(datastore, new DeleteMutationBuilder());
long numEntities = 0;
while (reader.advance()) {
Entity entity = reader.getCurrent();
numEntities++;
writer.write(entity);
}
writer.close();
LOG.info("Successfully deleted {} entities", numEntities);
}
use of org.jpl7.Query in project beam by apache.
the class V1TestUtil method countEntities.
/**
* Returns the total number of entities for the given datastore.
*/
static long countEntities(V1TestOptions options, String project, String ancestor) throws Exception {
// Read from datastore.
Datastore datastore = V1TestUtil.getDatastore(options, project);
Query query = V1TestUtil.makeAncestorKindQuery(options.getKind(), options.getNamespace(), ancestor);
V1TestReader reader = new V1TestReader(datastore, query, options.getNamespace());
long numEntitiesRead = 0;
while (reader.advance()) {
reader.getCurrent();
numEntitiesRead++;
}
return numEntitiesRead;
}
Aggregations