forked from apache/calcite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CALCITE-6728] Introduce new methods to lookup tables and schemas ins…
…ide schemas
- Loading branch information
Showing
1 changed file
with
12 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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 GitHub Actions / CheckerFramework (JDK 11)
Check failure on line 45 in core/src/main/java/org/apache/calcite/schema/lookup/LoadingCacheLookup.java GitHub Actions / CheckerFramework (JDK 11, oldest Guava)
|
||
@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(); | ||
} | ||
}); | ||
} | ||
|