it.unimi.dsi.fastutil.ints.IntArrays Java Examples

The following examples show how to use it.unimi.dsi.fastutil.ints.IntArrays. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StringDictionaryEncoder.java    From hive-dwrf with Apache License 2.0 6 votes vote down vote up
private void visitDictionary(Visitor<Text> visitor, VisitorContextImpl context
                    ) throws IOException {
    int[] keysArray = null;
    if (sortKeys) {
      keysArray = new int[numElements];
      for (int idx = 0; idx < numElements; idx++) {
        keysArray[idx] = idx + 1;
      }
      IntArrays.quickSort(keysArray, new TextPositionComparator());
    }

    for (int pos = 0; pos < numElements; pos++) {
      context.setOriginalPosition(keysArray == null? pos + 1: keysArray[pos]);
      visitor.visit(context);
    }
    keysArray = null;
}
 
Example #2
Source File: BottomSketch.java    From MHAP with Apache License 2.0 6 votes vote down vote up
public BottomSketch(String str, int nGramSize, int k, boolean doReverseCompliment)
{
	int[] hashes = HashUtils.computeSequenceHashes(str, nGramSize, doReverseCompliment);
	
	k = Math.min(k, hashes.length);
	
	int[] perm = new int[hashes.length];
	for (int iter=0; iter<hashes.length; iter++)
		perm[iter] = iter;

	//sort the array
	IntArrays.radixSortIndirect(perm, hashes, true);
	
	hashPositions = new int[k];
	
	for (int iter=0; iter<k; iter++)
	{
		int index = perm[iter];
		hashPositions[iter] = hashes[index]; 
	}

}
 
Example #3
Source File: ReorderingBlockingQueueTest.java    From BUbiNG with Apache License 2.0 6 votes vote down vote up
@Test
public void testBlocking() throws InterruptedException {
	for(final int size: new int[] { 10, 100, 128, 256 }) {
		for(final int d: new int[] { 1, 2, 3, 4 }) {
			final ReorderingBlockingQueue<Integer> q = new ReorderingBlockingQueue<>(size / d);
			final int[] perm = Util.identity(size);
			IntArrays.shuffle(perm, new XoRoShiRo128PlusRandom());
			for(int i = perm.length; i-- != 0;) {
				final int t = perm[i];
				new Thread() {
					@Override
					public void run() {
						try {
							q.put(Integer.valueOf(t), t);
						}
						catch (final InterruptedException e) {
							throw new RuntimeException(e.getMessage(), e);
						}
					}
				}.start();
			}
			for(int i = 0; i < perm.length; i++) assertEquals(i, q.take().intValue());
			assertEquals(0, q.size());
		}
	}
}
 
Example #4
Source File: TableSlice.java    From tablesaw with Apache License 2.0 5 votes vote down vote up
/** Returns an array of integers representing the source table indexes in sorted order. */
private int[] sortOn(IntComparator rowComparator) {
  int[] newRows;
  if (hasSelection()) {
    newRows = this.selection.toArray();
  } else {
    newRows = IntStream.range(0, table.rowCount()).toArray();
  }
  IntArrays.parallelQuickSort(newRows, rowComparator);
  return newRows;
}
 
Example #5
Source File: IntDictionaryEncoder.java    From hive-dwrf with Apache License 2.0 5 votes vote down vote up
public void visitDictionary(Visitor<Long> visitor, IntDictionaryEncoderVisitorContext context) throws IOException {
    int[] keysArray = null;
    if (sortKeys) {
      keysArray = new int[numElements];
      for (int idx = 0; idx < numElements; idx++) {
        keysArray[idx] = idx;
      }
      IntArrays.quickSort(keysArray, new LongPositionComparator());
    }
    for (int pos = 0; pos < numElements; pos++) {
      context.setOriginalPosition(keysArray == null? pos : keysArray[pos]);
      visitor.visit(context);
    }
}
 
Example #6
Source File: MutableSegmentImpl.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the docIds to use for iteration when the data is sorted by the given column.
 * <p>Called only by realtime record reader.
 *
 * @param column The column to use for sorting
 * @return The docIds to use for iteration
 */
public int[] getSortedDocIdIterationOrderWithSortedColumn(String column) {
  BaseMutableDictionary dictionary = _dictionaryMap.get(column);
  int numValues = dictionary.length();

  int[] dictIds = new int[numValues];
  for (int i = 0; i < numValues; i++) {
    dictIds[i] = i;
  }

  IntArrays.quickSort(dictIds, (dictId1, dictId2) -> dictionary.compare(dictId1, dictId2));
  RealtimeInvertedIndexReader invertedIndex = (RealtimeInvertedIndexReader) _invertedIndexMap.get(column);
  int[] docIds = new int[_numDocsIndexed];
  int docIdIndex = 0;
  for (int dictId : dictIds) {
    IntIterator intIterator = invertedIndex.getDocIds(dictId).getIntIterator();
    while (intIterator.hasNext()) {
      docIds[docIdIndex++] = intIterator.next();
    }
  }

  // Sanity check
  Preconditions.checkState(_numDocsIndexed == docIdIndex,
      "The number of documents indexed: %s is not equal to the number of sorted documents: %s", _numDocsIndexed,
      docIdIndex);

  return docIds;
}
 
Example #7
Source File: BottomOverlapSketch.java    From MHAP with Apache License 2.0 5 votes vote down vote up
public BottomOverlapSketch(String seq, int kmerSize, int sketchSize, boolean doReverseCompliment) throws ZeroNGramsFoundException
{
	this.kmerSize = kmerSize;
	this.seqLength = seq.length() - kmerSize + 1;
	
	if (this.seqLength<=0)
		throw new ZeroNGramsFoundException("Sequence length must be greater or equal to n-gram size "+kmerSize+".", seq);
	
	// compute just direct hash of sequence
	int[] hashes = HashUtils.computeSequenceHashes(seq, kmerSize, doReverseCompliment);

	int[] perm = new int[hashes.length];

	//init the array
	for (int iter = 0; iter < hashes.length; iter++)
		perm[iter] = iter;
	
	//sort the array
	IntArrays.radixSortIndirect(perm, hashes, true);
	
	//sketchSize = (int)Math.round(0.25*(double)this.seqLength);

	//find the largest storage value
	int k = Math.min(sketchSize, hashes.length);
	
	//allocate the memory
	this.orderedHashes = new int[k][2];

	for (int iter = 0; iter < this.orderedHashes.length; iter++)
	{
		int index = perm[iter];
		this.orderedHashes[iter][0] = hashes[index];
		this.orderedHashes[iter][1] = index;
	}
}
 
Example #8
Source File: TableSlice.java    From tablesaw with Apache License 2.0 5 votes vote down vote up
/** Returns an array of integers representing the source table indexes in sorted order. */
private int[] sortOn(IntComparator rowComparator) {
  int[] newRows;
  if (hasSelection()) {
    newRows = this.selection.toArray();
  } else {
    newRows = IntStream.range(0, table.rowCount()).toArray();
  }
  IntArrays.parallelQuickSort(newRows, rowComparator);
  return newRows;
}
 
Example #9
Source File: Relation.java    From tablesaw with Apache License 2.0 5 votes vote down vote up
public Relation removeColumns(int... columnIndexes) {
  IntArrays.quickSort(columnIndexes, IntComparators.OPPOSITE_COMPARATOR);
  for (int i : columnIndexes) {
    removeColumns(column(i));
  }
  return this;
}
 
Example #10
Source File: Table.java    From tablesaw with Apache License 2.0 5 votes vote down vote up
/** Returns a copy of this table sorted using the given comparator */
private Table sortOn(IntComparator rowComparator) {
  Table newTable = emptyCopy(rowCount());

  int[] newRows = rows();
  IntArrays.parallelQuickSort(newRows, rowComparator);

  Rows.copyRowsToTable(newRows, this, newTable);
  return newTable;
}
 
Example #11
Source File: SliceDictionaryColumnWriter.java    From presto with Apache License 2.0 5 votes vote down vote up
private static int[] getSortedDictionaryNullsLast(Block elementBlock)
{
    int[] sortedPositions = new int[elementBlock.getPositionCount()];
    for (int i = 0; i < sortedPositions.length; i++) {
        sortedPositions[i] = i;
    }

    IntArrays.quickSort(sortedPositions, 0, sortedPositions.length, (int left, int right) -> {
        boolean nullLeft = elementBlock.isNull(left);
        boolean nullRight = elementBlock.isNull(right);
        if (nullLeft && nullRight) {
            return 0;
        }
        if (nullLeft) {
            return 1;
        }
        if (nullRight) {
            return -1;
        }
        return elementBlock.compareTo(
                left,
                0,
                elementBlock.getSliceLength(left),
                elementBlock,
                right,
                0,
                elementBlock.getSliceLength(right));
    });

    return sortedPositions;
}
 
Example #12
Source File: Relation.java    From tablesaw with Apache License 2.0 5 votes vote down vote up
public Relation removeColumns(int... columnIndexes) {
  IntArrays.quickSort(columnIndexes, IntComparators.OPPOSITE_COMPARATOR);
  for (int i : columnIndexes) {
    removeColumns(column(i));
  }
  return this;
}
 
Example #13
Source File: Table.java    From tablesaw with Apache License 2.0 5 votes vote down vote up
/** Returns a copy of this table sorted using the given comparator */
private Table sortOn(IntComparator rowComparator) {
  Table newTable = emptyCopy(rowCount());

  int[] newRows = rows();
  IntArrays.parallelQuickSort(newRows, rowComparator);

  Rows.copyRowsToTable(newRows, this, newTable);
  return newTable;
}
 
Example #14
Source File: ReorderingBlockingQueueTest.java    From BUbiNG with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoBlocking() throws InterruptedException {
	for(final int size: new int[] { 1, 10, 100, 128, 256 }) {
		final ReorderingBlockingQueue<Integer> q = new ReorderingBlockingQueue<>(size);
		final int[] perm = Util.identity(size);
		IntArrays.shuffle(perm, new XoRoShiRo128PlusRandom());
		for(int i = perm.length; i-- != 0;) q.put(Integer.valueOf(perm[i]), perm[i]);
		for(int i = 0; i < perm.length; i++) assertEquals(i, q.take().intValue());
		assertEquals(0, q.size());
	}
}
 
Example #15
Source File: FastUtil.java    From minie with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Given an IntArrayList object, sort it, and return an integer array, containing the sorted elements
 * @param intList: the input list to be sorted
 * @return a sorted integer array
 */
public static int [] sort(IntArrayList intList){
    // Sort the indices and return them
    int [] sorted = new int[intList.size()];
    for (int i = 0; i < intList.size(); i++){
        sorted[i] = intList.getInt(i);
    }
    IntArrays.quickSort(sorted);
    
    return sorted;
}
 
Example #16
Source File: LayeredLabelPropagation.java    From fasten with Apache License 2.0 5 votes vote down vote up
private void update(final double gamma) {
	final int n = this.n;
	final int[] updateList = this.updateList;
	modified.set(0);
	nextArcs = nextNode = 0;

	if (exact) {
		if (startPerm == null) Util.identity(updateList);
		else Util.invertPermutation(startPerm, updateList);
	}

	// Local shuffle
	for(int i = 0; i < n;) IntArrays.shuffle(updateList, i, Math.min(i += SHUFFLE_GRANULARITY, n), r);

	final ProgressLogger pl = new ProgressLogger(LOGGER);
	pl.expectedUpdates = n;
	pl.logInterval = ProgressLogger.TEN_SECONDS;
	pl.itemsName = "nodes";
	pl.start("Starting update " + update + "...");

	final Thread[] thread = new Thread[numberOfThreads];

	nextArcs = nextNode =  0;
	for (int i = 0; i < numberOfThreads; i++) {
		thread[i] = new IterationThread(symGraph.copy(), gamma, i, pl);
		thread[i].setUncaughtExceptionHandler(simpleUncaughtExceptionHandler);
		thread[i].start();
	}

	for (int i = 0; i < numberOfThreads; i++)
		try {
			thread[i].join();
		}
		catch (final InterruptedException e) {
			throw new RuntimeException(e);
		}

	if (threadException != null) throw new RuntimeException(threadException);
	pl.done();
}
 
Example #17
Source File: IntDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
@Override
public void sortDescending() {
  int[] elements = values.toIntArray();
  IntArrays.parallelQuickSort(elements, reverseDictionarySortComparator);
  this.values = new IntArrayList(elements);
}
 
Example #18
Source File: IntDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
@Override
public void sortAscending() {
  int[] elements = values.toIntArray();
  IntArrays.parallelQuickSort(elements, dictionarySortComparator);
  this.values = new IntArrayList(elements);
}
 
Example #19
Source File: OneClassPreferenceFMData.java    From RankSys with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void shuffle() {
    IntArrays.shuffle(uidxs.elements(), 0, uidxs.size(), rnd);
}
 
Example #20
Source File: BPRPreferenceFMData.java    From RankSys with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void shuffle() {
    IntArrays.shuffle(uidxs.elements(), 0, uidxs.size(), rnd);
}
 
Example #21
Source File: CustomByteArrayFrontCodedList.java    From database with GNU General Public License v2.0 4 votes vote down vote up
public CustomByteArrayFrontCodedList(final Iterator<byte[]> arrays,
            final int ratio, final boolean hasDups) {

        assertRatio(ratio);
//        if (ratio < 1)
//            throw new IllegalArgumentException("Illegal ratio (" + ratio + ")");

        byte[] array = ByteArrays.EMPTY_ARRAY;
        int[] p = IntArrays.EMPTY_ARRAY;

        byte[][] a = new byte[2][];
        int curSize = 0, b = 0, common, length, minLength;

        while (arrays.hasNext()) {
            a[b] = (byte[]) arrays.next();
            length = a[b].length;

            if (n % ratio == 0) {
                p = IntArrays.grow(p, n / ratio + 1);
                p[n / ratio] = curSize;

                array = ByteArrays.grow(array,
                        curSize + count(length) + length, curSize);
                curSize += writeInt(array, length, curSize);
                System.arraycopy(a[b], 0, array, curSize, length);
                curSize += length;
            } else {
                minLength = a[1 - b].length;
                if (length < minLength)
                    minLength = length;
                for (common = 0; common < minLength; common++)
                    if (a[0][common] != a[1][common])
                        break;
                length -= common;

                array = ByteArrays.grow(array, curSize + count(length)
                        + count(common) + length, curSize);
                curSize += writeInt(array, length, curSize);
                curSize += writeInt(array, common, curSize);
                System.arraycopy(a[b], common, array, curSize, length);
                curSize += length;
            }

            b = 1 - b;
            n++;
        }

        this.ratio = ratio;
//      this.array = ByteArrays.trim(array, curSize);
        this.bb = new BackingByteArray( ByteArrays.trim(array, curSize) );
//        this.bb = new BackingByteBuffer( ByteBuffer.wrap(ByteArrays.trim(array, curSize) ));
        this.p = IntArrays.trim(p, (n + ratio - 1) / ratio);

        this.hasDups = hasDups;
    }
 
Example #22
Source File: IntDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
@Override
public void sortAscending() {
  int[] elements = values.toIntArray();
  IntArrays.parallelQuickSort(elements, dictionarySortComparator);
  this.values = new IntArrayList(elements);
}
 
Example #23
Source File: IntDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
@Override
public void sortDescending() {
  int[] elements = values.toIntArray();
  IntArrays.parallelQuickSort(elements, reverseDictionarySortComparator);
  this.values = new IntArrayList(elements);
}
 
Example #24
Source File: LayeredLabelPropagation.java    From fasten with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
	final ImmutableGraph symGraph = this.symGraph;
	final int numNodes = LayeredLabelPropagation.this.n;
	final long numArcs = LayeredLabelPropagation.this.symGraph.numArcs();
	final int[] perm = this.perm;
	int[] permutedSuccessors = new int[32];
	int[] successors;
	final long granularity = Math.max(1024, numArcs >>> 9);
	int start, end;

	double gapCost = 0;
	for (;;) {

		// Try to get another piece of work.
		synchronized(LayeredLabelPropagation.this.cumulativeOutdegrees) {
			if (nextNode == numNodes) {
				LayeredLabelPropagation.this.gapCost.add(gapCost);
				break;
			}
			start = nextNode;
			final long target = nextArcs + granularity;
			if (target >= numArcs) nextNode = numNodes;
			else {
				nextArcs = cumulativeOutdegrees.skipTo(target);
				nextNode = cumulativeOutdegrees.currentIndex();
			}
			end = nextNode;
		}

		final NodeIterator nodeIterator = symGraph.nodeIterator(start);
		for (int i = start; i < end; i++) {
			nodeIterator.nextInt();
			final int node = perm[i];
			final int outdegree = nodeIterator.outdegree();
			if (outdegree > 0) {
				successors = nodeIterator.successorArray();
				permutedSuccessors = IntArrays.grow(permutedSuccessors, outdegree);
				for (int j = outdegree; j-- != 0;)
					permutedSuccessors[j] = perm[successors[j]];
				IntArrays.quickSort(permutedSuccessors, 0, outdegree);
				int prev = node;
				for (int j = 0; j < outdegree; j++) {
					gapCost += Fast.ceilLog2(Math.abs(prev - permutedSuccessors[j]));
					prev = permutedSuccessors[j];
				}
			}
		}
	}
}
 
Example #25
Source File: LayeredLabelPropagation.java    From fasten with Apache License 2.0 4 votes vote down vote up
public OpenHashTableCounter() {
	mask = -1;
	count = IntArrays.EMPTY_ARRAY;
	key = IntArrays.EMPTY_ARRAY;
	location = IntArrays.EMPTY_ARRAY;
}
 
Example #26
Source File: CallGraphGenerator.java    From fasten with Apache License 2.0 4 votes vote down vote up
/** Generates <code>np</code> call graphs. Each call graph is obtained using {@link #preferentialAttachmentDAG(int, int, IntegerDistribution, RandomGenerator)} (with
 *  specified initial graph size (<code>initialGraphSizeDistribution</code>), graph size (<code>graphSizeDistribution</code>), outdegree distribution (<code>outdegreeDistribution</code>).
 *  Then a dependency DAG is generated between the call graphs, once more using {@link #preferentialAttachmentDAG(int, int, IntegerDistribution, RandomGenerator)} (this
 *  time the initial graph size is 1, whereas the outdegree distribution is <code>outdegreeDistribution</code>).
 *  Then to each node of each call graph a new set of outgoing arcs is generated (their number is chosen using <code>externalOutdegreeDistribution</code>): the target
 *  call graph is generated using the indegree distribution of the dependency DAG; the target node is chosen according to the reverse indegree distribution within the revision call graph.
 *
 * @param np number of revision call graphs to be generated.
 * @param graphSizeDistribution the distribution of the graph sizes (number of functions per call graph).
 * @param initialGraphSizeDistribution the distribution of the initial graph sizes (the initial independent set from which the preferential attachment starts).
 * @param outdegreeDistribution the distribution of internal outdegrees (number of internal calls per function).
 * @param externalOutdegreeDistribution the distribution of external outdegrees (number of external calls per function).
 * @param depExponent exponent of the Zipf distribution used to establish the dependencies between call graphs.
 * @param random the random object used for the generation.
 */
public void generate(final int np, final IntegerDistribution graphSizeDistribution, final IntegerDistribution initialGraphSizeDistribution,
		final IntegerDistribution outdegreeDistribution, final IntegerDistribution externalOutdegreeDistribution, final IntegerDistribution dependencyOutdegreeDistribution, final RandomGenerator random) {
	rcgs = new ArrayListMutableGraph[np];
	nodePermutation = new int[np][];
	final FenwickTree[] td = new FenwickTree[np];
	deps = new IntOpenHashSet[np];
	source2Targets = new ObjectOpenCustomHashSet[np];

	// Generate rcg of the np revisions, and the corresponding reverse preferential distribution; cumsize[i] is the sum of all nodes in packages <i
	for ( int i = 0; i < np; i++) {
		deps[i] = new IntOpenHashSet();
		final int n = graphSizeDistribution.sample();
		final int n0 = Math.min(initialGraphSizeDistribution.sample(), n);
		rcgs[i] = preferentialAttachmentDAG(n, n0, outdegreeDistribution, random);
		td[i] = getPreferentialDistribution(rcgs[i].immutableView(), true);
		nodePermutation[i] = Util.identity(n);
		Collections.shuffle(IntArrayList.wrap(nodePermutation[i]), new Random(random.nextLong()));
	}

	// Generate the dependency DAG between revisions using preferential attachment starting from 1 node
	final ArrayListMutableGraph depDAG = preferentialAttachmentDAG(np, 1, dependencyOutdegreeDistribution, random);

	// For each source package, generate function calls so to cover all dependencies
	for (int sourcePackage = 0; sourcePackage < np; sourcePackage++) {
		source2Targets[sourcePackage] = new ObjectOpenCustomHashSet<>(IntArrays.HASH_STRATEGY);
		final int outdegree = depDAG.outdegree(sourcePackage);
		if (outdegree == 0) continue; // No calls needed (I'm kinda busy)

		final int numFuncs = rcgs[sourcePackage].numNodes();
		final int[] externalArcs = new int[numFuncs];
		int allExternalArcs = 0;
		// We decide how many calls to dispatch from each function
		for (int sourceNode = 0; sourceNode < numFuncs; sourceNode++) allExternalArcs += (externalArcs[sourceNode] = externalOutdegreeDistribution.sample());
		// We create a global list of external successors by shuffling
		final int[] targetPackage = new int[allExternalArcs];
		final int[] succ = depDAG.successorArray(sourcePackage);
		for(int i = 0; i < outdegree; i++) deps[sourcePackage].add(succ[i]);
		for(int i = 0; i < allExternalArcs; i++) targetPackage[i] = succ[i % outdegree];
		MathArrays.shuffle(targetPackage, random);

		for (int sourceNode = allExternalArcs = 0; sourceNode < numFuncs; sourceNode++) {
			final int externalOutdegree = externalArcs[sourceNode];
			for (int t = 0; t < externalOutdegree; t++) {
				final int targetNode = td[targetPackage[allExternalArcs + t]].sample(random) - 1;
				source2Targets[sourcePackage].add(new int[] { sourceNode, targetPackage[allExternalArcs + t], targetNode });
			}
			allExternalArcs += externalOutdegree;
		}
	}
}
 
Example #27
Source File: ArraysOverlapFunction.java    From presto with Apache License 2.0 4 votes vote down vote up
@SqlNullable
@TypeParameter("E")
@SqlType(StandardTypes.BOOLEAN)
public Boolean arraysOverlap(
        @OperatorDependency(operator = LESS_THAN, argumentTypes = {"E", "E"}) MethodHandle lessThanFunction,
        @TypeParameter("E") Type type,
        @SqlType("array(E)") Block leftArray,
        @SqlType("array(E)") Block rightArray)
{
    int leftPositionCount = leftArray.getPositionCount();
    int rightPositionCount = rightArray.getPositionCount();

    if (leftPositionCount == 0 || rightPositionCount == 0) {
        return false;
    }

    if (leftPositions == null || leftPositions.length < leftPositionCount) {
        leftPositions = new int[leftPositionCount * 2];
    }

    if (rightPositions == null || rightPositions.length < rightPositionCount) {
        rightPositions = new int[rightPositionCount * 2];
    }

    for (int i = 0; i < leftPositionCount; i++) {
        leftPositions[i] = i;
    }
    for (int i = 0; i < rightPositionCount; i++) {
        rightPositions[i] = i;
    }
    IntArrays.quickSort(leftPositions, 0, leftPositionCount, intBlockCompare(type, leftArray));
    IntArrays.quickSort(rightPositions, 0, rightPositionCount, intBlockCompare(type, rightArray));

    int leftCurrentPosition = 0;
    int rightCurrentPosition = 0;
    while (leftCurrentPosition < leftPositionCount && rightCurrentPosition < rightPositionCount) {
        if (leftArray.isNull(leftPositions[leftCurrentPosition]) || rightArray.isNull(rightPositions[rightCurrentPosition])) {
            // Nulls are in the end of the array. Non-null elements do not overlap.
            return null;
        }
        int compareValue = type.compareTo(leftArray, leftPositions[leftCurrentPosition], rightArray, rightPositions[rightCurrentPosition]);
        if (compareValue > 0) {
            rightCurrentPosition++;
        }
        else if (compareValue < 0) {
            leftCurrentPosition++;
        }
        else {
            return true;
        }
    }
    return leftArray.isNull(leftPositions[leftPositionCount - 1]) || rightArray.isNull(rightPositions[rightPositionCount - 1]) ? null : false;
}