ScyllaDB University Live | Free Virtual Training Event
Learn more
ScyllaDB Documentation Logo Documentation
  • Deployments
    • Cloud
    • Server
  • Tools
    • ScyllaDB Manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
    • Supported Driver Versions
  • Resources
    • ScyllaDB University
    • Community Forum
    • Tutorials
Install
Search Ask AI
ScyllaDB Docs ScyllaDB Node.js Driver API Reference Classes TokenRange

TokenRange¶

TokenRange()

Represents a range of tokens on a Cassandra ring.

A range is start-exclusive and end-inclusive. It is empty when start and end are the same token, except if that is the minimum token, in which case the range covers the whole ring (this is consistent with the behavior of CQL range queries).

Note that CQL does not handle wrapping. To query all partitions in a range, see unwrap.

Constructor¶

new TokenRange()

Source

token.js, line 123

Methods¶

compare(other) → {Number}

Returns 0 if the values are equal, otherwise compares against start, if start is equal, compares against end.

Parameters:
Name Type Description
other TokenRange

Range to compare with.

Source

token.js, line 289

Returns:
Type
Number

contains(token) → {boolean}

Whether this range contains a given Token.

Parameters:
Name Type Description
token *

Token to check for.

Source

token.js, line 244

Returns:

Whether or not the Token is in this range.

Type
boolean

equals(other) → {boolean}

Determines if the input range is equivalent to this one.

Parameters:
Name Type Description
other TokenRange

Range to compare with.

Source

token.js, line 273

Returns:

Whether or not the ranges are equal.

Type
boolean

isEmpty() → {boolean}

A range is empty when start and end are the same token, except if that is the minimum token, in which case the range covers the whole ring. This is consistent with the behavior of CQL range queries.

Source

token.js, line 188

Returns:

Whether this range is empty.

Type
boolean

isWrappedAround() → {boolean}

A range wraps around the end of the ring when the start token is greater than the end token and the end token is not the minimum token.

Source

token.js, line 202

Returns:

Whether this range wraps around.

Type
boolean

splitEvenly(numberOfSplits) → {Array:.<TokenRange:>}

Splits this range into a number of smaller ranges of equal "size" (referring to the number of tokens, not the actual amount of data).

Splitting an empty range is not permitted. But not that, in edge cases, splitting a range might produce one or more empty ranges.

Parameters:
Name Type Description
numberOfSplits Number

Number of splits to make.

Source

token.js, line 144

Throws:

If splitting an empty range.

Type
Error
Returns:

Split ranges.

Type
Array:.<TokenRange:>

unwrap() → {Array:.<TokenRange:>}

Splits this range into a list of two non-wrapping ranges.

This will return the range itself if it is non-wrapped, or two ranges otherwise.

This is useful for CQL range queries, which do not handle wrapping.

Source

token.js, line 220

Returns:

The list of non-wrapping ranges.

Type
Array:.<TokenRange:>

Was this page helpful?

PREVIOUS
Token
NEXT
Interfaces
  • Create an issue
  • Edit this page

On this page

  • TokenRange
    • Constructor
    • Methods
ScyllaDB Node.js Driver
Search Ask AI
  • main
    • main
  • API Reference
    • Modules
      • auth
        • AuthProvider
        • Authenticator
        • PlainTextAuthProvider
      • concurrent
      • datastax
      • errors
        • ArgumentError
        • AuthenticationError
        • BusyConnectionError
        • DriverInternalError
        • NoHostAvailableError
        • NotSupportedError
        • OperationTimedOutError
        • ResponseError
      • geometry
      • mapping
        • DefaultTableMappings
        • Mapper
        • ModelBatchItem
        • ModelMapper
        • Result
        • UnderscoreCqlToCamelCaseMappings
        • TableMappings
      • metadata
        • Aggregate
        • ClientState
        • ColumnMetadata
        • Index
        • KeyspaceMetadata
        • MaterializedView
        • Metadata
        • SchemaFunction
        • Strategy
        • TableMetadata
        • UdtField
        • UserDefinedType
      • metrics
        • DefaultMetrics
        • ClientMetrics
      • policies
        • addressResolution
          • AddressTranslator
          • EC2MultiRegionTranslator
          • MappingAddressTranslator
        • loadBalancing
          • AllowListPolicy
          • DCAwareRoundRobinPolicy
          • DefaultLoadBalancingPolicy
          • LegacyDefaultLoadBalancingPolicy
          • LoadBalancingConfig
          • LoadBalancingPolicy
          • RoundRobinPolicy
          • TokenAwarePolicy
        • reconnection
          • ConstantReconnectionPolicy
          • ExponentialReconnectionPolicy
          • ReconnectionPolicy
        • retry
          • FallthroughRetryPolicy
          • RetryPolicy
        • speculativeExecution
          • ConstantSpeculativeExecutionPolicy
          • NoSpeculativeExecutionPolicy
          • SpeculativeExecutionPolicy
        • timestampGeneration
          • MonotonicTimestampGenerator
          • TimestampGenerator
      • tracker
        • RequestLogger
        • RequestTracker
      • types
        • Duration
        • InetAddress
        • Integer
        • LocalDate
        • Long
        • ResultSet
        • ResultStream
        • Row
        • TimeUuid
        • Vector
    • Classes
      • AddressResolver
      • ByteOrderedToken
      • Client
      • Encoder
      • EncoderMembers
      • ExecutionOptions
      • ExecutionProfile
      • FrameReader
      • HashSet
      • Host
      • HostMap
      • LineString
      • Murmur3Token
      • Point
      • Polygon
      • PreparedInfo
      • RandomToken
      • SslOptions
      • Token
      • TokenRange
    • Interfaces
    • Events
    • Global Functions and Constants
Docs Tutorials University Contact Us About Us
© 2026 ScyllaDB | Terms of Service | Privacy Policy | ScyllaDB, and ScyllaDB Cloud, are registered trademarks of ScyllaDB, Inc.
Last updated on 14 May 2026.
Powered by Sphinx 9.1.0 & ScyllaDB Theme 1.9.2