Skip to content

Commit

Permalink
Merge pull request #1111 from aol/memoizeFix
Browse files Browse the repository at this point in the history
fix: Memoize issue fix
  • Loading branch information
johnmcclean authored May 13, 2022
2 parents 4c185f3 + 5a5cd89 commit c987af4
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 25 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ subprojects {

}
}
/**

allprojects {
tasks.withType(JavaCompile) {
options.fork = true
Expand All @@ -142,4 +142,4 @@ allprojects {

}

**/

2 changes: 1 addition & 1 deletion cyclops-anym/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {
api project(':cyclops-futurestream')
api project(':cyclops-reactive-collections')
api project(':cyclops-pure')
compileOnly 'org.projectlombok:lombok:1.16.20'

testImplementation project(':cyclops').sourceSets.test.output
testImplementation 'io.projectreactor:reactor-core:3.0.7.RELEASE'
testImplementation group: 'junit', name: 'junit', version: '4.12'
Expand Down
2 changes: 1 addition & 1 deletion cyclops-futurestream/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies {
api project(':cyclops')
api project(':cyclops-reactive-collections')

compileOnly 'org.projectlombok:lombok:1.16.20'

testImplementation project(':cyclops').sourceSets.test.output
testImplementation 'org.reactivestreams:reactive-streams-tck:1.0.0'
testImplementation 'org.mockito:mockito-core:1.9.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import java.util.stream.Collectors;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.experimental.Builder;
import lombok.experimental.Wither;


/**
* This class allows a Batch of completable futures to be processed before collecting their results, to increase
* parallelism.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.experimental.Builder;
import lombok.Builder;
import lombok.experimental.Wither;

@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import com.oath.cyclops.internal.react.async.future.FastFuture;

import lombok.AllArgsConstructor;
import lombok.experimental.Builder;
import lombok.Builder;
import lombok.experimental.Wither;


/**
*
* Class that allows client code to only collect a sample of results from an Infinite SimpleReact Stream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.experimental.Builder;
import lombok.Builder;
import lombok.experimental.Wither;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,49 @@ public JsonDeserializer<?> findCollectionDeserializer(CollectionType type, Deser
public JsonDeserializer<?> findReferenceDeserializer(ReferenceType type,
DeserializationConfig config, BeanDescription bean,
TypeDeserializer typeDeserializer, JsonDeserializer<?> jsonDeserializer) throws JsonMappingException {
Class<?> raw = type.getRawClass();

return super.findReferenceDeserializer(type, config, bean, typeDeserializer, jsonDeserializer);
if (raw == Maybe.class) {
return new MaybeDeserializer(type);
}
if (raw == Option.class) {
return new OptionDeserializer(type);
}
if (raw == Eval.class) {
return new EvalDeserializer(type);
}
if (raw == Future.class) {
return new EvalDeserializer(type);
}
if (raw == Ior.class) {
return new IorDeserializer(type);
}
if (raw == LazyEither.class) {
return new LazyEitherDeserializer(type);
}
if (raw == LazyEither3.class) {
return new LazyEither3Deserializer(type);
}
if (raw == LazyEither4.class) {
return new LazyEither4Deserializer(type);
}

if (raw == Either.class) {
return new EitherDeserializer(type);
}
if (raw == Trampoline.class) {
return new TrampolineDeserializer(type);
}
if (raw == Unrestricted.class) {
return new TrampolineDeserializer(type);
}
if(tuples.contains(raw)) {
return new TupleDeserializer(raw);
}
if (PersistentMap.class.isAssignableFrom(type.getRawClass())) {
return new PersistentMapDeserializer(raw);
}
return super.findReferenceDeserializer(type, config, bean, typeDeserializer, jsonDeserializer);
}

}
1 change: 0 additions & 1 deletion cyclops-pure/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ dependencies {
api project(':cyclops')
api project(':cyclops-reactive-collections')

compileOnly 'org.projectlombok:lombok:1.16.20'
testImplementation project(':cyclops').sourceSets.test.output
testImplementation 'org.reactivestreams:reactive-streams-tck:1.0.0'
testImplementation 'org.mockito:mockito-core:1.9.5'
Expand Down
2 changes: 1 addition & 1 deletion cyclops-reactive-collections/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ configurations {
dependencies {
api project(':cyclops')
testImplementation project(':cyclops').sourceSets.test.output
compileOnly 'org.projectlombok:lombok:1.16.12'

testImplementation project(':cyclops').sourceSets.test.output
testImplementation 'org.reactivestreams:reactive-streams-tck:1.0.0'
testImplementation group: 'io.projectreactor', name: 'reactor-test', version: '3.2.2.RELEASE'
Expand Down
8 changes: 0 additions & 8 deletions cyclops/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ def custom = { "$rootDir/gradle/${it}.gradle" } //find custom plugins locally
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
//apply plugin: 'com.bmuschko.nexus'
apply plugin: 'jacoco'
apply from: custom('jacoco-version')
apply from: custom('jacoco-config')
Expand Down Expand Up @@ -102,12 +101,5 @@ task packageTests(type: Jar) {
artifacts.archives packageTests


/**

nexus {
sign = true
repositoryUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
snapshotRepositoryUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
}
**/

11 changes: 8 additions & 3 deletions cyclops/src/main/java/cyclops/function/Memoize.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,14 @@ public static <T> Function0<T> memoizeSupplier(final Supplier<T> s, final Cachea
* @param <R> Return type of Function
* @return Memoized asynchronously updating function
*/
public static <R> Function0<R> memoizeSupplierAsync(final Supplier<R> fn, ScheduledExecutorService ex, long updateRateInMillis){
return ()-> Memoize.memoizeFunctionAsync(a-> fn.get(),ex,updateRateInMillis)
.apply("k");
public static <R> Function0<R> memoizeSupplierAsync(Supplier<R> fn, ScheduledExecutorService ex, long updateRateInMillis) {
val memoizeFn = memoizeFunctionAsync((a) -> {
return fn.get();
}, ex, updateRateInMillis);

return () -> {
return memoizeFn.apply("k");
};
}
/**
* Memoize a Supplier and update the cached values asynchronously using the provided Scheduled Executor Service
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version = 10.4.0
version = 10.4.1
agronaVersion=1.1.11
reactiveStreamsVersion=1.0.3
reactorVersion=3.3.1.RELEASE
rxJava2Version=2.2.16
kindedJVersion=1.1.0
hamcrestVersion=1.3
lombokVersion=1.16.20
jacksonVersion=2.10.1
lombokVersion=1.18.4
jacksonVersion=2.13.2


POM_NAME=cyclops
Expand Down

0 comments on commit c987af4

Please sign in to comment.