io.sirix.node.RevisionReferencesNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sirix-core Show documentation
Show all versions of sirix-core Show documentation
SirixDB is a hybrid on-disk and in-memory document oriented, versioned database system. It has a lightweight buffer manager, stores everything in a huge persistent and durable tree and allows efficient reconstruction of every revision. Furthermore, SirixDB implements change tracking, diffing and supports time travel queries.
package io.sirix.node;
import io.sirix.node.interfaces.DataRecord;
import io.sirix.node.interfaces.RecordSerializer;
import java.util.Arrays;
import java.util.Objects;
public final class RevisionReferencesNode implements DataRecord {
private final long nodeKey;
private int[] revisions;
public RevisionReferencesNode(final long nodeKey, final int[] revisions) {
this.nodeKey = nodeKey;
this.revisions = revisions;
}
@Override
public long getNodeKey() {
return nodeKey;
}
@Override
public SirixDeweyID getDeweyID() {
return null;
}
@Override
public byte[] getDeweyIDAsBytes() {
return null;
}
@Override
public RecordSerializer getKind() {
return NodeKind.REVISION_REFERENCES_NODE;
}
@Override
public int getPreviousRevisionNumber() {
throw new UnsupportedOperationException();
}
@Override
public int getLastModifiedRevisionNumber() {
throw new UnsupportedOperationException();
}
public RevisionReferencesNode addRevision(final int revision) {
final int[] copy = new int[revisions.length + 1];
System.arraycopy(revisions, 0, copy, 0, revisions.length);
copy[copy.length - 1] = revision;
revisions = copy;
return this;
}
@Override
public int hashCode() {
int result = Objects.hash(nodeKey);
result = 31 * result + Arrays.hashCode(revisions);
return result;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
RevisionReferencesNode that = (RevisionReferencesNode) o;
return nodeKey == that.nodeKey && Arrays.equals(revisions, that.revisions);
}
public int[] getRevisions() {
return revisions;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy