public void copyFrom(final ORID iSource) { if (iSource == null) throw new IllegalArgumentException("Source is null"); clusterId = iSource.getClusterId(); clusterPosition = iSource.getClusterPosition(); }
@Override public int getObjectSize(OIdentifiable rid, Object... hints) { final ORID r = rid.getIdentity(); int size = OShortSerializer.SHORT_SIZE + OByteSerializer.BYTE_SIZE; final int zeroBits = Long.numberOfLeadingZeros(r.getClusterPosition()); final int zerosTillFullByte = zeroBits & 7; final int numberSize = 8 - (zeroBits - zerosTillFullByte) / 8; size += numberSize; return size; }
@Override public int compare(ORecord o1, ORecord o2) { long p1 = o1.getIdentity().getClusterPosition(); long p2 = o2.getIdentity().getClusterPosition(); if (p1 == p2) { return 0; } else if (p1 > p2) { return -1; } else { return 1; } } });
/** * {@inheritDoc} */ @Override public void serializeInByteBufferObject(OIdentifiable object, ByteBuffer buffer, Object... hints) { final ORID r = object.getIdentity(); buffer.putShort((short) r.getClusterId()); // Wrong implementation but needed for binary compatibility byte[] stream = new byte[OLongSerializer.LONG_SIZE]; OLongSerializer.INSTANCE.serialize(r.getClusterPosition(), stream, 0); buffer.put(stream); }
private boolean alreadyVisited(OResult nextValue) { if (nextValue.isElement()) { ORID identity = nextValue.getElement().get().getIdentity(); int cluster = identity.getClusterId(); long pos = identity.getClusterPosition(); if (cluster >= 0 && pos >= 0) { return pastRids.contains(identity); } } return pastItems.contains(nextValue); }
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 long otherClusterPos = iOther.getIdentity().getClusterPosition(); return (clusterPosition < otherClusterPos) ? -1 : ((clusterPosition == otherClusterPos) ? 0 : 1); } else if (clusterId > otherClusterId) return 1; return -1; }
private void markAsVisited(OResult nextValue) { if (nextValue.isElement()) { ORID identity = nextValue.getElement().get().getIdentity(); int cluster = identity.getClusterId(); long pos = identity.getClusterPosition(); if (cluster >= 0 && pos >= 0) { pastRids.add(identity); return; } } pastItems.add(nextValue); }
public void serialize(final OIdentifiable rid, final byte[] stream, final int startPosition, Object... hints) { final ORID r = rid.getIdentity(); short2bytes((short) r.getClusterId(), stream, startPosition); long2bytes(r.getClusterPosition(), stream, startPosition + OShortSerializer.SHORT_SIZE); }
public void serializeNativeObject(OIdentifiable rid, byte[] stream, int startPosition, Object... hints) { final ORID r = rid.getIdentity(); OShortSerializer.INSTANCE.serializeNative((short) r.getClusterId(), stream, startPosition); // Wrong implementation but needed for binary compatibility should be used serializeNative OLongSerializer.INSTANCE.serialize(r.getClusterPosition(), stream, startPosition + OShortSerializer.SHORT_SIZE); }
public void setValue(final ORID value) { setByteValue(NEXT_FREE_POSITION, (byte) 1); setShortValue(NEXT_FREE_POSITION + 1, (short) value.getClusterId()); setLongValue(NEXT_FREE_POSITION + 1 + OShortSerializer.SHORT_SIZE, value.getClusterPosition()); }
private static void writeLinkOptimized(final BytesContainer bytes, OIdentifiable link) { ORID id = link.getIdentity(); OVarIntSerializer.write(bytes, id.getClusterId()); OVarIntSerializer.write(bytes, id.getClusterPosition()); }
boolean addValue(final ORID rid) { final int size = getIntValue(RIDS_SIZE_OFFSET); final int position = size * RID_SIZE + RIDS_OFFSET; if (position + RID_SIZE > MAX_PAGE_SIZE_BYTES) { return false; } setShortValue(position, (short) rid.getClusterId()); setLongValue(position + OShortSerializer.SHORT_SIZE, rid.getClusterPosition()); setIntValue(RIDS_SIZE_OFFSET, size + 1); return true; }
private void invokeCallbacks() { for (ORecordOperation recordOperation : allEntries.values()) { final ORecord record = recordOperation.getRecord(); final ORID identity = record.getIdentity(); if (recordOperation.type == ORecordOperation.CREATED && recordOperation.createdCallback != null) recordOperation.createdCallback.call(new ORecordId(identity), identity.getClusterPosition()); else if (recordOperation.type == ORecordOperation.UPDATED && recordOperation.updatedCallback != null) recordOperation.updatedCallback.call(new ORecordId(identity), record.getVersion()); } }
protected static int writeNullLink(final BytesContainer bytes) { final int pos = OVarIntSerializer.write(bytes, NULL_RECORD_ID.getIdentity().getClusterId()); OVarIntSerializer.write(bytes, NULL_RECORD_ID.getIdentity().getClusterPosition()); return pos; }
private int writeNullLink(final BytesContainer bytes) { final int pos = OVarIntSerializer.write(bytes, NULL_RECORD_ID.getIdentity().getClusterId()); OVarIntSerializer.write(bytes, NULL_RECORD_ID.getIdentity().getClusterPosition()); return pos; }
private int writeNullLink(final BytesContainer bytes) { final int pos = OVarIntSerializer.write(bytes, NULL_RECORD_ID.getIdentity().getClusterId()); OVarIntSerializer.write(bytes, NULL_RECORD_ID.getIdentity().getClusterPosition()); return pos; }
private int writeNullLink(final BytesContainer bytes) { final int pos = OVarIntSerializer.write(bytes, NULL_RECORD_ID.getIdentity().getClusterId()); OVarIntSerializer.write(bytes, NULL_RECORD_ID.getIdentity().getClusterPosition()); return pos; }
private int writeOptimizedLink(final BytesContainer bytes, OIdentifiable link) { if (!link.getIdentity().isPersistent()) { final ORecord real = link.getRecord(); if (real != null) link = real; } final int pos = OVarIntSerializer.write(bytes, link.getIdentity().getClusterId()); OVarIntSerializer.write(bytes, link.getIdentity().getClusterPosition()); return pos; }
private int writeOptimizedLink(final BytesContainer bytes, OIdentifiable link) { if (!link.getIdentity().isPersistent()) { final ORecord real = link.getRecord(); if (real != null) link = real; } final int pos = OVarIntSerializer.write(bytes, link.getIdentity().getClusterId()); OVarIntSerializer.write(bytes, link.getIdentity().getClusterPosition()); return pos; }
private int writeOptimizedLink(final BytesContainer bytes, OIdentifiable link) { if (!link.getIdentity().isPersistent()) { final ORecord real = link.getRecord(); if (real != null) link = real; } final int pos = OVarIntSerializer.write(bytes, link.getIdentity().getClusterId()); OVarIntSerializer.write(bytes, link.getIdentity().getClusterPosition()); return pos; }