com.orientechnologies.orient.core.intent.OIntentMassiveInsert Java Examples

The following examples show how to use com.orientechnologies.orient.core.intent.OIntentMassiveInsert. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LuceneInsertReadMultithreadTest.java    From orientdb-lucene with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {

  db = new ODatabaseDocumentTx(url);
  db.open("admin", "admin");
  db.declareIntent(new OIntentMassiveInsert());
  db.begin();
  for (int i = 0; i < cycle; i++) {
    ODocument doc = new ODocument("City");

    doc.field("name", "Rome");

    db.save(doc);
    if (i % commitBuf == 0) {
      db.commit();
      db.begin();
    }

  }

  db.close();
}
 
Example #2
Source File: LuceneInsertMultithreadTest.java    From orientdb-lucene with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {

  db = new ODatabaseDocumentTx(url);
  db.open("admin", "admin");
  db.declareIntent(new OIntentMassiveInsert());
  db.begin();
  for (int i = 0; i < cycle; i++) {
    ODocument doc = new ODocument("City");

    doc.field("name", "Rome");

    db.save(doc);
    if (i % commitBuf == 0) {
      db.commit();
      db.begin();
    }

  }

  db.close();
}
 
Example #3
Source File: CSVImporter.java    From bjoern with GNU General Public License v3.0 5 votes vote down vote up
protected void openNoTxForMassiveInsert()
{
	OGlobalConfiguration.USE_WAL.setValue(false);
	OGlobalConfiguration.WAL_SYNC_ON_PAGE_FLUSH.setValue(false);

	noTx = new OrientGraphNoTx(
			"plocal:" + System.getProperty("ORIENTDB_HOME") + "/databases/" + dbName);
	noTx.declareIntent(new OIntentMassiveInsert());
}
 
Example #4
Source File: CreateCityDb.java    From orientdb-lucene with Apache License 2.0 5 votes vote down vote up
@Override
@Test(enabled = false)
public void init() throws Exception {
  String buildDirectory = System.getProperty("buildDirectory", ".");
  if (buildDirectory == null)
    buildDirectory = ".";

  String uri = "plocal:" + buildDirectory + "/databases/city";
  databaseDocumentTx = new ODatabaseDocumentTx(uri);
  if (databaseDocumentTx.exists()) {
    databaseDocumentTx.open("admin", "admin");
    databaseDocumentTx.drop();
  }
  databaseDocumentTx.create();
  OSchema schema = databaseDocumentTx.getMetadata().getSchema();
  if (schema.getClass("City") == null) {
    OClass oClass = schema.createClass("City");
    oClass.createProperty("latitude", OType.DOUBLE);
    oClass.createProperty("longitude", OType.DOUBLE);
    oClass.createProperty("name", OType.STRING);
    oClass.createIndex("City.name", "FULLTEXT", null, null, "LUCENE", new String[] { "name" });
    oClass.createIndex("City.lat_lng", "SPATIAL", null, null, "LUCENE", new String[] { "latitude", "longitude" });
  }
  ZipFile zipFile = new ZipFile("files/allCountries.zip");
  Enumeration<? extends ZipEntry> entries = zipFile.entries();

  while (entries.hasMoreElements()) {

    ZipEntry entry = entries.nextElement();
    if (entry.getName().equals("allCountries.txt")) {

      InputStream stream = zipFile.getInputStream(entry);
      lineReader = new LineNumberReader(new InputStreamReader(stream));
    }
  }

  databaseDocumentTx.declareIntent(new OIntentMassiveInsert());
}
 
Example #5
Source File: OrientDbLoader.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
public void init() {
    log.debug("Init loader");
    documentDatabase = new ODatabaseDocumentTx(dbUrl, false);
    String databaseName = documentDatabase.getName();

    if (documentDatabase.exists() && dbAutoDropIfExists) {
        log.debug("Dropping existent database '{}'", databaseName);
        documentDatabase.open(dbUser, dbPassword).drop();
    }

    if (documentDatabase.exists()) {
        log.debug("Open database '{}'", databaseName);
        documentDatabase.open(dbUser, dbPassword);

        if ((className != null) && autoDropClass) {
            OSchema schema = documentDatabase.getMetadata().getSchema();
            if (schema.existsClass(className)) {
                log.debug("Dropping class '{}'", className);
                documentDatabase.command(new OCommandSQL("DELETE FROM " + className)).execute();
                schema.dropClass(className);
            }
        }
    } else {
        long time = System.currentTimeMillis();
        log.debug("Create database '{}'", databaseName);
        documentDatabase.create();
        time = System.currentTimeMillis() - time;
        log.debug("Created database '{}' in {} ms", databaseName, time);
    }

    documentDatabase.declareIntent(new OIntentMassiveInsert());
}