View Javadoc

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.regionserver;
19  
20  import org.apache.hadoop.hbase.classification.InterfaceAudience;
21  
22  /**
23   * Holds details of the snapshot taken on a MemStore. Details include the snapshot's identifier,
24   * count of cells in it and total memory size occupied by all the cells, timestamp information of
25   * all the cells and a scanner to read all cells in it.
26   */
27  @InterfaceAudience.Private
28  public class MemStoreSnapshot {
29  
30    private final long id;
31    private final int cellsCount;
32    private final long size;
33    private final TimeRangeTracker timeRangeTracker;
34    private final KeyValueScanner scanner;
35    private final boolean tagsPresent;
36  
37    public MemStoreSnapshot(long id, int cellsCount, long size, TimeRangeTracker timeRangeTracker,
38        KeyValueScanner scanner, boolean tagsPresent) {
39      this.id = id;
40      this.cellsCount = cellsCount;
41      this.size = size;
42      this.timeRangeTracker = timeRangeTracker;
43      this.scanner = scanner;
44      this.tagsPresent = tagsPresent;
45    }
46  
47    /**
48     * @return snapshot's identifier.
49     */
50    public long getId() {
51      return id;
52    }
53  
54    /**
55     * @return Number of Cells in this snapshot.
56     */
57    public int getCellsCount() {
58      return cellsCount;
59    }
60  
61    /**
62     * @return Total memory size occupied by this snapshot.
63     */
64    public long getSize() {
65      return size;
66    }
67  
68    /**
69     * @return {@link TimeRangeTracker} for all the Cells in the snapshot.
70     */
71    public TimeRangeTracker getTimeRangeTracker() {
72      return this.timeRangeTracker;
73    }
74  
75    /**
76     * @return {@link KeyValueScanner} for iterating over the snapshot
77     */
78    public KeyValueScanner getScanner() {
79      return this.scanner;
80    }
81  
82    /**
83     * @return true if tags are present in this snapshot
84     */
85    public boolean isTagsPresent() {
86      return this.tagsPresent;
87    }
88  }