From 4c1157faa56b6fa68965a9438d5b25ee5a99ee2b Mon Sep 17 00:00:00 2001 From: aman bansal Date: Mon, 20 May 2024 21:52:14 +0530 Subject: [PATCH 1/3] Revert "fix | fix the query for fetching the updated document (#282)" This reverts commit a5b594f00d08df87991718a96006e60820fcf667. --- .../entity/query/service/EntityQueryServiceImpl.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/entity-service-impl/src/main/java/org/hypertrace/entity/query/service/EntityQueryServiceImpl.java b/entity-service-impl/src/main/java/org/hypertrace/entity/query/service/EntityQueryServiceImpl.java index 2039b195..d682dd04 100644 --- a/entity-service-impl/src/main/java/org/hypertrace/entity/query/service/EntityQueryServiceImpl.java +++ b/entity-service-impl/src/main/java/org/hypertrace/entity/query/service/EntityQueryServiceImpl.java @@ -6,7 +6,6 @@ import static java.util.Objects.isNull; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toUnmodifiableList; -import static org.hypertrace.core.documentstore.expression.operators.RelationalOperator.EQ; import static org.hypertrace.core.documentstore.expression.operators.RelationalOperator.IN; import static org.hypertrace.core.documentstore.model.options.ReturnDocumentType.NONE; import static org.hypertrace.entity.data.service.v1.AttributeValue.VALUE_LIST_FIELD_NUMBER; @@ -343,10 +342,7 @@ public void update(EntityUpdateRequest request, StreamObserver r // Finally, return the selections List documents = getProjectedDocuments( - maybeTenantId.get(), - request.getEntityIdsList(), - request.getSelectionList(), - requestContext); + request.getEntityIdsList(), request.getSelectionList(), requestContext); responseObserver.onNext( convertDocumentsToResultSetChunk(documents, request.getSelectionList())); @@ -535,7 +531,6 @@ private JSONDocument convertToJsonDocument(LiteralConstant literalConstant) { } private List getProjectedDocuments( - final String tenantId, final Iterable entityIds, final List selectionList, final RequestContext requestContext) @@ -555,11 +550,6 @@ private List getProjectedDocuments( IdentifierExpression.of(EntityServiceConstants.ENTITY_ID), IN, ConstantExpression.ofStrings(entityIdList))) - .expression( - RelationalExpression.of( - IdentifierExpression.of(EntityServiceConstants.TENANT_ID), - EQ, - ConstantExpression.of(tenantId))) .build(); final org.hypertrace.core.documentstore.query.Query query = From 82b074bf4dd6f779c52c18ad76b3f9bfdb79daaa Mon Sep 17 00:00:00 2001 From: aman-bansal Date: Mon, 20 May 2024 21:56:17 +0530 Subject: [PATCH 2/3] fix | fix the query for fetching the updated document --- .../query/service/EntityQueryServiceImpl.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/entity-service-impl/src/main/java/org/hypertrace/entity/query/service/EntityQueryServiceImpl.java b/entity-service-impl/src/main/java/org/hypertrace/entity/query/service/EntityQueryServiceImpl.java index d682dd04..4d68d0d9 100644 --- a/entity-service-impl/src/main/java/org/hypertrace/entity/query/service/EntityQueryServiceImpl.java +++ b/entity-service-impl/src/main/java/org/hypertrace/entity/query/service/EntityQueryServiceImpl.java @@ -6,6 +6,7 @@ import static java.util.Objects.isNull; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toUnmodifiableList; +import static org.hypertrace.core.documentstore.expression.operators.RelationalOperator.EQ; import static org.hypertrace.core.documentstore.expression.operators.RelationalOperator.IN; import static org.hypertrace.core.documentstore.model.options.ReturnDocumentType.NONE; import static org.hypertrace.entity.data.service.v1.AttributeValue.VALUE_LIST_FIELD_NUMBER; @@ -45,6 +46,7 @@ import org.hypertrace.core.documentstore.SingleValueKey; import org.hypertrace.core.documentstore.expression.impl.ConstantExpression; import org.hypertrace.core.documentstore.expression.impl.IdentifierExpression; +import org.hypertrace.core.documentstore.expression.impl.LogicalExpression; import org.hypertrace.core.documentstore.expression.impl.RelationalExpression; import org.hypertrace.core.documentstore.model.options.UpdateOptions; import org.hypertrace.core.documentstore.model.subdoc.SubDocumentUpdate; @@ -342,7 +344,10 @@ public void update(EntityUpdateRequest request, StreamObserver r // Finally, return the selections List documents = getProjectedDocuments( - request.getEntityIdsList(), request.getSelectionList(), requestContext); + maybeTenantId.get(), + request.getEntityIdsList(), + request.getSelectionList(), + requestContext); responseObserver.onNext( convertDocumentsToResultSetChunk(documents, request.getSelectionList())); @@ -531,6 +536,7 @@ private JSONDocument convertToJsonDocument(LiteralConstant literalConstant) { } private List getProjectedDocuments( + final String tenantId, final Iterable entityIds, final List selectionList, final RequestContext requestContext) @@ -546,10 +552,16 @@ private List getProjectedDocuments( final Filter filter = Filter.builder() .expression( - RelationalExpression.of( - IdentifierExpression.of(EntityServiceConstants.ENTITY_ID), - IN, - ConstantExpression.ofStrings(entityIdList))) + LogicalExpression.and( + List.of( + RelationalExpression.of( + IdentifierExpression.of(EntityServiceConstants.ENTITY_ID), + IN, + ConstantExpression.ofStrings(entityIdList)), + RelationalExpression.of( + IdentifierExpression.of(EntityServiceConstants.TENANT_ID), + EQ, + ConstantExpression.of(tenantId))))) .build(); final org.hypertrace.core.documentstore.query.Query query = From 8f86f0c7c4e09e7d4e032e9c448b560b04d8342a Mon Sep 17 00:00:00 2001 From: aman-bansal Date: Mon, 20 May 2024 22:04:47 +0530 Subject: [PATCH 3/3] making it pretty --- .../entity/query/service/EntityQueryServiceImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/entity-service-impl/src/main/java/org/hypertrace/entity/query/service/EntityQueryServiceImpl.java b/entity-service-impl/src/main/java/org/hypertrace/entity/query/service/EntityQueryServiceImpl.java index 13bf70eb..4d68d0d9 100644 --- a/entity-service-impl/src/main/java/org/hypertrace/entity/query/service/EntityQueryServiceImpl.java +++ b/entity-service-impl/src/main/java/org/hypertrace/entity/query/service/EntityQueryServiceImpl.java @@ -6,6 +6,7 @@ import static java.util.Objects.isNull; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toUnmodifiableList; +import static org.hypertrace.core.documentstore.expression.operators.RelationalOperator.EQ; import static org.hypertrace.core.documentstore.expression.operators.RelationalOperator.IN; import static org.hypertrace.core.documentstore.model.options.ReturnDocumentType.NONE; import static org.hypertrace.entity.data.service.v1.AttributeValue.VALUE_LIST_FIELD_NUMBER; @@ -343,7 +344,10 @@ public void update(EntityUpdateRequest request, StreamObserver r // Finally, return the selections List documents = getProjectedDocuments( - request.getEntityIdsList(), request.getSelectionList(), requestContext); + maybeTenantId.get(), + request.getEntityIdsList(), + request.getSelectionList(), + requestContext); responseObserver.onNext( convertDocumentsToResultSetChunk(documents, request.getSelectionList())); @@ -532,6 +536,7 @@ private JSONDocument convertToJsonDocument(LiteralConstant literalConstant) { } private List getProjectedDocuments( + final String tenantId, final Iterable entityIds, final List selectionList, final RequestContext requestContext)