axiodb
Version:
A blazing-fast, lightweight, and scalable nodejs package based DBMS for modern application. Supports schemas, encryption, and advanced query capabilities.
34 lines • 1.26 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable @typescript-eslint/no-explicit-any */
const worker_threads_1 = require("worker_threads");
const Searcher_utils_1 = __importDefault(require("../../utility/Searcher.utils"));
const { chunk, query, aditionalFiled } = worker_threads_1.workerData;
const result = [];
let left = 0;
let right = chunk.length - 1;
while (left <= right) {
const indices = [];
for (let i = 0; i < 2 && left + i <= right; i++)
indices.push(left + i);
for (let i = 0; i < 2 && right - i > left + 1; i++)
indices.push(right - i);
for (const index of indices) {
const rawItem = chunk[index];
const item = aditionalFiled ? rawItem[aditionalFiled] : rawItem;
if (item !== undefined &&
item !== null &&
Searcher_utils_1.default.matchesQuery(item, query)) {
result.push(rawItem);
}
}
left += 2;
right -= 2;
}
if (worker_threads_1.parentPort) {
worker_threads_1.parentPort.postMessage(result);
}
//# sourceMappingURL=WorkerForSearch.engine.js.map