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; 021import org.apache.yetus.audience.InterfaceAudience; 022 023/** 024 * Used to separate the row constructing logic. 025 * <p> 026 * After we add heartbeat support for scan, RS may return partial result even if allowPartial is 027 * false and batch is 0. With this interface, the implementation now looks like: 028 * <ol> 029 * <li>Get results from ScanResponse proto.</li> 030 * <li>Pass them to ScanResultCache and get something back.</li> 031 * <li>If we actually get something back, then pass it to ScanConsumer.</li> 032 * </ol> 033 */ 034@InterfaceAudience.Private 035interface ScanResultCache { 036 037 static final Result[] EMPTY_RESULT_ARRAY = new Result[0]; 038 039 /** 040 * Add the given results to cache and get valid results back. 041 * @param results the results of a scan next. Must not be null. 042 * @param isHeartbeatMessage indicate whether the results is gotten from a heartbeat response. 043 * @return valid results, never null. 044 */ 045 Result[] addAndGet(Result[] results, boolean isHeartbeatMessage) throws IOException; 046 047 /** 048 * Clear the cached result if any. Called when scan error and we will start from a start of a row 049 * again. 050 */ 051 void clear(); 052 053 /** 054 * Return the number of complete rows. Used to implement limited scan. 055 */ 056 int numberOfCompleteRows(); 057}