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