use of org.hypertrace.entity.query.service.v1.TotalEntitiesRequest in project gateway-service by hypertrace.
the class EntityDataServiceEntityFetcher method getTotal.
@Override
public long getTotal(EntitiesRequestContext requestContext, EntitiesRequest entitiesRequest) {
EntityQueryRequest.Builder builder = EntityQueryRequest.newBuilder().setEntityType(entitiesRequest.getEntityType()).setFilter(EntityServiceAndGatewayServiceConverter.convertToEntityServiceFilter(entitiesRequest.getFilter()));
// add time filter for supported scope
EntityServiceAndGatewayServiceConverter.addBetweenTimeFilter(entitiesRequest.getStartTimeMillis(), entitiesRequest.getEndTimeMillis(), attributeMetadataProvider, entitiesRequest, builder, requestContext);
EntityQueryRequest entityQueryRequest = builder.build();
TotalEntitiesRequest totalEntitiesRequest = TotalEntitiesRequest.newBuilder().setEntityType(entitiesRequest.getEntityType()).setFilter(entityQueryRequest.getFilter()).build();
TotalEntitiesResponse response = entityQueryServiceClient.total(totalEntitiesRequest, requestContext.getHeaders());
return response.getTotal();
}
use of org.hypertrace.entity.query.service.v1.TotalEntitiesRequest in project entity-service by hypertrace.
the class EntityQueryServiceImpl method total.
@Override
public void total(TotalEntitiesRequest request, StreamObserver<TotalEntitiesResponse> responseObserver) {
RequestContext requestContext = RequestContext.CURRENT.get();
Optional<String> tenantId = requestContext.getTenantId();
if (tenantId.isEmpty()) {
responseObserver.onError(new ServiceException("Tenant id is missing in the request."));
return;
}
// converting total entities request to entity query request
EntityQueryRequest entityQueryRequest = EntityQueryRequest.newBuilder().setEntityType(request.getEntityType()).setFilter(request.getFilter()).build();
// converting entity query request to entity data service query
Query query = entityQueryConverter.convertToEDSQuery(requestContext, entityQueryRequest);
// TODO: Replace to use the new org.hypertrace.core.documentstore.query.Query DTO
long total = entitiesCollection.total(DocStoreConverter.transform(tenantId.get(), query, emptyList()));
responseObserver.onNext(TotalEntitiesResponse.newBuilder().setTotal(total).build());
responseObserver.onCompleted();
}
Aggregations