Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.facebook.presto.util.array;
// Note: this code was forked from fastutil (http://fastutil.di.unimi.it/)
// Copyright (C) 2010-2013 Sebastiano Vigna
public final class BigArrays
    private BigArrays()
    {
    }

    
Initial number of segments to support in array.
    public static final int INITIAL_SEGMENTS = 1024;

    
The shift used to compute the segment associated with an index (equivalently, the logarithm of the segment size).
    public static final int SEGMENT_SHIFT = 10;

    
Size of a single segment of a BigArray
    public static final int SEGMENT_SIZE = 1 << ;

    
The mask used to compute the offset associated to an index.
    public static final int SEGMENT_MASK =  - 1;

    
Computes the segment associated with a given index.

Parameters:
index an index into a big array.
Returns:
the associated segment.
    public static int segment(long index)
    {
        return (int) (index >>> );
    }

    
Computes the offset associated with a given index.

Parameters:
index an index into a big array.
Returns:
the associated offset (in the associated segment).
    public static int offset(long index)
    {
        return (int) (index & );
    }
New to GrepCode? Check out our FAQ X