Search in sources :

Example 96 with Portfolio

use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.

the class HashIndexQueryIntegrationTest method testHashIndexOnNonSequentialHashForLocalRegion.

/**
   * Tests that hash index on non sequential hashes for local region
   * 
   * @throws Exception
   */
@Test
public void testHashIndexOnNonSequentialHashForLocalRegion() throws Exception {
    createLocalRegion("portfolios");
    for (int i = 0; i < 100; i++) {
        Portfolio p = new Portfolio(i);
        p.shortID = (short) i;
        region.put("" + i, p);
    }
    for (int i = 200; i < 300; i++) {
        Portfolio p = new Portfolio(i);
        p.shortID = (short) i;
        region.put("" + i, p);
    }
    for (int i = 500; i < 600; i++) {
        Portfolio p = new Portfolio(i);
        p.shortID = (short) i;
        region.put("" + i, p);
    }
    helpTestHashIndexForQuery("Select * FROM /portfolios p where p.ID != 1");
}
Also used : Portfolio(org.apache.geode.cache.query.data.Portfolio) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 97 with Portfolio

use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.

the class HashIndexQueryIntegrationTest method testHashIndexWithLimitQueryForLocalRegion.

/**
   * Tests that hash index is used and that it returns the correct result for local region
   * 
   * @throws Exception
   */
@Test
public void testHashIndexWithLimitQueryForLocalRegion() throws Exception {
    createLocalRegion("portfolios");
    int numEntries = 200;
    int numIds = 100;
    for (int i = 0; i < numEntries; i++) {
        Portfolio p = new Portfolio(i % (numIds));
        p.shortID = (short) i;
        region.put("" + i, p);
    }
    helpTestHashIndexForQuery("SELECT * FROM /portfolios.entries p WHERE p.key = '1' limit 3", "p.key", "/portfolios.entries p");
}
Also used : Portfolio(org.apache.geode.cache.query.data.Portfolio) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 98 with Portfolio

use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.

the class HashIndexQueryIntegrationTest method testHashIndexWithNestedQueryWithShortVsIntegerCompareForLocalRegion.

/**
   * Tests that hash index with Short vs Integer comparison
   * 
   * @throws Exception
   */
@Test
public void testHashIndexWithNestedQueryWithShortVsIntegerCompareForLocalRegion() throws Exception {
    createLocalRegion("portfolios");
    int numEntries = 200;
    int numIds = 100;
    for (int i = 0; i < numEntries; i++) {
        Portfolio p = new Portfolio(i % (numIds));
        p.shortID = (short) i;
        region.put("" + i, p);
    }
    helpTestHashIndexForQuery("SELECT * FROM /portfolios p WHERE p.shortID in (SELECT p2.ID FROM /portfolios p2 WHERE p2.shortID = 1)", "p.shortID", "/portfolios p");
}
Also used : Portfolio(org.apache.geode.cache.query.data.Portfolio) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 99 with Portfolio

use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.

the class HashIndexQueryIntegrationTest method testHashIndexOnNonSequentialHashForPartitionedRegion.

/**
   * Tests that hash index on non sequential hashes for partitioned region
   * 
   * @throws Exception
   */
@Test
public void testHashIndexOnNonSequentialHashForPartitionedRegion() throws Exception {
    createPartitionedRegion("portfolios");
    for (int i = 0; i < 100; i++) {
        Portfolio p = new Portfolio(i);
        p.shortID = (short) i;
        region.put("" + i, p);
    }
    for (int i = 200; i < 300; i++) {
        Portfolio p = new Portfolio(i);
        p.shortID = (short) i;
        region.put("" + i, p);
    }
    for (int i = 500; i < 600; i++) {
        Portfolio p = new Portfolio(i);
        p.shortID = (short) i;
        region.put("" + i, p);
    }
    helpTestHashIndexForQuery("Select * FROM /portfolios p where p.ID != 1");
}
Also used : Portfolio(org.apache.geode.cache.query.data.Portfolio) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 100 with Portfolio

use of org.apache.geode.cache.query.data.Portfolio in project geode by apache.

the class HashIndexQueryIntegrationTest method testHashIndexEqualsForMultipleResultQueryOnPartitionedRegion.

/**
   * Tests that hash index is used and that it returns the correct number of results on partitioned
   * region
   * 
   * @throws Exception
   */
@Test
public void testHashIndexEqualsForMultipleResultQueryOnPartitionedRegion() throws Exception {
    createPartitionedRegion("portfolios");
    // Create the data
    int numEntries = 200;
    int numIds = 100;
    for (int i = 0; i < numEntries; i++) {
        Portfolio p = new Portfolio(i % (numIds));
        p.shortID = (short) i;
        region.put("" + i, p);
    }
    helpTestHashIndexForQuery("Select * FROM /portfolios p where p.ID = 1");
}
Also used : Portfolio(org.apache.geode.cache.query.data.Portfolio) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

Portfolio (org.apache.geode.cache.query.data.Portfolio)520 Test (org.junit.Test)415 Region (org.apache.geode.cache.Region)302 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)298 SelectResults (org.apache.geode.cache.query.SelectResults)247 Query (org.apache.geode.cache.query.Query)235 QueryService (org.apache.geode.cache.query.QueryService)195 Index (org.apache.geode.cache.query.Index)121 AttributesFactory (org.apache.geode.cache.AttributesFactory)85 Iterator (java.util.Iterator)81 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)72 LocalRegion (org.apache.geode.internal.cache.LocalRegion)69 VM (org.apache.geode.test.dunit.VM)65 Host (org.apache.geode.test.dunit.Host)64 Cache (org.apache.geode.cache.Cache)62 CacheException (org.apache.geode.cache.CacheException)49 DefaultQuery (org.apache.geode.cache.query.internal.DefaultQuery)47 QueryObserverAdapter (org.apache.geode.cache.query.internal.QueryObserverAdapter)47 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)47 IndexExistsException (org.apache.geode.cache.query.IndexExistsException)46