Search in sources :

Example 1 with OSimpleKeyIndexDefinition

use of com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition in project orientdb by orientechnologies.

the class IndexManagerTest method testDropSimpleKey.

@Test
public void testDropSimpleKey() {
    final OIndexManager indexManager = database.getMetadata().getIndexManager();
    indexManager.createIndex("simplekeytwo", OClass.INDEX_TYPE.UNIQUE.toString(), new OSimpleKeyIndexDefinition(-1, OType.INTEGER), null, null, null);
    assertNotNull(indexManager.getIndex("simplekeytwo"));
    indexManager.dropIndex("simplekeytwo");
    assertNull(indexManager.getIndex("simplekeytwo"));
}
Also used : OIndexManager(com.orientechnologies.orient.core.index.OIndexManager) OSimpleKeyIndexDefinition(com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition) Test(org.testng.annotations.Test)

Example 2 with OSimpleKeyIndexDefinition

use of com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition in project orientdb by orientechnologies.

the class OrientIndex method create.

private void create(final String indexName, final Class<? extends Element> indexClass, OType iKeyType) {
    this.indexClass = indexClass;
    if (iKeyType == null)
        iKeyType = OType.STRING;
    final OIndexFactory factory = OIndexes.getFactory(OClass.INDEX_TYPE.DICTIONARY.toString(), null);
    this.recordKeyValueIndex = new OIndexTxAwareOneValue(graph.getRawGraph(), (OIndex<OIdentifiable>) graph.getRawGraph().getMetadata().getIndexManager().createIndex("__@recordmap@___" + indexName, OClass.INDEX_TYPE.DICTIONARY.toString(), new OSimpleKeyIndexDefinition(factory.getLastVersion(), OType.LINK, OType.STRING), null, null, null));
    final String className;
    if (Vertex.class.isAssignableFrom(indexClass))
        className = VERTEX;
    else if (Edge.class.isAssignableFrom(indexClass))
        className = EDGE;
    else
        className = indexClass.getName();
    final ODocument metadata = new ODocument();
    metadata.field(CONFIG_CLASSNAME, className);
    metadata.field(CONFIG_RECORD_MAP_NAME, recordKeyValueIndex.getName());
    final OIndexFactory nuFactory = OIndexes.getFactory(OClass.INDEX_TYPE.NOTUNIQUE.toString(), null);
    // CREATE THE MAP
    this.underlying = new OIndexTxAwareMultiValue(graph.getRawGraph(), (OIndex<Set<OIdentifiable>>) graph.getRawGraph().getMetadata().getIndexManager().createIndex(indexName, OClass.INDEX_TYPE.NOTUNIQUE.toString(), new OSimpleKeyIndexDefinition(nuFactory.getLastVersion(), iKeyType), null, null, metadata));
}
Also used : OIndex(com.orientechnologies.orient.core.index.OIndex) OSimpleKeyIndexDefinition(com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition) OIndexTxAwareMultiValue(com.orientechnologies.orient.core.index.OIndexTxAwareMultiValue) OIndexTxAwareOneValue(com.orientechnologies.orient.core.index.OIndexTxAwareOneValue) OIndexFactory(com.orientechnologies.orient.core.index.OIndexFactory) Edge(com.tinkerpop.blueprints.Edge) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 3 with OSimpleKeyIndexDefinition

use of com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition in project orientdb by orientechnologies.

the class LuceneManualIndexTest method testManualIndexInsideTransaction.

@Test
public void testManualIndexInsideTransaction() throws Exception {
    // refs https://github.com/orientechnologies/orientdb/issues/7255
    OIndex<?> index = db.getMetadata().getIndexManager().createIndex("test", OClass.INDEX_TYPE.FULLTEXT.toString(), new OSimpleKeyIndexDefinition(1, OType.STRING), null, null, null, OLuceneIndexFactory.LUCENE_ALGORITHM);
    db.begin();
    ODocument document = db.newInstance();
    document.field("name", "Rob");
    db.save(document);
    index.put("Rob", document.getIdentity());
    index.flush();
    List<ODocument> docs = db.command(new OSQLSynchQuery("select from index:test where key LUCENE 'k0:rob'")).execute();
    Assert.assertEquals(docs.size(), 1);
    db.commit();
}
Also used : OSimpleKeyIndexDefinition(com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 4 with OSimpleKeyIndexDefinition

use of com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition in project orientdb by orientechnologies.

the class MVRBTreeInsertionSpeedTest method init.

@Override
@Test(enabled = false)
public void init() throws Exception {
    OGlobalConfiguration.NON_TX_CLUSTERS_SYNC_IMMEDIATELY.setValue("");
    OGlobalConfiguration.INDEX_MANUAL_LAZY_UPDATES.setValue(10000);
    String buildDirectory = System.getProperty("buildDirectory", ".");
    if (buildDirectory == null)
        buildDirectory = ".";
    databaseDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDirectory + "/uniqueHashIndexTest");
    if (databaseDocumentTx.exists()) {
        databaseDocumentTx.open("admin", "admin");
        databaseDocumentTx.drop();
    }
    databaseDocumentTx.create();
    index = (OIndexUnique) databaseDocumentTx.getMetadata().getIndexManager().createIndex("mvrbtreeIndexTest", "UNIQUE", new OSimpleKeyIndexDefinition(-1, OType.STRING), new int[0], null, null);
}
Also used : OSimpleKeyIndexDefinition(com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Example 5 with OSimpleKeyIndexDefinition

use of com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition in project orientdb by orientechnologies.

the class HashIndexSpeedTest method init.

@Override
@Test(enabled = false)
public void init() throws Exception {
    String buildDirectory = System.getProperty("buildDirectory", ".");
    if (buildDirectory == null)
        buildDirectory = ".";
    databaseDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDirectory + "/uniqueHashIndexTest");
    if (databaseDocumentTx.exists()) {
        databaseDocumentTx.open("admin", "admin");
        databaseDocumentTx.drop();
    }
    databaseDocumentTx.create();
    hashIndex = databaseDocumentTx.getMetadata().getIndexManager().createIndex("hashIndex", "UNIQUE_HASH_INDEX", new OSimpleKeyIndexDefinition(-1, OType.STRING), new int[0], null, null);
}
Also used : OSimpleKeyIndexDefinition(com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Aggregations

OSimpleKeyIndexDefinition (com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition)13 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)6 Test (org.testng.annotations.Test)5 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)4 OIndex (com.orientechnologies.orient.core.index.OIndex)3 OIndexFactory (com.orientechnologies.orient.core.index.OIndexFactory)3 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)2 OIndexManagerProxy (com.orientechnologies.orient.core.index.OIndexManagerProxy)2 OIndexTxAwareOneValue (com.orientechnologies.orient.core.index.OIndexTxAwareOneValue)2 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)2 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)2 Test (org.junit.Test)2 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)1 ORecordId (com.orientechnologies.orient.core.id.ORecordId)1 OCompositeKey (com.orientechnologies.orient.core.index.OCompositeKey)1 OIndexManager (com.orientechnologies.orient.core.index.OIndexManager)1 OIndexTxAwareMultiValue (com.orientechnologies.orient.core.index.OIndexTxAwareMultiValue)1 OIntentMassiveInsert (com.orientechnologies.orient.core.intent.OIntentMassiveInsert)1 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)1 OCommandSQLParsingException (com.orientechnologies.orient.core.sql.OCommandSQLParsingException)1