Skip to content

Commit

Permalink
[CALCITE-6728] Introduce new methods to lookup tables and schemas ins…
Browse files Browse the repository at this point in the history
…ide schemas
  • Loading branch information
kramerul committed Dec 19, 2024
1 parent 21e9dec commit ace53df
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.UncheckedExecutionException;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
Expand All @@ -44,18 +42,24 @@ public LoadingCacheLookup(Lookup<T> delegate) {
this.delegate = delegate;
this.cache = CacheBuilder.newBuilder()
.expireAfterWrite(1, TimeUnit.MINUTES)
.build(new CacheLoader<String, @NonNull T>() {
@Override public @NonNull T load(String name) throws Exception {
return Optional.ofNullable(delegate.get(name))
.orElseThrow(() -> new EntryNotFoundException());
.build(new CacheLoader<String, T>() {

Check failure on line 45 in core/src/main/java/org/apache/calcite/schema/lookup/LoadingCacheLookup.java

View workflow job for this annotation

GitHub Actions / CheckerFramework (JDK 11)

[Task :core:compileJava] [type.argument.type.incompatible] incompatible type argument for type parameter V1 extends @initialized @nonnull Object of build. .build(new CacheLoader<String, T>() { ^ found : T extends @initialized @nullable Object

Check failure on line 45 in core/src/main/java/org/apache/calcite/schema/lookup/LoadingCacheLookup.java

View workflow job for this annotation

GitHub Actions / CheckerFramework (JDK 11, oldest Guava)

[Task :core:compileJava] [type.argument.type.incompatible] incompatible type argument for type parameter V1 extends @initialized @nonnull Object of build. .build(new CacheLoader<String, T>() { ^ found : T extends @initialized @nullable Object
@Override public T load(String name) throws Exception {
T result = delegate.get(name);
if (result != null) {
return result;
}
throw new EntryNotFoundException();
}
});
this.cacheIgnoreCase = CacheBuilder.newBuilder()
.expireAfterWrite(1, TimeUnit.MINUTES)
.build(new CacheLoader<String, Named<T>>() {
@Override public Named<T> load(String name) throws Exception {
return Optional.ofNullable(delegate.getIgnoreCase(name))
.orElseThrow(() -> new EntryNotFoundException());
Named<T> result = delegate.getIgnoreCase(name);
if (result != null) {
return result;
}
throw new EntryNotFoundException();
}
});
}
Expand Down

0 comments on commit ace53df

Please sign in to comment.