use of com.orientechnologies.orient.core.record.impl.ORecordBytes in project orientdb by orientechnologies.
the class Account method toStream.
@OBeforeSerialization
public void toStream(final ODocument iDocument) {
if (thumbnail != null) {
// WRITE THE PHOTO IN AN EXTERNAL RECORD AS PURE BINARY
OBlob externalPhoto = new ORecordBytes(thumbnail);
iDocument.field("externalPhoto", externalPhoto);
}
}
use of com.orientechnologies.orient.core.record.impl.ORecordBytes in project orientdb by orientechnologies.
the class LocalCreateBinaryDocumentSpeedTest method cycle.
@Override
@Test(enabled = false)
public void cycle() {
final OStorage storage = database.getStorage();
((OAbstractPaginatedStorage) storage).startGatheringPerformanceStatisticForCurrentThread();
record = new ORecordBytes(database, payload);
record.save();
if (data.getCyclesDone() == data.getCycles() - 1)
database.commit();
OSessionStoragePerformanceStatistic sessionStoragePerformanceStatistic = ((OAbstractPaginatedStorage) storage).completeGatheringPerformanceStatisticForCurrentThread();
System.out.println(sessionStoragePerformanceStatistic.toDocument().toJSON("prettyPrint"));
}
use of com.orientechnologies.orient.core.record.impl.ORecordBytes in project orientdb by orientechnologies.
the class OConsoleDatatabaseAppTest method testSelectBinaryDoc.
@Test
public void testSelectBinaryDoc() throws IOException {
final StringBuilder builder = new StringBuilder();
OConsoleDatabaseApp app = new OConsoleDatabaseApp(new String[] {}) {
@Override
public void message(String iMessage, Object... iArgs) {
builder.append(String.format(iMessage, iArgs)).append("\n");
}
};
app.createDatabase("memory:test", null, null, "memory", null, null);
ODatabaseDocument db = app.getCurrentDatabase();
db.addBlobCluster("blobTest");
ORecord record = db.save(new ORecordBytes("blobContent".getBytes()), "blobTest");
builder.setLength(0);
app.select(" from " + record.getIdentity() + " limit -1 ");
assertTrue(builder.toString().contains("<binary>"));
}
use of com.orientechnologies.orient.core.record.impl.ORecordBytes in project orientdb by orientechnologies.
the class TestBinaryRecordsQuery method testSelectBinary.
@Test
public void testSelectBinary() {
database.save(new ORecordBytes("blabla".getBytes()), "BlobCluster");
List<ORecord> res = database.query(new OSQLSynchQuery<Object>("select from cluster:BlobCluster"));
assertEquals(1, res.size());
}
use of com.orientechnologies.orient.core.record.impl.ORecordBytes in project orientdb by orientechnologies.
the class TestBinaryRecordsQuery method testSelectDeleteBinary.
@Test
public void testSelectDeleteBinary() {
ORecord rec = database.save(new ORecordBytes("blabla".getBytes()), "BlobCluster");
database.getMetadata().getSchema().createClass("RecordPointer");
ODocument doc = new ODocument("RecordPointer");
doc.field("ref", rec);
database.save(doc);
Integer res = database.command(new OCommandSQL("delete from cluster:BlobCluster where @rid in (select ref from RecordPointer)")).execute();
database.getLocalCache().clear();
assertEquals(1, res.intValue());
rec = database.load(rec.getIdentity());
assertNull(rec);
}
Aggregations