}
}
@SuppressWarnings("unchecked")
public OSerializableStream fromStream(final byte[] iStream) throws OSerializationException {
final OProfilerMBean profiler = Orient.instance().getProfiler();
final long timer = profiler.startChrono();
try {
stream.setSource(iStream);
byte protocolVersion = stream.peek();
if (protocolVersion != -1) {
// @COMPATIBILITY BEFORE 0.9.25
stream.getAsByte();
if (protocolVersion != CURRENT_PROTOCOL_VERSION)
OLogManager
.instance()
.debug(
this,
"Found tree %s created with MVRBTree protocol version %d while current one supports the version %d. The tree will be migrated transparently",
getRecord().getIdentity(), protocolVersion, CURRENT_PROTOCOL_VERSION);
}
root = new ORecordId();
root.fromStream(stream.getAsByteArrayFixed(ORecordId.PERSISTENT_SIZE));
size = stream.getAsInteger();
if (protocolVersion == -1)
// @COMPATIBILITY BEFORE 0.9.25
pageSize = stream.getAsShort();
else
pageSize = stream.getAsInteger();
// @COMPATIBILITY BEFORE 1.0
if (protocolVersion < 1) {
keySize = 1;
OLogManager.instance().warn(this,
"Previous index version was found, partial composite index queries may do not work if you " + "do not recreate index.");
} else
keySize = stream.getAsInteger();
// @COMPATIBILITY BEFORE 1.0
if (protocolVersion < 3) {
streamKeySerializer = OStreamSerializerFactory.get(stream.getAsStringCustom());
valueSerializer = OStreamSerializerFactory.get(stream.getAsStringCustom());
keySerializer = createRelatedSerializer(streamKeySerializer);
} else {
keySerializer = (OBinarySerializer<K>) OBinarySerializerFactory.getInstance().getObjectSerializer(stream.getAsByte());
valueSerializer = OStreamSerializerFactory.get(stream.getAsStringCustom());
final String oldKeySerializerName = stream.getAsStringCustom();
if (oldKeySerializerName != null && oldKeySerializerName.length() > 0)
streamKeySerializer = OStreamSerializerFactory.get(oldKeySerializerName);
}
} catch (Exception e) {
OLogManager.instance().error(this, "Error on unmarshalling OMVRBTreeMapProvider object from record: %s", e,
OSerializationException.class, root);
} finally {
profiler.stopChrono(profiler.getProcessMetric("mvrbtree.fromStream"), "Deserialize a MVRBTree", timer);
}
return this;
}