@Override public byte[] toStream() throws OSerializationException { if (element != null) return element.toStream(); return null; }
@Override public byte[] toStream() throws OSerializationException { return element.toStream(); }
@Override public byte[] toStream() { if (_recordFormat == null) setup(); return toStream(false); }
protected void copyTo(final OrientElement iCopy) { iCopy.graph = graph; iCopy.settings = settings; if (rawElement instanceof ODocument) { iCopy.rawElement = new ODocument().fromStream(((ODocument) rawElement).toStream()); } else if (rawElement instanceof ORID) iCopy.rawElement = ((ORID) rawElement).copy(); else throw new IllegalArgumentException("Cannot clone element " + rawElement); }
protected byte[] serializeQueryParameters(final Map<Object, Object> params) { if (params == null || params.size() == 0) // NO PARAMETER, JUST SEND 0 return OCommonConst.EMPTY_BYTE_ARRAY; final ODocument param = new ODocument(); param.field("params", convertToRIDsIfPossible(params)); return param.toStream(); }
@Override public byte[] onUpdate(OStorage storage, byte iRecordType, final ORecordId rid, final int iRecordVersion, final byte[] iRecordContent, final AtomicInteger iDatabaseVersion) { if (iRecordType == ODocument.RECORD_TYPE) { // No need lock, is already inside a lock. Use database to read temporary objects too OStorageOperationResult<ORawBuffer> res = storage.readRecord(rid, null, false, false, null); final ODocument storedRecord = new ODocument(rid).fromStream(res.getResult().getBuffer()); ODocument newRecord = (ODocument) ORecordSaveThreadLocal.getLast(); if (newRecord == null || !newRecord.getIdentity().equals(rid)) newRecord = new ODocument(rid).fromStream(iRecordContent); storedRecord.merge(newRecord, true, true); iDatabaseVersion.set(Math.max(iDatabaseVersion.get(), iRecordVersion) + 1); return storedRecord.toStream(); } else // NO DOCUMENT, CANNOT MERGE SO RELY TO THE VERSION CHECK checkVersions(rid, iRecordVersion, iDatabaseVersion.get()); return null; }
ORID rid = document.getIdentity(); if (rid.getClusterId() != primaryClusterId) { db.save(new ODocument(document.toStream())); db.delete(rid); moveCount++;
db.close(); main.fromStream(main.toStream());