xiangfu0 commented on code in PR #17939: URL: https://github.com/apache/pinot/pull/17939#discussion_r3069107420
########## pinot-core/src/main/java/org/apache/pinot/core/data/manager/ingest/InsertRowApplier.java: ########## @@ -0,0 +1,191 @@ +/** + * 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.core.data.manager.ingest; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.apache.pinot.spi.data.readers.GenericRow; +import org.apache.pinot.spi.ingest.PreparedStore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * Applies committed insert data to Pinot's mutable segment path. + * + * <p>On commit, reads prepared batches from the {@link PreparedStore} and provides them for + * indexing into mutable segments. Tracks applied statement IDs in a persistent file to enable + * idempotent replay after server restart. + * + * <p>The applied-statement tracking file is stored at + * {@code <dataDir>/insert/applied_statements.log}. + * + * <p>This class is thread-safe for concurrent apply operations on different statements. Concurrent + * apply on the same statement is not expected. + */ +public class InsertRowApplier { + + private static final Logger LOGGER = LoggerFactory.getLogger(InsertRowApplier.class); + private static final String APPLIED_STATEMENTS_FILE = "applied_statements.log"; + + private final PreparedStore _preparedStore; + private final File _appliedStatementsFile; + private final Set<String> _appliedStatements; + private final Object _fileLock = new Object(); + Review Comment: Addressed in `e805c72443`. `_appliedStatements` now uses `ConcurrentHashMap.newKeySet()` so the unsynchronized `contains()` reads are safe while updates remain serialized under `_fileLock`. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
