Skip to content

Commit 280f3b7

Browse files
Change cache types to allow different in and output data
1 parent 7b34f78 commit 280f3b7

3 files changed

Lines changed: 20 additions & 26 deletions

File tree

packages/actor-rdf-join-inner-multi-bind/lib/ActorRdfJoinMultiBind.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ export class ActorRdfJoinMultiBind extends ActorRdfJoin<IActorRdfJoinMultiBindTe
240240
// We must use Math.max, because the last metadata is not necessarily the biggest, but it's the least preferred.
241241
// If join entries are produced locally, we increase the possibility of doing this bind join, as it's cheap.
242242
const isRemoteAccess = requestItemTimes.some(time => time > 0);
243-
// console.log(isRemoteAccess);
244243
if (metadatas[0].cardinality.value * this.minMaxCardinalityRatio / (isRemoteAccess ? 1 : 3) >
245244
Math.max(...metadatas.map(metadata => metadata.cardinality.value))) {
246245
return failTest(`Actor ${this.name} can only run if the smallest stream is much smaller than largest stream`);

packages/cache-manager-entries/lib/CacheKeys.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,4 @@ ISourceState,
1717
cacheSourceStateQuerySource: new CacheKey<ISourceState, ISourceState, { headers: Headers } >(
1818
'@comunica/persistent-cache-manager:sourceStateQuerySource',
1919
),
20-
/**
21-
* Cache stores indexed source states with subject and object based bloomfilters
22-
* and acts as a query source. Getting from cache
23-
* emits the bindings to any queryBinding calls associated with that get
24-
*/
25-
cacheSourceStateQuerySourceBloomFilter: new CacheKey<
26-
ISourceStateBloomFilter,
27-
ISourceStateBloomFilter,
28-
{ headers: Headers }
29-
>(
30-
'@comunica/persistent-cache-manager:sourceStateQuerySourceBloomFilter',
31-
)
32-
3320
};

packages/types/lib/IPersistentCacheManager.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import type { AsyncIterator } from 'asynciterator';
22

3-
export interface IPersistentCache<T> {
4-
get: (key: string) => Promise<T | undefined>;
5-
getMany: (keys: string[]) => Promise<(T | undefined)[]>;
6-
set: (key: string, value: T) => Promise<void>;
3+
/**
4+
* Interface for a cache entry, allows the cache to output (O) different data
5+
* from what it being put into the cache (I).
6+
*/
7+
export interface IPersistentCache<S, O> {
8+
get: (key: string) => Promise<O | undefined>;
9+
getMany: (keys: string[]) => Promise<(O | undefined)[]>;
10+
set: (key: string, value: S) => Promise<void>;
711
has: (key: string) => Promise<boolean>;
812
delete: (key: string) => Promise<boolean>;
9-
entries: () => AsyncIterator<[string, T]>;
13+
entries: () => AsyncIterator<[string, O]>;
1014
size: () => Promise<number>;
1115
serialize: () => Promise<void>;
1216
/**
@@ -48,36 +52,40 @@ export interface ICacheMetrics {
4852
* tracking period
4953
*/
5054
evictionPercentage: number;
55+
/**
56+
* Additional metrics not covered by the base class
57+
*/
58+
additionalMetrics?: Record<string, any>;
5159
}
5260
/**
5361
* Interface of class that sets a value in a given cache for a given key. This can
5462
* be a simple URL -> ISourceState mapping or URL -> Source Data Summary. The
5563
* computation and logic of what to store is done in the setInCache function.
56-
* T = The type of data being stored (e.g., ISourceState)
64+
* I = The type of data being stored (e.g., ISourceState)
5765
* C = The context needed to derive additional storage logic
5866
*/
5967
export interface ISetFn<I, S, C> {
6068
setInCache: (
6169
key: string,
6270
value: I,
63-
cache: IPersistentCache<S>,
71+
cache: IPersistentCache<S, any>,
6472
context: C
6573
) => Promise<void>;
6674
}
6775

68-
export interface ICacheRegistryEntry<I, S, C> {
69-
cache: IPersistentCache<S>;
76+
export interface ICacheRegistryEntry<I, S, O, C> {
77+
cache: IPersistentCache<S, O>;
7078
setFn: ISetFn<I, S, C>;
7179
}
7280

7381
/**
7482
* Interface for a class that returns a view over the cache. This can be
7583
* just retrieving a key, a summary of the content of the cache, or
7684
* the content of a cache matching a certain operator (e.g. triple pattern).
77-
* T the output type of the constructed view
85+
* I the output type of the constructed view
7886
* C the context needed to construct the view
7987
*/
80-
export interface ICacheView<S, C, K> {
81-
construct: (cache: IPersistentCache<S>, context: C) => Promise<K | undefined>;
88+
export interface ICacheView<S, O, C, K> {
89+
construct: (cache: IPersistentCache<S, O>, context: C) => Promise<K | undefined>;
8290
}
8391

0 commit comments

Comments
 (0)