* Constructs a Token from the input buffer(s) or string input. If a string is passed in * it is assumed this matches the token representation reported by cassandra. * @param {Array |Buffer|String} components * @returns {Token} constructed token from the input buffer.
(components)
| 387 | * @returns {Token} constructed token from the input buffer. |
| 388 | */ |
| 389 | newToken(components) { |
| 390 | if (!this.tokenizer) { |
| 391 | throw new Error('Partitioner not established. This should only happen if metadata was disabled or you have not connected yet.'); |
| 392 | } |
| 393 | if (Array.isArray(components)) { |
| 394 | return this.tokenizer.hash(Buffer.concat(components)); |
| 395 | } |
| 396 | else if (typeof components === "string") { |
| 397 | return this.tokenizer.parse(components); |
| 398 | } |
| 399 | return this.tokenizer.hash(components); |
| 400 | } |
| 401 | |
| 402 | /** |
| 403 | * Constructs a TokenRange from the given start and end tokens. |