View Javadoc

1   /**
2    * Copyright 2009 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  /**
23   * Implementing classes of this interface will be used for the tracking
24   * and enforcement of columns and numbers of versions during the course of a
25   * Get or Scan operation.
26   * <p>
27   * Currently there are two different types of Store/Family-level queries.
28   * <ul><li>{@link ExplicitColumnTracker} is used when the query specifies
29   * one or more column qualifiers to return in the family.
30   * <p>
31   * This class is utilized by {@link ScanQueryMatcher} through two methods:
32   * <ul><li>{@link #checkColumn} is called when a Put satisfies all other
33   * conditions of the query.  This method returns a {@link org.apache.hadoop.hbase.regionserver.ScanQueryMatcher.MatchCode} to define
34   * what action should be taken.
35   * <li>{@link #update} is called at the end of every StoreFile or memstore.
36   * <p>
37   * This class is NOT thread-safe as queries are never multi-threaded
38   */
39  public interface ColumnTracker {
40    /**
41     * Keeps track of the number of versions for the columns asked for
42     * @param bytes
43     * @param offset
44     * @param length
45     * @param timestamp
46     * @return The match code instance.
47     */
48    public ScanQueryMatcher.MatchCode checkColumn(byte [] bytes, int offset,
49        int length, long timestamp);
50  
51    /**
52     * Updates internal variables in between files
53     */
54    public void update();
55  
56    /**
57     * Resets the Matcher
58     */
59    public void reset();
60  
61    /**
62     *
63     * @return <code>true</code> when done.
64     */
65    public boolean done();
66  
67    /**
68     * Used by matcher and scan/get to get a hint of the next column
69     * to seek to after checkColumn() returns SKIP.  Returns the next interesting
70     * column we want, or NULL there is none (wildcard scanner).
71     *
72     * Implementations aren't required to return anything useful unless the most recent
73     * call was to checkColumn() and the return code was SKIP.  This is pretty implementation
74     * detail-y, but optimizations are like that.
75     *
76     * @return null, or a ColumnCount that we should seek to
77     */
78    public ColumnCount getColumnHint();
79  }