Пример #1
0
  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;
  }
Пример #2
0
  @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;
  }
Пример #3
0
  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;
  }
Пример #4
0
 public boolean isTemporary() {
   return clusterId != -1 && clusterPosition.isTemporary();
 }
Пример #5
0
 public boolean isNew() {
   return clusterPosition.isNew();
 }
Пример #6
0
 public boolean isPersistent() {
   return clusterId > -1 && clusterPosition.isPersistent();
 }
Пример #7
0
 public boolean isValid() {
   return clusterPosition.isValid();
 }
Пример #8
0
 @Override
 public ORID nextRid() {
   return new ORecordId(clusterId, clusterPosition.inc());
 }
Пример #9
0
 public String next() {
   return generateString(clusterId, clusterPosition.inc());
 }
Пример #10
0
 public int toStream(final OMemoryStream iStream) throws IOException {
   final int beginOffset = OBinaryProtocol.short2bytes((short) clusterId, iStream);
   iStream.write(clusterPosition.toStream());
   return beginOffset;
 }
Пример #11
0
 @Override
 public int hashCode() {
   int result = clusterId;
   result = 31 * result + clusterPosition.hashCode();
   return result;
 }