vrajat commented on code in PR #14110: URL: https://github.com/apache/pinot/pull/14110#discussion_r1879342446
########## pinot-common/src/main/java/org/apache/pinot/common/cursors/AbstractResponseStore.java: ########## @@ -0,0 +1,264 @@ +/** + * 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.cursors; + +import java.util.ArrayList; +import java.util.List; +import org.apache.pinot.common.metrics.BrokerMeter; +import org.apache.pinot.common.metrics.BrokerMetrics; +import org.apache.pinot.common.response.BrokerResponse; +import org.apache.pinot.common.response.CursorResponse; +import org.apache.pinot.common.response.broker.CursorResponseNative; +import org.apache.pinot.common.response.broker.ResultTable; +import org.apache.pinot.spi.cursors.ResponseStore; +import org.apache.pinot.spi.env.PinotConfiguration; + + +public abstract class AbstractResponseStore implements ResponseStore { + + /** + * Initialize the store. + * @param config Subset configuration of pinot.broker.cursor.response.store.<type> + * @param brokerHost Hostname of the broker where ResponseStore is created + * @param brokerPort Port of the broker where the ResponseStore is created + * @param brokerMetrics Metrics utility to track cursor metrics. + */ + public abstract void init(PinotConfiguration config, String brokerHost, int brokerPort, BrokerMetrics brokerMetrics, + String expirationTime) + throws Exception; + + /** + * Get the BrokerMetrics object to update metrics + * @return A BrokerMetrics object + */ + protected abstract BrokerMetrics getBrokerMetrics(); + + /** + * Get the hostname of the broker where the query is executed + * @return String containing the hostname + */ + protected abstract String getBrokerHost(); + + /** + * Get the port of the broker where the query is executed + * @return int containing the port + */ + protected abstract int getBrokerPort(); + + /** + * Get the expiration interval of a query response. + * @return long containing the expiration interval. + */ + protected abstract long getExpirationIntervalInMs(); + + /** + * Write a CursorResponse + * @param requestId Request ID of the response + * @param response The response to write + * @throws Exception Thrown if there is any error while writing the response + */ + protected abstract void writeResponse(String requestId, CursorResponse response) + throws Exception; + + /** + * Write a {@link ResultTable} to the store + * @param requestId Request ID of the response + * @param resultTable The {@link ResultTable} of the query + * @throws Exception Thrown if there is any error while writing the result table. + * @return Returns the number of bytes written + */ + protected abstract long writeResultTable(String requestId, ResultTable resultTable) + throws Exception; + + /** + * Read the response (excluding the {@link ResultTable}) from the store + * @param requestId Request ID of the response + * @return CursorResponse (without the {@link ResultTable}) + * @throws Exception Thrown if there is any error while reading the response + */ + public abstract CursorResponse readResponse(String requestId) + throws Exception; + + /** + * Read the {@link ResultTable} of a query response + * @param requestId Request ID of the query + * @param offset Offset of the result slice + * @param numRows Number of rows required in the slice + * @return {@link ResultTable} of the query + * @throws Exception Thrown if there is any error while reading the result table + */ + protected abstract ResultTable readResultTable(String requestId, int offset, int numRows) + throws Exception; + + protected abstract boolean deleteResponseImpl(String requestId) + throws Exception; + + /** + * Stores the response in the store. {@link CursorResponse} and @link{ResultTable} are stored separately. Review Comment: Fixed -- 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]
