View Javadoc

1   /**
2    * Copyright 2010 The Apache Software Foundation
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  package org.apache.hadoop.hbase.regionserver;
21  
22  import org.apache.hadoop.hbase.KeyValue;
23  
24  import java.io.Closeable;
25  import java.io.IOException;
26  import java.util.List;
27  
28  /**
29   * Internal scanners differ from client-side scanners in that they operate on
30   * HStoreKeys and byte[] instead of RowResults. This is because they are
31   * actually close to how the data is physically stored, and therefore it is more
32   * convenient to interact with them that way. It is also much easier to merge
33   * the results across SortedMaps than RowResults.
34   *
35   * <p>Additionally, we need to be able to determine if the scanner is doing
36   * wildcard column matches (when only a column family is specified or if a
37   * column regex is specified) or if multiple members of the same column family
38   * were specified. If so, we need to ignore the timestamp to ensure that we get
39   * all the family members, as they may have been last updated at different
40   * times.
41   */
42  public interface InternalScanner extends Closeable {
43    /**
44     * Grab the next row's worth of values.
45     * @param results return output array
46     * @return true if more rows exist after this one, false if scanner is done
47     * @throws IOException e
48     */
49    public boolean next(List<KeyValue> results) throws IOException;
50    
51    /**
52     * Grab the next row's worth of values.
53     * @param results return output array
54     * @param metric the metric name
55     * @return true if more rows exist after this one, false if scanner is done
56     * @throws IOException e
57     */
58    public boolean next(List<KeyValue> results, String metric) throws IOException;
59  
60    /**
61     * Grab the next row's worth of values with a limit on the number of values
62     * to return.
63     * @param result return output array
64     * @param limit limit on row count to get
65     * @return true if more rows exist after this one, false if scanner is done
66     * @throws IOException e
67     */
68    public boolean next(List<KeyValue> result, int limit) throws IOException;
69    
70    /**
71     * Grab the next row's worth of values with a limit on the number of values
72     * to return.
73     * @param result return output array
74     * @param limit limit on row count to get
75     * @param metric the metric name
76     * @return true if more rows exist after this one, false if scanner is done
77     * @throws IOException e
78     */
79    public boolean next(List<KeyValue> result, int limit, String metric) throws IOException;
80  
81    /**
82     * Closes the scanner and releases any resources it has allocated
83     * @throws IOException
84     */
85    public void close() throws IOException;
86  }