private void initMassiveOrderSkipLimit(ODatabaseDocumentTx db) {
    db.getMetadata().getSchema().createClass("MassiveOrderSkipLimit");
    db.declareIntent(new OIntentMassiveInsert());
    String fieldValue =
        "laskdf lkajsd flaksjdf laksjd flakjsd flkasjd flkajsd flkajsd flkajsd flkajsd flkajsd flkjas;lkj a;ldskjf laksdj asdklasdjf lskdaj fladsd";
    for (int i = 0; i < ORDER_SKIP_LIMIT_ITEMS; i++) {
      ODocument doc = new ODocument("MassiveOrderSkipLimit");
      doc.field("nnum", i);
      doc.field("aaa", fieldValue);
      doc.field("bbb", fieldValue);
      doc.field("bbba", fieldValue);
      doc.field("daf", fieldValue);
      doc.field("dfgd", fieldValue);
      doc.field("dgd", fieldValue);

      doc.save();
    }
    db.declareIntent(null);
  }
예제 #2
0
  public static void insert() {
    database.declareIntent(new OIntentMassiveInsert());
    database.begin(TXTYPE.NOTX);
    long ndoc = 1000000;
    ODocument doc = new ODocument();

    System.out.println("Inserting " + ndoc + " docs...");

    long block = System.nanoTime();
    for (long i = 1; i <= ndoc; i++) {
      doc.field("id", i);
      doc.field("val1", 4.0d);
      doc.field("val2", 5.0d);
      doc.field("val3", 6.0f);
      doc.field("val4", 255);
      doc.field("val5", "this is the description for a long comic books -" + i);
      doc.field("name", "this is secmask put on top - " + i);
      doc.setClassName("Account");
      doc.save();
      doc.reset();
      if (i % 100000 == 0) {
        double time = (double) (System.nanoTime() - block) / 1000000;
        System.out.println(i * 100 / ndoc + "%.\t" + time + "\t" + 100000.0d / time + " docs/ms");
        block = System.nanoTime();
      }
    }
    database.commit();

    System.out.println("Insertion done, now indexing ids...");

    block = System.nanoTime();

    // CREATE THE INDEX AT THE END
    database
        .getMetadata()
        .getSchema()
        .getClass("Account")
        .getProperty("id")
        .createIndex(OClass.INDEX_TYPE.UNIQUE);

    System.out.println("Indexing done in: " + (System.nanoTime() - block) / 1000000 + "ms");
  }