Package jetbrains.buildServer.vcs.impl
Class ArrayBasedLongIndex<T>
- java.lang.Object
-
- jetbrains.buildServer.vcs.impl.ArrayBasedLongIndex<T>
-
- Type Parameters:
T
- type of stored values
- All Implemented Interfaces:
LongIndex<T>
public class ArrayBasedLongIndex<T> extends Object implements LongIndex<T>
Thread-safe array-based LongIndex for non-negative long keys.Implemented as an array of arrays (chunks). When value is written or read by key, higher bits of the key give an index of a chunk, lower bits - an index inside a chunk.
A size of the chunk is regulated by the
chunkPower
constructor parameter,chunkSize = 2^chunkPower
. The larger a chunkPower, the bigger chunks are and the fewer chunks index have for the same number of elements.The upper bound for keys stored in the index is
MAX_ARRAY_SIZE * chunkSize
.
-
-
Constructor Summary
Constructors Constructor Description ArrayBasedLongIndex()
ArrayBasedLongIndex(int chunkPower, boolean optimizeForRead)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
T
get(long key)
Returns value stored for given key.List<Integer>
optimizeForReadPerformance(long minId, long maxId)
Optimizes chunks corresponding to the specified ids range for read performance (irregadless of the max id, the last chunk will never be optimized)void
processAscending(LongIndexProcessor<T> p)
void
processAscending(LongIndexProcessor<T> p, long startKey)
void
processDescending(LongIndexProcessor<T> p)
void
processDescending(LongIndexProcessor<T> p, long startKey)
void
set(long key, T value)
Writes value for given keyint
size()
-
-
-
Method Detail
-
clear
public void clear()
-
size
public int size()
-
processAscending
public void processAscending(@NotNull LongIndexProcessor<T> p)
-
processAscending
public void processAscending(@NotNull LongIndexProcessor<T> p, long startKey)
-
processDescending
public void processDescending(@NotNull LongIndexProcessor<T> p)
-
processDescending
public void processDescending(@NotNull LongIndexProcessor<T> p, long startKey)
-
set
public void set(long key, T value)
Writes value for given key- Specified by:
set
in interfaceLongIndex<T>
- Parameters:
key
- key of interestvalue
- value to write- Throws:
IllegalArgumentException
- if key is too large for this index
-
get
@Nullable public T get(long key)
Returns value stored for given key. Returns null if key is too large for this index
-
-