@Override
  public void init() {
    OProfiler.getInstance().startRecording();

    database = new ODatabaseDocumentTx(System.getProperty("url")).open("admin", "admin");
    record = database.newInstance();

    database.declareIntent(new OIntentMassiveInsert());
    database.begin(TXTYPE.NOTX);
  }
  @Override
  public void init() {
    Orient.instance().getProfiler().startRecording();

    database = new ODatabaseDocumentTx(System.getProperty("url")).open("admin", "admin");
    record = database.newInstance();

    database.declareIntent(new OIntentMassiveInsert());
    database.begin(TXTYPE.NOTX);

    beginRecords = database.countClass("Account");
    System.out.println("Total accounts: " + beginRecords);
  }
Ejemplo n.º 3
0
  @Test
  public void queryCountWithConditions() {
    OClass indexed = database.getMetadata().getSchema().getOrCreateClass("Indexed");
    indexed.createProperty("key", OType.STRING);
    indexed.createIndex("keyed", OClass.INDEX_TYPE.NOTUNIQUE, "key");
    database.<ODocument>newInstance("Indexed").field("key", "one").save();
    database.<ODocument>newInstance("Indexed").field("key", "two").save();

    List<ODocument> result =
        database
            .command(
                new OSQLSynchQuery<ODocument>(
                    "select count(*) as total from Indexed where key > 'one'"))
            .execute();

    Assert.assertTrue(result.size() == 1);
    for (ODocument d : result) {
      Assert.assertNotNull(d.field("total"));
      Assert.assertTrue(((Number) d.field("total")).longValue() > 0);
    }
  }