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  
36    public MemStoreSnapshot(long id, int cellsCount, long size, TimeRangeTracker timeRangeTracker,
37        KeyValueScanner scanner) {
38      this.id = id;
39      this.cellsCount = cellsCount;
40      this.size = size;
41      this.timeRangeTracker = timeRangeTracker;
42      this.scanner = scanner;
43    }
44  
45    /**
46     * @return snapshot's identifier.
47     */
48    public long getId() {
49      return id;
50    }
51  
52    /**
53     * @return Number of Cells in this snapshot.
54     */
55    public int getCellsCount() {
56      return cellsCount;
57    }
58  
59    /**
60     * @return Total memory size occupied by this snapshot.
61     */
62    public long getSize() {
63      return size;
64    }
65  
66    /**
67     * @return {@link TimeRangeTracker} for all the Cells in the snapshot.
68     */
69    public TimeRangeTracker getTimeRangeTracker() {
70      return this.timeRangeTracker;
71    }
72  
73    /**
74     * @return {@link KeyValueScanner} for iterating over the snapshot
75     */
76    public KeyValueScanner getScanner() {
77      return this.scanner;
78    }
79  }