MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / defineInstanceMembers

Function defineInstanceMembers

lib/encoder.js:156–1667  ·  view source on GitHub ↗

* Declares the privileged instance members. * @private

()

Source from the content-addressed store, hash-verified

154 * @private
155 */
156function defineInstanceMembers() {
157 /**
158 * Sets the protocol version and the encoding/decoding methods depending on the protocol version
159 * @param {Number} value
160 * @ignore
161 * @internal
162 */
163 this.setProtocolVersion = function (value) {
164 this.protocolVersion = value;
165 //Set the collection serialization based on the protocol version
166 this.decodeCollectionLength = decodeCollectionLengthV3;
167 this.getLengthBuffer = getLengthBufferV3;
168 this.collectionLengthSize = 4;
169 if (!types.protocolVersion.uses4BytesCollectionLength(this.protocolVersion)) {
170 this.decodeCollectionLength = decodeCollectionLengthV2;
171 this.getLengthBuffer = getLengthBufferV2;
172 this.collectionLengthSize = 2;
173 }
174 };
175
176 const customDecoders = {
177 [customTypeNames.duration]: decodeDuration,
178 [customTypeNames.lineString]: decodeLineString,
179 [customTypeNames.point]: decodePoint,
180 [customTypeNames.polygon]: decodePolygon,
181 [customTypeNames.dateRange]: decodeDateRange
182 };
183
184 const customEncoders = {
185 [customTypeNames.duration]: encodeDuration,
186 [customTypeNames.lineString]: encodeLineString,
187 [customTypeNames.point]: encodePoint,
188 [customTypeNames.polygon]: encodePolygon,
189 [customTypeNames.dateRange]: encodeDateRange
190 };
191
192 // Decoding methods
193 this.decodeBlob = function (bytes) {
194 return this.handleBuffer(bytes);
195 };
196
197 /**
198 *
199 * @param {Buffer} bytes
200 * @param {OtherCustomColumnInfo | VectorColumnInfo} columnInfo
201 */
202 this.decodeCustom = function (bytes, columnInfo) {
203
204 // Make sure we actually have something to process in typeName before we go any further
205 if (!columnInfo) {
206 return this.handleBuffer(bytes);
207 }
208
209 // Special handling for vector custom types (since they have args)
210 if ('customTypeName' in columnInfo && columnInfo.customTypeName === 'vector') {
211 return this.decodeVector(bytes, columnInfo);
212 }
213

Callers

nothing calls this directly

Calls 15

readValuesFunction · 0.85
addItemFunction · 0.85
parseParamsFunction · 0.85
concatRoutingKeyFunction · 0.85
encodeParamFunction · 0.85
toNumberMethod · 0.80
fromStringMethod · 0.80
getBufferMethod · 0.80
fromNumberMethod · 0.80
toImmutableMethod · 0.80
unshiftMethod · 0.80
toStringMethod · 0.65

Tested by

no test coverage detected