public void setDirty(ORecord record) { ODirtyManager real = getReal(); if (record.getIdentity().isNew() && !record.getIdentity().isTemporary()) { if (real.newRecords == null) real.newRecords = Collections.newSetFromMap(new IdentityHashMap<ORecord, Boolean>()); real.newRecords.add(record); } else { if (real.updateRecords == null) real.updateRecords = Collections.newSetFromMap(new IdentityHashMap<ORecord, Boolean>()); real.updateRecords.add(record); } }
@Override @Nonnull public String getValue() { if (encoded == null) { checkState(!identity.isTemporary(), "attempted use of temporary/uncommitted document id"); encoded = owner.getRecordIdObfuscator().encode(owner.getSchemaType(), identity); } return encoded; }
public void remove(Object key, OIdentifiable value) { try { if (value.getIdentity().isTemporary()) { writer.deleteDocuments(engine.deleteQuery(key, value)); } else { deleted.putIfAbsent(value.getIdentity().toString(), new ArrayList<>()); deleted.get(value.getIdentity().toString()).add(key.toString()); Document doc = engine.buildDocument(key, value); deletedDocs.add(doc); deletedIdx.addDocument(doc); } } catch (IOException e) { throw OException .wrapException(new OLuceneIndexException("Error while deleting documents in transaction from lucene index"), e); } }
public <K extends OIdentifiable> void serializeChanges(Map<K, Change> changes, OBinarySerializer<K> keySerializer, byte[] stream, int offset) { OIntegerSerializer.INSTANCE.serializeLiteral(changes.size(), stream, offset); offset += OIntegerSerializer.INT_SIZE; for (Map.Entry<K, Change> entry : changes.entrySet()) { K key = entry.getKey(); if (key.getIdentity().isTemporary()) //noinspection unchecked key = key.getRecord(); keySerializer.serialize(key, stream, offset); offset += keySerializer.getObjectSize(key); offset += entry.getValue().serialize(stream, offset); } }
public void remove(Object key, OIdentifiable value) { try { if (value.getIdentity().isTemporary()) { writer.deleteDocuments(engine.deleteQuery(key, value)); } else { deleted.add(value.getIdentity().toString()); Document doc = engine.buildDocument(key, value); deletedDocs.add(doc); deletedIdx.addDocument(doc); } } catch (IOException e) { throw OException .wrapException(new OLuceneIndexException("Error while deleting documents in transaction from lucene index"), e); } }
private static OIdentifiable readLinkOptimizedEmbedded(final BytesContainer bytes) { ORID rid = new ORecordId(OVarIntSerializer.readAsInteger(bytes), OVarIntSerializer.readAsLong(bytes)); OIdentifiable identifiable = null; if (rid.isTemporary()) identifiable = rid.getRecord(); if (identifiable == null) identifiable = rid; return identifiable; }
private boolean shouldBeDeserializedAsEmbedded(Object record, OType iType) { return record instanceof ODocument && !((ODocument) record).getIdentity().isTemporary() && !((ODocument) record).getIdentity().isPersistent() && (iType == null || !iType.isLink()); }
private boolean checkDeletedInTx(OVertex currentVertex) { ORID id; if (currentVertex.getRecord() != null) id = currentVertex.getRecord().getIdentity(); else return false; final ORecordOperation oper = getTransaction().getRecordEntry(id); if (oper == null) return id.isTemporary(); else return oper.type == ORecordOperation.DELETED; }
private static OIdentifiable readLinkOptimizedSBTree(final BytesContainer bytes) { ORID rid = new ORecordId(OVarIntSerializer.readAsInteger(bytes), OVarIntSerializer.readAsLong(bytes)); final OIdentifiable identifiable; if (rid.isTemporary() && rid.getRecord() != null) identifiable = rid.getRecord(); else identifiable = rid; return identifiable; }
protected boolean checkDeletedInTx() { ODatabaseDocument db = getDatabase(); if (db == null) return false; ORID id; if (getRecord() != null) id = getRecord().getIdentity(); else return false; final ORecordOperation oper = db.getTransaction().getRecordEntry(id); if (oper == null) return id.isTemporary(); else return oper.type == ORecordOperation.DELETED; }
protected boolean checkDeletedInTx() { ODatabaseDocument db = getDatabase(); if (db == null) return false; ORID id; if (getRecord() != null) id = getRecord().getIdentity(); else return false; final ORecordOperation oper = db.getTransaction().getRecordEntry(id); if (oper == null) return id.isTemporary(); else return oper.type == ORecordOperation.DELETED; }
protected boolean checkDeletedInTx() { OrientBaseGraph curGraph = getGraph(); if (curGraph == null) return false; ORID id; if (getRecord() != null) id = getRecord().getIdentity(); else return false; final ORecordOperation oper = curGraph.getRawGraph().getTransaction().getRecordEntry(id); if (oper == null) return id.isTemporary(); else return oper.type == ORecordOperation.DELETED; }
.isDirty() && !iCurrentRecord.getIdentity().isTemporary()) { final OBinaryField bField = ((OSQLFilterItemField) iValue).getBinaryField(iCurrentRecord); if (bField != null)
@Override public int deserialize(final byte[] stream, int offset) { this.size = OIntegerSerializer.INSTANCE.deserializeLiteral(stream, offset); int entriesSize = OIntegerSerializer.INSTANCE.deserializeLiteral(stream, offset); offset += OIntegerSerializer.INT_SIZE; for (int i = 0; i < entriesSize; i++) { ORID rid = OLinkSerializer.INSTANCE.deserialize(stream, offset); offset += OLinkSerializer.RID_SIZE; OIdentifiable identifiable = null; if (rid.isTemporary()) identifiable = rid.getRecord(); if (identifiable == null) identifiable = rid; if (identifiable == null) OLogManager.instance().warn(this, "Found null reference during ridbag deserialization (rid=%s)", rid); else addEntry(identifiable); } return offset; }
@Override public ORecord loadRecordIfVersionIsNotLatest(ORID rid, final int recordVersion, String fetchPlan, boolean ignoreCache) throws ORecordNotFoundException { checkTransaction(); final ORecord txRecord = getRecord(rid); if (txRecord == OBasicTransaction.DELETED_RECORD) // DELETED IN TX throw new ORecordNotFoundException(rid); if (txRecord != null) { if (txRecord.getVersion() > recordVersion) return txRecord; else return null; } if (rid.isTemporary()) throw new ORecordNotFoundException(rid); // DELEGATE TO THE STORAGE, NO TOMBSTONES SUPPORT IN TX MODE final ORecord record = database .executeReadRecord((ORecordId) rid, null, recordVersion, fetchPlan, ignoreCache, !ignoreCache, false, OStorage.LOCKING_STRATEGY.NONE, new SimpleRecordReader(database.isPrefetchRecords())); if (record != null && isolationLevel == ISOLATION_LEVEL.REPEATABLE_READ) // KEEP THE RECORD IN TX TO ASSURE REPEATABLE READS addRecord(record, ORecordOperation.LOADED, null); return record; }
public ORecord loadRecord(final ORID rid, final ORecord iRecord, final String fetchPlan, final boolean ignoreCache, final boolean iUpdateCache, final boolean loadTombstone, final OStorage.LOCKING_STRATEGY lockingStrategy) { checkTransaction(); final ORecord txRecord = getRecord(rid); if (txRecord == OBasicTransaction.DELETED_RECORD) // DELETED IN TX return null; if (txRecord != null) { if (iRecord != null && txRecord != iRecord) OLogManager.instance().warn(this, "Found record in transaction with the same RID %s but different instance. " + "Probably the record has been loaded from another transaction and reused on the current one: reload it " + "from current transaction before to update or delete it", iRecord.getIdentity()); return txRecord; } if (rid.isTemporary()) return null; // DELEGATE TO THE STORAGE, NO TOMBSTONES SUPPORT IN TX MODE final ORecord record = database .executeReadRecord((ORecordId) rid, iRecord, -1, fetchPlan, ignoreCache, iUpdateCache, loadTombstone, lockingStrategy, new SimpleRecordReader(database.isPrefetchRecords())); if (record != null && isolationLevel == ISOLATION_LEVEL.REPEATABLE_READ) // KEEP THE RECORD IN TX TO ASSURE REPEATABLE READS addRecord(record, ORecordOperation.LOADED, null); return record; }
private Object getValueAsRecord(ODocument iRecord, String iFieldValue, OType iType, String iOptions, String[] fields) { ORID rid = new ORecordId(OIOUtils.getStringContent(getFieldValue("@rid", fields))); boolean shouldReload = rid.isTemporary(); final ODocument recordInternal = (ODocument) fromString(iFieldValue, new ODocument(), null, iOptions, shouldReload); if (shouldBeDeserializedAsEmbedded(recordInternal, iType)) ODocumentInternal.addOwner(recordInternal, iRecord); else { ODatabaseDocument database = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (rid.isPersistent() && database != null) { ODocument documentToMerge = database.load(rid); documentToMerge.merge(recordInternal, false, false); return documentToMerge; } } return recordInternal; }
if (rid.isTemporary()) return null;