Search in sources :

Example 1 with Numbers

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

the class NumericQueryJUnitTest method putData.

// creates a Numbers object and puts it into the specified region
private void putData(int id, Region region) throws ParseException {
    Numbers obj = new Numbers(id);
    region.put(id, obj);
    region.put(id + numElem, obj);
}
Also used : Numbers(org.apache.geode.cache.query.data.Numbers)

Example 2 with Numbers

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

the class NegativeNumberQueriesJUnitTest method populateRegionsWithNumbers.

// end of testGetQueryTimes
private void populateRegionsWithNumbers() throws Exception {
    CacheUtils.log("--------------------- Populating Data -------------------------");
    for (int i = 0; i < 100; i++) {
        region.put(String.valueOf(i), new Numbers(i));
    }
    for (int i = -100; i > -200; i--) {
        region.put(String.valueOf(i), new Numbers(i));
    }
    CacheUtils.log("--------------------- Data Populatio done -------------------------");
}
Also used : Numbers(org.apache.geode.cache.query.data.Numbers)

Example 3 with Numbers

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

the class IndexStatisticsJUnitTest method testCompactRangeIndexNumKeysStats.

@Test
public void testCompactRangeIndexNumKeysStats() throws Exception {
    String regionName = "testCompactRegionIndexNumKeysStats_region";
    Region region = CacheUtils.createRegion(regionName, Numbers.class);
    Index index = qs.createIndex("idIndexName", "r.max1", "/" + regionName + " r");
    IndexStatistics stats = index.getStatistics();
    // Add an object and check stats
    Numbers obj1 = new Numbers(1);
    obj1.max1 = 20;
    region.put(1, obj1);
    assertEquals(1, stats.getNumberOfValues());
    assertEquals(1, stats.getNumberOfKeys());
    // assertIndexDetailsEquals(1, stats.getNumberOfValues(20f));
    assertEquals(1, stats.getNumUpdates());
    // add a second object with the same index key
    Numbers obj2 = new Numbers(1);
    obj2.max1 = 20;
    region.put(2, obj2);
    assertEquals(2, stats.getNumberOfValues());
    assertEquals(1, stats.getNumberOfKeys());
    // assertIndexDetailsEquals(2, stats.getNumberOfValues(20f));
    assertEquals(2, stats.getNumUpdates());
    // remove the second object and check that keys are 1
    region.remove(2);
    assertEquals(1, stats.getNumberOfValues());
    assertEquals(1, stats.getNumberOfKeys());
    // assertIndexDetailsEquals(1, stats.getNumberOfValues(20f));
    assertEquals(3, stats.getNumUpdates());
    // remove the first object and check that keys are 0
    region.remove(1);
    assertEquals(0, stats.getNumberOfValues());
    assertEquals(0, stats.getNumberOfKeys());
    // assertIndexDetailsEquals(0, stats.getNumberOfValues(20f));
    assertEquals(4, stats.getNumUpdates());
    // add object with a different key and check results
    obj2.max1 = 21;
    region.put(3, obj2);
    assertEquals(1, stats.getNumberOfValues());
    assertEquals(1, stats.getNumberOfKeys());
    // assertIndexDetailsEquals(0, stats.getNumberOfValues(20f));
    assertEquals(5, stats.getNumUpdates());
    // add object with original key and check that num keys are 2
    obj1.max1 = 20;
    region.put(1, obj1);
    assertEquals(2, stats.getNumberOfValues());
    assertEquals(2, stats.getNumberOfKeys());
    // assertIndexDetailsEquals(1, stats.getNumberOfValues(20f));
    assertEquals(6, stats.getNumUpdates());
}
Also used : IndexStatistics(org.apache.geode.cache.query.IndexStatistics) Numbers(org.apache.geode.cache.query.data.Numbers) Region(org.apache.geode.cache.Region) Index(org.apache.geode.cache.query.Index) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

Numbers (org.apache.geode.cache.query.data.Numbers)3 Region (org.apache.geode.cache.Region)1 Index (org.apache.geode.cache.query.Index)1 IndexStatistics (org.apache.geode.cache.query.IndexStatistics)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 Test (org.junit.Test)1