@based/db 0.2.0 → 0.2.1

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.
Binary file
Binary file
@@ -55,7 +55,7 @@ export declare const VECTOR_DOT_PRODUCT = 0;
55
55
  export declare const VECTOR_MANHATTAN_DIST = 1;
56
56
  export declare const VECTOR_COSTINE_SIMILARITY = 2;
57
57
  export declare const VECTOR_EUCLIDEAN_DIST = 3;
58
- export declare const getVectorFn: (optsFn?: FilterOpts["fn"]) => 1 | 0 | 3 | 2;
58
+ export declare const getVectorFn: (optsFn?: FilterOpts["fn"]) => 1 | 0 | 2 | 3;
59
59
  export declare const toFilterCtx: (def: QueryDef, op: Operator, opts?: FilterOpts) => FilterCtx;
60
60
  export declare const operatorReverseMap: Record<OPERATOR, string>;
61
61
  export declare const ALIGNMENT_NOT_SET = 255;
@@ -20,8 +20,8 @@ export const startUpdateHandler = (server) => {
20
20
  if (markedIdSubs) {
21
21
  const buffer = new Uint8Array(markedIdSubs);
22
22
  for (let i = 0; i < buffer.byteLength; i += 8) {
23
- const subId = readUint32(buffer, i);
24
- const id = readUint32(buffer, i + 4);
23
+ const id = readUint32(buffer, i);
24
+ const subId = readUint32(buffer, i + 4);
25
25
  const subContainer = server.subscriptions.ids.get(subId);
26
26
  const ids = subContainer.ids.get(id);
27
27
  if (ids) {
@@ -92,11 +92,21 @@ const replaceNowValues = (query, now) => {
92
92
  writeInt64(query, dateNow + offset, byteIndex);
93
93
  }
94
94
  };
95
+ let total = 0;
96
+ let exectime = 0;
97
+ let int;
95
98
  export const registerSubscription = (server, query, sub, onData, onError, subInterval) => {
96
99
  // this can change dynamicly
97
100
  if (subInterval) {
98
101
  server.subscriptions.subInterval = subInterval;
99
102
  }
103
+ if (!int)
104
+ int = setInterval(() => {
105
+ console.log('EXECED', total, exectime / total, 'ms exec time');
106
+ if (server.stopped) {
107
+ clearInterval(int);
108
+ }
109
+ }, 1e3);
100
110
  let killed = false;
101
111
  // now maybe just once per second? (for now)
102
112
  if (server.subscriptions.active === 0) {
@@ -110,10 +120,13 @@ export const registerSubscription = (server, query, sub, onData, onError, subInt
110
120
  if (now) {
111
121
  replaceNowValues(query, now);
112
122
  }
123
+ let d = Date.now();
113
124
  server.getQueryBuf(query).then((res) => {
114
125
  if (killed) {
115
126
  return;
116
127
  }
128
+ total++;
129
+ exectime += Date.now() - d;
117
130
  if (res.byteLength >= 4) {
118
131
  onData(res);
119
132
  }
@@ -129,7 +142,7 @@ export const registerSubscription = (server, query, sub, onData, onError, subInt
129
142
  });
130
143
  }
131
144
  else {
132
- console.log('Allready fired block');
145
+ // console.log('Allready fired block')
133
146
  }
134
147
  };
135
148
  server.subscriptions.active++;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@based/db",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "main": "./dist/src/index.js",
6
6
  "scripts": {
@@ -42,9 +42,9 @@
42
42
  ],
43
43
  "dependencies": {
44
44
  "@based/hash": "1.1.0",
45
- "@based/schema": "5.1.0",
45
+ "@based/schema": "5.1.1",
46
46
  "@based/utils": "1.2.0",
47
- "@based/protocol": "0.1.0",
47
+ "@based/protocol": "0.1.1",
48
48
  "exit-hook": "^4.0.0"
49
49
  },
50
50
  "optionalDependencies": {