public byte[] toStream() { final int serializedSize = OClusterPositionFactory.INSTANCE.getSerializedSize(); byte[] buffer = new byte[OBinaryProtocol.SIZE_SHORT + serializedSize]; OBinaryProtocol.short2bytes((short) clusterId, buffer, 0); System.arraycopy( clusterPosition.toStream(), 0, buffer, OBinaryProtocol.SIZE_SHORT, serializedSize); return buffer; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof OIdentifiable)) return false; final ORecordId other = (ORecordId) ((OIdentifiable) obj).getIdentity(); if (clusterId != other.clusterId) return false; if (!clusterPosition.equals(other.clusterPosition)) return false; return true; }
public int compareTo(final OIdentifiable iOther) { if (iOther == this) return 0; if (iOther == null) return 1; final int otherClusterId = iOther.getIdentity().getClusterId(); if (clusterId == otherClusterId) { final OClusterPosition otherClusterPos = iOther.getIdentity().getClusterPosition(); return clusterPosition.compareTo(otherClusterPos); } else if (clusterId > otherClusterId) return 1; return -1; }
public boolean isTemporary() { return clusterId != -1 && clusterPosition.isTemporary(); }
public boolean isNew() { return clusterPosition.isNew(); }
public boolean isPersistent() { return clusterId > -1 && clusterPosition.isPersistent(); }
public boolean isValid() { return clusterPosition.isValid(); }
@Override public ORID nextRid() { return new ORecordId(clusterId, clusterPosition.inc()); }
public String next() { return generateString(clusterId, clusterPosition.inc()); }
public int toStream(final OMemoryStream iStream) throws IOException { final int beginOffset = OBinaryProtocol.short2bytes((short) clusterId, iStream); iStream.write(clusterPosition.toStream()); return beginOffset; }
@Override public int hashCode() { int result = clusterId; result = 31 * result + clusterPosition.hashCode(); return result; }