@Override public byte[] toStream(ORecord iSource, boolean iOnlyDelta) { if (iSource instanceof OBlob) { return iSource.toStream(); } else if (iSource instanceof ORecordFlat) { return iSource.toStream(); } else { final BytesContainer container = new BytesContainer(); // SERIALIZE RECORD serialize((ODocument) iSource, container, false); return container.fitBytes(); } }
/** * Creates a new object by the record received. */ public ORawBuffer(final ORecord iRecord) { this.buffer = iRecord.toStream(); this.version = iRecord.getVersion(); this.recordType = ORecordInternal.getRecordType(iRecord); }
@Override public byte[] toStream(final ORecord iSource, final boolean iOnlyDelta) { if (iSource instanceof OBlob) { return iSource.toStream(); } else if (iSource instanceof ORecordFlat) { return iSource.toStream(); } else { final BytesContainer container = new BytesContainer(); // WRITE SERIALIZER VERSION int pos = container.alloc(1); container.bytes[pos] = CURRENT_RECORD_VERSION; // SERIALIZE RECORD serializerByVersion[CURRENT_RECORD_VERSION].serialize((ODocument) iSource, container, false); return container.fitBytes(); } }
@Override public byte[] toStream(final ORecord iSource, final boolean iOnlyDelta) { if (iSource instanceof OBlob) { return iSource.toStream(); } else if (iSource instanceof ORecordFlat) { return iSource.toStream(); } else { final BytesContainer container = new BytesContainer(); // WRITE SERIALIZER VERSION int pos = container.alloc(1); container.bytes[pos] = currentSerializerVersion; // SERIALIZE RECORD serializerByVersion[currentSerializerVersion].serialize((ODocument) iSource, container, false); return container.fitBytes(); } }
@Override public byte[] toStream(final ORecord iSource, boolean iOnlyDelta) { try { return iSource.toStream(); } catch (Exception e) { final String message = "Error on unmarshalling object in binary format: " + iSource.getIdentity(); OLogManager.instance().error(this, message, e); throw OException.wrapException(new OSerializationException(message), e); } }
return Orient.instance().getRecordFactoryManager().getRecordTypeName(ORecordInternal.getRecordType(iCurrent.getRecord())); else if (iFieldName.equalsIgnoreCase(ATTRIBUTE_SIZE)) { final byte[] stream = iCurrent.getRecord().toStream(); return stream != null ? stream.length : 0; } else if (iFieldName.equalsIgnoreCase(ATTRIBUTE_FIELDS)) return ((ODocument) iCurrent.getRecord()).fieldNames(); else if (iFieldName.equalsIgnoreCase(ATTRIBUTE_RAW)) return new String(iCurrent.getRecord().toStream());
@Override public <RET extends ORecord> RET reload(ORecord record, String fetchPlan, boolean ignoreCache, boolean force) { checkIfActive(); final ORecord loadedRecord = currentTx.reloadRecord(record.getIdentity(), record, fetchPlan, ignoreCache, force); if (loadedRecord != null && record != loadedRecord) { record.fromStream(loadedRecord.toStream()); ORecordInternal.setVersion(record, loadedRecord.getVersion()); } else if (loadedRecord == null) { throw new ORecordNotFoundException(record.getIdentity()); } return (RET) record; }
public OBinaryField getBinaryField(final OIdentifiable iRecord) { if (iRecord == null) throw new OCommandExecutionException("expression item '" + name + "' cannot be resolved because current record is NULL"); if (operationsChain != null && operationsChain.size() > 0) // CANNOT USE BINARY FIELDS return null; final ORecord rec = iRecord.getRecord(); BytesContainer serialized = new BytesContainer(rec.toStream()); byte version = serialized.bytes[serialized.offset++]; ODocumentSerializer serializer = ORecordSerializerBinary.INSTANCE.getSerializer(version); //check for embedded objects, they have invalid ID and they are serialized with class name if (!serializer.isSerializingClassNameByDefault()){ return ORecordSerializerBinary.INSTANCE.getSerializer(version).deserializeField(serialized, rec instanceof ODocument ? ((ODocument) rec).getSchemaClass() : null, name); } else{ return serializer.deserializeFieldWithClassName(serialized, rec instanceof ODocument ? ((ODocument) rec).getSchemaClass() : null, name); } }
} catch (Exception t) { if (rec != null) { final byte[] buffer = rec.toStream();
public void bindToCache(ODatabaseDocumentInternal db) { if (isRecord()) { ORecord rec = element.getRecord(); ORecord cached = db.getLocalCache().findRecord(rec.getIdentity()); if (cached != null) { if (!cached.isDirty()) { cached.fromStream(rec.toStream()); } element = cached; } else { db.getLocalCache().updateRecord(rec); } } } }
final byte[] buffer = rec.toStream();
iRecord.fromStream(record.toStream()); ORecordInternal.setVersion(iRecord, record.getVersion()); record = iRecord;