@based/db 0.0.42 → 0.0.43
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/dist/lib/darwin_aarch64/libnode-v20.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v21.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v24.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/linux_aarch64/libnode-v20.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v21.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v24.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/libnode-v20.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v21.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v24.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/src/client/query/aggregates/aggregation.d.ts +1 -0
- package/dist/src/client/query/aggregates/aggregation.js +26 -0
- package/dist/src/client/query/toBuffer.js +4 -7
- package/dist/src/client/query/types.d.ts +2 -1
- package/dist/src/client/query/types.js +1 -0
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -3,3 +3,4 @@ import { AggregateType } from './types.js';
|
|
|
3
3
|
export declare const aggregateToBuffer: (aggregates: QueryDefAggregation) => Uint8Array;
|
|
4
4
|
export declare const groupBy: (def: QueryDef, field: string) => void;
|
|
5
5
|
export declare const addAggregate: (type: AggregateType, def: QueryDef, fields: (string | string[])[]) => void;
|
|
6
|
+
export declare const isRootCountOnly: (def: QueryDef, filterSize: number) => boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { writeUint16 } from '@saulx/utils';
|
|
2
|
+
import { QueryDefType } from '../types.js';
|
|
2
3
|
import { UINT32 } from '@based/schema/def';
|
|
3
4
|
import { aggregationFieldDoesNotExist } from '../validation.js';
|
|
4
5
|
export const aggregateToBuffer = (aggregates) => {
|
|
@@ -107,4 +108,29 @@ export const addAggregate = (type, def, fields) => {
|
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
};
|
|
111
|
+
export const isRootCountOnly = (def, filterSize) => {
|
|
112
|
+
if (filterSize != 0) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
if (def.type !== QueryDefType.Root) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
if (def.aggregate.groupBy) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
if (def.aggregate.aggregates.size !== 1) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
if (!def.aggregate.aggregates.has(255)) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
const aggs = def.aggregate.aggregates.get(255);
|
|
128
|
+
if (aggs.length !== 1) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
if (aggs[0].type !== 2 /* AggregateType.COUNT */) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
};
|
|
110
136
|
//# sourceMappingURL=aggregation.js.map
|
|
@@ -4,7 +4,7 @@ import { includeToBuffer } from './include/toBuffer.js';
|
|
|
4
4
|
import { filterToBuffer } from './query.js';
|
|
5
5
|
import { searchToBuffer } from './search/index.js';
|
|
6
6
|
import { ENCODER } from '@saulx/utils';
|
|
7
|
-
import { aggregateToBuffer } from './aggregates/aggregation.js';
|
|
7
|
+
import { aggregateToBuffer, isRootCountOnly } from './aggregates/aggregation.js';
|
|
8
8
|
const byteSize = (arr) => {
|
|
9
9
|
return arr.reduce((a, b) => {
|
|
10
10
|
return a + b.byteLength;
|
|
@@ -33,9 +33,6 @@ export function defToBuffer(db, def) {
|
|
|
33
33
|
edgesSize = byteSize(edges);
|
|
34
34
|
}
|
|
35
35
|
const size = (edges ? edgesSize + 3 : 0) + byteSize(include);
|
|
36
|
-
// ---------------------------------------
|
|
37
|
-
// move down and will handle size after store the size Var
|
|
38
|
-
// only for references | edges
|
|
39
36
|
if (def.aggregate) {
|
|
40
37
|
const aggregateSize = def.aggregate.size || 0;
|
|
41
38
|
if (aggregateSize === 0) {
|
|
@@ -43,7 +40,9 @@ export function defToBuffer(db, def) {
|
|
|
43
40
|
}
|
|
44
41
|
const filterSize = def.filter.size || 0;
|
|
45
42
|
const buf = new Uint8Array(16 + filterSize + aggregateSize);
|
|
46
|
-
buf[0] =
|
|
43
|
+
buf[0] = isRootCountOnly(def, filterSize)
|
|
44
|
+
? QueryType.aggregatesCountType
|
|
45
|
+
: QueryType.aggregates;
|
|
47
46
|
buf[1] = def.schema.idUint8[0];
|
|
48
47
|
buf[2] = def.schema.idUint8[1];
|
|
49
48
|
buf[3] = def.range.offset;
|
|
@@ -66,8 +65,6 @@ export function defToBuffer(db, def) {
|
|
|
66
65
|
result.push(buf);
|
|
67
66
|
// ignore this for now...
|
|
68
67
|
// result.push(...include)
|
|
69
|
-
// console.log('toBuffer > result: ', result)
|
|
70
|
-
// later this has to be a branch
|
|
71
68
|
return result;
|
|
72
69
|
}
|
|
73
70
|
if (def.type === QueryDefType.Root) {
|
|
@@ -5,6 +5,7 @@ export var QueryType;
|
|
|
5
5
|
QueryType[QueryType["default"] = 2] = "default";
|
|
6
6
|
QueryType[QueryType["alias"] = 3] = "alias";
|
|
7
7
|
QueryType[QueryType["aggregates"] = 4] = "aggregates";
|
|
8
|
+
QueryType[QueryType["aggregatesCountType"] = 5] = "aggregatesCountType";
|
|
8
9
|
})(QueryType || (QueryType = {}));
|
|
9
10
|
var QueryDefType;
|
|
10
11
|
(function (QueryDefType) {
|