1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package org.apache.hadoop.hbase.client;
19
20 import java.io.IOException;
21
22 import org.apache.hadoop.hbase.classification.InterfaceAudience;
23
24 /**
25 * Used to separate the row constructing logic.
26 * <p>
27 * After we add heartbeat support for scan, RS may return partial result even if allowPartial is
28 * false and batch is 0. With this interface, the implementation now looks like:
29 * <ol>
30 * <li>Get results from ScanResponse proto.</li>
31 * <li>Pass them to ScanResultCache and get something back.</li>
32 * <li>If we actually get something back, then pass it to ScanConsumer.</li>
33 * </ol>
34 */
35 @InterfaceAudience.Private
36 interface ScanResultCache {
37
38 static final Result[] EMPTY_RESULT_ARRAY = new Result[0];
39
40 /**
41 * Add the given results to cache and get valid results back.
42 * @param results the results of a scan next. Must not be null.
43 * @param isHeartbeatMessage indicate whether the results is gotten from a heartbeat response.
44 * @return valid results, never null.
45 */
46 Result[] addAndGet(Result[] results, boolean isHeartbeatMessage) throws IOException;
47
48 /**
49 * Clear the cached result if any. Called when scan error and we will start from a start of a row
50 * again.
51 */
52 void clear();
53
54 /**
55 * Return the number of complete rows. Used to implement limited scan.
56 */
57 int numberOfCompleteRows();
58 }