Search in sources :

Example 1 with IndexStoreEntry

use of org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry in project geode by apache.

the class IndexMaintenanceJUnitTest method validateIndexForKeys.

private void validateIndexForKeys(CompactRangeIndex ri) {
    assertEquals(6, ri.getIndexStorage().size());
    CloseableIterator<IndexStoreEntry> itr = null;
    try {
        itr = ri.getIndexStorage().iterator(null);
        while (itr.hasNext()) {
            IndexStoreEntry reEntry = (IndexStoreEntry) itr.next();
            Object obj = reEntry.getDeserializedRegionKey();
            assertTrue(obj instanceof String);
            assertTrue(idSet.contains(obj));
        }
    } finally {
        if (itr != null) {
            itr.close();
        }
    }
}
Also used : MemoryIndexStoreEntry(org.apache.geode.cache.query.internal.index.MemoryIndexStore.MemoryIndexStoreEntry) IndexStoreEntry(org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry)

Example 2 with IndexStoreEntry

use of org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry in project geode by apache.

the class MapIndexStoreJUnitTest method validateIndexStorage.

/**
   * iterates through the index storage structure and compares size with the test list
   */
private void validateIndexStorage() {
    CloseableIterator<IndexStoreEntry> iterator = null;
    try {
        ArrayList structureList = new ArrayList();
        iterator = indexDataStructure.iterator(null);
        while (iterator.hasNext()) {
            IndexStoreEntry ie = iterator.next();
            if (entriesContains(ie)) {
                structureList.add(ie);
            } else {
                fail("IndexDataStructure returned an IndexEntry that should not be present:" + ie);
            }
        }
        assertEquals("Expected Number of entries did not match", entries.size(), structureList.size());
    } finally {
        if (iterator != null) {
            iterator.close();
        }
    }
}
Also used : ArrayList(java.util.ArrayList) IndexStoreEntry(org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry)

Example 3 with IndexStoreEntry

use of org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry in project geode by apache.

the class PdxStringQueryJUnitTest method testQueriesWithCompactRangeIndexPdxInstances.

@Test
public void testQueriesWithCompactRangeIndexPdxInstances() throws Exception {
    Index index = qs.createIndex("index1", "secId", "/exampleRegion");
    assertTrue(index instanceof CompactRangeIndex);
    putPdxInstances();
    CloseableIterator<IndexStoreEntry> indexIterator = null;
    try {
        indexIterator = ((CompactRangeIndex) index).getIndexStorage().iterator(null);
        while (indexIterator.hasNext()) {
            assertTrue(indexIterator.next().getDeserializedKey() instanceof PdxString);
        }
    } finally {
        if (indexIterator != null) {
            indexIterator.close();
        }
    }
    executeQueriesValidateResults(INDEX_TYPE_COMPACTRANGE);
    r.clear();
}
Also used : CompactRangeIndex(org.apache.geode.cache.query.internal.index.CompactRangeIndex) IndexStoreEntry(org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry) CompactRangeIndex(org.apache.geode.cache.query.internal.index.CompactRangeIndex) RangeIndex(org.apache.geode.cache.query.internal.index.RangeIndex) PrimaryKeyIndex(org.apache.geode.cache.query.internal.index.PrimaryKeyIndex) PdxString(org.apache.geode.pdx.internal.PdxString) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 4 with IndexStoreEntry

use of org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry in project geode by apache.

the class PdxStringQueryJUnitTest method testQueriesWithCompactRangeIndexPdxInstancesREUpdateInProgress.

@Test
public void testQueriesWithCompactRangeIndexPdxInstancesREUpdateInProgress() throws Exception {
    Index index = qs.createIndex("index1", "secId", "/exampleRegion");
    assertTrue(index instanceof CompactRangeIndex);
    putPdxInstancesWithREUpdateInProgress();
    CloseableIterator<IndexStoreEntry> indexIterator = null;
    try {
        indexIterator = ((CompactRangeIndex) index).getIndexStorage().iterator(null);
        while (indexIterator.hasNext()) {
            assertTrue(indexIterator.next().getDeserializedKey() instanceof PdxString);
        }
    } finally {
        if (indexIterator != null) {
            indexIterator.close();
        }
    }
    executeQueriesValidateResults(INDEX_TYPE_COMPACTRANGE);
    r.clear();
}
Also used : CompactRangeIndex(org.apache.geode.cache.query.internal.index.CompactRangeIndex) IndexStoreEntry(org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry) CompactRangeIndex(org.apache.geode.cache.query.internal.index.CompactRangeIndex) RangeIndex(org.apache.geode.cache.query.internal.index.RangeIndex) PrimaryKeyIndex(org.apache.geode.cache.query.internal.index.PrimaryKeyIndex) PdxString(org.apache.geode.pdx.internal.PdxString) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 5 with IndexStoreEntry

use of org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry in project geode by apache.

the class RangeIndex method queryEquijoinCondition.

// Asif TODO: Provide explanation of the method. Test this method
@Override
public List queryEquijoinCondition(IndexProtocol indx, ExecutionContext context) throws TypeMismatchException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException {
    // get a read lock when doing a lookup
    long start = updateIndexUseStats();
    ((AbstractIndex) indx).updateIndexUseStats();
    List data = new ArrayList();
    Iterator inner = null;
    try {
        // We will iterate over each of the valueToEntries Map to obatin the keys
        // & its correspodning
        // Entry to ResultSet Map
        Iterator outer = this.valueToEntriesMap.entrySet().iterator();
        if (indx instanceof CompactRangeIndex) {
            inner = ((CompactRangeIndex) indx).getIndexStorage().iterator(null);
        } else {
            inner = ((RangeIndex) indx).getValueToEntriesMap().entrySet().iterator();
        }
        Map.Entry outerEntry = null;
        Object innerEntry = null;
        Object outerKey = null;
        Object innerKey = null;
        // boolean incrementOuter = true;
        boolean incrementInner = true;
        outer: while (outer.hasNext()) {
            // if (incrementOuter) {
            outerEntry = (Map.Entry) outer.next();
            // }
            outerKey = outerEntry.getKey();
            while (!incrementInner || inner.hasNext()) {
                if (incrementInner) {
                    innerEntry = inner.next();
                    if (innerEntry instanceof IndexStoreEntry) {
                        innerKey = ((IndexStoreEntry) innerEntry).getDeserializedKey();
                    } else {
                        innerKey = ((Map.Entry) innerEntry).getKey();
                    }
                }
                int compare = ((Comparable) outerKey).compareTo(innerKey);
                if (compare == 0) {
                    // Asif :Select the data
                    // incrementOuter = true;
                    Object innerValue = null;
                    if (innerEntry instanceof IndexStoreEntry) {
                        innerValue = ((CompactRangeIndex) indx).getIndexStorage().get(outerKey);
                    } else {
                        innerValue = ((Map.Entry) innerEntry).getValue();
                    }
                    populateListForEquiJoin(data, outerEntry.getValue(), innerValue, context, null);
                    incrementInner = true;
                    continue outer;
                } else if (compare < 0) {
                    // Asif :The outer key is smaller than the inner key. That means
                    // that we need to increment the outer loop without moving inner loop.
                    // incrementOuter = true;
                    incrementInner = false;
                    continue outer;
                } else {
                    // Asif : The outer key is greater than inner key , so increment the
                    // inner loop without changing outer
                    incrementInner = true;
                }
            }
            break;
        }
        return data;
    } finally {
        ((AbstractIndex) indx).updateIndexUseEndStats(start);
        updateIndexUseEndStats(start);
        if (inner != null && indx instanceof CompactRangeIndex) {
            ((CloseableIterator<IndexStoreEntry>) inner).close();
        }
    }
}
Also used : CloseableIterator(org.apache.geode.internal.cache.persistence.query.CloseableIterator) ArrayList(java.util.ArrayList) IndexStoreEntry(org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry) RegionEntry(org.apache.geode.internal.cache.RegionEntry) IndexStoreEntry(org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry) CloseableIterator(org.apache.geode.internal.cache.persistence.query.CloseableIterator) RuntimeIterator(org.apache.geode.cache.query.internal.RuntimeIterator) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Object2ObjectOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap) Map(java.util.Map) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) NavigableMap(java.util.NavigableMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) SortedMap(java.util.SortedMap)

Aggregations

IndexStoreEntry (org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry)12 ArrayList (java.util.ArrayList)7 List (java.util.List)6 MemoryIndexStoreEntry (org.apache.geode.cache.query.internal.index.MemoryIndexStore.MemoryIndexStoreEntry)6 Iterator (java.util.Iterator)5 RuntimeIterator (org.apache.geode.cache.query.internal.RuntimeIterator)5 CloseableIterator (org.apache.geode.internal.cache.persistence.query.CloseableIterator)5 Map (java.util.Map)4 HashSet (java.util.HashSet)3 CqEntry (org.apache.geode.cache.query.internal.CqEntry)3 RegionEntry (org.apache.geode.internal.cache.RegionEntry)3 Object2ObjectOpenHashMap (it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap)2 Collection (java.util.Collection)2 Entry (java.util.Map.Entry)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 EntryDestroyedException (org.apache.geode.cache.EntryDestroyedException)2 CompiledSortCriterion (org.apache.geode.cache.query.internal.CompiledSortCriterion)2 IndexInfo (org.apache.geode.cache.query.internal.IndexInfo)2 CompactRangeIndex (org.apache.geode.cache.query.internal.index.CompactRangeIndex)2 PrimaryKeyIndex (org.apache.geode.cache.query.internal.index.PrimaryKeyIndex)2