Skip to content

Commit ad7b9fe

Browse files
committed
added use of include values
1 parent 60db5a7 commit ad7b9fe

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.sharrissf.sample</groupId>
55
<artifactId>ehcache-search-sample</artifactId>
6-
<version>0.0.8-SNAPSHOT</version>
6+
<version>0.0.9-SNAPSHOT</version>
77
<name>Ehcache Search Sample</name>
88
<description>Quick samples with the Ehcache Search Nightly
99
</description>

src/assemble/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
java -Xms200m -Xmx200m -cp ".:./target/ehcache-search-sample-0.0.8-SNAPSHOT.jar:./lib/ehcache-core-2.4.0-SNAPSHOT.jar:./lib/slf4j-api-1.6.1.jar:./lib/slf4j-jdk14-1.6.1.jar" org.sharrissf.sample.EhcacheSearchPlaying
1+
java -Xms200m -Xmx200m -cp ".:./target/ehcache-search-sample-0.0.9-SNAPSHOT.jar:./lib/ehcache-core-2.4.0-SNAPSHOT.jar:./lib/slf4j-api-1.6.1.jar:./lib/slf4j-jdk14-1.6.1.jar" org.sharrissf.sample.EhcacheSearchPlaying

src/main/java/org/sharrissf/sample/EhcacheSearchPlaying.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ private void initializeCache() {
4141
Configuration cacheManagerConfig = new Configuration();
4242

4343
// ***To Cluster With Terracotta***
44-
// add the ehcache-terracotta-ee jar to your class path and uncomment the
44+
// add the ehcache-terracotta-ee jar to your class path and uncomment
45+
// the
4546
// code in the "To Cluster With Terracotta" sections
4647
//
4748
// TerracottaClientConfiguration tcConfig = new
4849
// TerracottaClientConfiguration()
4950
// .url("localhost:9510");
5051
// cacheManagerConfig.addTerracottaConfig(tcConfig);
51-
52+
5253
// ***To Cluster With Terracotta***
5354

5455
cacheManagerConfig.addDefaultCache(new CacheConfiguration());
@@ -76,7 +77,7 @@ private void initializeCache() {
7677
searchable.addSearchAttribute(new SearchAttribute().name("state")
7778
.expression("value.getAddress().getState()"));
7879

79-
// Coding your own extracter
80+
// Coding your own extractor
8081
searchable.addSearchAttribute(new SearchAttribute().name("name")
8182
.className(NameAttributeExtractor.class.getName()));
8283

@@ -105,9 +106,10 @@ public void runTests() throws IOException {
105106
Attribute<Gender> gender = cache.getSearchAttribute("gender");
106107
Attribute<String> name = cache.getSearchAttribute("name");
107108
Attribute<String> state = cache.getSearchAttribute("state");
108-
109+
109110
Query query = cache.createQuery();
110111
query.includeKeys();
112+
query.includeValues();
111113
query.addCriteria(name.ilike("Ari*").and(gender.eq(Gender.MALE)))
112114
.addOrderBy(age, Direction.ASCENDING).maxResults(10);
113115

@@ -120,11 +122,9 @@ public void runTests() throws IOException {
120122
+ " Size: " + results.size());
121123
System.out.println("----Results-----\n");
122124
for (Result result : results.all()) {
123-
System.out
124-
.println("Got: Key[" + result.getKey() + "] Value class ["
125-
+ cache.get(result.getKey()).getValue()
126-
+ "] Value ["
127-
+ cache.get(result.getKey()).getValue() + "]");
125+
System.out.println("Got: Key[" + result.getKey()
126+
+ "] Value class [" + result.getValue().getClass()
127+
+ "] Value [" + result.getValue() + "]");
128128
}
129129

130130
read();
@@ -149,7 +149,8 @@ public void runTests() throws IOException {
149149
Query averageAgeQuery = cache.createQuery();
150150
averageAgeQuery.includeAggregator(Aggregators.average(age));
151151
System.out.println("Average age: "
152-
+ averageAgeQuery.execute().all().iterator().next().getAggregatorResults());
152+
+ averageAgeQuery.execute().all().iterator().next()
153+
.getAggregatorResults());
153154

154155
read();
155156

@@ -160,7 +161,8 @@ public void runTests() throws IOException {
160161
agesBetween.addCriteria(age.between(30, 40));
161162
agesBetween.includeAggregator(Aggregators.average(age));
162163
System.out.println("Average age between 30 and 40: "
163-
+ agesBetween.execute().all().iterator().next().getAggregatorResults());
164+
+ agesBetween.execute().all().iterator().next()
165+
.getAggregatorResults());
164166

165167
read();
166168

@@ -170,7 +172,8 @@ public void runTests() throws IOException {
170172
state.eq("NJ"));
171173
newJerseyCountQuery.includeAggregator(Aggregators.count());
172174
System.out.println("Count of people from NJ: "
173-
+ newJerseyCountQuery.execute().all().iterator().next().getAggregatorResults());
175+
+ newJerseyCountQuery.execute().all().iterator().next()
176+
.getAggregatorResults());
174177
}
175178

176179
private void loadCache() {

0 commit comments

Comments
 (0)