001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.client;
019
020import java.io.IOException;
021
022import org.apache.yetus.audience.InterfaceAudience;
023
024/**
025 * Used to separate the row constructing logic.
026 * <p>
027 * After we add heartbeat support for scan, RS may return partial result even if allowPartial is
028 * false and batch is 0. With this interface, the implementation now looks like:
029 * <ol>
030 * <li>Get results from ScanResponse proto.</li>
031 * <li>Pass them to ScanResultCache and get something back.</li>
032 * <li>If we actually get something back, then pass it to ScanConsumer.</li>
033 * </ol>
034 */
035@InterfaceAudience.Private
036interface ScanResultCache {
037
038  static final Result[] EMPTY_RESULT_ARRAY = new Result[0];
039
040  /**
041   * Add the given results to cache and get valid results back.
042   * @param results the results of a scan next. Must not be null.
043   * @param isHeartbeatMessage indicate whether the results is gotten from a heartbeat response.
044   * @return valid results, never null.
045   */
046  Result[] addAndGet(Result[] results, boolean isHeartbeatMessage) throws IOException;
047
048  /**
049   * Clear the cached result if any. Called when scan error and we will start from a start of a row
050   * again.
051   */
052  void clear();
053
054  /**
055   * Return the number of complete rows. Used to implement limited scan.
056   */
057  int numberOfCompleteRows();
058}