Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Duda committed Jul 17, 2020
2 parents 8b7a538 + 83dfc7e commit 8788710
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Applications currently using chili-core

|application|description|
|---|---|
|[flashcards](https://flashcardsalligator.com/)|Progressive web app for studying with flashcards.|
|[flashcards](https://github.com/codingchili/flashcards-webapp)|Progressive web app for studying with flashcards.|
|[ethereum-ingest](https://github.com/codingchili/ethereum-ingest)|Ethereum block/transaction import utility.|
|[zapperfly-asm](https://github.com/codingchili/zapperfly-asm)|Extra simple clustered build servers.|
|[chili-game-ext](https://github.com/codingchili/chili-game-ext)|2D MMORPG game in development.|
Expand Down
6 changes: 3 additions & 3 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ dependencies {
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.9'

compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:7.3.0'
compile 'com.googlecode.cqengine:cqengine:3.4.0'
compile 'com.googlecode.cqengine:cqengine:3.5.0'

/* keep these in sync with cqengine, used internally. */
compile 'com.esotericsoftware:reflectasm:1.11.7'
compile 'com.esotericsoftware:kryo:5.0.0-RC5'
compile 'com.esotericsoftware:reflectasm:1.11.9'
compile 'com.esotericsoftware:kryo:5.0.0-RC6'

testCompile 'io.vertx:vertx-unit:3.8.0'
testCompile 'junit:junit:4.12'
Expand Down
18 changes: 6 additions & 12 deletions core/main/java/com/codingchili/core/storage/IndexedMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.googlecode.cqengine.IndexedCollection;
import com.googlecode.cqengine.attribute.*;
import com.googlecode.cqengine.attribute.support.SimpleFunction;
import com.googlecode.cqengine.query.option.QueryOptions;
import com.googlecode.cqengine.resultset.ResultSet;
import io.vertx.core.AsyncResult;
Expand Down Expand Up @@ -61,24 +62,25 @@ public IndexedCollection<Value> getDatabase() {
return db;
}

@SuppressWarnings("unchecked")
public Attribute<Value, String> getAttribute(String fieldName, boolean multiValue) {
if (holder.attributes.containsKey(fieldName)) {
return holder.attributes.get(fieldName);
} else {
Attribute<Value, String> attribute;

if (multiValue) {
attribute = new MultiValueAttribute<>((Class<Value>) Generic.class, String.class, fieldName) {
attribute = new MultiValueAttribute<>(context.valueClass(), String.class, fieldName) {
@Override
public Iterable<String> getValues(Value indexing, QueryOptions queryOptions) {
return Serializer.getValueByPath(indexing, fieldName).stream()
.map(item -> (item + ""))::iterator;
}
};
} else {
attribute = attribute(fieldName, (indexing) ->
(Serializer.getValueByPath(indexing, fieldName).iterator().next() + ""));
attribute = attribute(context.valueClass(), String.class, fieldName,
(SimpleFunction<Value, String>) (indexing) ->
Serializer.getValueByPath(indexing, fieldName).iterator().next() + ""
);
}
holder.attributes.put(fieldName, attribute);
return attribute;
Expand Down Expand Up @@ -119,14 +121,6 @@ public void setMapper(Function<Value, Value> mapper) {
this.mapper = mapper;
}

/**
* when creating an index on a multivalued attribute a reflective operation is invoked.
* This reflective invocation fails since Value is of generic type. To circumvent this,
* a class that implements Storable, which is the common interface with Value is used.
*/
private abstract class Generic implements Storable {
}

@Override
public void get(String key, Handler<AsyncResult<Value>> handler) {
context.blocking(blocking -> {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 8788710

Please sign in to comment.