]>
Commit | Line | Data |
---|---|---|
20effc67 TL |
1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | // This source code is licensed under both the GPLv2 (found in the | |
3 | // COPYING file in the root directory) and Apache 2.0 License | |
4 | // (found in the LICENSE.Apache file in the root directory). | |
5 | ||
6 | package org.rocksdb; | |
7 | ||
8 | import java.util.Objects; | |
9 | ||
10 | public class MemTableInfo { | |
11 | private final String columnFamilyName; | |
12 | private final long firstSeqno; | |
13 | private final long earliestSeqno; | |
14 | private final long numEntries; | |
15 | private final long numDeletes; | |
16 | ||
17 | /** | |
18 | * Access is package private as this will only be constructed from | |
19 | * C++ via JNI and for testing. | |
20 | */ | |
21 | MemTableInfo(final String columnFamilyName, final long firstSeqno, final long earliestSeqno, | |
22 | final long numEntries, final long numDeletes) { | |
23 | this.columnFamilyName = columnFamilyName; | |
24 | this.firstSeqno = firstSeqno; | |
25 | this.earliestSeqno = earliestSeqno; | |
26 | this.numEntries = numEntries; | |
27 | this.numDeletes = numDeletes; | |
28 | } | |
29 | ||
30 | /** | |
31 | * Get the name of the column family to which memtable belongs. | |
32 | * | |
33 | * @return the name of the column family. | |
34 | */ | |
35 | public String getColumnFamilyName() { | |
36 | return columnFamilyName; | |
37 | } | |
38 | ||
39 | /** | |
40 | * Get the Sequence number of the first element that was inserted into the | |
41 | * memtable. | |
42 | * | |
43 | * @return the sequence number of the first inserted element. | |
44 | */ | |
45 | public long getFirstSeqno() { | |
46 | return firstSeqno; | |
47 | } | |
48 | ||
49 | /** | |
50 | * Get the Sequence number that is guaranteed to be smaller than or equal | |
51 | * to the sequence number of any key that could be inserted into this | |
52 | * memtable. It can then be assumed that any write with a larger(or equal) | |
53 | * sequence number will be present in this memtable or a later memtable. | |
54 | * | |
55 | * @return the earliest sequence number. | |
56 | */ | |
57 | public long getEarliestSeqno() { | |
58 | return earliestSeqno; | |
59 | } | |
60 | ||
61 | /** | |
62 | * Get the total number of entries in memtable. | |
63 | * | |
64 | * @return the total number of entries. | |
65 | */ | |
66 | public long getNumEntries() { | |
67 | return numEntries; | |
68 | } | |
69 | ||
70 | /** | |
71 | * Get the total number of deletes in memtable. | |
72 | * | |
73 | * @return the total number of deletes. | |
74 | */ | |
75 | public long getNumDeletes() { | |
76 | return numDeletes; | |
77 | } | |
78 | ||
79 | @Override | |
80 | public boolean equals(Object o) { | |
81 | if (this == o) | |
82 | return true; | |
83 | if (o == null || getClass() != o.getClass()) | |
84 | return false; | |
85 | MemTableInfo that = (MemTableInfo) o; | |
86 | return firstSeqno == that.firstSeqno && earliestSeqno == that.earliestSeqno | |
87 | && numEntries == that.numEntries && numDeletes == that.numDeletes | |
88 | && Objects.equals(columnFamilyName, that.columnFamilyName); | |
89 | } | |
90 | ||
91 | @Override | |
92 | public int hashCode() { | |
93 | return Objects.hash(columnFamilyName, firstSeqno, earliestSeqno, numEntries, numDeletes); | |
94 | } | |
95 | ||
96 | @Override | |
97 | public String toString() { | |
98 | return "MemTableInfo{" | |
99 | + "columnFamilyName='" + columnFamilyName + '\'' + ", firstSeqno=" + firstSeqno | |
100 | + ", earliestSeqno=" + earliestSeqno + ", numEntries=" + numEntries | |
101 | + ", numDeletes=" + numDeletes + '}'; | |
102 | } | |
103 | } |