# TokenRange

<div class="jsdoc-content"><header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>TokenRange<span class="signature">()</span><span class="type-signature"></span></h2>
        
            <div class="class-description"><p>Represents a range of tokens on a Cassandra ring.</p>
<p>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).</p>
<p>Note that CQL does not handle wrapping.  To query all partitions
in a range, see unwrap.</p></div>
        
    
</header>


    
        

    
    </div>

## Constructor

<div class="jsdoc-content">
    

    
    <h4 class="name" id="TokenRange"><span class="type-signature"></span>new TokenRange<span class="signature">()</span><span class="type-signature"></span></h4>
    

    















<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/token.js#L125" target="_blank" rel="noopener">token.js, line 125</a></p></div>




















    
    

    

    

    

    

    

    

    

    
        </div>

## Methods

<div class="jsdoc-content">

        
            

    

    
    <h4 class="name" id="compare"><span class="type-signature"></span>compare<span class="signature">(other)</span><span class="type-signature"> &rarr; {Number}</span></h4>
    

    



<div class="description">
    <p>Returns 0 if the values are equal, otherwise compares against
start, if start is equal, compares against end.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>other</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="TokenRange.html">TokenRange</a></span>


            
            </td>

            

            

            <td class="description last"><p>Range to compare with.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/token.js#L291" target="_blank" rel="noopener">token.js, line 291</a></p></div>















<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Number</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="contains"><span class="type-signature"></span>contains<span class="signature">(token)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
    

    



<div class="description">
    <p>Whether this range contains a given Token.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>token</code></td>
            

            <td class="type">
            
                
<span class="param-type">\*</span>


            
            </td>

            

            

            <td class="description last"><p>Token to check for.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/token.js#L246" target="_blank" rel="noopener">token.js, line 246</a></p></div>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Whether or not the Token is in this range.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">boolean</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="equals"><span class="type-signature"></span>equals<span class="signature">(other)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
    

    



<div class="description">
    <p>Determines if the input range is equivalent to this one.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>other</code></td>
            

            <td class="type">
            
                
<span class="param-type"><a href="TokenRange.html">TokenRange</a></span>


            
            </td>

            

            

            <td class="description last"><p>Range to compare with.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/token.js#L275" target="_blank" rel="noopener">token.js, line 275</a></p></div>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Whether or not the ranges are equal.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">boolean</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="isEmpty"><span class="type-signature"></span>isEmpty<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
    

    



<div class="description">
    <p>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.</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/token.js#L190" target="_blank" rel="noopener">token.js, line 190</a></p></div>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Whether this range is empty.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">boolean</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="isWrappedAround"><span class="type-signature"></span>isWrappedAround<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
    

    



<div class="description">
    <p>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.</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/token.js#L204" target="_blank" rel="noopener">token.js, line 204</a></p></div>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Whether this range wraps around.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">boolean</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="splitEvenly"><span class="type-signature"></span>splitEvenly<span class="signature">(numberOfSplits)</span><span class="type-signature"> &rarr; {Array&lt;<a href="TokenRange.html">TokenRange</a>>}</span></h4>
    

    



<div class="description">
    <p>Splits this range into a number of smaller ranges of equal &quot;size&quot;
(referring to the number of tokens, not the actual amount of data).</p>
<p>Splitting an empty range is not permitted.  But not that, in edge
cases, splitting a range might produce one or more empty ranges.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>numberOfSplits</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last"><p>Number of splits to make.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/token.js#L146" target="_blank" rel="noopener">token.js, line 146</a></p></div>













<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>If splitting an empty range.</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type">Error</span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    


<h5>Returns:</h5>

        
<div class="param-desc">
    <p>Split ranges.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Array&lt;<a href="TokenRange.html">TokenRange</a>></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="unwrap"><span class="type-signature"></span>unwrap<span class="signature">()</span><span class="type-signature"> &rarr; {Array&lt;<a href="TokenRange.html">TokenRange</a>>}</span></h4>
    

    



<div class="description">
    <p>Splits this range into a list of two non-wrapping ranges.</p>
<p>This will return the range itself if it is non-wrapped, or two
ranges otherwise.</p>
<p>This is useful for CQL range queries, which do not handle
wrapping.</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/token.js#L222" target="_blank" rel="noopener">token.js, line 222</a></p></div>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>The list of non-wrapping ranges.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Array&lt;<a href="TokenRange.html">TokenRange</a>></span>


    </dd>
</dl></div>
