|
|
|
|
@ -72,7 +72,7 @@ app.get('/rangeQuery', (req, res) => {
|
|
|
|
|
if (parsedQueryPoint.length !== mtree.dimension)
|
|
|
|
|
return res.status(400).send('Query point has the wrong dimension');
|
|
|
|
|
|
|
|
|
|
console.time('mtreeRangeQuery');
|
|
|
|
|
/*console.time('mtreeRangeQuery');
|
|
|
|
|
const result = mtree.rangeQuery(parsedQueryPoint, parsedRadius);
|
|
|
|
|
console.timeEnd('mtreeRangeQuery');
|
|
|
|
|
//console.log(result.length);
|
|
|
|
|
@ -82,7 +82,21 @@ app.get('/rangeQuery', (req, res) => {
|
|
|
|
|
console.timeEnd('sequentialSearch');
|
|
|
|
|
//console.log(sequentialResult.length);
|
|
|
|
|
|
|
|
|
|
res.send(result);
|
|
|
|
|
res.send(result);*/
|
|
|
|
|
const start = performance.now();
|
|
|
|
|
const result = mtree.rangeQuery(parsedQueryPoint, parsedRadius);
|
|
|
|
|
const RangeQueryTime = performance.now() - start;
|
|
|
|
|
|
|
|
|
|
const start2 = performance.now();
|
|
|
|
|
const sequentialResult = points.filter(point => mtree.distanceFunction(point, parsedQueryPoint) <= parsedRadius);
|
|
|
|
|
const sequentialSearchTime = performance.now() - start2;
|
|
|
|
|
|
|
|
|
|
const timingResult = {
|
|
|
|
|
mtreeRangeQuery: RangeQueryTime,
|
|
|
|
|
sequentialSearch: sequentialSearchTime
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
res.send({ values: result, timingResult });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Perform a k-NN query on the MTree
|
|
|
|
|
@ -102,18 +116,20 @@ app.get('/kNNQuery', (req, res) => {
|
|
|
|
|
}
|
|
|
|
|
const kInt = parseInt(k, 10);
|
|
|
|
|
|
|
|
|
|
console.time('mtreeKNNQuery');
|
|
|
|
|
const start = performance.now();
|
|
|
|
|
const result = mtree.kNNQuery(parsedQueryPoint, kInt);
|
|
|
|
|
console.timeEnd('mtreeKNNQuery');
|
|
|
|
|
//console.log(result);
|
|
|
|
|
const mtreeKNNQueryTime = performance.now() - start;
|
|
|
|
|
|
|
|
|
|
console.time('sequentialSearch');
|
|
|
|
|
const start2 = performance.now();
|
|
|
|
|
const sequentialResult = points.sort((a, b) => mtree.distanceFunction(a, parsedQueryPoint) - mtree.distanceFunction(b, parsedQueryPoint)).slice(0, kInt);
|
|
|
|
|
console.timeEnd('sequentialSearch');
|
|
|
|
|
//const sequentialResultWithDistance = sequentialResult.map(point => ({point, distance: mtree.distanceFunction(point, parsedQueryPoint)}));
|
|
|
|
|
//console.log(sequentialResult);
|
|
|
|
|
const sequentialSearchTime = performance.now() - start2;
|
|
|
|
|
|
|
|
|
|
const timingResult = {
|
|
|
|
|
mtreeKNNQuery: mtreeKNNQueryTime,
|
|
|
|
|
sequentialSearch: sequentialSearchTime
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
res.send(result);
|
|
|
|
|
res.send({ values: result, timingResult });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Recreate the MTree with the given dimensions
|
|
|
|
|
|