@milaboratories/pf-driver 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +1 -0
  2. package/dist/__external/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.52.4_tslib@2.7.0_typescript@5.6.3/__external/tslib/tslib.es6.cjs +77 -0
  3. package/dist/__external/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.52.4_tslib@2.7.0_typescript@5.6.3/__external/tslib/tslib.es6.cjs.map +1 -0
  4. package/dist/__external/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.52.4_tslib@2.7.0_typescript@5.6.3/__external/tslib/tslib.es6.js +74 -0
  5. package/dist/__external/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.52.4_tslib@2.7.0_typescript@5.6.3/__external/tslib/tslib.es6.js.map +1 -0
  6. package/dist/data_info_helpers.cjs +21 -0
  7. package/dist/data_info_helpers.cjs.map +1 -0
  8. package/dist/data_info_helpers.d.ts +3 -0
  9. package/dist/data_info_helpers.d.ts.map +1 -0
  10. package/dist/data_info_helpers.js +19 -0
  11. package/dist/data_info_helpers.js.map +1 -0
  12. package/dist/driver_decl.d.ts +38 -0
  13. package/dist/driver_decl.d.ts.map +1 -0
  14. package/dist/driver_double.cjs +98 -0
  15. package/dist/driver_double.cjs.map +1 -0
  16. package/dist/driver_double.d.ts +12 -0
  17. package/dist/driver_double.d.ts.map +1 -0
  18. package/dist/driver_double.js +95 -0
  19. package/dist/driver_double.js.map +1 -0
  20. package/dist/driver_impl.cjs +378 -0
  21. package/dist/driver_impl.cjs.map +1 -0
  22. package/dist/driver_impl.d.ts +54 -0
  23. package/dist/driver_impl.d.ts.map +1 -0
  24. package/dist/driver_impl.js +375 -0
  25. package/dist/driver_impl.js.map +1 -0
  26. package/dist/index.cjs +14 -0
  27. package/dist/index.cjs.map +1 -0
  28. package/dist/index.d.ts +5 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +4 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/logging.cjs +9 -0
  33. package/dist/logging.cjs.map +1 -0
  34. package/dist/logging.d.ts +2 -0
  35. package/dist/logging.d.ts.map +1 -0
  36. package/dist/logging.js +7 -0
  37. package/dist/logging.js.map +1 -0
  38. package/dist/pframe_pool.cjs +196 -0
  39. package/dist/pframe_pool.cjs.map +1 -0
  40. package/dist/pframe_pool.d.ts +35 -0
  41. package/dist/pframe_pool.d.ts.map +1 -0
  42. package/dist/pframe_pool.js +193 -0
  43. package/dist/pframe_pool.js.map +1 -0
  44. package/dist/ptable_cache_per_frame.cjs +69 -0
  45. package/dist/ptable_cache_per_frame.cjs.map +1 -0
  46. package/dist/ptable_cache_per_frame.d.ts +25 -0
  47. package/dist/ptable_cache_per_frame.d.ts.map +1 -0
  48. package/dist/ptable_cache_per_frame.js +66 -0
  49. package/dist/ptable_cache_per_frame.js.map +1 -0
  50. package/dist/ptable_cache_plain.cjs +54 -0
  51. package/dist/ptable_cache_plain.cjs.map +1 -0
  52. package/dist/ptable_cache_plain.d.ts +21 -0
  53. package/dist/ptable_cache_plain.d.ts.map +1 -0
  54. package/dist/ptable_cache_plain.js +51 -0
  55. package/dist/ptable_cache_plain.js.map +1 -0
  56. package/dist/ptable_def_pool.cjs +53 -0
  57. package/dist/ptable_def_pool.cjs.map +1 -0
  58. package/dist/ptable_def_pool.d.ts +21 -0
  59. package/dist/ptable_def_pool.d.ts.map +1 -0
  60. package/dist/ptable_def_pool.js +50 -0
  61. package/dist/ptable_def_pool.js.map +1 -0
  62. package/dist/ptable_pool.cjs +167 -0
  63. package/dist/ptable_pool.cjs.map +1 -0
  64. package/dist/ptable_pool.d.ts +26 -0
  65. package/dist/ptable_pool.d.ts.map +1 -0
  66. package/dist/ptable_pool.js +164 -0
  67. package/dist/ptable_pool.js.map +1 -0
  68. package/dist/ptable_shared.cjs +10 -0
  69. package/dist/ptable_shared.cjs.map +1 -0
  70. package/dist/ptable_shared.d.ts +7 -0
  71. package/dist/ptable_shared.d.ts.map +1 -0
  72. package/dist/ptable_shared.js +8 -0
  73. package/dist/ptable_shared.js.map +1 -0
  74. package/package.json +54 -0
  75. package/src/data_info_helpers.ts +26 -0
  76. package/src/driver_decl.ts +82 -0
  77. package/src/driver_double.test.ts +135 -0
  78. package/src/driver_double.ts +134 -0
  79. package/src/driver_impl.ts +535 -0
  80. package/src/index.ts +4 -0
  81. package/src/logging.ts +5 -0
  82. package/src/pframe_pool.ts +257 -0
  83. package/src/ptable_cache_per_frame.ts +86 -0
  84. package/src/ptable_cache_plain.ts +67 -0
  85. package/src/ptable_def_pool.ts +50 -0
  86. package/src/ptable_pool.ts +187 -0
  87. package/src/ptable_shared.ts +11 -0
@@ -0,0 +1,66 @@
1
+ import { LRUCache } from 'lru-cache';
2
+ import { logPFrames } from './logging.js';
3
+
4
+ const PTableCachePerFrameOpsDefaults = {
5
+ pFrameCacheMaxCount: 18, // SHM trees create 3 PTables per graphic, we want to cache 6 graphics per PFrame
6
+ pFramesCacheMaxSize: 8 * 1024 * 1024 * 1024, // 8 GB, same as blob driver cache (must be at least 2GB)
7
+ };
8
+ class PTableCachePerFrame {
9
+ logger;
10
+ ops;
11
+ perFrame = new Map();
12
+ global;
13
+ disposeListeners = new Set();
14
+ constructor(logger, ops) {
15
+ this.logger = logger;
16
+ this.ops = ops;
17
+ this.global = new LRUCache({
18
+ maxSize: this.ops.pFramesCacheMaxSize,
19
+ dispose: (resource, key, reason) => {
20
+ if (reason === 'evict') {
21
+ this.perFrame.get(resource.resource.pFrame)?.delete(key);
22
+ }
23
+ if (this.perFrame.get(resource.resource.pFrame)?.size === 0) {
24
+ this.perFrame.delete(resource.resource.pFrame);
25
+ }
26
+ resource.unref();
27
+ if (logPFrames()) {
28
+ logger('info', `calculateTableData cache - removed PTable ${key} (reason: ${reason})`);
29
+ }
30
+ },
31
+ });
32
+ }
33
+ cache(resource, size) {
34
+ const key = resource.key;
35
+ if (logPFrames()) {
36
+ this.logger('info', `calculateTableData cache - added PTable ${key} with size ${size}`);
37
+ }
38
+ this.global.set(key, resource, { size: Math.max(size, 1) }); // 1 is minimum size to avoid cache evictions
39
+ let perFrame = this.perFrame.get(resource.resource.pFrame);
40
+ if (!perFrame) {
41
+ perFrame = new LRUCache({
42
+ max: this.ops.pFrameCacheMaxCount,
43
+ dispose: (_resource, key, reason) => {
44
+ if (reason === 'evict') {
45
+ this.global.delete(key);
46
+ }
47
+ },
48
+ });
49
+ this.perFrame.set(resource.resource.pFrame, perFrame);
50
+ }
51
+ perFrame.set(key, resource);
52
+ if (!this.disposeListeners.has(key)) {
53
+ const disposeListener = () => {
54
+ this.perFrame.get(resource.resource.pFrame)?.delete(key);
55
+ this.global.delete(key);
56
+ this.disposeListeners.delete(key);
57
+ resource.resource.disposeSignal.removeEventListener('abort', disposeListener);
58
+ };
59
+ this.disposeListeners.add(key);
60
+ resource.resource.disposeSignal.addEventListener('abort', disposeListener);
61
+ }
62
+ }
63
+ }
64
+
65
+ export { PTableCachePerFrame, PTableCachePerFrameOpsDefaults };
66
+ //# sourceMappingURL=ptable_cache_per_frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ptable_cache_per_frame.js","sources":["../src/ptable_cache_per_frame.ts"],"sourcesContent":["import type { PFrameHandle, PTableHandle } from '@platforma-sdk/model';\nimport type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';\nimport type { PoolEntry } from '@milaboratories/ts-helpers';\nimport { LRUCache } from 'lru-cache';\nimport { logPFrames } from './logging';\nimport type { PTableHolder } from './ptable_pool';\n\nexport type PTableCachePerFrameOps = {\n /** Maximum number of `calculateTableData` results cached for each PFrame */\n pFrameCacheMaxCount: number;\n /**\n * Maximum size of `calculateTableData` results cached for PFrames overall.\n * The limit is soft, as the same table could be materialized with other requests and will not be deleted in such case.\n * Also each table has predeccessors, overlapping predecessors will be counted twice, so the effective limit is smaller.\n */\n pFramesCacheMaxSize: number;\n};\n\nexport const PTableCachePerFrameOpsDefaults: PTableCachePerFrameOps = {\n pFrameCacheMaxCount: 18, // SHM trees create 3 PTables per graphic, we want to cache 6 graphics per PFrame\n pFramesCacheMaxSize: 8 * 1024 * 1024 * 1024, // 8 GB, same as blob driver cache (must be at least 2GB)\n};\n\nexport class PTableCachePerFrame {\n private readonly perFrame = new Map<PFrameHandle, LRUCache<PTableHandle, PoolEntry<PTableHandle, PTableHolder>>>();\n private readonly global: LRUCache<PTableHandle, PoolEntry<PTableHandle, PTableHolder>>;\n private readonly disposeListeners = new Set<PTableHandle>();\n\n constructor(\n private readonly logger: PFrameInternal.Logger,\n private readonly ops: PTableCachePerFrameOps,\n ) {\n this.global = new LRUCache<PTableHandle, PoolEntry<PTableHandle, PTableHolder>>({\n maxSize: this.ops.pFramesCacheMaxSize,\n dispose: (resource, key, reason) => {\n if (reason === 'evict') {\n this.perFrame.get(resource.resource.pFrame)?.delete(key);\n }\n\n if (this.perFrame.get(resource.resource.pFrame)?.size === 0) {\n this.perFrame.delete(resource.resource.pFrame);\n }\n\n resource.unref();\n if (logPFrames()) {\n logger('info', `calculateTableData cache - removed PTable ${key} (reason: ${reason})`);\n }\n },\n });\n }\n\n public cache(resource: PoolEntry<PTableHandle, PTableHolder>, size: number): void {\n const key = resource.key;\n if (logPFrames()) {\n this.logger('info', `calculateTableData cache - added PTable ${key} with size ${size}`);\n }\n\n this.global.set(key, resource, { size: Math.max(size, 1) }); // 1 is minimum size to avoid cache evictions\n\n let perFrame = this.perFrame.get(resource.resource.pFrame);\n if (!perFrame) {\n perFrame = new LRUCache<PTableHandle, PoolEntry<PTableHandle, PTableHolder>>({\n max: this.ops.pFrameCacheMaxCount,\n dispose: (_resource, key, reason) => {\n if (reason === 'evict') {\n this.global.delete(key);\n }\n },\n });\n this.perFrame.set(resource.resource.pFrame, perFrame);\n }\n perFrame.set(key, resource);\n\n if (!this.disposeListeners.has(key)) {\n const disposeListener = () => {\n this.perFrame.get(resource.resource.pFrame)?.delete(key);\n this.global.delete(key);\n\n this.disposeListeners.delete(key);\n resource.resource.disposeSignal.removeEventListener('abort', disposeListener);\n };\n this.disposeListeners.add(key);\n resource.resource.disposeSignal.addEventListener('abort', disposeListener);\n }\n }\n}\n"],"names":[],"mappings":";;;AAkBO,MAAM,8BAA8B,GAA2B;IACpE,mBAAmB,EAAE,EAAE;IACvB,mBAAmB,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;;MAGhC,mBAAmB,CAAA;AAMX,IAAA,MAAA;AACA,IAAA,GAAA;AANF,IAAA,QAAQ,GAAG,IAAI,GAAG,EAA+E;AACjG,IAAA,MAAM;AACN,IAAA,gBAAgB,GAAG,IAAI,GAAG,EAAgB;IAE3D,WAAA,CACmB,MAA6B,EAC7B,GAA2B,EAAA;QAD3B,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,GAAG,GAAH,GAAG;AAEpB,QAAA,IAAI,CAAC,MAAM,GAAG,IAAI,QAAQ,CAAsD;AAC9E,YAAA,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,mBAAmB;YACrC,OAAO,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,KAAI;AACjC,gBAAA,IAAI,MAAM,KAAK,OAAO,EAAE;AACtB,oBAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC;gBAC1D;AAEA,gBAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE;oBAC3D,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAChD;gBAEA,QAAQ,CAAC,KAAK,EAAE;gBAChB,IAAI,UAAU,EAAE,EAAE;oBAChB,MAAM,CAAC,MAAM,EAAE,CAAA,0CAAA,EAA6C,G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CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC;AACxD,gBAAA,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;AAEvB,gBAAA,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC;gBACjC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,mBAAmB,CAAC,OAAO,EAAE,eAAe,CAAC;AAC/E,YAAA,CAAC;AACD,YAAA,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC;YAC9B,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,gBAAgB,CAAC,OAAO,EAAE,eAAe,CAAC;QAC5E;IACF;AACD;;;;"}
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ var lruCache = require('lru-cache');
4
+ var logging = require('./logging.cjs');
5
+
6
+ const PTableCachePlainOpsDefaults = {
7
+ pTablesCacheMaxSize: 32 * 1024 * 1024 * 1024, // 32 GB (must be at least 8GB)
8
+ };
9
+ class PTableCachePlain {
10
+ logger;
11
+ global;
12
+ disposeListeners = new Set();
13
+ constructor(logger, ops) {
14
+ this.logger = logger;
15
+ this.global = new lruCache.LRUCache({
16
+ maxSize: ops.pTablesCacheMaxSize,
17
+ dispose: (resource, key, reason) => {
18
+ resource.unref();
19
+ if (logging.logPFrames()) {
20
+ logger('info', `createPTable cache - removed PTable ${key} (reason: ${reason})`);
21
+ }
22
+ },
23
+ });
24
+ }
25
+ cache(resource, size, defDisposeSignal) {
26
+ const key = resource.key;
27
+ if (logging.logPFrames()) {
28
+ this.logger('info', `createPTable cache - added PTable ${key} with size ${size}`);
29
+ }
30
+ const status = {};
31
+ this.global.set(key, resource, { size: Math.max(size, 1), status }); // 1 is minimum size to avoid cache evictions
32
+ if (status.maxEntrySizeExceeded) {
33
+ resource.unref();
34
+ if (logging.logPFrames()) {
35
+ this.logger('info', `createPTable cache - removed PTable ${key} (maxEntrySizeExceeded)`);
36
+ }
37
+ }
38
+ else {
39
+ if (!this.disposeListeners.has(key)) {
40
+ const disposeListener = () => {
41
+ this.global.delete(key);
42
+ this.disposeListeners.delete(key);
43
+ defDisposeSignal.removeEventListener('abort', disposeListener);
44
+ };
45
+ this.disposeListeners.add(key);
46
+ defDisposeSignal.addEventListener('abort', disposeListener);
47
+ }
48
+ }
49
+ }
50
+ }
51
+
52
+ exports.PTableCachePlain = PTableCachePlain;
53
+ exports.PTableCachePlainOpsDefaults = PTableCachePlainOpsDefaults;
54
+ //# sourceMappingURL=ptable_cache_plain.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ptable_cache_plain.cjs","sources":["../src/ptable_cache_plain.ts"],"sourcesContent":["import type { PTableHandle } from '@platforma-sdk/model';\nimport type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';\nimport type { PoolEntry } from '@milaboratories/ts-helpers';\nimport { LRUCache } from 'lru-cache';\nimport { logPFrames } from './logging';\nimport type { PTableHolder } from './ptable_pool';\n\nexport type PTableCachePlainOps = {\n /**\n * Maximum size of `createPTable` results cached on disk.\n * The limit is soft, as the same table could be materialized with other requests and will not be deleted in such case.\n * Also each table has predeccessors, overlapping predecessors will be counted twice, so the effective limit is smaller.\n */\n pTablesCacheMaxSize: number;\n};\n\nexport const PTableCachePlainOpsDefaults: PTableCachePlainOps = {\n pTablesCacheMaxSize: 32 * 1024 * 1024 * 1024, // 32 GB (must be at least 8GB)\n};\n\nexport class PTableCachePlain {\n private readonly global: LRUCache<PTableHandle, PoolEntry<PTableHandle, PTableHolder>>;\n private readonly disposeListeners = new Set<PTableHandle>();\n\n constructor(\n private readonly logger: PFrameInternal.Logger,\n ops: PTableCachePlainOps,\n ) {\n this.global = new LRUCache<PTableHandle, PoolEntry<PTableHandle, PTableHolder>>({\n maxSize: ops.pTablesCacheMaxSize,\n dispose: (resource, key, reason) => {\n resource.unref();\n if (logPFrames()) {\n logger('info', `createPTable cache - removed PTable ${key} (reason: ${reason})`);\n }\n },\n });\n }\n\n public cache(resource: PoolEntry<PTableHandle, PTableHolder>, size: number, defDisposeSignal: AbortSignal): void {\n const key = resource.key;\n if (logPFrames()) {\n this.logger('info', `createPTable cache - added PTable ${key} with size ${size}`);\n }\n\n const status: LRUCache.Status<PoolEntry<PTableHandle, PTableHolder>> = {};\n this.global.set(key, resource, { size: Math.max(size, 1), status }); // 1 is minimum size to avoid cache evictions\n\n if (status.maxEntrySizeExceeded) {\n resource.unref();\n if (logPFrames()) {\n this.logger('info', `createPTable cache - removed PTable ${key} (maxEntrySizeExceeded)`);\n }\n } else {\n if (!this.disposeListeners.has(key)) {\n const disposeListener = () => {\n this.global.delete(key);\n\n this.disposeListeners.delete(key);\n defDisposeSignal.removeEventListener('abort', disposeListener);\n };\n this.disposeListeners.add(key);\n defDisposeSignal.addEventListener('abort', disposeListener);\n }\n }\n }\n}\n"],"names":["LRUCache","logPFrames"],"mappings":";;;;;AAgBO,MAAM,2BAA2B,GAAwB;IAC9D,mBAAmB,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;;MAGjC,gBAAgB,CAAA;AAKR,IAAA,MAAA;AAJF,IAAA,MAAM;AACN,IAAA,gBAAgB,GAAG,IAAI,GAAG,EAAgB;IAE3D,WAAA,CACmB,MAA6B,EAC9C,GAAwB,EAAA;QADP,IAAA,CAAA,MAAM,GAAN,MAAM;AAGvB,QAAA,IAAI,CAAC,MAAM,GAAG,IAAIA,iBAAQ,CAAsD;YAC9E,OAAO,EAAE,GAAG,CAAC,mBAAmB;YAChC,OAAO,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,KAAI;gBACjC,QAAQ,CAAC,KAAK,EAAE;gBAChB,IAAIC,kBAAU,EAAE,EAAE;oBAChB,MAAM,CAAC,MAAM,EAAE,CAAA,oCAAA,EAAuC,GAAG,CAAA,UAAA,EAAa,MAAM,CAAA,CAAA,CAAG,CAAC;gBAClF;YACF,CAAC;AACF,SAAA,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{ PFrameInternal } from '@milaboratories/pl-model-middle-layer';
3
+ import type { PoolEntry } from '@milaboratories/ts-helpers';
4
+ import type { PTableHolder } from './ptable_pool';
5
+ export type PTableCachePlainOps = {
6
+ /**
7
+ * Maximum size of `createPTable` results cached on disk.
8
+ * The limit is soft, as the same table could be materialized with other requests and will not be deleted in such case.
9
+ * Also each table has predeccessors, overlapping predecessors will be counted twice, so the effective limit is smaller.
10
+ */
11
+ pTablesCacheMaxSize: number;
12
+ };
13
+ export declare const PTableCachePlainOpsDefaults: PTableCachePlainOps;
14
+ export declare class PTableCachePlain {
15
+ private readonly logger;
16
+ private readonly global;
17
+ private readonly disposeListeners;
18
+ constructor(logger: PFrameInternal.Logger, ops: PTableCachePlainOps);
19
+ cache(resource: PoolEntry<PTableHandle, PTableHolder>, size: number, defDisposeSignal: AbortSignal): void;
20
+ }
21
+ //# sourceMappingURL=ptable_cache_plain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ptable_cache_plain.d.ts","sourceRoot":"","sources":["../src/ptable_cache_plain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,mBAEzC,CAAC;AAEF,qBAAa,gBAAgB;IAKzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgE;IACvF,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA2B;gBAGzC,MAAM,EAAE,cAAc,CAAC,MAAM,EAC9C,GAAG,EAAE,mBAAmB;IAanB,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,WAAW,GAAG,IAAI;CA2BjH"}
@@ -0,0 +1,51 @@
1
+ import { LRUCache } from 'lru-cache';
2
+ import { logPFrames } from './logging.js';
3
+
4
+ const PTableCachePlainOpsDefaults = {
5
+ pTablesCacheMaxSize: 32 * 1024 * 1024 * 1024, // 32 GB (must be at least 8GB)
6
+ };
7
+ class PTableCachePlain {
8
+ logger;
9
+ global;
10
+ disposeListeners = new Set();
11
+ constructor(logger, ops) {
12
+ this.logger = logger;
13
+ this.global = new LRUCache({
14
+ maxSize: ops.pTablesCacheMaxSize,
15
+ dispose: (resource, key, reason) => {
16
+ resource.unref();
17
+ if (logPFrames()) {
18
+ logger('info', `createPTable cache - removed PTable ${key} (reason: ${reason})`);
19
+ }
20
+ },
21
+ });
22
+ }
23
+ cache(resource, size, defDisposeSignal) {
24
+ const key = resource.key;
25
+ if (logPFrames()) {
26
+ this.logger('info', `createPTable cache - added PTable ${key} with size ${size}`);
27
+ }
28
+ const status = {};
29
+ this.global.set(key, resource, { size: Math.max(size, 1), status }); // 1 is minimum size to avoid cache evictions
30
+ if (status.maxEntrySizeExceeded) {
31
+ resource.unref();
32
+ if (logPFrames()) {
33
+ this.logger('info', `createPTable cache - removed PTable ${key} (maxEntrySizeExceeded)`);
34
+ }
35
+ }
36
+ else {
37
+ if (!this.disposeListeners.has(key)) {
38
+ const disposeListener = () => {
39
+ this.global.delete(key);
40
+ this.disposeListeners.delete(key);
41
+ defDisposeSignal.removeEventListener('abort', disposeListener);
42
+ };
43
+ this.disposeListeners.add(key);
44
+ defDisposeSignal.addEventListener('abort', disposeListener);
45
+ }
46
+ }
47
+ }
48
+ }
49
+
50
+ export { PTableCachePlain, PTableCachePlainOpsDefaults };
51
+ //# sourceMappingURL=ptable_cache_plain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ptable_cache_plain.js","sources":["../src/ptable_cache_plain.ts"],"sourcesContent":["import type { PTableHandle } from '@platforma-sdk/model';\nimport type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';\nimport type { PoolEntry } from '@milaboratories/ts-helpers';\nimport { LRUCache } from 'lru-cache';\nimport { logPFrames } from './logging';\nimport type { PTableHolder } from './ptable_pool';\n\nexport type PTableCachePlainOps = {\n /**\n * Maximum size of `createPTable` results cached on disk.\n * The limit is soft, as the same table could be materialized with other requests and will not be deleted in such case.\n * Also each table has predeccessors, overlapping predecessors will be counted twice, so the effective limit is smaller.\n */\n pTablesCacheMaxSize: number;\n};\n\nexport const PTableCachePlainOpsDefaults: PTableCachePlainOps = {\n pTablesCacheMaxSize: 32 * 1024 * 1024 * 1024, // 32 GB (must be at least 8GB)\n};\n\nexport class PTableCachePlain {\n private readonly global: LRUCache<PTableHandle, PoolEntry<PTableHandle, PTableHolder>>;\n private readonly disposeListeners = new Set<PTableHandle>();\n\n constructor(\n private readonly logger: PFrameInternal.Logger,\n ops: PTableCachePlainOps,\n ) {\n this.global = new LRUCache<PTableHandle, PoolEntry<PTableHandle, PTableHolder>>({\n maxSize: ops.pTablesCacheMaxSize,\n dispose: (resource, key, reason) => {\n resource.unref();\n if (logPFrames()) {\n logger('info', `createPTable cache - removed PTable ${key} (reason: ${reason})`);\n }\n },\n });\n }\n\n public cache(resource: PoolEntry<PTableHandle, PTableHolder>, size: number, defDisposeSignal: AbortSignal): void {\n const key = resource.key;\n if (logPFrames()) {\n this.logger('info', `createPTable cache - added PTable ${key} with size ${size}`);\n }\n\n const status: LRUCache.Status<PoolEntry<PTableHandle, PTableHolder>> = {};\n this.global.set(key, resource, { size: Math.max(size, 1), status }); // 1 is minimum size to avoid cache evictions\n\n if (status.maxEntrySizeExceeded) {\n resource.unref();\n if (logPFrames()) {\n this.logger('info', `createPTable cache - removed PTable ${key} (maxEntrySizeExceeded)`);\n }\n } else {\n if (!this.disposeListeners.has(key)) {\n const disposeListener = () => {\n this.global.delete(key);\n\n this.disposeListeners.delete(key);\n defDisposeSignal.removeEventListener('abort', disposeListener);\n };\n this.disposeListeners.add(key);\n defDisposeSignal.addEventListener('abort', disposeListener);\n }\n }\n }\n}\n"],"names":[],"mappings":";;;AAgBO,MAAM,2BAA2B,GAAwB;IAC9D,mBAAmB,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;;MAGjC,gBAAgB,CAAA;AAKR,IAAA,MAAA;AAJF,IAAA,MAAM;AACN,IAAA,gBAAgB,GAAG,IAAI,GAAG,EAAgB;IAE3D,WAAA,CACmB,MAA6B,EAC9C,GAAwB,EAAA;QADP,IAAA,CAAA,MAAM,GAAN,MAAM;AAGvB,QAAA,IAAI,CAAC,MAAM,GAAG,IAAI,QAAQ,CAAsD;YAC9E,OAAO,EAAE,GAAG,CAAC,mBAAmB;YAChC,OAAO,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,KAAI;gBACjC,QAAQ,CAAC,KAAK,EAAE;gBAChB,IAAI,UAAU,EAAE,EAAE;oBAChB,MAAM,CAAC,MAAM,EAAE,CAAA,oCAAA,EAAuC,GAAG,CAAA,UAAA,EAAa,MAAM,CAAA,CAAA,CAAG,CAAC;gBAClF;YACF,CAAC;AACF,SAAA,CAAC;IACJ;AAEO,IAAA,KAAK,CAAC,QAA+C,EAAE,IAAY,EAAE,gBAA6B,EAAA;AACvG,QAAA,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG;QACxB,IAAI,UAAU,EAAE,EAAE;YAChB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA,kCAAA,EAAqC,GAAG,CAAA,WAAA,EAAc,IAAI,CAAA,CAAE,CAAC;QACnF;QAEA,MAAM,MAAM,GAA2D,EAAE;QACzE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AAEpE,QAAA,IAAI,MAAM,CAAC,oBAAoB,EAAE;YAC/B,QAAQ,CAAC,KAAK,EAAE;YAChB,IAAI,UAAU,EAAE,EAAE;gBAChB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA,oCAAA,EAAuC,GAAG,CAAA,uBAAA,CAAyB,CAAC;YAC1F;QACF;aAAO;YACL,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBACnC,MAAM,eAAe,GAAG,MAAK;AAC3B,oBAAA,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;AAEvB,oBAAA,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC;AACjC,oBAAA,gBAAgB,CAAC,mBAAmB,CAAC,OAAO,EAAE,eAAe,CAAC;AAChE,gBAAA,CAAC;AACD,gBAAA,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC;AAC9B,gBAAA,gBAAgB,CAAC,gBAAgB,CAAC,OAAO,EAAE,eAAe,CAAC;YAC7D;QACF;IACF;AACD;;;;"}
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ var model = require('@platforma-sdk/model');
4
+ var tsHelpers = require('@milaboratories/ts-helpers');
5
+ var logging = require('./logging.cjs');
6
+ var ptable_shared = require('./ptable_shared.cjs');
7
+
8
+ class PTableDefHolder {
9
+ def;
10
+ pTableHandle;
11
+ logger;
12
+ abortController = new AbortController();
13
+ constructor(def, pTableHandle, logger) {
14
+ this.def = def;
15
+ this.pTableHandle = pTableHandle;
16
+ this.logger = logger;
17
+ if (logging.logPFrames()) {
18
+ this.logger('info', `PTable definition saved (pTableHandle = ${this.pTableHandle})`);
19
+ }
20
+ }
21
+ get disposeSignal() {
22
+ return this.abortController.signal;
23
+ }
24
+ [Symbol.dispose]() {
25
+ this.abortController.abort();
26
+ if (logging.logPFrames()) {
27
+ this.logger('info', `PTable definition disposed (pTableHandle = ${this.pTableHandle})`);
28
+ }
29
+ }
30
+ }
31
+ class PTableDefPool extends tsHelpers.RefCountPoolBase {
32
+ logger;
33
+ constructor(logger) {
34
+ super();
35
+ this.logger = logger;
36
+ }
37
+ calculateParamsKey(params) {
38
+ return ptable_shared.stableKeyFromFullPTableDef(params);
39
+ }
40
+ createNewResource(params, key) {
41
+ return new PTableDefHolder(params, key, this.logger);
42
+ }
43
+ getByKey(key) {
44
+ const resource = super.tryGetByKey(key);
45
+ if (!resource)
46
+ throw new model.PFrameDriverError(`PTable definition not found, handle = ${key}`);
47
+ return resource;
48
+ }
49
+ }
50
+
51
+ exports.PTableDefHolder = PTableDefHolder;
52
+ exports.PTableDefPool = PTableDefPool;
53
+ //# sourceMappingURL=ptable_def_pool.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ptable_def_pool.cjs","sources":["../src/ptable_def_pool.ts"],"sourcesContent":["import { PFrameDriverError, type PTableHandle } from '@platforma-sdk/model';\nimport type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';\nimport { RefCountPoolBase } from '@milaboratories/ts-helpers';\nimport { logPFrames } from './logging';\nimport { stableKeyFromFullPTableDef, type FullPTableDef } from './ptable_shared';\n\nexport class PTableDefHolder implements Disposable {\n private readonly abortController = new AbortController();\n\n constructor(\n public readonly def: FullPTableDef,\n private readonly pTableHandle: PTableHandle,\n private readonly logger: PFrameInternal.Logger,\n ) {\n if (logPFrames()) {\n this.logger('info', `PTable definition saved (pTableHandle = ${this.pTableHandle})`);\n }\n }\n\n public get disposeSignal(): AbortSignal {\n return this.abortController.signal;\n }\n\n [Symbol.dispose](): void {\n this.abortController.abort();\n if (logPFrames()) {\n this.logger('info', `PTable definition disposed (pTableHandle = ${this.pTableHandle})`);\n }\n }\n}\n\nexport class PTableDefPool extends RefCountPoolBase<FullPTableDef, PTableHandle, PTableDefHolder> {\n constructor(private readonly logger: PFrameInternal.Logger) {\n super();\n }\n\n protected calculateParamsKey(params: FullPTableDef): PTableHandle {\n return stableKeyFromFullPTableDef(params);\n }\n\n protected createNewResource(params: FullPTableDef, key: PTableHandle): PTableDefHolder {\n return new PTableDefHolder(params, key, this.logger);\n }\n\n public getByKey(key: PTableHandle): PTableDefHolder {\n const resource = super.tryGetByKey(key);\n if (!resource) throw new PFrameDriverError(`PTable definition not found, handle = ${key}`);\n return resource;\n }\n}\n"],"names":["logPFrames","RefCountPoolBase","stableKeyFromFullPTableDef","PFrameDriverError"],"mappings":";;;;;;;MAMa,eAAe,CAAA;AAIR,IAAA,GAAA;AACC,IAAA,YAAA;AACA,IAAA,MAAA;AALF,IAAA,eAAe,GAAG,IAAI,eAAe,EAAE;AAExD,IAAA,WAAA,CACkB,GAAkB,EACjB,YAA0B,EAC1B,MAA6B,EAAA;QAF9B,IAAA,CAAA,GAAG,GAAH,GAAG;QACF,IAAA,CAAA,YAAY,GAAZ,YAAY;QACZ,IAAA,CAAA,MAAM,GAAN,MAAM;QAEvB,IAAIA,kBAAU,EAAE,EAAE;YAChB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA,wCAAA,EAA2C,IAAI,CAAC,YAAY,CAAA,CAAA,CAAG,CAAC;QACtF;IACF;AAEA,IAAA,IAAW,aAAa,GAAA;AACtB,QAAA,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM;IACpC;IAEA,CAAC,MAAM,CAAC,OAAO,CAAC,GAAA;AACd,QAAA,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE;QAC5B,IAAIA,kBAAU,EAAE,EAAE;YAChB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA,2CAAA,EAA8C,IAAI,CAAC,YAAY,CAAA,CAAA,CAAG,CAAC;QACzF;IACF;AACD;AAEK,MAAO,aAAc,SAAQC,0BAA8D,CAAA;AAClE,IAAA,MAAA;AAA7B,IAAA,WAAA,CAA6B,MAA6B,EAAA;AACxD,QAAA,KAAK,EAAE;QADoB,IAAA,CAAA,MAAM,GAAN,MAAM;IAEnC;AAEU,IAAA,kBAAkB,CAAC,MAAqB,EAAA;AAChD,QAAA,OAAOC,wCAA0B,CAAC,MAAM,CAAC;IAC3C;IAEU,iBAAiB,CAAC,MAAqB,EAAE,GAAiB,EAAA;QAClE,OAAO,IAAI,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC;IACtD;AAEO,IAAA,QAAQ,CAAC,GAAiB,EAAA;QAC/B,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC;AACvC,QAAA,IAAI,CAAC,QAAQ;AAAE,YAAA,MAAM,IAAIC,uBAAiB,CAAC,yCAAyC,GAAG,CAAA,CAAE,CAAC;AAC1F,QAAA,OAAO,QAAQ;IACjB;AACD;;;;;"}
@@ -0,0 +1,21 @@
1
+ import { type PTableHandle } from '@platforma-sdk/model';
2
+ import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
3
+ import { RefCountPoolBase } from '@milaboratories/ts-helpers';
4
+ import { type FullPTableDef } from './ptable_shared';
5
+ export declare class PTableDefHolder implements Disposable {
6
+ readonly def: FullPTableDef;
7
+ private readonly pTableHandle;
8
+ private readonly logger;
9
+ private readonly abortController;
10
+ constructor(def: FullPTableDef, pTableHandle: PTableHandle, logger: PFrameInternal.Logger);
11
+ get disposeSignal(): AbortSignal;
12
+ [Symbol.dispose](): void;
13
+ }
14
+ export declare class PTableDefPool extends RefCountPoolBase<FullPTableDef, PTableHandle, PTableDefHolder> {
15
+ private readonly logger;
16
+ constructor(logger: PFrameInternal.Logger);
17
+ protected calculateParamsKey(params: FullPTableDef): PTableHandle;
18
+ protected createNewResource(params: FullPTableDef, key: PTableHandle): PTableDefHolder;
19
+ getByKey(key: PTableHandle): PTableDefHolder;
20
+ }
21
+ //# sourceMappingURL=ptable_def_pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ptable_def_pool.d.ts","sourceRoot":"","sources":["../src/ptable_def_pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEjF,qBAAa,eAAgB,YAAW,UAAU;aAI9B,GAAG,EAAE,aAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM;IALzB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;gBAGvC,GAAG,EAAE,aAAa,EACjB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,cAAc,CAAC,MAAM;IAOhD,IAAW,aAAa,IAAI,WAAW,CAEtC;IAED,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAMzB;AAED,qBAAa,aAAc,SAAQ,gBAAgB,CAAC,aAAa,EAAE,YAAY,EAAE,eAAe,CAAC;IACnF,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,cAAc,CAAC,MAAM;IAI1D,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,YAAY;IAIjE,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,GAAG,eAAe;IAI/E,QAAQ,CAAC,GAAG,EAAE,YAAY,GAAG,eAAe;CAKpD"}
@@ -0,0 +1,50 @@
1
+ import { PFrameDriverError } from '@platforma-sdk/model';
2
+ import { RefCountPoolBase } from '@milaboratories/ts-helpers';
3
+ import { logPFrames } from './logging.js';
4
+ import { stableKeyFromFullPTableDef } from './ptable_shared.js';
5
+
6
+ class PTableDefHolder {
7
+ def;
8
+ pTableHandle;
9
+ logger;
10
+ abortController = new AbortController();
11
+ constructor(def, pTableHandle, logger) {
12
+ this.def = def;
13
+ this.pTableHandle = pTableHandle;
14
+ this.logger = logger;
15
+ if (logPFrames()) {
16
+ this.logger('info', `PTable definition saved (pTableHandle = ${this.pTableHandle})`);
17
+ }
18
+ }
19
+ get disposeSignal() {
20
+ return this.abortController.signal;
21
+ }
22
+ [Symbol.dispose]() {
23
+ this.abortController.abort();
24
+ if (logPFrames()) {
25
+ this.logger('info', `PTable definition disposed (pTableHandle = ${this.pTableHandle})`);
26
+ }
27
+ }
28
+ }
29
+ class PTableDefPool extends RefCountPoolBase {
30
+ logger;
31
+ constructor(logger) {
32
+ super();
33
+ this.logger = logger;
34
+ }
35
+ calculateParamsKey(params) {
36
+ return stableKeyFromFullPTableDef(params);
37
+ }
38
+ createNewResource(params, key) {
39
+ return new PTableDefHolder(params, key, this.logger);
40
+ }
41
+ getByKey(key) {
42
+ const resource = super.tryGetByKey(key);
43
+ if (!resource)
44
+ throw new PFrameDriverError(`PTable definition not found, handle = ${key}`);
45
+ return resource;
46
+ }
47
+ }
48
+
49
+ export { PTableDefHolder, PTableDefPool };
50
+ //# sourceMappingURL=ptable_def_pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ptable_def_pool.js","sources":["../src/ptable_def_pool.ts"],"sourcesContent":["import { PFrameDriverError, type PTableHandle } from '@platforma-sdk/model';\nimport type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';\nimport { RefCountPoolBase } from '@milaboratories/ts-helpers';\nimport { logPFrames } from './logging';\nimport { stableKeyFromFullPTableDef, type FullPTableDef } from './ptable_shared';\n\nexport class PTableDefHolder implements Disposable {\n private readonly abortController = new AbortController();\n\n constructor(\n public readonly def: FullPTableDef,\n private readonly pTableHandle: PTableHandle,\n private readonly logger: PFrameInternal.Logger,\n ) {\n if (logPFrames()) {\n this.logger('info', `PTable definition saved (pTableHandle = ${this.pTableHandle})`);\n }\n }\n\n public get disposeSignal(): AbortSignal {\n return this.abortController.signal;\n }\n\n [Symbol.dispose](): void {\n this.abortController.abort();\n if (logPFrames()) {\n this.logger('info', `PTable definition disposed (pTableHandle = ${this.pTableHandle})`);\n }\n }\n}\n\nexport class PTableDefPool extends RefCountPoolBase<FullPTableDef, PTableHandle, PTableDefHolder> {\n constructor(private readonly logger: PFrameInternal.Logger) {\n super();\n }\n\n protected calculateParamsKey(params: FullPTableDef): PTableHandle {\n return stableKeyFromFullPTableDef(params);\n }\n\n protected createNewResource(params: FullPTableDef, key: PTableHandle): PTableDefHolder {\n return new PTableDefHolder(params, key, this.logger);\n }\n\n public getByKey(key: PTableHandle): PTableDefHolder {\n const resource = super.tryGetByKey(key);\n if (!resource) throw new PFrameDriverError(`PTable definition not found, handle = ${key}`);\n return resource;\n }\n}\n"],"names":[],"mappings":";;;;;MAMa,eAAe,CAAA;AAIR,IAAA,GAAA;AACC,IAAA,YAAA;AACA,IAAA,MAAA;AALF,IAAA,eAAe,GAAG,IAAI,eAAe,EAAE;AAExD,IAAA,WAAA,CACkB,GAAkB,EACjB,YAA0B,EAC1B,MAA6B,EAAA;QAF9B,IAAA,CAAA,GAAG,GAAH,GAAG;QACF,IAAA,CAAA,YAAY,GAAZ,YAAY;QACZ,IAAA,CAAA,MAAM,GAAN,MAAM;QAEvB,IAAI,UAAU,EAAE,EAAE;YAChB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA,wCAAA,EAA2C,IAAI,CAAC,YAAY,CAAA,CAAA,CAAG,CAAC;QACtF;IACF;AAEA,IAAA,IAAW,aAAa,GAAA;AACtB,QAAA,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM;IACpC;IAEA,CAAC,MAAM,CAAC,OAAO,CAAC,GAAA;AACd,QAAA,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE;QAC5B,IAAI,UAAU,EAAE,EAAE;YAChB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA,2CAAA,EAA8C,IAAI,CAAC,YAAY,CAAA,CAAA,CAAG,CAAC;QACzF;IACF;AACD;AAEK,MAAO,aAAc,SAAQ,gBAA8D,CAAA;AAClE,IAAA,MAAA;AAA7B,IAAA,WAAA,CAA6B,MAA6B,EAAA;AACxD,QAAA,KAAK,EAAE;QADoB,IAAA,CAAA,MAAM,GAAN,MAAM;IAEnC;AAEU,IAAA,kBAAkB,CAAC,MAAqB,EAAA;AAChD,QAAA,OAAO,0BAA0B,CAAC,MAAM,CAAC;IAC3C;IAEU,iBAAiB,CAAC,MAAqB,EAAE,GAAiB,EAAA;QAClE,OAAO,IAAI,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC;IACtD;AAEO,IAAA,QAAQ,CAAC,GAAiB,EAAA;QAC/B,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC;AACvC,QAAA,IAAI,CAAC,QAAQ;AAAE,YAAA,MAAM,IAAI,iBAAiB,CAAC,yCAAyC,GAAG,CAAA,CAAE,CAAC;AAC1F,QAAA,OAAO,QAAQ;IACjB;AACD;;;;"}
@@ -0,0 +1,167 @@
1
+ 'use strict';
2
+
3
+ var model = require('@platforma-sdk/model');
4
+ var tsHelpers = require('@milaboratories/ts-helpers');
5
+ var logging = require('./logging.cjs');
6
+ var ptable_shared = require('./ptable_shared.cjs');
7
+
8
+ class PTableHolder {
9
+ pFrame;
10
+ pTablePromise;
11
+ predecessor;
12
+ abortController = new AbortController();
13
+ combinedDisposeSignal;
14
+ constructor(pFrame, pFrameDisposeSignal, pTablePromise, predecessor) {
15
+ this.pFrame = pFrame;
16
+ this.pTablePromise = pTablePromise;
17
+ this.predecessor = predecessor;
18
+ this.combinedDisposeSignal = AbortSignal.any([pFrameDisposeSignal, this.abortController.signal]);
19
+ }
20
+ get disposeSignal() {
21
+ return this.combinedDisposeSignal;
22
+ }
23
+ [Symbol.dispose]() {
24
+ this.abortController.abort();
25
+ this.predecessor?.unref();
26
+ void this.pTablePromise
27
+ .then((pTable) => pTable.dispose())
28
+ .catch(() => { });
29
+ }
30
+ }
31
+ class PTablePool extends tsHelpers.RefCountPoolBase {
32
+ pFrames;
33
+ pTableDefs;
34
+ logger;
35
+ constructor(pFrames, pTableDefs, logger) {
36
+ super();
37
+ this.pFrames = pFrames;
38
+ this.pTableDefs = pTableDefs;
39
+ this.logger = logger;
40
+ }
41
+ calculateParamsKey(params) {
42
+ return ptable_shared.stableKeyFromFullPTableDef(params);
43
+ }
44
+ createNewResource(params, key) {
45
+ if (logging.logPFrames()) {
46
+ this.logger('info', `PTable creation (pTableHandle = ${key}): `
47
+ + `${JSON.stringify(params, model.bigintReplacer)}`);
48
+ }
49
+ const handle = params.pFrameHandle;
50
+ const { pFramePromise, disposeSignal } = this.pFrames.getByKey(handle);
51
+ const defDisposeSignal = this.pTableDefs.tryGetByKey(key)?.disposeSignal;
52
+ const combinedSignal = AbortSignal.any([disposeSignal, defDisposeSignal].filter((s) => !!s));
53
+ // 3. Sort
54
+ if (params.def.sorting.length > 0) {
55
+ const predecessor = this.acquire({
56
+ ...params,
57
+ def: {
58
+ ...params.def,
59
+ sorting: [],
60
+ },
61
+ });
62
+ const { resource: { pTablePromise } } = predecessor;
63
+ const sortedTable = pTablePromise.then((pTable) => pTable.sort(params.def.sorting));
64
+ return new PTableHolder(handle, combinedSignal, sortedTable, predecessor);
65
+ }
66
+ // 2. Filter (except the case with artificial columns where cartesian creates too many rows)
67
+ if (!hasArtificialColumns(params.def.src) && params.def.filters.length > 0) {
68
+ const predecessor = this.acquire({
69
+ ...params,
70
+ def: {
71
+ ...params.def,
72
+ filters: [],
73
+ },
74
+ });
75
+ const { resource: { pTablePromise } } = predecessor;
76
+ const filteredTable = pTablePromise.then((pTable) => pTable.filter(params.def.filters));
77
+ return new PTableHolder(handle, combinedSignal, filteredTable, predecessor);
78
+ }
79
+ // 1. Join
80
+ const table = pFramePromise.then((pFrame) => pFrame.createTable({
81
+ src: joinEntryToInternal(params.def.src),
82
+ // `params.def.filters` would be non-empty only when join has artificial columns
83
+ filters: [...params.def.partitionFilters, ...params.def.filters],
84
+ }));
85
+ return new PTableHolder(handle, combinedSignal, table);
86
+ }
87
+ getByKey(key) {
88
+ const resource = super.tryGetByKey(key);
89
+ if (!resource)
90
+ throw new model.PFrameDriverError(`PTable not found, handle = ${key}`);
91
+ return resource;
92
+ }
93
+ }
94
+ function hasArtificialColumns(entry) {
95
+ switch (entry.type) {
96
+ case 'column':
97
+ case 'slicedColumn':
98
+ case 'inlineColumn':
99
+ return false;
100
+ case 'artificialColumn':
101
+ return true;
102
+ case 'full':
103
+ case 'inner':
104
+ return entry.entries.some(hasArtificialColumns);
105
+ case 'outer':
106
+ return hasArtificialColumns(entry.primary) || entry.secondary.some(hasArtificialColumns);
107
+ default:
108
+ model.assertNever(entry);
109
+ }
110
+ }
111
+ function joinEntryToInternal(entry) {
112
+ const type = entry.type;
113
+ switch (type) {
114
+ case 'column':
115
+ return {
116
+ type: 'column',
117
+ columnId: entry.column,
118
+ };
119
+ case 'slicedColumn':
120
+ return {
121
+ type: 'slicedColumn',
122
+ columnId: entry.column,
123
+ newId: entry.newId,
124
+ axisFilters: entry.axisFilters,
125
+ };
126
+ case 'artificialColumn':
127
+ return {
128
+ type: 'artificialColumn',
129
+ columnId: entry.column,
130
+ newId: entry.newId,
131
+ axesIndices: entry.axesIndices,
132
+ };
133
+ case 'inlineColumn':
134
+ return {
135
+ type: 'inlineColumn',
136
+ newId: entry.column.id,
137
+ spec: entry.column.spec,
138
+ dataInfo: {
139
+ type: 'Json',
140
+ keyLength: entry.column.spec.axesSpec.length,
141
+ data: entry.column.data.reduce((acc, row) => {
142
+ acc[JSON.stringify(row.key)] = row.val;
143
+ return acc;
144
+ }, {}),
145
+ },
146
+ };
147
+ case 'inner':
148
+ case 'full':
149
+ return {
150
+ type: entry.type,
151
+ entries: entry.entries.map((col) => joinEntryToInternal(col)),
152
+ };
153
+ case 'outer':
154
+ return {
155
+ type: 'outer',
156
+ primary: joinEntryToInternal(entry.primary),
157
+ secondary: entry.secondary.map((col) => joinEntryToInternal(col)),
158
+ };
159
+ default:
160
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
161
+ throw new model.PFrameDriverError(`unsupported PFrame join entry type: ${type}`);
162
+ }
163
+ }
164
+
165
+ exports.PTableHolder = PTableHolder;
166
+ exports.PTablePool = PTablePool;
167
+ //# sourceMappingURL=ptable_pool.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ptable_pool.cjs","sources":["../src/ptable_pool.ts"],"sourcesContent":["import {\n assertNever,\n bigintReplacer,\n PFrameDriverError,\n type PFrameHandle,\n type PTableHandle,\n type JoinEntry,\n type JsonSerializable,\n type PColumnValue,\n type PObjectId,\n} from '@platforma-sdk/model';\nimport type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';\nimport { RefCountPoolBase, type PoolEntry } from '@milaboratories/ts-helpers';\nimport { logPFrames } from './logging';\nimport type { PFramePool } from './pframe_pool';\nimport { stableKeyFromFullPTableDef, type FullPTableDef } from './ptable_shared';\nimport type { PTableDefPool } from './ptable_def_pool';\n\nexport class PTableHolder implements Disposable {\n private readonly abortController = new AbortController();\n private readonly combinedDisposeSignal: AbortSignal;\n\n constructor(\n public readonly pFrame: PFrameHandle,\n pFrameDisposeSignal: AbortSignal,\n public readonly pTablePromise: Promise<PFrameInternal.PTableV7>,\n private readonly predecessor?: PoolEntry<PTableHandle, PTableHolder>,\n ) {\n this.combinedDisposeSignal = AbortSignal.any([pFrameDisposeSignal, this.abortController.signal]);\n }\n\n public get disposeSignal(): AbortSignal {\n return this.combinedDisposeSignal;\n }\n\n [Symbol.dispose](): void {\n this.abortController.abort();\n this.predecessor?.unref();\n void this.pTablePromise\n .then((pTable) => pTable.dispose())\n .catch(() => { /* mute error */ });\n }\n}\n\nexport class PTablePool<TreeEntry extends JsonSerializable>\n extends RefCountPoolBase<FullPTableDef, PTableHandle, PTableHolder> {\n constructor(\n private readonly pFrames: PFramePool<TreeEntry>,\n private readonly pTableDefs: PTableDefPool,\n private readonly logger: PFrameInternal.Logger,\n ) {\n super();\n }\n\n protected calculateParamsKey(params: FullPTableDef): PTableHandle {\n return stableKeyFromFullPTableDef(params);\n }\n\n protected createNewResource(params: FullPTableDef, key: PTableHandle): PTableHolder {\n if (logPFrames()) {\n this.logger('info',\n `PTable creation (pTableHandle = ${key}): `\n + `${JSON.stringify(params, bigintReplacer)}`,\n );\n }\n\n const handle = params.pFrameHandle;\n const { pFramePromise, disposeSignal } = this.pFrames.getByKey(handle);\n\n const defDisposeSignal = this.pTableDefs.tryGetByKey(key)?.disposeSignal;\n const combinedSignal = AbortSignal.any([disposeSignal, defDisposeSignal].filter((s) => !!s));\n\n // 3. Sort\n if (params.def.sorting.length > 0) {\n const predecessor = this.acquire({\n ...params,\n def: {\n ...params.def,\n sorting: [],\n },\n });\n const { resource: { pTablePromise } } = predecessor;\n const sortedTable = pTablePromise.then((pTable) => pTable.sort(params.def.sorting));\n return new PTableHolder(handle, combinedSignal, sortedTable, predecessor);\n }\n\n // 2. Filter (except the case with artificial columns where cartesian creates too many rows)\n if (!hasArtificialColumns(params.def.src) && params.def.filters.length > 0) {\n const predecessor = this.acquire({\n ...params,\n def: {\n ...params.def,\n filters: [],\n },\n });\n const { resource: { pTablePromise } } = predecessor;\n const filteredTable = pTablePromise.then((pTable) => pTable.filter(params.def.filters));\n return new PTableHolder(handle, combinedSignal, filteredTable, predecessor);\n }\n\n // 1. Join\n const table = pFramePromise.then((pFrame) => pFrame.createTable({\n src: joinEntryToInternal(params.def.src),\n // `params.def.filters` would be non-empty only when join has artificial columns\n filters: [...params.def.partitionFilters, ...params.def.filters],\n }));\n return new PTableHolder(handle, combinedSignal, table);\n }\n\n public getByKey(key: PTableHandle): PTableHolder {\n const resource = super.tryGetByKey(key);\n if (!resource) throw new PFrameDriverError(`PTable not found, handle = ${key}`);\n return resource;\n }\n}\n\nfunction hasArtificialColumns<T>(entry: JoinEntry<T>): boolean {\n switch (entry.type) {\n case 'column':\n case 'slicedColumn':\n case 'inlineColumn':\n return false;\n case 'artificialColumn':\n return true;\n case 'full':\n case 'inner':\n return entry.entries.some(hasArtificialColumns);\n case 'outer':\n return hasArtificialColumns(entry.primary) || entry.secondary.some(hasArtificialColumns);\n default:\n assertNever(entry);\n }\n}\n\nfunction joinEntryToInternal(entry: JoinEntry<PObjectId>): PFrameInternal.JoinEntryV4 {\n const type = entry.type;\n switch (type) {\n case 'column':\n return {\n type: 'column',\n columnId: entry.column,\n };\n case 'slicedColumn':\n return {\n type: 'slicedColumn',\n columnId: entry.column,\n newId: entry.newId,\n axisFilters: entry.axisFilters,\n };\n case 'artificialColumn':\n return {\n type: 'artificialColumn',\n columnId: entry.column,\n newId: entry.newId,\n axesIndices: entry.axesIndices,\n };\n case 'inlineColumn':\n return {\n type: 'inlineColumn',\n newId: entry.column.id,\n spec: entry.column.spec,\n dataInfo: {\n type: 'Json',\n keyLength: entry.column.spec.axesSpec.length,\n data: entry.column.data.reduce((acc, row) => {\n acc[JSON.stringify(row.key)] = row.val;\n return acc;\n }, {} as Record<string, PColumnValue>),\n },\n };\n case 'inner':\n case 'full':\n return {\n type: entry.type,\n entries: entry.entries.map((col) => joinEntryToInternal(col)),\n };\n case 'outer':\n return {\n type: 'outer',\n primary: joinEntryToInternal(entry.primary),\n secondary: entry.secondary.map((col) => joinEntryToInternal(col)),\n };\n default:\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw new PFrameDriverError(`unsupported PFrame join entry type: ${type satisfies never}`);\n }\n}\n"],"names":["RefCountPoolBase","stableKeyFromFullPTableDef","logPFrames","bigintReplacer","PFrameDriverError","assertNever"],"mappings":";;;;;;;MAkBa,YAAY,CAAA;AAKL,IAAA,MAAA;AAEA,IAAA,aAAA;AACC,IAAA,WAAA;AAPF,IAAA,eAAe,GAAG,IAAI,eAAe,EAAE;AACvC,IAAA,qBAAqB;AAEtC,IAAA,WAAA,CACkB,MAAoB,EACpC,mBAAgC,EAChB,aAA+C,EAC9C,WAAmD,EAAA;QAHpD,IAAA,CAAA,MAAM,GAAN,MAAM;QAEN,IAAA,CAA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,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG;AACtC,wBAAA,OAAO,GAAG;oBACZ,CAAC,EAAE,EAAkC,CAAC;AACvC,iBAAA;aACF;AACH,QAAA,KAAK,OAAO;AACZ,QAAA,KAAK,MAAM;YACT,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,IAAI;AAChB,gBAAA,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAC;aAC9D;AACH,QAAA,KAAK,OAAO;YACV,OAAO;AACL,gBAAA,IAAI,EAAE,OAAO;AACb,gBAAA,OAAO,EAAE,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC;AAC3C,gBAAA,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAC;aAClE;AACH,QAAA;;AAEE,YAAA,MAAM,IAAID,uBAAiB,CAAC,uCAAuC,IAAoB,CAAA,CAAE,CAAC;;AAEhG;;;;;"}
@@ -0,0 +1,26 @@
1
+ import { type PFrameHandle, type PTableHandle, type JsonSerializable } from '@platforma-sdk/model';
2
+ import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
3
+ import { RefCountPoolBase, type PoolEntry } from '@milaboratories/ts-helpers';
4
+ import type { PFramePool } from './pframe_pool';
5
+ import { type FullPTableDef } from './ptable_shared';
6
+ import type { PTableDefPool } from './ptable_def_pool';
7
+ export declare class PTableHolder implements Disposable {
8
+ readonly pFrame: PFrameHandle;
9
+ readonly pTablePromise: Promise<PFrameInternal.PTableV7>;
10
+ private readonly predecessor?;
11
+ private readonly abortController;
12
+ private readonly combinedDisposeSignal;
13
+ constructor(pFrame: PFrameHandle, pFrameDisposeSignal: AbortSignal, pTablePromise: Promise<PFrameInternal.PTableV7>, predecessor?: PoolEntry<PTableHandle, PTableHolder> | undefined);
14
+ get disposeSignal(): AbortSignal;
15
+ [Symbol.dispose](): void;
16
+ }
17
+ export declare class PTablePool<TreeEntry extends JsonSerializable> extends RefCountPoolBase<FullPTableDef, PTableHandle, PTableHolder> {
18
+ private readonly pFrames;
19
+ private readonly pTableDefs;
20
+ private readonly logger;
21
+ constructor(pFrames: PFramePool<TreeEntry>, pTableDefs: PTableDefPool, logger: PFrameInternal.Logger);
22
+ protected calculateParamsKey(params: FullPTableDef): PTableHandle;
23
+ protected createNewResource(params: FullPTableDef, key: PTableHandle): PTableHolder;
24
+ getByKey(key: PTableHandle): PTableHolder;
25
+ }
26
+ //# sourceMappingURL=ptable_pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ptable_pool.d.ts","sourceRoot":"","sources":["../src/ptable_pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,YAAY,EAEjB,KAAK,gBAAgB,EAGtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,qBAAa,YAAa,YAAW,UAAU;aAK3B,MAAM,EAAE,YAAY;aAEpB,aAAa,EAAE,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC;IAC/D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAP/B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IACzD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAc;gBAGlC,MAAM,EAAE,YAAY,EACpC,mBAAmB,EAAE,WAAW,EAChB,aAAa,EAAE,OAAO,CA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