Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions persistit/core/src/main/java/com/persistit/BufferPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,22 @@ public int compareTo(final BufferHolder buffer) {

}

/**
* Equality is defined by the same (volumeId, page) ordering key used by
* {@link #compareTo(BufferHolder)}, so that {@code equals} stays
* consistent with the natural ordering.
*/
@Override
public boolean equals(final Object object) {
return this == object
|| (object instanceof BufferHolder && compareTo((BufferHolder) object) == 0);
}

@Override
public int hashCode() {
return Long.hashCode(_volumeId) * 31 + Long.hashCode(_page);
}

@Override
public String toString() {
final Buffer buffer = _buffer;
Expand Down
17 changes: 17 additions & 0 deletions persistit/core/src/main/java/com/persistit/JournalManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Portions Copyrighted 2026 3A Systems, LLC
*/

package com.persistit;
Expand Down Expand Up @@ -2158,6 +2159,22 @@ public int compareTo(final TransactionMapItem ts) {
}
}

/**
* Equality is kept consistent with {@link #compareTo(TransactionMapItem)}:
* two items are equal exactly when they order equally (same commit
* timestamp for committed items, otherwise same start timestamp).
*/
@Override
public boolean equals(final Object object) {
return this == object
|| (object instanceof TransactionMapItem && compareTo((TransactionMapItem) object) == 0);
}

@Override
public int hashCode() {
return Long.hashCode(isCommitted() ? _commitTimestamp : _startTimestamp);
}

final static Comparator<TransactionMapItem> TRANSACTION_MAP_ITEM_COMPARATOR = new Comparator<TransactionMapItem>() {

@Override
Expand Down
18 changes: 18 additions & 0 deletions persistit/core/src/main/java/com/persistit/TreeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,24 @@ public int compareTo(final Node node) {
return _key.compareTo(node._key);
}

/**
* Equality is kept consistent with {@link #compareTo(Node)}: two nodes
* are equal exactly when they order equally (same tree and key, or both
* with no tree).
*/
@Override
public boolean equals(final Object object) {
return this == object || (object instanceof Node && compareTo((Node) object) == 0);
}

@Override
public int hashCode() {
// Consistent with compareTo: equal nodes share the same tree
// instance (or both have none), so the tree's identity hash yields
// equal hash codes for equal nodes.
return _tree == null ? 0 : System.identityHashCode(_tree);
}

@Override
public String toString() {
Node n = this;
Expand Down
Loading