@Override protected final ORID getImmutableResourceId(final ORID iResourceId) { return new ORecordId(iResourceId); } }
@Override public OIdentifiable deserializeFromByteBufferObject(ByteBuffer buffer) { final int cluster = buffer.getShort(); final int numberSize = buffer.get(); final byte[] number = new byte[numberSize]; buffer.get(number); long position = 0; for (int i = 0; i < numberSize; i++) { position = position | ((0xFF & number[i]) << (i * 8)); } return new ORecordId(cluster, position); }
public static ORecordId newORecordId(Object obj) { if (obj == null) return null; if (obj instanceof ORecordId) return (ORecordId) obj; if (obj instanceof Map) { @SuppressWarnings({ "unchecked", "rawtypes" }) Map<String, Number> map = (Map) obj; return new ORecordId(map.get(CLUSTER_ID).intValue(), map.get(CLUSTER_POSITION).longValue()); } throw new IllegalArgumentException("Unable to convert unknow type to ORecordId " + obj.getClass()); }
@Override public ORawBuffer readRecordIfVersionIsNotLatest(long clusterPosition, int recordVersion) throws IOException, ORecordNotFoundException { throw OException.wrapException(new ORecordNotFoundException(new ORecordId(id, clusterPosition), "Record with rid #" + id + ":" + clusterPosition + " was not found in database"), new OOfflineClusterException("Cannot read a record from the offline cluster '" + name + "'")); }
@Override public ORID next() { if (!hasNext()) { throw new IllegalStateException(); } ORecordId result = new ORecordId(currentCluster, currentId); currentId++; fetchNext(); return result; }
public ORecordId deserializeNativeObject(byte[] stream, int startPosition) { final int clusterId = OShortSerializer.INSTANCE.deserializeNative(stream, startPosition); // Wrong implementation but needed for binary compatibility should be used deserializeNative final long clusterPosition = OLongSerializer.INSTANCE.deserialize(stream, startPosition + OShortSerializer.SHORT_SIZE); return new ORecordId(clusterId, clusterPosition); }
protected static ORecordId readOptimizedLink(final BytesContainer bytes, boolean justRunThrough) { int clusterId = OVarIntSerializer.readAsInteger(bytes); long clusterPos = OVarIntSerializer.readAsLong(bytes); if (justRunThrough) return null; else return new ORecordId(clusterId, clusterPos); }
public List<ORID> getValues() { final List<ORID> rids = new ArrayList<>(); final int size = getIntValue(RIDS_SIZE_OFFSET); final int end = size * RID_SIZE + RIDS_OFFSET; for (int position = RIDS_OFFSET; position < end; position += RID_SIZE) { final int clusterId = getShortValue(position); final long clusterPosition = getLongValue(position + OShortSerializer.SHORT_SIZE); rids.add(new ORecordId(clusterId, clusterPosition)); } return rids; }
public ORecordId readRID() throws IOException { final int clusterId = readShort(); final long clusterPosition = readLong(); return new ORecordId(clusterId, clusterPosition); }
protected ORecordAbstract setIdentity(final int iClusterId, final long iClusterPosition) { if (_recordId == null || _recordId == ORecordId.EMPTY_RECORD_ID) _recordId = new ORecordId(iClusterId, iClusterPosition); else { _recordId.setClusterId(iClusterId); _recordId.setClusterPosition(iClusterPosition); } return this; }
@Override protected ORID doDecode(final OClass type, final String encoded) throws Exception { byte[] decoded = Hex.decode(encoded); return new ORecordId().fromStream(decoded); } }
public ORecordId readRID() throws IOException { final int clusterId = readShort(); final long clusterPosition = readLong(); return new ORecordId(clusterId, clusterPosition); }
@Override protected ORID doDecode(final OClass type, final String encoded) throws Exception { Cipher cipher = crypto.createCipher(TRANSFORMATION); byte[] encrypted = Hex.decode(encoded); cipher.init(Cipher.DECRYPT_MODE, secretKey, paramSpec); byte[] plain = cipher.doFinal(encrypted); return new ORecordId().fromStream(plain); } }
@Override public ORID getBeginRidRange(final Object iLeft, final Object iRight) { if (iLeft instanceof OSQLFilterItemField && ODocumentHelper.ATTRIBUTE_RID.equals(((OSQLFilterItemField) iLeft).getRoot())) if (iRight instanceof ORID) return new ORecordId(((ORID) iRight).next()); else { if (iRight instanceof OSQLFilterItemParameter && ((OSQLFilterItemParameter) iRight).getValue(null, null, null) instanceof ORID) return new ORecordId(((ORID) ((OSQLFilterItemParameter) iRight).getValue(null, null, null)).next()); } return null; }
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()); } }
private void invokeCallbacks() { for (ORecordOperation recordOperation : recordOperations.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()); } }
public ORID getValue() { if (getByteValue(NEXT_FREE_POSITION) == 0) { return null; } final int clusterId = getShortValue(NEXT_FREE_POSITION + 1); final long clusterPosition = getLongValue(NEXT_FREE_POSITION + 1 + OShortSerializer.SHORT_SIZE); return new ORecordId(clusterId, clusterPosition); }
@Override protected void queryFromStream(final OMemoryStream buffer, ORecordSerializer serializer) { super.queryFromStream(buffer, serializer); final String rid = buffer.getAsString(); if ("".equals(rid)) nextPageRID = null; else nextPageRID = new ORecordId(rid); final byte[] serializedPrevParams = buffer.getAsByteArray(); previousQueryParams = deserializeQueryParameters(serializedPrevParams, serializer); }
/** * Should be used only by console commands */ public void loadRecordInternal(String iRecordId, String iFetchPlan) { checkForDatabase(); currentRecord = currentDatabase.load(new ORecordId(iRecordId), iFetchPlan); displayRecord(null); message("\nOK"); }
private void distributedDropIndex(final String iName) { String dropIndexDDL = "DROP INDEX `" + iName + "`"; //noinspection deprecation getDatabase().command(new OCommandSQL(dropIndexDDL)).execute(); ORecordInternal .setIdentity(delegate.getDocument(), new ORecordId(getDatabase().getStorage().getConfiguration().getIndexMgrRecordId())); reload(); }