Search in sources :

Example 6 with OIndex

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

the class OChainedIndexProxyFindBestIndexTest method testPriorityHashOverNonHash.

@Test
public void testPriorityHashOverNonHash() throws Exception {
    final OIndexUnique expectedResult = mockUniqueHashIndex();
    final List<OIndex<?>> indexes = Arrays.<OIndex<?>>asList(mockUniqueIndex(), mockUniqueCompositeIndex(), expectedResult, mockUniqueIndex(), mockUniqueCompositeIndex());
    final OIndex<?> result = OChainedIndexProxy.findBestIndex(indexes);
    Assert.assertSame(result, expectedResult);
}
Also used : OIndexUnique(com.orientechnologies.orient.core.index.OIndexUnique) OIndex(com.orientechnologies.orient.core.index.OIndex) Test(org.testng.annotations.Test)

Example 7 with OIndex

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

the class OChainedIndexProxyFindBestIndexTest method testDoNotUseCompositeHashIndex.

@Test
public void testDoNotUseCompositeHashIndex() throws Exception {
    final OIndexUnique expectedResult = mockUniqueIndex();
    final List<OIndex<?>> indexes = Arrays.<OIndex<?>>asList(mockUniqueCompositeHashIndexWithNullSupport(), expectedResult, mockUniqueCompositeHashIndexWithNullSupport());
    final OIndex<?> result = OChainedIndexProxy.findBestIndex(indexes);
    Assert.assertSame(result, expectedResult);
}
Also used : OIndexUnique(com.orientechnologies.orient.core.index.OIndexUnique) OIndex(com.orientechnologies.orient.core.index.OIndex) Test(org.testng.annotations.Test)

Example 8 with OIndex

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

the class OChainedIndexProxyFindBestIndexTest method testPriorityNonCompositeOverComposite.

@Test
public void testPriorityNonCompositeOverComposite() throws Exception {
    final OIndexUnique expectedResult = mockUniqueIndex();
    final List<OIndex<?>> indexes = Arrays.<OIndex<?>>asList(mockUniqueCompositeIndexWithNullSupport(), mockUniqueCompositeHashIndexWithNullSupport(), expectedResult, mockUniqueCompositeIndexWithNullSupport(), mockUniqueCompositeHashIndexWithNullSupport());
    final OIndex<?> result = OChainedIndexProxy.findBestIndex(indexes);
    Assert.assertSame(result, expectedResult);
}
Also used : OIndexUnique(com.orientechnologies.orient.core.index.OIndexUnique) OIndex(com.orientechnologies.orient.core.index.OIndex) Test(org.testng.annotations.Test)

Example 9 with OIndex

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

the class IndexCustomKeyTest method testTransactionalUsageWorks.

public void testTransactionalUsageWorks() {
    database.begin(OTransaction.TXTYPE.OPTIMISTIC);
    // OIndex<?> index = getManualIndex();
    ComparableBinary key3 = new ComparableBinary(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 3 });
    ODocument doc1 = new ODocument().field("k", "key3");
    final OIndex index = getIndex();
    index.put(key3, doc1);
    ComparableBinary key4 = new ComparableBinary(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4 });
    ODocument doc2 = new ODocument().field("k", "key4");
    index.put(key4, doc2);
    database.commit();
    Assert.assertEquals(index.get(key3), doc1);
    Assert.assertEquals(index.get(key4), doc2);
}
Also used : OIndex(com.orientechnologies.orient.core.index.OIndex) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 10 with OIndex

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

the class IndexManagerTest method testGetClassInvolvedIndexesThreePropertiesArrayParams.

@Test(dependsOnMethods = { "createCompositeIndexTestWithListener", "createCompositeIndexTestWithoutListener", "testCreateOnePropertyIndexTest" })
public void testGetClassInvolvedIndexesThreePropertiesArrayParams() {
    final OIndexManager indexManager = database.getMetadata().getIndexManager();
    final Set<OIndex<?>> result = indexManager.getClassInvolvedIndexes(CLASS_NAME, "fTwo", "fOne", "fThree");
    assertEquals(result.size(), 1);
    assertEquals(result.iterator().next().getName(), "compositetwo");
}
Also used : OIndexManager(com.orientechnologies.orient.core.index.OIndexManager) OIndex(com.orientechnologies.orient.core.index.OIndex) Test(org.testng.annotations.Test)

Aggregations

OIndex (com.orientechnologies.orient.core.index.OIndex)98 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)54 Test (org.testng.annotations.Test)50 OIndexDefinition (com.orientechnologies.orient.core.index.OIndexDefinition)26 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)20 OIndexManager (com.orientechnologies.orient.core.index.OIndexManager)18 OCompositeIndexDefinition (com.orientechnologies.orient.core.index.OCompositeIndexDefinition)16 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)16 Test (org.junit.Test)14 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)12 Collection (java.util.Collection)11 OPropertyIndexDefinition (com.orientechnologies.orient.core.index.OPropertyIndexDefinition)9 OPropertyMapIndexDefinition (com.orientechnologies.orient.core.index.OPropertyMapIndexDefinition)8 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)8 HashSet (java.util.HashSet)6 OConfigurationException (com.orientechnologies.orient.core.exception.OConfigurationException)5 OIndexManagerProxy (com.orientechnologies.orient.core.index.OIndexManagerProxy)5 OIndexUnique (com.orientechnologies.orient.core.index.OIndexUnique)5 Map (java.util.Map)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)4