Search in sources :

Example 31 with ORecordBytes

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);
    }
}
Also used : OBlob(com.orientechnologies.orient.core.record.impl.OBlob) ORecordBytes(com.orientechnologies.orient.core.record.impl.ORecordBytes) OBeforeSerialization(com.orientechnologies.orient.core.annotation.OBeforeSerialization)

Example 32 with ORecordBytes

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"));
}
Also used : ORecordBytes(com.orientechnologies.orient.core.record.impl.ORecordBytes) OStorage(com.orientechnologies.orient.core.storage.OStorage) OAbstractPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage) OSessionStoragePerformanceStatistic(com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic) OrientMonoThreadTest(com.orientechnologies.orient.test.database.base.OrientMonoThreadTest) Test(org.testng.annotations.Test)

Example 33 with ORecordBytes

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>"));
}
Also used : ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) ORecord(com.orientechnologies.orient.core.record.ORecord) ORecordBytes(com.orientechnologies.orient.core.record.impl.ORecordBytes) OConsoleDatabaseApp(com.orientechnologies.orient.console.OConsoleDatabaseApp) Test(org.junit.Test)

Aggregations

ORecordBytes (com.orientechnologies.orient.core.record.impl.ORecordBytes)33 OBlob (com.orientechnologies.orient.core.record.impl.OBlob)20 Test (org.testng.annotations.Test)19 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)9 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)7 ORID (com.orientechnologies.orient.core.id.ORID)6 ORecord (com.orientechnologies.orient.core.record.ORecord)6 Test (org.junit.Test)6 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)4 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)4 IOException (java.io.IOException)4 OIntentMassiveInsert (com.orientechnologies.orient.core.intent.OIntentMassiveInsert)3 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)3 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)2 BufferedInputStream (java.io.BufferedInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ArrayList (java.util.ArrayList)2 OConsoleDatabaseApp (com.orientechnologies.orient.console.OConsoleDatabaseApp)1