Java Code Examples for com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx#drop()
The following examples show how to use
com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx#drop() .
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: CreateCityDb.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@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 2
Source File: CreateLocationDb.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@Override @Test(enabled = false) public void init() throws Exception { String buildDirectory = System.getProperty("buildDirectory", "."); if (buildDirectory == null) buildDirectory = "."; databaseDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDirectory + "/location"); if (databaseDocumentTx.exists()) { databaseDocumentTx.open("admin", "admin"); databaseDocumentTx.drop(); } databaseDocumentTx.create(); OSchema schema = databaseDocumentTx.getMetadata().getSchema(); OClass oClass = schema.createClass("City"); oClass.createProperty("latitude", OType.DOUBLE); oClass.createProperty("longitude", OType.DOUBLE); oClass.createProperty("name", OType.STRING); oClass.createIndex("City.latitude_longitude", "SPATIAL", null, null, "LUCENE", new String[] { "latitude", "longitude" }); oClass.createIndex("City.name", "FULLTEXT", null, null, "LUCENE", new String[] { "name" }); ZipFile zipFile = new ZipFile("files/location.csv.zip"); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); if (entry.getName().equals("location.csv")) { InputStream stream = zipFile.getInputStream(entry); reader = new CSVReader(new InputStreamReader(stream), ','); } } }
Example 3
Source File: LuceneInsertMultithreadTest.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@Test public void testConcurrentInsertWithIndex() throws Exception { databaseDocumentTx = new ODatabaseDocumentTx(url); if (!url.contains("remote:") && databaseDocumentTx.exists()) { databaseDocumentTx.open("admin", "admin"); databaseDocumentTx.drop(); databaseDocumentTx.create(); } else { databaseDocumentTx.create(); } OSchema schema = databaseDocumentTx.getMetadata().getSchema(); if (schema.getClass("City") == null) { OClass oClass = schema.createClass("City"); oClass.createProperty("name", OType.STRING); oClass.createIndex("City.name", "FULLTEXT", null, null, "LUCENE", new String[] { "name" }); } Thread[] threads = new Thread[THREADS + RTHREADS]; for (int i = 0; i < THREADS; ++i) threads[i] = new Thread(new LuceneInsertThread(CYCLE), "ConcurrentWriteTest" + i); for (int i = THREADS; i < THREADS + RTHREADS; ++i) threads[i] = new Thread(new LuceneReadThread(CYCLE), "ConcurrentReadTest" + i); for (int i = 0; i < THREADS + RTHREADS; ++i) threads[i].start(); for (int i = 0; i < THREADS + RTHREADS; ++i) threads[i].join(); OIndex idx = schema.getClass("City").getClassIndex("City.name"); Assert.assertEquals(idx.getSize(), THREADS * CYCLE); databaseDocumentTx.drop(); }
Example 4
Source File: DatabaseExternalizerTest.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
private void dropDb() { ODatabaseDocumentTx db = database.getInstance().connect(); db.drop(); assertFalse(db.exists()); }
Example 5
Source File: OOrientDBLoader.java From orientdb-etl with Apache License 2.0 | 4 votes |
@Override public void configure(final OETLProcessor iProcessor, final ODocument iConfiguration, final OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); if (iConfiguration.containsField("dbURL")) dbURL = (String) resolve(iConfiguration.field("dbURL")); if (iConfiguration.containsField("dbUser")) dbUser = (String) resolve(iConfiguration.field("dbUser")); if (iConfiguration.containsField("dbPassword")) dbPassword = (String) resolve(iConfiguration.field("dbPassword")); if (iConfiguration.containsField("dbType")) dbType = DB_TYPE.valueOf(iConfiguration.field("dbType").toString().toUpperCase()); if (iConfiguration.containsField("tx")) tx = (Boolean) iConfiguration.field("tx"); if (iConfiguration.containsField("wal")) wal = (Boolean) iConfiguration.field("wal"); if (iConfiguration.containsField("txUseLog")) txUseLog = (Boolean) iConfiguration.field("txUseLog"); if (iConfiguration.containsField("batchCommit")) batchCommit = (Integer) iConfiguration.field("batchCommit"); if (iConfiguration.containsField("dbAutoCreate")) dbAutoCreate = (Boolean) iConfiguration.field("dbAutoCreate"); if (iConfiguration.containsField("dbAutoDropIfExists")) dbAutoDropIfExists = (Boolean) iConfiguration.field("dbAutoDropIfExists"); if (iConfiguration.containsField("dbAutoCreateProperties")) dbAutoCreateProperties = (Boolean) iConfiguration.field("dbAutoCreateProperties"); if (iConfiguration.containsField("useLightweightEdges")) useLightweightEdges = (Boolean) iConfiguration.field("useLightweightEdges"); if (iConfiguration.containsField("standardElementConstraints")) standardElementConstraints = (Boolean) iConfiguration.field("standardElementConstraints"); clusterName = iConfiguration.field("cluster"); className = iConfiguration.field("class"); indexes = iConfiguration.field("indexes"); classes = iConfiguration.field("classes"); if (iConfiguration.containsField("settings")) { final ODocument settings = (ODocument) iConfiguration.field("settings"); settings.setAllowChainedAccess(false); for (String s : settings.fieldNames()) { final OGlobalConfiguration v = OGlobalConfiguration.findByKey(s); if (v != null) v.setValue(settings.field(s)); } } if (!wal) OGlobalConfiguration.USE_WAL.setValue(wal); switch (dbType) { case DOCUMENT: final ODatabaseDocumentTx documentDatabase = new ODatabaseDocumentTx(dbURL); if (documentDatabase.exists() && dbAutoDropIfExists) { log(OETLProcessor.LOG_LEVELS.INFO, "Dropping existent database '%s'...", dbURL); documentDatabase.open(dbUser, dbPassword); documentDatabase.drop(); } if (documentDatabase.exists()) { log(OETLProcessor.LOG_LEVELS.DEBUG, "Opening database '%s'...", dbURL); documentDatabase.open(dbUser, dbPassword); } else if (dbAutoCreate) { documentDatabase.create(); } else throw new IllegalArgumentException("Database '" + dbURL + "' not exists and 'dbAutoCreate' setting is false"); documentDatabase.close(); break; case GRAPH: final OrientGraphFactory factory = new OrientGraphFactory(dbURL, dbUser, dbPassword); if (dbAutoDropIfExists && factory.exists()) { log(OETLProcessor.LOG_LEVELS.INFO, "Dropping existent database '%s'...", dbURL); factory.drop(); } final OrientBaseGraph graphDatabase = tx ? factory.getTx() : factory.getNoTx(); graphDatabase.shutdown(); break; } }