Skip to content

Commit

Permalink
Clean-up DatastoreV1.java
Browse files Browse the repository at this point in the history
Fix javadoc link, move off of deprecated getProperties() method to getPropertiesOrThrow()
  • Loading branch information
lukecwik committed Oct 28, 2022
1 parent 07b823a commit e8559c4
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public class DatastoreV1 {
/**
* When choosing the number of updates in a single RPC, do not go below this value. The actual
* number of entities per request may be lower when we flush for the end of a bundle or if we hit
* {@link DatastoreV1.DATASTORE_BATCH_UPDATE_BYTES_LIMIT}.
* {@link #DATASTORE_BATCH_UPDATE_BYTES_LIMIT}.
*/
@VisibleForTesting static final int DATASTORE_BATCH_UPDATE_ENTITIES_MIN = 5;

Expand Down Expand Up @@ -398,7 +398,7 @@ private static long queryLatestStatisticsTimestamp(
throw new NoSuchElementException("Datastore total statistics unavailable");
}
Entity entity = batch.getEntityResults(0).getEntity();
return entity.getProperties().get("timestamp").getTimestampValue().getSeconds() * 1000000;
return entity.getPropertiesOrThrow("timestamp").getTimestampValue().getSeconds() * 1000000;
}

/**
Expand Down Expand Up @@ -451,7 +451,7 @@ static long getEstimatedSizeBytes(
throws DatastoreException {
String ourKind = query.getKind(0).getName();
Entity entity = getLatestTableStats(ourKind, namespace, datastore, readTime);
return entity.getProperties().get("entity_bytes").getIntegerValue();
return entity.getPropertiesOrThrow("entity_bytes").getIntegerValue();
}

private static PartitionId.Builder forNamespace(@Nullable String namespace) {
Expand Down Expand Up @@ -684,7 +684,7 @@ public long getNumEntities(
options, v1Options.getProjectId(), v1Options.getLocalhost());

Entity entity = getLatestTableStats(ourKind, namespace, datastore, getReadTime());
return entity.getProperties().get("count").getIntegerValue();
return entity.getPropertiesOrThrow("count").getIntegerValue();
} catch (Exception e) {
return -1;
}
Expand Down

0 comments on commit e8559c4

Please sign in to comment.