Skip to content

Commit

Permalink
high level changes
Browse files Browse the repository at this point in the history
  • Loading branch information
srinjoyray committed Oct 28, 2024
1 parent 4a9e891 commit e3f4cf2
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ protected TransactionImpl.InternalTransaction doBeginTransaction(TransactionOpti

Future<DatastoreV3Pb.Transaction> future =
DatastoreApiHelper.makeAsyncCall(
apiConfig, DatastoreService_3.Method.BeginTransaction, request.build(), remoteTxn.buildPartial());
apiConfig, DatastoreService_3.Method.BeginTransaction, request.build(), remoteTxn.build());

return new InternalTransactionV3(apiConfig, request.getApp(), future);
}
Expand Down Expand Up @@ -527,7 +527,7 @@ public Future<KeyRange> allocateIds(final Key parent, final String kind, long nu
req.setModelKey(allocateIdsRef);
AllocateIdsResponse.Builder resp = AllocateIdsResponse.newBuilder();
Future<AllocateIdsResponse> future =
makeAsyncCall(apiConfig, DatastoreService_3.Method.AllocateIds, req.buildPartial(), resp.buildPartial());
makeAsyncCall(apiConfig, DatastoreService_3.Method.AllocateIds, req.build(), resp.build());
return new FutureWrapper<AllocateIdsResponse, KeyRange>(future) {
@Override
protected KeyRange wrap(AllocateIdsResponse resp) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected String generateXmlForIndex(Index index, IndexSource source) {
* @return The index that must be present in order to fulfill the query, or {@code null} if no
* index is needed.
*/
protected Index.Builder compositeIndexForQuery(final IndexComponentsOnlyQuery indexOnlyQuery) {
protected Index.Builder compositeIndexForQuery(final IndexComponentsOnlyQuery indexOnlyQuery) {
DatastoreV3Pb.Query.Builder query = indexOnlyQuery.getQuery().toBuilder();

boolean hasKind = query.hasKind();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ private static void addListPropertyToPb(
}
property.getValue(); // Indicate to the proto that we have set this field
if (indexed) {
proto.addProperty(property.buildPartial());
proto.addProperty(property.build());
} else {
proto.addRawProperty(property.buildPartial());
proto.addRawProperty(property.build());
}
} else {
// Write every element to the PB
Expand Down Expand Up @@ -395,7 +395,7 @@ private static Property buildImplicitKeyProperty(EntityProto proto) {
PropertyValue.Builder propVal = PropertyValue.newBuilder();
propVal.setReferenceValue(KeyType.toReferenceValue(proto.getKey()));
keyProp.setValue(propVal.build());
return keyProp.buildPartial();
return keyProp.build();
}

/**
Expand Down Expand Up @@ -1663,7 +1663,7 @@ public EmbeddedEntity getValue(PropertyValue propertyValue) {
if (proto.hasKey() && !proto.getKey().getApp().isEmpty()) {
result.setKey(KeyTranslator.createFromPb(proto.getKey()));
}
extractPropertiesFromPb(proto.buildPartial(), result.getPropertyMap());
extractPropertiesFromPb(proto.build(), result.getPropertyMap());
return result;
}

Expand All @@ -1687,7 +1687,7 @@ public void toV3Value(Object value, PropertyValue.Builder propertyValue) {
}
addPropertiesToPb(structProp.getPropertyMap(), proto);
// TODO: Figure out how to do partial serialization.
propertyValue.setStringValueBytes(proto.buildPartial().toByteString()).buildPartial();
propertyValue.setStringValueBytes(proto.build().toByteString()).build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static EntityProto convertToPb(Entity entity) {
}

DataTypeTranslator.addPropertiesToPb(entity.getPropertyMap(), proto);
return proto.buildPartial();
return proto.build();
}

// All methods are static. Do not instantiate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ public static Index.Property convertFromPb(OnestoreEntity.Index.Property propert
}

public static Index convertFromPb(OnestoreEntity.Index index) {
return convertFromPb(OnestoreEntity.CompositeIndex.newBuilder().setId(0).setDefinition(index).buildPartial());
return convertFromPb(OnestoreEntity.CompositeIndex.newBuilder().setId(0).setDefinition(index).build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static Reference convertToPb(Key key) {
reference.setNameSpace(nameSpace);
}

Path.Builder path = reference.buildPartial().getPath().toBuilder();
Path.Builder path = reference.getPathBuilder();
while (key != null) {
Element.Builder pathElement = Element.newBuilder();
pathElement.setType(key.getKind());
Expand All @@ -91,7 +91,7 @@ public static Reference convertToPb(Key key) {
reversedPath.addElement(element);
}
reference.setPath(reversedPath.build());
return reference.buildPartial();
return reference.build();
}

public static void updateKey(Reference reference, Key key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public NextRequest buildNextCallPrototype(QueryResult initialResult) {
req.setCompile(true);
}
// This used to call .freeze() but that method has been deleted, see go/javaproto1freezeremoval
return req.buildPartial();
return req.build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ public QueryResultsSource runQuery(FetchOptions fetchOptions, Query query, Trans

Future<DatastoreV3Pb.QueryResult> result =
DatastoreApiHelper.makeAsyncCall(
apiConfig, Method.RunQuery, queryProto.buildPartial(), DatastoreV3Pb.QueryResult.newBuilder().buildPartial());
apiConfig, Method.RunQuery, queryProto.build(), DatastoreV3Pb.QueryResult.getDefaultInstance());

// Adding more info to DatastoreNeedIndexException if thrown
result =
new FutureWrapper<DatastoreV3Pb.QueryResult, DatastoreV3Pb.QueryResult>(result) {
@Override
protected Throwable convertException(Throwable cause) {
if (cause instanceof DatastoreNeedIndexException) {
addMissingIndexData(queryProto.buildPartial(), (DatastoreNeedIndexException) cause);
addMissingIndexData(queryProto.build(), (DatastoreNeedIndexException) cause);
}
return cause;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static DatastoreV3Pb.Query convertToPb(Query query, FetchOptions fetchOpt
proto.addPropertyName(projection.getPropertyName());
}

return proto.buildPartial();
return proto.build();
}

static Order convertSortPredicateToPb(Query.SortPredicate predicate) {
Expand Down Expand Up @@ -213,7 +213,7 @@ private static Filter convertFilterPredicateToPb(Query.FilterPredicate predicate
.setValue(DataTypeTranslator.toV3Value(predicate.getValue()));
}

return filterPb.buildPartial();
return filterPb.build();
}

private static DatastoreV3Pb.GeoRegion convertGeoRegionToPb(Query.GeoRegion region) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Message;
import com.google.protobuf.MessageLite;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

Expand Down Expand Up @@ -50,7 +49,7 @@ public static <T> T convertBytesToPb(byte[] bytes, Class<T> messageClass)
throw new RuntimeException(
"Could not parse request bytes into " + classDescription(messageClass));
}
return messageClass.cast(proto.buildPartial());
return messageClass.cast(proto.build());
}
if (Message.class.isAssignableFrom(messageClass)) {
Method method = messageClass.getMethod("parseFrom", byte[].class);
Expand Down

0 comments on commit e3f4cf2

Please sign in to comment.