Skip to content

Commit

Permalink
Clean up test code and javadoc formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajay Kannan committed Mar 1, 2016
1 parent f6cc097 commit 15865cc
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 311 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,19 @@ static KeyFactory newKeyFactory(DatastoreOptions options) {
}

/**
* Returns a list with a value for each given key (ordered by input).
* {@code null} values are returned for nonexistent keys.
* Returns a list with a value for each given key (ordered by input). {@code null} values are
* returned for nonexistent keys.
*/
static List<Entity> fetch(Transaction reader, Key... keys) {
Iterator<Entity> entities = reader.get(keys);
return compileEntities(keys, entities);
return compileEntities(keys, reader.get(keys));
}

/**
* Returns a list with a value for each given key (ordered by input).
* {@code null} values are returned for nonexistent keys.
* Returns a list with a value for each given key (ordered by input). {@code null} values are
* returned for nonexistent keys.
*/
static List<Entity> fetch(Datastore reader, Key[] keys, ReadOption... options) {
Iterator<Entity> entities;
entities = reader.get(Arrays.asList(keys), options);
return compileEntities(keys, entities);
return compileEntities(keys, reader.get(Arrays.asList(keys), options));
}

private static List<Entity> compileEntities(Key[] keys, Iterator<Entity> entities) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,11 @@ public Iterator<Entity> get(Iterable<Key> keys, ReadOption... options) {

private static com.google.datastore.v1beta3.ReadOptions toReadOptionsPb(ReadOption... options) {
com.google.datastore.v1beta3.ReadOptions readOptionsPb = null;
if (options != null) {
Map<Class<? extends ReadOption>, ReadOption> optionsMap = ReadOption.asImmutableMap(options);
EventualConsistency eventualConsistency =
(EventualConsistency) optionsMap.get(EventualConsistency.class);
if (eventualConsistency != null) {
readOptionsPb =
com.google.datastore.v1beta3.ReadOptions.newBuilder()
.setReadConsistency(ReadConsistency.EVENTUAL)
.build();
}
if (options != null
&& ReadOption.asImmutableMap(options).containsKey(EventualConsistency.class)) {
readOptionsPb = com.google.datastore.v1beta3.ReadOptions.newBuilder()
.setReadConsistency(ReadConsistency.EVENTUAL)
.build();
}
return readOptionsPb;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public boolean isEventual() {
}
}

ReadOption() {}
private ReadOption() {}

/**
* Returns a {@code ReadOption} that specifies eventual consistency.
Expand Down
Loading

0 comments on commit 15865cc

Please sign in to comment.