Examples of ORecordBytes


Examples of com.orientechnologies.orient.core.record.impl.ORecordBytes

  @OAfterDeserialization
  public void fromStream(final ODocument iDocument) {
    initialized = true;
    if (iDocument.containsField("externalPhoto")) {
      // READ THE PHOTO FROM AN EXTERNAL RECORD AS PURE BINARY
      ORecordBytes extRecord = iDocument.field("externalPhoto");
      photo = extRecord.toStream();
    }
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ORecordBytes

  @OBeforeSerialization
  public void toStream(final ODocument iDocument) {
    if (thumbnail != null) {
      // WRITE THE PHOTO IN AN EXTERNAL RECORD AS PURE BINARY
      ORecordBytes externalPhoto = new ORecordBytes(iDocument.getDatabase(), thumbnail);
      iDocument.field("externalPhoto", externalPhoto);
    }
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ORecordBytes

  @Test
  public void testBasicCreateExternal() {
    database.open("admin", "admin");

    ORecordBytes record = new ORecordBytes(database, "This is a test".getBytes());
    record.save();
    rid = record.getIdentity();

    database.close();
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ORecordBytes

  @Test(dependsOnMethods = "testBasicCreateExternal")
  public void testBasicReadExternal() {
    database.open("admin", "admin");

    ORecordBytes record = database.load(rid);

    Assert.assertEquals("This is a test", new String(record.toStream()));

    database.close();
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ORecordBytes

  @Test(dependsOnMethods = "testBasicReadExternal")
  public void testMixedCreateExternal() {
    database.open("admin", "admin");

    ODocument doc = new ODocument(database);
    doc.field("binary", new ORecordBytes(database, "Binary data".getBytes()));

    doc.save();
    rid = doc.getIdentity();

    database.close();
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ORecordBytes

        final ORecordStringable record = (ORecordStringable) iRecord;
        json.writeAttribute(indentLevel + 1, true, "value", record.value());

      } else if (iRecord instanceof ORecordBytes) {
        // BYTES
        final ORecordBytes record = (ORecordBytes) iRecord;
        json.writeAttribute(indentLevel + 1, true, "value", OBase64Utils.encodeBytes(record.toStream()));
      } else

        throw new OSerializationException("Error on marshalling record of type '" + iRecord.getClass()
            + "' to JSON. The record type can't be exported to JSON");
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ORecordBytes

        return new ORecordFlat(iDatabase);
      }
    });
    declareRecordType(ORecordBytes.RECORD_TYPE, "bytes", ORecordBytes.class, new ORecordFactory() {
      public ORecord<?> newRecord(ODatabaseRecord iDatabase) {
        return new ORecordBytes(iDatabase);
      }
    });
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ORecordBytes

      for (int i = 0; i < count; i++) {
        doc.reset();
        doc.setClassName("Chunk");
        doc.field("hash", "key" + Integer.toString(i));
        doc.field("binary", new ORecordBytes(database, data));
        doc.save();

        ORID rid = doc.getIdentity();
        if (i % 100 == 0)
          System.out.println("ORID=" + rid);
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ORecordBytes

        Assert.assertTrue(result.size() > 0);

        if (result != null && result.size() > 0) {
          ODocument doc = (ODocument) result.iterator().next();
          System.out.println("loaded " + i + "(" + rand + "), binary record: " + doc.field("binary", ORID.class));
          ORecordBytes record = doc.field("binary");
          Assert.assertNotNull(record);
          if (record != null) {
            byte[] data = record.toStream();
            Assert.assertTrue(data.length == size);
          }
        } else {
          System.out.println("key not found " + rand);
        }
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ORecordBytes

    database.begin(TXTYPE.NOTX);
  }

  @Override
  public void cycle() {
    record = new ORecordBytes(database, payload);
    record.save();

    if (data.getCyclesDone() == data.getCycles() - 1)
      database.commit();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.