use of com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerSchemaAware2CSV in project orientdb by orientechnologies.
the class TestDistributeConfigSerialization method executeTest.
@Override
protected void executeTest() throws Exception {
ODatabaseDocumentTx db = new ODatabaseDocumentTx("plocal:target/server0/databases/" + getDatabaseName());
try {
db.setSerializer(new ORecordSerializerSchemaAware2CSV());
db.create();
db.getMetadata().getSchema().createClass("TestMessaging");
db.activateOnCurrentThread();
db.save(new ODocument("TestMessaging").field("test", "test"));
db.query(new OSQLSynchQuery("select from TestMessaging "));
db.close();
} catch (OException e) {
e.printStackTrace();
Assert.fail("error on creating a csv database in distributed environment");
}
try {
db = new ODatabaseDocumentTx("remote:localhost/" + getDatabaseName());
db.open("admin", "admin");
db.query(new OSQLSynchQuery("select from TestMessaging "));
db.close();
} catch (OException e) {
e.printStackTrace();
Assert.fail("error on creating a csv database in distributed environment");
}
}
use of com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerSchemaAware2CSV in project orientdb by orientechnologies.
the class OClassImpl method setNameInternal.
private void setNameInternal(final String name) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
acquireSchemaWriteLock();
try {
checkEmbedded();
final String oldName = this.name;
owner.changeClassName(this.name, name, this);
this.name = name;
ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (!database.getStorageVersions().classesAreDetectedByClusterId()) {
for (int clusterId : clusterIds) {
long[] range = storage.getClusterDataRange(clusterId);
OPhysicalPosition[] positions = storage.ceilingPhysicalPositions(clusterId, new OPhysicalPosition(range[0]));
do {
for (OPhysicalPosition position : positions) {
final ORecordId identity = new ORecordId(clusterId, position.clusterPosition);
final ORawBuffer record = storage.readRecord(identity, null, true, false, null).getResult();
if (record.recordType == ODocument.RECORD_TYPE) {
final ORecordSerializerSchemaAware2CSV serializer = (ORecordSerializerSchemaAware2CSV) ORecordSerializerFactory.instance().getFormat(ORecordSerializerSchemaAware2CSV.NAME);
String persName = new String(record.buffer, "UTF-8");
if (serializer.getClassName(persName).equalsIgnoreCase(name)) {
final ODocument document = new ODocument();
document.setLazyLoad(false);
document.fromStream(record.buffer);
ORecordInternal.setVersion(document, record.version);
ORecordInternal.setIdentity(document, identity);
document.setClassName(name);
document.setDirty();
document.save();
}
}
if (positions.length > 0)
positions = storage.higherPhysicalPositions(clusterId, positions[positions.length - 1]);
}
} while (positions.length > 0);
}
}
renameCluster(oldName, this.name);
} catch (UnsupportedEncodingException e) {
throw OException.wrapException(new OSchemaException("Error reading schema"), e);
} finally {
releaseSchemaWriteLock();
}
}
Aggregations