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    private final long id;
30    private final int cellsCount;
31    private final long size;
32    private final TimeRangeTracker timeRangeTracker;
33    private final KeyValueScanner scanner;
34    private final boolean tagsPresent;
35  
36    public MemStoreSnapshot(long id, ImmutableSegment snapshot) {
37      this.id = id;
38      this.cellsCount = snapshot.getCellsCount();
39      this.size = snapshot.keySize();
40      this.timeRangeTracker = snapshot.getTimeRangeTracker();
41      this.scanner = snapshot.getKeyValueScanner();
42      this.tagsPresent = snapshot.isTagsPresent();
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  
80    /**
81     * @return true if tags are present in this snapshot
82     */
83    public boolean isTagsPresent() {
84      return this.tagsPresent;
85    }
86  }