@ragestudio/scylla-odm 0.22.2 → 0.22.4
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/batch/index.d.ts +3 -3
- package/batch/index.d.ts.map +1 -1
- package/client.d.ts +6 -5
- package/client.d.ts.map +1 -1
- package/client.js +11 -12
- package/client.js.map +1 -1
- package/cql_gen/create_table.d.ts +1 -1
- package/cql_gen/create_table.d.ts.map +1 -1
- package/document/index.d.ts +3 -3
- package/document/index.d.ts.map +1 -1
- package/driver/LICENSE.txt +177 -0
- package/driver/NOTICE.txt +67 -0
- package/driver/auth/index.d.ts +37 -0
- package/driver/auth/index.js +37 -0
- package/driver/auth/no-auth-provider.js +73 -0
- package/driver/auth/plain-text-auth-provider.js +81 -0
- package/driver/auth/provider.js +77 -0
- package/driver/client-options.js +442 -0
- package/driver/client.js +1267 -0
- package/driver/concurrent/index.d.ts +49 -0
- package/driver/concurrent/index.js +366 -0
- package/driver/connection.js +1034 -0
- package/driver/control-connection.js +1282 -0
- package/driver/encoder.js +2316 -0
- package/driver/errors.js +223 -0
- package/driver/execution-options.js +612 -0
- package/driver/execution-profile.js +274 -0
- package/driver/host-connection-pool.js +587 -0
- package/driver/host.js +699 -0
- package/driver/index.d.ts +387 -0
- package/driver/index.js +81 -0
- package/driver/mapping/cache.js +214 -0
- package/driver/mapping/doc-info-adapter.js +171 -0
- package/driver/mapping/index.d.ts +219 -0
- package/driver/mapping/index.js +57 -0
- package/driver/mapping/mapper.js +225 -0
- package/driver/mapping/mapping-handler.js +641 -0
- package/driver/mapping/model-batch-item.js +215 -0
- package/driver/mapping/model-batch-mapper.js +141 -0
- package/driver/mapping/model-mapper.js +315 -0
- package/driver/mapping/model-mapping-info.js +225 -0
- package/driver/mapping/object-selector.js +417 -0
- package/driver/mapping/q.js +156 -0
- package/driver/mapping/query-generator.js +556 -0
- package/driver/mapping/result-mapper.js +123 -0
- package/driver/mapping/result.js +139 -0
- package/driver/mapping/table-mappings.js +133 -0
- package/driver/mapping/tree.js +160 -0
- package/driver/metadata/aggregate.js +79 -0
- package/driver/metadata/client-state.js +119 -0
- package/driver/metadata/data-collection.js +182 -0
- package/driver/metadata/event-debouncer.js +174 -0
- package/driver/metadata/index.d.ts +276 -0
- package/driver/metadata/index.js +1156 -0
- package/driver/metadata/materialized-view.js +49 -0
- package/driver/metadata/schema-function.js +98 -0
- package/driver/metadata/schema-index.js +166 -0
- package/driver/metadata/schema-parser.js +1399 -0
- package/driver/metadata/table-metadata.js +77 -0
- package/driver/operation-state.js +206 -0
- package/driver/policies/address-resolution.js +145 -0
- package/driver/policies/index.d.ts +241 -0
- package/driver/policies/index.js +110 -0
- package/driver/policies/load-balancing.js +970 -0
- package/driver/policies/reconnection.js +166 -0
- package/driver/policies/retry.js +326 -0
- package/driver/policies/speculative-execution.js +150 -0
- package/driver/policies/timestamp-generation.js +176 -0
- package/driver/prepare-handler.js +347 -0
- package/driver/promise-utils.js +191 -0
- package/driver/readers.js +624 -0
- package/driver/request-execution.js +644 -0
- package/driver/request-handler.js +332 -0
- package/driver/requests.js +618 -0
- package/driver/stream-id-stack.js +209 -0
- package/driver/streams.js +745 -0
- package/driver/token.js +325 -0
- package/driver/tokenizer.js +631 -0
- package/driver/types/big-decimal.js +282 -0
- package/driver/types/duration.js +576 -0
- package/driver/types/index.d.ts +486 -0
- package/driver/types/index.js +733 -0
- package/driver/types/inet-address.js +262 -0
- package/driver/types/integer.js +818 -0
- package/driver/types/local-date.js +280 -0
- package/driver/types/local-time.js +299 -0
- package/driver/types/mutable-long.js +385 -0
- package/driver/types/protocol-version.js +391 -0
- package/driver/types/result-set.js +287 -0
- package/driver/types/result-stream.js +164 -0
- package/driver/types/row.js +85 -0
- package/driver/types/time-uuid.js +414 -0
- package/driver/types/tuple.js +103 -0
- package/driver/types/uuid.js +160 -0
- package/driver/types/vector.js +130 -0
- package/driver/types/version-number.js +153 -0
- package/driver/utils.js +1485 -0
- package/driver/writers.js +350 -0
- package/global.d.ts +1 -1
- package/global.d.ts.map +1 -1
- package/index.d.ts +6 -6
- package/index.d.ts.map +1 -1
- package/index.js +6 -6
- package/index.js.map +1 -1
- package/migrate/index.d.ts +1 -1
- package/migrate/index.d.ts.map +1 -1
- package/migrate/index.js +1 -1
- package/migrate/index.js.map +1 -1
- package/model/index.d.ts +6 -6
- package/model/index.d.ts.map +1 -1
- package/model/index.js +10 -10
- package/model/index.js.map +1 -1
- package/operations/countAll.d.ts +1 -1
- package/operations/countAll.d.ts.map +1 -1
- package/operations/delete.d.ts +3 -4
- package/operations/delete.d.ts.map +1 -1
- package/operations/delete.js +1 -1
- package/operations/delete.js.map +1 -1
- package/operations/find.d.ts +2 -2
- package/operations/find.d.ts.map +1 -1
- package/operations/find.js +1 -1
- package/operations/find.js.map +1 -1
- package/operations/findOne.d.ts +2 -2
- package/operations/findOne.d.ts.map +1 -1
- package/operations/findOne.js +1 -1
- package/operations/findOne.js.map +1 -1
- package/operations/insert.d.ts +3 -3
- package/operations/insert.d.ts.map +1 -1
- package/operations/insert.js +2 -2
- package/operations/insert.js.map +1 -1
- package/operations/sync.d.ts +1 -1
- package/operations/sync.d.ts.map +1 -1
- package/operations/sync.js +1 -1
- package/operations/sync.js.map +1 -1
- package/operations/tableExists.d.ts +1 -1
- package/operations/tableExists.d.ts.map +1 -1
- package/operations/update.d.ts +3 -3
- package/operations/update.d.ts.map +1 -1
- package/operations/update.js +2 -2
- package/operations/update.js.map +1 -1
- package/package.json +4 -12
- package/schema/index.d.ts +1 -1
- package/schema/index.d.ts.map +1 -1
- package/types.d.ts +4 -4
- package/types.d.ts.map +1 -1
- package/utils/queryParser.d.ts +1 -1
- package/utils/queryParser.d.ts.map +1 -1
- package/utils/queryParser.js +1 -1
- package/utils/queryParser.js.map +1 -1
- package/utils/typeChecker.d.ts +1 -1
- package/utils/typeChecker.d.ts.map +1 -1
- package/utils/typeChecker.js +1 -1
- package/utils/typeChecker.js.map +1 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import types from "./types/index.js"
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Group size
|
|
22
|
+
* @type {number}
|
|
23
|
+
*/
|
|
24
|
+
const groupSize = 128
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Number used to right shift ids to allocate them into groups
|
|
28
|
+
* @const
|
|
29
|
+
* @type {number}
|
|
30
|
+
*/
|
|
31
|
+
const shiftToGroup = 7
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Amount of groups that can be released per time
|
|
35
|
+
* If it grows larger than 4 groups (128 * 4), groups can be released
|
|
36
|
+
* @const
|
|
37
|
+
* @type {number}
|
|
38
|
+
*/
|
|
39
|
+
const releasableSize = 4
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 32K possible stream ids depending for protocol v3 and above
|
|
43
|
+
* @const
|
|
44
|
+
* @type {number}
|
|
45
|
+
*/
|
|
46
|
+
const maxGroupsFor2Bytes = 256
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Delay used to check if groups can be released
|
|
50
|
+
* @const
|
|
51
|
+
* @type {number}
|
|
52
|
+
*/
|
|
53
|
+
const defaultReleaseDelay = 5000
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Represents a queue of ids from 0 to maximum stream id supported by the protocol version.
|
|
57
|
+
* Clients can dequeue a stream id using {@link StreamIdStack#shift()} and enqueue (release) using
|
|
58
|
+
* {@link StreamIdStack#push()}
|
|
59
|
+
*/
|
|
60
|
+
class StreamIdStack {
|
|
61
|
+
/**
|
|
62
|
+
* Creates a new instance of StreamIdStack.
|
|
63
|
+
* @param {number} version Protocol version
|
|
64
|
+
* @constructor
|
|
65
|
+
*/
|
|
66
|
+
constructor(version) {
|
|
67
|
+
//Ecmascript Number is 64-bit double, it can be optimized by the engine into a 32-bit int, but nothing below that.
|
|
68
|
+
//We try to allocate as few as possible in arrays of 128
|
|
69
|
+
this.currentGroup = generateGroup(0)
|
|
70
|
+
this.groupIndex = 0
|
|
71
|
+
this.groups = [this.currentGroup]
|
|
72
|
+
this.releaseTimeout = null
|
|
73
|
+
this.setVersion(version)
|
|
74
|
+
/**
|
|
75
|
+
* Returns the amount of ids currently in use
|
|
76
|
+
* @member {number}
|
|
77
|
+
*/
|
|
78
|
+
this.inUse = 0
|
|
79
|
+
this.releaseDelay = defaultReleaseDelay
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Sets the protocol version
|
|
84
|
+
* @param {Number} version
|
|
85
|
+
*/
|
|
86
|
+
setVersion(version) {
|
|
87
|
+
//128 or 32K stream ids depending on the protocol version
|
|
88
|
+
this.maxGroups = types.protocolVersion.uses2BytesStreamIds(version)
|
|
89
|
+
? maxGroupsFor2Bytes
|
|
90
|
+
: 1
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Dequeues an id.
|
|
95
|
+
* Similar to {@link Array#pop()}.
|
|
96
|
+
* @returns {Number} Returns an id or null
|
|
97
|
+
*/
|
|
98
|
+
pop() {
|
|
99
|
+
let id = this.currentGroup.pop()
|
|
100
|
+
if (typeof id !== "undefined") {
|
|
101
|
+
this.inUse++
|
|
102
|
+
return id
|
|
103
|
+
}
|
|
104
|
+
//try to use the following groups
|
|
105
|
+
while (this.groupIndex < this.groups.length - 1) {
|
|
106
|
+
//move to the following group
|
|
107
|
+
this.currentGroup = this.groups[++this.groupIndex]
|
|
108
|
+
//try dequeue
|
|
109
|
+
id = this.currentGroup.pop()
|
|
110
|
+
if (typeof id !== "undefined") {
|
|
111
|
+
this.inUse++
|
|
112
|
+
return id
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return this._tryCreateGroup()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Enqueue an id for future use.
|
|
120
|
+
* Similar to {@link Array#push()}.
|
|
121
|
+
* @param {Number} id
|
|
122
|
+
*/
|
|
123
|
+
push(id) {
|
|
124
|
+
this.inUse--
|
|
125
|
+
const groupIndex = id >> shiftToGroup
|
|
126
|
+
const group = this.groups[groupIndex]
|
|
127
|
+
group.push(id)
|
|
128
|
+
if (groupIndex < this.groupIndex) {
|
|
129
|
+
//Set the lower group to be used to dequeue from
|
|
130
|
+
this.groupIndex = groupIndex
|
|
131
|
+
this.currentGroup = group
|
|
132
|
+
}
|
|
133
|
+
this._tryIssueRelease()
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Clears all timers
|
|
138
|
+
*/
|
|
139
|
+
clear() {
|
|
140
|
+
if (this.releaseTimeout) {
|
|
141
|
+
clearTimeout(this.releaseTimeout)
|
|
142
|
+
this.releaseTimeout = null
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Tries to create an additional group and returns a new id
|
|
148
|
+
* @returns {Number} Returns a new id or null if it's not possible to create a new group
|
|
149
|
+
* @private
|
|
150
|
+
*/
|
|
151
|
+
_tryCreateGroup() {
|
|
152
|
+
if (this.groups.length === this.maxGroups) {
|
|
153
|
+
//we can have an additional group
|
|
154
|
+
return null
|
|
155
|
+
}
|
|
156
|
+
//Add a new group at the last position
|
|
157
|
+
this.groupIndex = this.groups.length
|
|
158
|
+
//Using 128 * groupIndex as initial value
|
|
159
|
+
this.currentGroup = generateGroup(this.groupIndex << shiftToGroup)
|
|
160
|
+
this.groups.push(this.currentGroup)
|
|
161
|
+
this.inUse++
|
|
162
|
+
return this.currentGroup.pop()
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
_tryIssueRelease() {
|
|
166
|
+
if (this.releaseTimeout || this.groups.length <= releasableSize) {
|
|
167
|
+
//Nothing to release or a release delay has been issued
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
this.releaseTimeout = setTimeout(
|
|
172
|
+
() => this._releaseGroups(),
|
|
173
|
+
this.releaseDelay,
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
_releaseGroups() {
|
|
178
|
+
let counter = 0
|
|
179
|
+
let index = this.groups.length - 1
|
|
180
|
+
//only release up to n groups (n = releasable size)
|
|
181
|
+
//shrink back up to n groups not all the way up to 1
|
|
182
|
+
while (
|
|
183
|
+
counter++ < releasableSize &&
|
|
184
|
+
this.groups.length > releasableSize &&
|
|
185
|
+
index > this.groupIndex
|
|
186
|
+
) {
|
|
187
|
+
if (this.groups[index].length !== groupSize) {
|
|
188
|
+
//the group is being used
|
|
189
|
+
break
|
|
190
|
+
}
|
|
191
|
+
this.groups.pop()
|
|
192
|
+
index--
|
|
193
|
+
}
|
|
194
|
+
this.releaseTimeout = null
|
|
195
|
+
//Issue next release if applies
|
|
196
|
+
this._tryIssueRelease()
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function generateGroup(initialValue) {
|
|
201
|
+
const arr = new Array(groupSize)
|
|
202
|
+
const upperBound = initialValue + groupSize - 1
|
|
203
|
+
for (let i = 0; i < groupSize; i++) {
|
|
204
|
+
arr[i] = upperBound - i
|
|
205
|
+
}
|
|
206
|
+
return arr
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export default StreamIdStack
|