package org.warp.jcwdb; import java.util.Objects; public class IndexDetails { /** * The bitmask is used to determine if an index has been deleted */ public static final int BITMASK_SIZE = Integer.BYTES; public static final int OFFSET_BYTES = Long.BYTES; public static final int DATA_SIZE_BYTES = Integer.BYTES; public static final int TYPE_BYTES = Integer.BYTES; public static final int HASH_BYTES = Long.BYTES; public static final int TOTAL_BYTES = BITMASK_SIZE + OFFSET_BYTES + DATA_SIZE_BYTES + TYPE_BYTES + HASH_BYTES; public static final int MASK_DELETED = 0b00000001; private final long offset; private final int size; private final int type; private final long hash; public IndexDetails(long offset, int size, int type, long hash) { this.offset = offset; this.size = size; this.type = type; this.hash = hash; } public IndexDetails(IndexDetails indexDetails) { this.offset = indexDetails.offset; this.size = indexDetails.size; this.type = indexDetails.type; this.hash = indexDetails.hash; } public long getOffset() { return offset; } public int getSize() { return size; } public int getType() { return type; } public long getHash() { return hash; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (int) (hash ^ (hash >>> 32)); result = prime * result + (int) (offset ^ (offset >>> 32)); result = prime * result + size; result = prime * result + type; return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; IndexDetails other = (IndexDetails) obj; if (hash != other.hash) return false; if (offset != other.offset) return false; if (size != other.size) return false; if (type != other.type) return false; return true; } @Override public String toString() { return "IndexDetails [offset=" + offset + ", size=" + size + ", type=" + type + ", hash=" + hash + "]"; } }