axiodb 13.1.4 → 14.2.7
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.
- package/.graphifyignore +12 -0
- package/a.txt +11 -0
- package/lib/Helper/UniqueGenerator.helper.d.ts +4 -3
- package/lib/Helper/UniqueGenerator.helper.js +7 -4
- package/lib/Helper/UniqueGenerator.helper.js.map +1 -1
- package/lib/Services/CRUD Operation/Create.operation.js +1 -1
- package/lib/Services/CRUD Operation/Create.operation.js.map +1 -1
- package/lib/Services/Index/Index.service.d.ts +32 -101
- package/lib/Services/Index/Index.service.js +122 -142
- package/lib/Services/Index/Index.service.js.map +1 -1
- package/lib/Services/Index/IndexCache.service.d.ts +19 -52
- package/lib/Services/Index/IndexCache.service.js +48 -95
- package/lib/Services/Index/IndexCache.service.js.map +1 -1
- package/lib/Services/Index/ReadIndex.service.js +21 -13
- package/lib/Services/Index/ReadIndex.service.js.map +1 -1
- package/lib/Services/Transaction/Transaction.service.js +2 -2
- package/lib/Services/Transaction/Transaction.service.js.map +1 -1
- package/lib/Services/Transaction/TransactionIndexManager.service.js +6 -6
- package/lib/Services/Transaction/TransactionIndexManager.service.js.map +1 -1
- package/lib/config/Keys/Keys.d.ts +3 -0
- package/lib/config/Keys/Keys.js +4 -1
- package/lib/config/Keys/Keys.js.map +1 -1
- package/lib/engine/Filesystem/FileManager.d.ts +16 -0
- package/lib/engine/Filesystem/FileManager.js +67 -0
- package/lib/engine/Filesystem/FileManager.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Index.service.js","sourceRoot":"","sources":["../../../source/Services/Index/Index.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,iDAAiD;AACjD,sFAA8D;AAC9D,0FAAkE;AAClE,qFAAsD;AACtD,mFAA0D;AAQ1D;IAUE,YAAY,IAAY;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,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AS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;gBAChG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;KAAA;IAED;;OAEG;IACW,eAAe;;YAC3B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACnE,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,CAAC;KAAA;IAED;;;OAGG;IACa,qBAAqB,CAAE,GAAQ;;YAC7C,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;gBACnE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;oBAAE,OAAO,SAAS,CAAC;gBACzC,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;gBACjE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,IAA8B,EAAE,EAAE,CACvD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,CAC/D,CAAC;YACJ,CAAC;uBAAO,CAAC;gBACP,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;KAAA;CACF"}
|
|
@@ -19,15 +19,15 @@ interface IndexData {
|
|
|
19
19
|
*
|
|
20
20
|
* Features:
|
|
21
21
|
* - Eagerly loads all indexes on collection initialization
|
|
22
|
-
* - Keeps indexes in both memory (speed) and disk (persistence)
|
|
23
|
-
* - Cold start recovery:
|
|
22
|
+
* - Keeps indexes in both memory (speed) and disk (persistence) as JSONL
|
|
23
|
+
* - Cold start recovery: Streams from disk on cache miss
|
|
24
24
|
* - Thread-safe with simple lock mechanism
|
|
25
25
|
* - Dual-write: Updates both memory and disk atomically
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
28
|
* ```typescript
|
|
29
29
|
* const indexCache = IndexCache.getInstance('/path/to/collection');
|
|
30
|
-
* await indexCache.loadAllIndexes(); // Eager load
|
|
30
|
+
* await indexCache.loadAllIndexes(); // Eager load (streamed)
|
|
31
31
|
* const indexData = await indexCache.getIndex('email'); // O(1) memory access
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
@@ -46,96 +46,63 @@ export declare class IndexCache {
|
|
|
46
46
|
private constructor();
|
|
47
47
|
/**
|
|
48
48
|
* Returns the shared IndexCache for a collection path, creating it on first use.
|
|
49
|
-
* All index services (Insert/Read/Delete/Collection) must go through this instead of
|
|
50
|
-
* constructing their own instance, otherwise locking and caching are per-call and
|
|
51
|
-
* provide no real coordination.
|
|
52
|
-
*
|
|
53
|
-
* @param collectionPath - Absolute path of the collection this cache belongs to
|
|
54
49
|
*/
|
|
55
50
|
static getInstance(collectionPath: string): IndexCache;
|
|
56
51
|
/**
|
|
57
|
-
* Releases the shared IndexCache for a collection path
|
|
58
|
-
* itself is deleted), stopping its cleanup timer and dropping it from the registry.
|
|
59
|
-
*
|
|
60
|
-
* @param collectionPath - Absolute path of the collection whose cache should be released
|
|
52
|
+
* Releases the shared IndexCache for a collection path.
|
|
61
53
|
*/
|
|
62
54
|
static releaseInstance(collectionPath: string): void;
|
|
63
55
|
/**
|
|
64
|
-
* Stops the cleanup timer and clears cached state.
|
|
56
|
+
* Stops the cleanup timer and clears cached state.
|
|
65
57
|
*/
|
|
66
58
|
dispose(): void;
|
|
67
59
|
/**
|
|
68
|
-
* Generates a random TTL between 5-15 minutes
|
|
69
|
-
* Randomization prevents cache stampede (thundering herd problem)
|
|
60
|
+
* Generates a random TTL between 5-15 minutes.
|
|
70
61
|
*/
|
|
71
62
|
private generateRandomTTL;
|
|
72
63
|
/**
|
|
73
|
-
* Starts periodic cleanup of expired cache entries
|
|
64
|
+
* Starts periodic cleanup of expired cache entries.
|
|
74
65
|
*/
|
|
75
66
|
private startCleanupInterval;
|
|
76
67
|
/**
|
|
77
|
-
* Removes all expired entries from cache
|
|
68
|
+
* Removes all expired entries from cache.
|
|
78
69
|
*/
|
|
79
70
|
private cleanupExpiredEntries;
|
|
80
71
|
/**
|
|
81
|
-
* Checks if a cached entry is expired
|
|
72
|
+
* Checks if a cached entry is expired.
|
|
82
73
|
*/
|
|
83
74
|
private isExpired;
|
|
84
75
|
/**
|
|
85
|
-
* Eagerly loads all indexes into memory
|
|
86
|
-
* Called during collection initialization for maximum query performance
|
|
76
|
+
* Eagerly loads all indexes into memory using streaming reads.
|
|
77
|
+
* Called during collection initialization for maximum query performance.
|
|
87
78
|
*
|
|
88
79
|
* @returns Promise that resolves when all indexes are loaded
|
|
89
80
|
*/
|
|
90
81
|
loadAllIndexes(): Promise<void>;
|
|
91
82
|
/**
|
|
92
|
-
* Gets index data for a specific field
|
|
93
|
-
* Returns from memory if available, loads from disk if not (cold start recovery)
|
|
94
|
-
*
|
|
95
|
-
* @param fieldName - The indexed field name (e.g., 'email', 'age')
|
|
96
|
-
* @returns Index data or null if index doesn't exist
|
|
83
|
+
* Gets index data for a specific field.
|
|
84
|
+
* Returns from memory if available, loads from disk via streaming if not (cold start recovery).
|
|
97
85
|
*/
|
|
98
86
|
getIndex(fieldName: string): Promise<IndexData | null>;
|
|
99
87
|
/**
|
|
100
|
-
* Updates an index in both memory and disk atomically
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* @param fieldName - The indexed field name
|
|
104
|
-
* @param indexData - The updated index data
|
|
105
|
-
* @returns True if update successful, false otherwise
|
|
88
|
+
* Updates an index in both memory and disk atomically.
|
|
89
|
+
* Writes in JSONL format.
|
|
106
90
|
*/
|
|
107
91
|
updateIndex(fieldName: string, indexData: IndexData): Promise<boolean>;
|
|
108
92
|
/**
|
|
109
|
-
* Invalidates a specific index (removes from memory)
|
|
110
|
-
* Disk copy remains for persistence and recovery
|
|
111
|
-
*
|
|
112
|
-
* @param fieldName - The indexed field name to invalidate
|
|
93
|
+
* Invalidates a specific index (removes from memory).
|
|
113
94
|
*/
|
|
114
95
|
invalidateIndex(fieldName: string): Promise<void>;
|
|
115
96
|
/**
|
|
116
|
-
* Invalidates all indexes (removes all from memory)
|
|
117
|
-
* Used when indexes are dropped or collection is cleared
|
|
118
|
-
* Disk copies remain for recovery
|
|
97
|
+
* Invalidates all indexes (removes all from memory).
|
|
119
98
|
*/
|
|
120
99
|
invalidateAll(): Promise<void>;
|
|
121
100
|
/**
|
|
122
|
-
* Acquires a per-field mutex
|
|
123
|
-
*
|
|
124
|
-
* Implemented as a chained promise queue: each call captures the current tail of the
|
|
125
|
-
* chain, awaits it (so it truly blocks until every earlier holder has released), then
|
|
126
|
-
* appends its own pending promise as the new tail. The caller MUST invoke the returned
|
|
127
|
-
* release function exactly once (typically in a `finally` block) to hand the lock to
|
|
128
|
-
* the next queued waiter.
|
|
129
|
-
*
|
|
130
|
-
* @param key - The lock key (typically field name)
|
|
131
|
-
* @returns A release function that unblocks the next waiter for this key
|
|
132
|
-
* @private
|
|
101
|
+
* Acquires a per-field mutex.
|
|
133
102
|
*/
|
|
134
103
|
private acquireLock;
|
|
135
104
|
/**
|
|
136
|
-
* Gets current cache statistics for monitoring
|
|
137
|
-
*
|
|
138
|
-
* @returns Object containing cache size and loaded index count
|
|
105
|
+
* Gets current cache statistics for monitoring.
|
|
139
106
|
*/
|
|
140
107
|
getCacheStats(): {
|
|
141
108
|
indexCount: number;
|
|
@@ -18,20 +18,21 @@ exports.IndexCache = void 0;
|
|
|
18
18
|
const Keys_1 = require("../../config/Keys/Keys");
|
|
19
19
|
const FileManager_1 = __importDefault(require("../../engine/Filesystem/FileManager"));
|
|
20
20
|
const Converter_helper_1 = __importDefault(require("../../Helper/Converter.helper"));
|
|
21
|
+
const Index_service_1 = require("./Index.service");
|
|
21
22
|
/**
|
|
22
23
|
* In-memory cache for index data
|
|
23
24
|
*
|
|
24
25
|
* Features:
|
|
25
26
|
* - Eagerly loads all indexes on collection initialization
|
|
26
|
-
* - Keeps indexes in both memory (speed) and disk (persistence)
|
|
27
|
-
* - Cold start recovery:
|
|
27
|
+
* - Keeps indexes in both memory (speed) and disk (persistence) as JSONL
|
|
28
|
+
* - Cold start recovery: Streams from disk on cache miss
|
|
28
29
|
* - Thread-safe with simple lock mechanism
|
|
29
30
|
* - Dual-write: Updates both memory and disk atomically
|
|
30
31
|
*
|
|
31
32
|
* @example
|
|
32
33
|
* ```typescript
|
|
33
34
|
* const indexCache = IndexCache.getInstance('/path/to/collection');
|
|
34
|
-
* await indexCache.loadAllIndexes(); // Eager load
|
|
35
|
+
* await indexCache.loadAllIndexes(); // Eager load (streamed)
|
|
35
36
|
* const indexData = await indexCache.getIndex('email'); // O(1) memory access
|
|
36
37
|
* ```
|
|
37
38
|
*/
|
|
@@ -40,7 +41,7 @@ class IndexCache {
|
|
|
40
41
|
this.cleanupInterval = null;
|
|
41
42
|
this.cache = new Map();
|
|
42
43
|
this.indexFolderPath = `${collectionPath}/indexes`;
|
|
43
|
-
this.indexMetaPath = `${this.indexFolderPath}
|
|
44
|
+
this.indexMetaPath = `${this.indexFolderPath}/${Keys_1.General.Index_Meta_File}`;
|
|
44
45
|
this.fileManager = new FileManager_1.default();
|
|
45
46
|
this.converter = new Converter_helper_1.default();
|
|
46
47
|
this.lockChains = new Map();
|
|
@@ -48,11 +49,6 @@ class IndexCache {
|
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
51
|
* Returns the shared IndexCache for a collection path, creating it on first use.
|
|
51
|
-
* All index services (Insert/Read/Delete/Collection) must go through this instead of
|
|
52
|
-
* constructing their own instance, otherwise locking and caching are per-call and
|
|
53
|
-
* provide no real coordination.
|
|
54
|
-
*
|
|
55
|
-
* @param collectionPath - Absolute path of the collection this cache belongs to
|
|
56
52
|
*/
|
|
57
53
|
static getInstance(collectionPath) {
|
|
58
54
|
let instance = IndexCache.instances.get(collectionPath);
|
|
@@ -63,10 +59,7 @@ class IndexCache {
|
|
|
63
59
|
return instance;
|
|
64
60
|
}
|
|
65
61
|
/**
|
|
66
|
-
* Releases the shared IndexCache for a collection path
|
|
67
|
-
* itself is deleted), stopping its cleanup timer and dropping it from the registry.
|
|
68
|
-
*
|
|
69
|
-
* @param collectionPath - Absolute path of the collection whose cache should be released
|
|
62
|
+
* Releases the shared IndexCache for a collection path.
|
|
70
63
|
*/
|
|
71
64
|
static releaseInstance(collectionPath) {
|
|
72
65
|
const instance = IndexCache.instances.get(collectionPath);
|
|
@@ -76,7 +69,7 @@ class IndexCache {
|
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
71
|
/**
|
|
79
|
-
* Stops the cleanup timer and clears cached state.
|
|
72
|
+
* Stops the cleanup timer and clears cached state.
|
|
80
73
|
*/
|
|
81
74
|
dispose() {
|
|
82
75
|
if (this.cleanupInterval) {
|
|
@@ -87,14 +80,13 @@ class IndexCache {
|
|
|
87
80
|
this.lockChains.clear();
|
|
88
81
|
}
|
|
89
82
|
/**
|
|
90
|
-
* Generates a random TTL between 5-15 minutes
|
|
91
|
-
* Randomization prevents cache stampede (thundering herd problem)
|
|
83
|
+
* Generates a random TTL between 5-15 minutes.
|
|
92
84
|
*/
|
|
93
85
|
generateRandomTTL() {
|
|
94
86
|
return Math.floor(Math.random() * (IndexCache.MAX_TTL_MS - IndexCache.MIN_TTL_MS + 1) + IndexCache.MIN_TTL_MS);
|
|
95
87
|
}
|
|
96
88
|
/**
|
|
97
|
-
* Starts periodic cleanup of expired cache entries
|
|
89
|
+
* Starts periodic cleanup of expired cache entries.
|
|
98
90
|
*/
|
|
99
91
|
startCleanupInterval() {
|
|
100
92
|
if (this.cleanupInterval)
|
|
@@ -102,13 +94,12 @@ class IndexCache {
|
|
|
102
94
|
this.cleanupInterval = setInterval(() => {
|
|
103
95
|
this.cleanupExpiredEntries();
|
|
104
96
|
}, IndexCache.CLEANUP_INTERVAL_MS);
|
|
105
|
-
// Ensure cleanup doesn't prevent process exit
|
|
106
97
|
if (this.cleanupInterval.unref) {
|
|
107
98
|
this.cleanupInterval.unref();
|
|
108
99
|
}
|
|
109
100
|
}
|
|
110
101
|
/**
|
|
111
|
-
* Removes all expired entries from cache
|
|
102
|
+
* Removes all expired entries from cache.
|
|
112
103
|
*/
|
|
113
104
|
cleanupExpiredEntries() {
|
|
114
105
|
const now = Date.now();
|
|
@@ -119,39 +110,36 @@ class IndexCache {
|
|
|
119
110
|
}
|
|
120
111
|
}
|
|
121
112
|
/**
|
|
122
|
-
* Checks if a cached entry is expired
|
|
113
|
+
* Checks if a cached entry is expired.
|
|
123
114
|
*/
|
|
124
115
|
isExpired(cached) {
|
|
125
116
|
return Date.now() >= cached.expiresAt;
|
|
126
117
|
}
|
|
127
118
|
/**
|
|
128
|
-
* Eagerly loads all indexes into memory
|
|
129
|
-
* Called during collection initialization for maximum query performance
|
|
119
|
+
* Eagerly loads all indexes into memory using streaming reads.
|
|
120
|
+
* Called during collection initialization for maximum query performance.
|
|
130
121
|
*
|
|
131
122
|
* @returns Promise that resolves when all indexes are loaded
|
|
132
123
|
*/
|
|
133
124
|
loadAllIndexes() {
|
|
134
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
135
126
|
try {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (!metaExists.status) {
|
|
139
|
-
return; // No indexes created yet
|
|
140
|
-
}
|
|
141
|
-
// Read index metadata file
|
|
142
|
-
const metaContent = yield this.fileManager.ReadFile(this.indexMetaPath);
|
|
143
|
-
if (!metaContent.status) {
|
|
127
|
+
const metaLines = yield this.fileManager.ReadLines(this.indexMetaPath);
|
|
128
|
+
if (metaLines.length === 0)
|
|
144
129
|
return;
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
// Load each index file into memory in parallel
|
|
148
|
-
const loadPromises = indexMeta.map((meta) => __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
// Load each index file in parallel
|
|
131
|
+
const loadPromises = metaLines.map((line) => __awaiter(this, void 0, void 0, function* () {
|
|
149
132
|
try {
|
|
133
|
+
const meta = this.converter.ToObject(line);
|
|
150
134
|
const indexPath = meta.path;
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
135
|
+
const fieldName = meta.indexFieldName;
|
|
136
|
+
// Stream the JSONL index file line-by-line
|
|
137
|
+
const indexLines = yield this.fileManager.ReadLines(indexPath);
|
|
138
|
+
if (indexLines.length === 0)
|
|
139
|
+
return;
|
|
140
|
+
const indexData = Index_service_1.IndexManager.deserializeIndexData(indexLines);
|
|
141
|
+
if (indexData) {
|
|
142
|
+
this.cache.set(fieldName, {
|
|
155
143
|
data: indexData,
|
|
156
144
|
loadedAt: new Date(),
|
|
157
145
|
expiresAt: Date.now() + this.generateRandomTTL(),
|
|
@@ -161,46 +149,40 @@ class IndexCache {
|
|
|
161
149
|
}
|
|
162
150
|
catch (error) {
|
|
163
151
|
// Silent per-index failure - continue loading other indexes
|
|
164
|
-
console.error(`Failed to load index ${
|
|
152
|
+
console.error(`Failed to load index ${line}:`, error);
|
|
165
153
|
}
|
|
166
154
|
}));
|
|
167
155
|
yield Promise.all(loadPromises);
|
|
168
156
|
}
|
|
169
157
|
catch (error) {
|
|
170
|
-
// Silent failure - indexes will load from disk on demand (cold start recovery)
|
|
171
158
|
console.error("Failed to load indexes into memory:", error);
|
|
172
159
|
}
|
|
173
160
|
});
|
|
174
161
|
}
|
|
175
162
|
/**
|
|
176
|
-
* Gets index data for a specific field
|
|
177
|
-
* Returns from memory if available, loads from disk if not (cold start recovery)
|
|
178
|
-
*
|
|
179
|
-
* @param fieldName - The indexed field name (e.g., 'email', 'age')
|
|
180
|
-
* @returns Index data or null if index doesn't exist
|
|
163
|
+
* Gets index data for a specific field.
|
|
164
|
+
* Returns from memory if available, loads from disk via streaming if not (cold start recovery).
|
|
181
165
|
*/
|
|
182
166
|
getIndex(fieldName) {
|
|
183
167
|
return __awaiter(this, void 0, void 0, function* () {
|
|
184
168
|
// Try memory cache first (O(1) fast path)
|
|
185
169
|
const cached = this.cache.get(fieldName);
|
|
186
170
|
if (cached) {
|
|
187
|
-
// Check if entry is expired
|
|
188
171
|
if (this.isExpired(cached)) {
|
|
189
172
|
this.cache.delete(fieldName);
|
|
190
|
-
// Fall through to reload from disk
|
|
191
173
|
}
|
|
192
174
|
else {
|
|
193
175
|
return cached.data;
|
|
194
176
|
}
|
|
195
177
|
}
|
|
196
|
-
// Cache miss or expired -
|
|
178
|
+
// Cache miss or expired - stream from disk (cold start recovery)
|
|
197
179
|
try {
|
|
198
|
-
const indexPath = `${this.indexFolderPath}/${fieldName}${Keys_1.General.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
180
|
+
const indexPath = `${this.indexFolderPath}/${fieldName}${Keys_1.General.Index_File_EXT}`;
|
|
181
|
+
// Attempt streaming read first (JSONL)
|
|
182
|
+
const lines = yield this.fileManager.ReadLines(indexPath);
|
|
183
|
+
if (lines.length > 0) {
|
|
184
|
+
const indexData = Index_service_1.IndexManager.deserializeIndexData(lines);
|
|
185
|
+
if (indexData) {
|
|
204
186
|
this.cache.set(fieldName, {
|
|
205
187
|
data: indexData,
|
|
206
188
|
loadedAt: new Date(),
|
|
@@ -209,35 +191,25 @@ class IndexCache {
|
|
|
209
191
|
});
|
|
210
192
|
return indexData;
|
|
211
193
|
}
|
|
212
|
-
catch (parseError) {
|
|
213
|
-
// JSON parse failed - index file may be corrupted, return null
|
|
214
|
-
console.error(`Index file corrupted for ${fieldName}, skipping cache`);
|
|
215
|
-
return null;
|
|
216
|
-
}
|
|
217
194
|
}
|
|
195
|
+
// Streaming read failed — index file may not exist (normal for unindexed fields)
|
|
218
196
|
}
|
|
219
|
-
catch (
|
|
220
|
-
// Index doesn't exist - this is normal for unindexed fields
|
|
221
|
-
}
|
|
197
|
+
catch (_a) { /* index doesn't exist */ }
|
|
222
198
|
return null;
|
|
223
199
|
});
|
|
224
200
|
}
|
|
225
201
|
/**
|
|
226
|
-
* Updates an index in both memory and disk atomically
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* @param fieldName - The indexed field name
|
|
230
|
-
* @param indexData - The updated index data
|
|
231
|
-
* @returns True if update successful, false otherwise
|
|
202
|
+
* Updates an index in both memory and disk atomically.
|
|
203
|
+
* Writes in JSONL format.
|
|
232
204
|
*/
|
|
233
205
|
updateIndex(fieldName, indexData) {
|
|
234
206
|
return __awaiter(this, void 0, void 0, function* () {
|
|
235
|
-
// Acquire lock for this field to prevent concurrent writes
|
|
236
207
|
const release = yield this.acquireLock(fieldName);
|
|
237
208
|
try {
|
|
238
|
-
const indexPath = `${this.indexFolderPath}/${fieldName}${Keys_1.General.
|
|
239
|
-
// Write to disk first for durability (
|
|
240
|
-
const
|
|
209
|
+
const indexPath = `${this.indexFolderPath}/${fieldName}${Keys_1.General.Index_File_EXT}`;
|
|
210
|
+
// Write to disk first for durability (JSONL format)
|
|
211
|
+
const jsonlContent = Index_service_1.IndexManager.serializeIndexData(indexData);
|
|
212
|
+
const writeResult = yield this.fileManager.WriteFile(indexPath, jsonlContent);
|
|
241
213
|
if (!writeResult.status) {
|
|
242
214
|
return false;
|
|
243
215
|
}
|
|
@@ -256,10 +228,7 @@ class IndexCache {
|
|
|
256
228
|
});
|
|
257
229
|
}
|
|
258
230
|
/**
|
|
259
|
-
* Invalidates a specific index (removes from memory)
|
|
260
|
-
* Disk copy remains for persistence and recovery
|
|
261
|
-
*
|
|
262
|
-
* @param fieldName - The indexed field name to invalidate
|
|
231
|
+
* Invalidates a specific index (removes from memory).
|
|
263
232
|
*/
|
|
264
233
|
invalidateIndex(fieldName) {
|
|
265
234
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -267,9 +236,7 @@ class IndexCache {
|
|
|
267
236
|
});
|
|
268
237
|
}
|
|
269
238
|
/**
|
|
270
|
-
* Invalidates all indexes (removes all from memory)
|
|
271
|
-
* Used when indexes are dropped or collection is cleared
|
|
272
|
-
* Disk copies remain for recovery
|
|
239
|
+
* Invalidates all indexes (removes all from memory).
|
|
273
240
|
*/
|
|
274
241
|
invalidateAll() {
|
|
275
242
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -277,17 +244,7 @@ class IndexCache {
|
|
|
277
244
|
});
|
|
278
245
|
}
|
|
279
246
|
/**
|
|
280
|
-
* Acquires a per-field mutex
|
|
281
|
-
*
|
|
282
|
-
* Implemented as a chained promise queue: each call captures the current tail of the
|
|
283
|
-
* chain, awaits it (so it truly blocks until every earlier holder has released), then
|
|
284
|
-
* appends its own pending promise as the new tail. The caller MUST invoke the returned
|
|
285
|
-
* release function exactly once (typically in a `finally` block) to hand the lock to
|
|
286
|
-
* the next queued waiter.
|
|
287
|
-
*
|
|
288
|
-
* @param key - The lock key (typically field name)
|
|
289
|
-
* @returns A release function that unblocks the next waiter for this key
|
|
290
|
-
* @private
|
|
247
|
+
* Acquires a per-field mutex.
|
|
291
248
|
*/
|
|
292
249
|
acquireLock(key) {
|
|
293
250
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -303,9 +260,7 @@ class IndexCache {
|
|
|
303
260
|
});
|
|
304
261
|
}
|
|
305
262
|
/**
|
|
306
|
-
* Gets current cache statistics for monitoring
|
|
307
|
-
*
|
|
308
|
-
* @returns Object containing cache size and loaded index count
|
|
263
|
+
* Gets current cache statistics for monitoring.
|
|
309
264
|
*/
|
|
310
265
|
getCacheStats() {
|
|
311
266
|
return {
|
|
@@ -316,8 +271,6 @@ class IndexCache {
|
|
|
316
271
|
}
|
|
317
272
|
exports.IndexCache = IndexCache;
|
|
318
273
|
// One IndexCache per collection path - shared across Insert/Read/Delete/Collection
|
|
319
|
-
// so the lock and the memory cache actually serialize/coordinate across operations
|
|
320
|
-
// instead of each call site racing on its own private state.
|
|
321
274
|
IndexCache.instances = new Map();
|
|
322
275
|
// TTL constants (5-15 minutes in milliseconds)
|
|
323
276
|
IndexCache.MIN_TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexCache.service.js","sourceRoot":"","sources":["../../../source/Services/Index/IndexCache.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAAsD;AACtD,uDAAuD;AACvD,iDAAiD;AACjD,sFAA8D;AAC9D,qFAAsD;
|
|
1
|
+
{"version":3,"file":"IndexCache.service.js","sourceRoot":"","sources":["../../../source/Services/Index/IndexCache.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAAsD;AACtD,uDAAuD;AACvD,iDAAiD;AACjD,sFAA8D;AAC9D,qFAAsD;AACtD,mDAA+C;AA2B/C;;;;;;;;;;;;;;;;GAgBG;AACH;IAiBE,YAAoB,cAAsB;QAPlC,oBAAe,GAA0C,IAAI,CAAC;QAQpE,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,eAAe,GAAG,GAAG,cAAc,UAAU,CAAC;QACnD,IAAI,CAAC,aAAa,GAAG,GAAG,IAAI,CAAC,eAAe,IAAI,cAAO,CAAC,eAAe,EAAE,CAAC;QAC1E,IAAI,CAAC,WAAW,GAAG,IAAI,qBAAW,EAAE,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,WAAW,CAAC,cAAsB;QAC9C,IAAI,QAAQ,GAAG,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,QAAQ,GAAG,IAAI,UAAU,CAAC,cAAc,CAAC,CAAC;YAC1C,UAAU,CAAC,SAAS,CAA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,aAAa;AAC3C,8BAAmB,GAAG,EAAE,GAAG,IAAI,AAAZ,CAAa,CAAC,uBAAuB"}
|
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ReadIndex = void 0;
|
|
16
16
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
17
|
+
const Keys_1 = require("../../config/Keys/Keys");
|
|
17
18
|
const Index_service_1 = require("./Index.service");
|
|
18
19
|
const IndexCache_service_1 = require("./IndexCache.service");
|
|
19
20
|
const SortedIndexValues_helper_1 = __importDefault(require("../../Helper/SortedIndexValues.helper"));
|
|
@@ -61,15 +62,22 @@ class ReadIndex extends Index_service_1.IndexManager {
|
|
|
61
62
|
const finalValueFiles = indexData.indexEntries[queryValue];
|
|
62
63
|
return finalValueFiles || [];
|
|
63
64
|
}
|
|
64
|
-
// Cache miss - fall back to disk read (cold start recovery)
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
// Cache miss - fall back to disk read (cold start recovery), stream JSONL
|
|
66
|
+
const indexPath = `${this.indexFolderPath}/${matchedIndexFile.indexFieldName}${Keys_1.General.Index_File_EXT}`;
|
|
67
|
+
try {
|
|
68
|
+
const lines = yield this.fileManager.ReadLines(indexPath);
|
|
69
|
+
const indexData = Index_service_1.IndexManager.deserializeIndexData(lines);
|
|
70
|
+
if (indexData) {
|
|
71
|
+
const queryValue = query[indexData.fieldName];
|
|
72
|
+
if (typeof queryValue === 'object' && queryValue !== null) {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
const finalValueFiles = indexData.indexEntries[queryValue];
|
|
76
|
+
return finalValueFiles || [];
|
|
77
|
+
}
|
|
70
78
|
}
|
|
71
|
-
|
|
72
|
-
return
|
|
79
|
+
catch (_a) { /* stream failed */ }
|
|
80
|
+
return [];
|
|
73
81
|
}
|
|
74
82
|
else {
|
|
75
83
|
return [];
|
|
@@ -213,11 +221,11 @@ class ReadIndex extends Index_service_1.IndexManager {
|
|
|
213
221
|
*/
|
|
214
222
|
findMatchingIndexMeta(document) {
|
|
215
223
|
return __awaiter(this, void 0, void 0, function* () {
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
224
|
+
const lines = yield this.fileManager.ReadLines(this.indexMetaPath);
|
|
225
|
+
if (lines.length === 0)
|
|
226
|
+
return undefined;
|
|
227
|
+
const entries = lines.map(line => this.converter.ToObject(line));
|
|
228
|
+
return entries.find((meta) => Object.prototype.hasOwnProperty.call(document, meta.indexFieldName));
|
|
221
229
|
});
|
|
222
230
|
}
|
|
223
231
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadIndex.service.js","sourceRoot":"","sources":["../../../source/Services/Index/ReadIndex.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,mDAA+C;AAC/C,6DAAkD;AAClD,qGAAsE;AAEtE,eAAuB,SAAQ,4BAAY;IAGzC,YAAa,IAAY;QACvB,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,UAAU,GAAG,+BAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACU,gBAAgB,CAAE,KAAU;;YACvC,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;YACjE,IAAG,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBAClC,oEAAoE;gBACpE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;gBAElF,IAAI,SAAS,EAAE,CAAC;oBACd,2CAA2C;oBAC3C,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,SAAS,CA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,OAAO,CAAC,IAAI,CAAC,CAAC,IAA8B,EAAE,EAAE,CACrD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,CACpE,CAAC;QACJ,CAAC;KAAA;CACF"}
|
|
@@ -145,7 +145,7 @@ class Transaction {
|
|
|
145
145
|
if (!data || typeof data !== 'object') {
|
|
146
146
|
throw new Error("Data must be a valid object");
|
|
147
147
|
}
|
|
148
|
-
const documentId = new UniqueGenerator_helper_1.default(
|
|
148
|
+
const documentId = new UniqueGenerator_helper_1.default(Keys_1.General.DocumentId_Length).RandomWord(true, true);
|
|
149
149
|
const operation = {
|
|
150
150
|
type: 'INSERT',
|
|
151
151
|
documentId,
|
|
@@ -317,7 +317,7 @@ class Transaction {
|
|
|
317
317
|
let documentId = op.documentId;
|
|
318
318
|
let filePath = `${this.collectionPath}/${documentId}${Keys_1.General.DBMS_File_EXT}`;
|
|
319
319
|
while ((yield this.FileManager.FileExists(filePath)).status) {
|
|
320
|
-
documentId = new UniqueGenerator_helper_1.default(
|
|
320
|
+
documentId = new UniqueGenerator_helper_1.default(Keys_1.General.DocumentId_Length).RandomWord(true, true);
|
|
321
321
|
filePath = `${this.collectionPath}/${documentId}${Keys_1.General.DBMS_File_EXT}`;
|
|
322
322
|
}
|
|
323
323
|
if (documentId !== op.documentId) {
|