use of org.infinispan.query.test.Person in project infinispan by infinispan.
the class LoopingWriterTest method writeStuff.
/**
* We write a lot of elements.. and run a Query occasionally to check.
*/
private void writeStuff(final Cache<Object, Object> cache) {
final long startTime = System.nanoTime();
for (int i = 1; i < TOTAL_LOOPS; i++) {
final String key = "K" + i;
final Person value = new Person(key, key, i);
cache.put(key, value);
if (i % QUERY_PERIODICITY == 0) {
countElementsViaQuery(cache, i);
}
if (i % TIMESAMPLE_PERIODICITY == 0) {
final long currentTimeStamp = System.nanoTime();
final long elapsed = currentTimeStamp - startTime;
final double elementsWrittenPerSecond = ((double) TimeUnit.NANOSECONDS.convert(i, TimeUnit.SECONDS)) / elapsed;
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(2);
nf.setGroupingUsed(true);
System.out.println("Transactions committed to index per second: " + nf.format(elementsWrittenPerSecond) + ". Total documents: " + i + " Total time: " + Util.prettyPrintTime(elapsed, TimeUnit.NANOSECONDS));
}
}
}
use of org.infinispan.query.test.Person in project infinispan by infinispan.
the class SharedCacheLoaderQueryIndexTest method testPreloadIndexingAfterAddingNewNode.
public void testPreloadIndexingAfterAddingNewNode() {
loadCacheEntries(this.<String, Person>caches().get(0));
List<DummyInMemoryStore> cacheStores = TestingUtil.cachestores(caches());
for (DummyInMemoryStore dimcs : cacheStores) {
assertTrue("Cache misconfigured, maybe cache store not pointing to same place, maybe passivation on...etc", dimcs.contains(persons[0].getName()));
int clear = dimcs.stats().get("clear");
assertEquals("Cache store should not be cleared, purgeOnStartup is false", clear, 0);
int write = dimcs.stats().get("write");
assertEquals("Cache store should have been written to 4 times, but was written to " + write + " times", write, 4);
}
// Before adding a node, verify that the query resolves properly
executeSimpleQuery(this.<String, Person>caches().get(0));
addNodeCheckingContentsAndQuery();
}
use of org.infinispan.query.test.Person in project infinispan by infinispan.
the class QueryPhrasesTest method testKeyword.
public void testKeyword() {
loadTestingData();
Query<Person> cacheQuery = createCacheQuery(Person.class, "name:'Eats' OR blurb:'Eats'");
List<Person> found = cacheQuery.execute().list();
assertEquals(2, found.size());
person4 = new Person();
person4.setName("Some name with Eats");
person4.setBlurb("Description without keyword.");
cache.put("someKey", person4);
found = cacheQuery.execute().list();
assertEquals(3, found.size());
assertTrue(found.contains(person2));
assertTrue(found.contains(person3));
assertTrue(found.contains(person4));
}
use of org.infinispan.query.test.Person in project infinispan by infinispan.
the class QueryPhrasesTest method testPhraseSentence.
public void testPhraseSentence() {
loadTestingData();
Query<Person> cacheQuery = createCacheQuery(Person.class, "blurb:'Eats grass'");
List<Person> found = cacheQuery.execute().list();
assertEquals(1, found.size());
assertTrue(found.contains(person2));
person4 = new Person();
person4.setName("Another goat");
person4.setBlurb("Eats grass and drinks water.");
cache.put("anotherKey", person4);
found = cacheQuery.execute().list();
assertEquals(2, found.size());
assertTrue(found.contains(person2));
assertTrue(found.contains(person4));
}
use of org.infinispan.query.test.Person in project infinispan by infinispan.
the class QueryPhrasesTest method loadTestingData.
private void loadTestingData() {
person1 = new Person();
person1.setName("Navin Surtani");
person1.setBlurb("Likes playing WoW");
person1.setAge(20);
person2 = new Person();
person2.setName("Big Goat");
person2.setBlurb("Eats grass");
person2.setAge(30);
person3 = new Person();
person3.setName("Mini Goat");
person3.setBlurb("Eats cheese");
person3.setAge(25);
cache.put(key1, person1);
cache.put(key2, person2);
cache.put(key3, person3);
}
Aggregations