Skip to content

Commit

Permalink
wip - fixed DatastoreCallbacksTests
Browse files Browse the repository at this point in the history
  • Loading branch information
srinjoyray committed Nov 7, 2024
1 parent 6b973ca commit d770e51
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.protobuf.Message;
import com.google.protobuf.MessageLite;
import com.google.protobuf.MessageLiteOrBuilder;
import com.google.storage.onestore.v3.proto2api.OnestoreEntity.CompositeIndex;
import com.google.storage.onestore.v3.proto2api.OnestoreEntity.EntityProto;
Expand Down Expand Up @@ -79,13 +80,13 @@ class AsyncDatastoreServiceImpl extends BaseAsyncDatastoreServiceImpl {
*/
private abstract class V3Batcher<
S extends Message,
R extends MessageLiteOrBuilder,
R extends MessageLite.Builder,
F,
T extends Message>
extends BaseRpcBatcher<S, R, F, T> {
@Override
final R newBatch(R baseBatch) {
return (R) baseBatch.getDefaultInstanceForType().toBuilder().clone();
return (R) baseBatch.clone();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,7 @@ public EmbeddedEntity getValue(PropertyValue propertyValue) {
if (proto.hasKey() && !proto.getKey().getApp().isEmpty()) {
result.setKey(KeyTranslator.createFromPb(proto.getKey()));
}
extractPropertiesFromPb(proto.build(), result.getPropertyMap());
extractPropertiesFromPb(proto.buildPartial(), result.getPropertyMap());
return result;
}

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,12 +864,12 @@ public PutResponse putImpl(Status status, PutRequest request) {
EntityProto.Builder clone = entity.toBuilder().clone();
clones.add(clone.build());
checkArgument(clone.hasKey());
Reference key = clone.getKey();
Reference.Builder key = clone.getKeyBuilder();
checkArgument(key.getPath().getElementCount() > 0);

clone.getKey().toBuilder().setApp(app);
clone.getKeyBuilder().setApp(app);

Element.Builder lastPath = getLastElement(key).toBuilder();
Element.Builder lastPath = getLastElement(key.build()).toBuilder();

if (lastPath.getId() == 0 && !lastPath.hasName()) {
if (autoIdAllocationPolicy == AutoIdAllocationPolicy.SEQUENTIAL) {
Expand All @@ -878,12 +878,12 @@ public PutResponse putImpl(Status status, PutRequest request) {
lastPath.setId(toScatteredId(entityIdScattered.getAndIncrement()));
}
}

key.getPathBuilder().setElement(key.getPath().getElementCount() - 1, lastPath);
preprocessEntity(clone);

if (clone.getEntityGroup().getElementCount() == 0) {
// The entity needs its entity group set.
Path.Builder group = clone.getEntityGroup().toBuilder();
Path.Builder group = clone.getEntityGroupBuilder();
Element root = key.getPath().getElementList().get(0);
Element.Builder pathElement = group.addElementBuilder();
pathElement.setType(root.getType());
Expand Down Expand Up @@ -2775,7 +2775,7 @@ private EntityProto.Builder postProcessEntityForQuery(EntityProto entity) {
.mergeFrom(prop.getValue());
}
}
} else if (query.hasKeysOnly()) {
} else if (query.getKeysOnly()) {
result = EntityProto.newBuilder();
result.getKeyBuilder().mergeFrom(entity.getKey());
result.getEntityGroup();
Expand Down
4 changes: 0 additions & 4 deletions shared_sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,5 @@
<artifactId>auto-value</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-apis</artifactId>
</dependency>
</dependencies>
</project>

0 comments on commit d770e51

Please sign in to comment.