use of com.orientechnologies.orient.core.metadata.schema.OGlobalProperty in project orientdb by orientechnologies.
the class ORecordSerializerBinaryDebug method deserializeDebug.
public ORecordSerializationDebug deserializeDebug(final byte[] iSource, ODatabaseDocumentInternal db) {
ORecordSerializationDebug debugInfo = new ORecordSerializationDebug();
OImmutableSchema schema = ((OMetadataInternal) db.getMetadata()).getImmutableSchemaSnapshot();
BytesContainer bytes = new BytesContainer(iSource);
if (bytes.bytes[0] != 0)
throw new OSystemException("Unsupported binary serialization version");
bytes.skip(1);
try {
final String className = readString(bytes);
debugInfo.className = className;
} catch (RuntimeException ex) {
debugInfo.readingFailure = true;
debugInfo.readingException = ex;
debugInfo.failPosition = bytes.offset;
return debugInfo;
}
debugInfo.properties = new ArrayList<ORecordSerializationDebugProperty>();
int last = 0;
String fieldName;
int valuePos;
OType type;
while (true) {
ORecordSerializationDebugProperty debugProperty = new ORecordSerializationDebugProperty();
OGlobalProperty prop = null;
try {
final int len = OVarIntSerializer.readAsInteger(bytes);
if (len != 0)
debugInfo.properties.add(debugProperty);
if (len == 0) {
// SCAN COMPLETED
break;
} else if (len > 0) {
// PARSE FIELD NAME
fieldName = stringFromBytes(bytes.bytes, bytes.offset, len).intern();
bytes.skip(len);
valuePos = readInteger(bytes);
type = readOType(bytes);
} else {
// LOAD GLOBAL PROPERTY BY ID
final int id = (len * -1) - 1;
debugProperty.globalId = id;
prop = schema.getGlobalPropertyById(id);
valuePos = readInteger(bytes);
debugProperty.valuePos = valuePos;
if (prop != null) {
fieldName = prop.getName();
if (prop.getType() != OType.ANY)
type = prop.getType();
else
type = readOType(bytes);
} else {
continue;
}
}
debugProperty.name = fieldName;
debugProperty.type = type;
if (valuePos != 0) {
int headerCursor = bytes.offset;
bytes.offset = valuePos;
try {
debugProperty.value = deserializeValue(bytes, type, new ODocument());
} catch (RuntimeException ex) {
debugProperty.faildToRead = true;
debugProperty.readingException = ex;
debugProperty.failPosition = bytes.offset;
}
if (bytes.offset > last)
last = bytes.offset;
bytes.offset = headerCursor;
} else
debugProperty.value = null;
} catch (RuntimeException ex) {
debugInfo.readingFailure = true;
debugInfo.readingException = ex;
debugInfo.failPosition = bytes.offset;
return debugInfo;
}
}
return debugInfo;
}
use of com.orientechnologies.orient.core.metadata.schema.OGlobalProperty in project orientdb by orientechnologies.
the class ORecordSerializerNetworkV0 method getFieldNames.
@Override
public String[] getFieldNames(ODocument reference, final BytesContainer bytes) {
// SKIP CLASS NAME
final int classNameLen = OVarIntSerializer.readAsInteger(bytes);
bytes.skip(classNameLen);
final List<String> result = new ArrayList<String>();
String fieldName;
while (true) {
OGlobalProperty prop = null;
final int len = OVarIntSerializer.readAsInteger(bytes);
if (len == 0) {
// SCAN COMPLETED
break;
} else if (len > 0) {
// PARSE FIELD NAME
fieldName = stringFromBytes(bytes.bytes, bytes.offset, len).intern();
result.add(fieldName);
// SKIP THE REST
bytes.skip(len + OIntegerSerializer.INT_SIZE + 1);
} else {
// LOAD GLOBAL PROPERTY BY ID
final int id = (len * -1) - 1;
prop = ODocumentInternal.getGlobalPropertyById(reference, id);
result.add(prop.getName());
// SKIP THE REST
bytes.skip(OIntegerSerializer.INT_SIZE + (prop.getType() != OType.ANY ? 0 : 1));
}
}
return result.toArray(new String[result.size()]);
}
Aggregations