Jackie-Jiang commented on code in PR #12346: URL: https://github.com/apache/pinot/pull/12346#discussion_r1473577054
########## pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/ValidDocIdMetadataInfo.java: ########## @@ -28,14 +28,16 @@ public class ValidDocIdMetadataInfo { private final long _totalValidDocs; private final long _totalInvalidDocs; private final long _totalDocs; + private final String _crc; Review Comment: (minor) Rename it to `_segmentCRC` to be more specific? Otherwise people might misread it as valid doc id crc ########## pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/ValidDocIdsBitmapResponse.java: ########## @@ -0,0 +1,47 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.common.restlet.resources; + +import com.fasterxml.jackson.annotation.JsonProperty; + + +public class ValidDocIdsBitmapResponse { + private final String _segmentName; + private final String _crc; Review Comment: Same here, `_segmentCRC` ########## pinot-server/src/main/java/org/apache/pinot/server/api/resources/TablesResource.java: ########## @@ -465,10 +466,64 @@ public Response downloadSegment( } } + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("/segments/{tableNameWithType}/{segmentName}/validDocIdsBitmap") + @ApiOperation(value = "Download validDocIds bitmap for an REALTIME immutable segment", notes = + "Download validDocIds for " + "an immutable segment in bitmap format.") + public ValidDocIdsBitmapResponse downloadValidDocIdsBitmap( + @ApiParam(value = "Name of the table with type REALTIME", required = true, example = "myTable_REALTIME") + @PathParam("tableNameWithType") String tableNameWithType, + @ApiParam(value = "Name of the segment", required = true) @PathParam("segmentName") @Encoded String segmentName, + @Context HttpHeaders httpHeaders) { + segmentName = URIUtils.decode(segmentName); + LOGGER.info("Received a request to download validDocIds for segment {} table {}", segmentName, tableNameWithType); + // Validate data access + ServerResourceUtils.validateDataAccess(_accessControlFactory, tableNameWithType, httpHeaders); + + TableDataManager tableDataManager = + ServerResourceUtils.checkGetTableDataManager(_serverInstance, tableNameWithType); + SegmentDataManager segmentDataManager = tableDataManager.acquireSegment(segmentName); + if (segmentDataManager == null) { + throw new WebApplicationException( + String.format("Table %s segment %s does not exist", tableNameWithType, segmentName), + Response.Status.NOT_FOUND); + } + + try { + IndexSegment indexSegment = segmentDataManager.getSegment(); + if (!(indexSegment instanceof ImmutableSegmentImpl)) { + throw new WebApplicationException( + String.format("Table %s segment %s is not a immutable segment", tableNameWithType, segmentName), + Response.Status.BAD_REQUEST); + } + + // Adopt the same logic as the query execution to get the valid doc ids. 'FilterPlanNode.run()' Review Comment: Not introduced in this PR, but this logic is incorrect. We cannot read the valid doc ids from memory because it might be modified during ingestion, and if the server re-consume the data (e.g. restart), some valid docs might be missing. We should use the valid doc ids from the snapshot. Same for the valid doc ids metadata api -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org