Searches the partition in the partition array using hashValue.
769638
def _LowerBoundSearch(partitions, hash_value):
        
        for i in xrange(0, len(partitions) - 1):
            if partitions[i].CompareTo(hash_value) <= 0 and partitions[i+1].CompareTo(hash_value) > 0:
                return i

        return len(partitions) - 1
152137
public void setPartitionValues(java.util.Collection<String> partitionValues) {
        if (partitionValues == null) {
            this.partitionValues = null;
            return;
        }

        this.partitionValues = new java.util.ArrayList<String>(partitionValues);
    }
595127
private int find(int key, int hash) {
        int index = index(hash);
        final int maxTry = capacity;
        for (int i = 0; i < maxTry; i++) {
            Object slot = values[index];
            if (slot == null) return -1;
            if (slot != GUARD) return keys[index] == key ? index : -1;
            index = nextIndex(index);
        }
        return -1;
    }
1030294
long get(final T key) {
    if (key == null) { return 0; }
    final int probe = hashProbe(key);
    if (states[probe] > 0) {
      assert (keys[probe]).equals(key);
      return values[probe];
    }
    return 0;
  }
561728
Object getParameterAtIndex(int partitionIndex) {
        try {
            if (serializedParams != null) {
                return ParameterSet.getParameterAtIndex(partitionIndex, serializedParams.duplicate());
            } else {
                return params.get().getParam(partitionIndex);
            }
        }
        catch (Exception ex) {
            throw new RuntimeException("Invalid partitionIndex: " + partitionIndex, ex);
        }
    }
730491
private static int findIndex(int[] buckets, int i) {      
        // Hash the value of i into a slot.  Note that because we're using the
        // bitwise-and to perform the mod, the slot will always be positive even
        // if i is negative.
        int slot = i & (buckets.length - 1);
        int initial = slot;

        int firstDeletedSeen = -1;
        do {
            int val = buckets[slot];
            // Record the first DELETED slot we see, but don't return until
            // after we've progressed to either an emtpy slot or the slot with
            // the value.  This ensures that if we somehow delete a sequence of
            // values preceding the slot with the desired value the iteration
            // continues.  However, by recording this slot, if we don't find the
            // value, we can return this index to indicate whether the slot
            // would go.
            if (val == DELETED_MARKER && firstDeletedSeen < 0)
                firstDeletedSeen = slot;
            // If we found the value itself, then return the slot
            else if (val == i)
                return slot;  
            // Otherwise, if we found an EMPTY slot, then check whether the
            // value should be placed (potentially) in this slot or in a prior
            // slot that contains a deleted value.
            else if (val == EMPTY_MARKER) {
                return (firstDeletedSeen < 0) ? slot : firstDeletedSeen;
            }
        } while ((slot = (slot + 1) % buckets.length) != initial);

        // If the linear probe has wrapped all the way around the array and if
        // so, return a negative index.  This should only happen if the array is
        // completely full and cannot be grown.
        return -1;           
    }
333351
@SuppressWarnings("unchecked") // is memcmp-able and uses the trie
  public int getPartition(K key, V value, int numPartitions) {
    return partitions.findPartition(key);
  }
1177130
public int indexOf(int hashCode) {
		int pos=binarySearchHashCode(hashCode);
		if(pos<0) return -1;

		// Try backwards until different hashCode
		while(pos>0 && get(pos-1).hashCode()==hashCode) pos--;
		return pos;
	}
45087
public String[] getPartitionKeys(String location, Job job) throws IOException
    {
        if (!usePartitionFilter)
            return null;
        List<ColumnDef> indexes = getIndexes();
        String[] partitionKeys = new String[indexes.size()];
        for (int i = 0; i < indexes.size(); i++)
        {
            partitionKeys[i] = new String(indexes.get(i).getName());
        }
        return partitionKeys;
    }
231686
function partitionValueToIndex (partition, value) {
  var group;

  if (!partition) {
    // no(sub)partitioning return first element
    return 0;
  }

  // with (sub)partitioning
  group = partition.groups.get(value, 'value');

  if (group) {
    // string in partition
    return group.groupIndex;
  } else {
    // string not in partition
    return -1;
  }
}
1195064
private HashtableEntry findEntry(Object key, int hashcode, int retrieveMode, boolean checkExpired, long current, int tableid)
                    throws IOException,
                    EOFException,
                    FileManagerException,
                    ClassNotFoundException,
                    HashtableOnDiskException {

        long previous = 0;

        long next = 0;
        int hash = 0;

        initReadBuffer(current);
        next = headerin.readLong();
        hash = headerin.readInt();

        while (current != 0) {
            if (hash == hashcode) { // hash the same?
                // 
                // Need to finish collision resolution and maybe return the object
                //
                HashtableEntry entry = readEntry2(current, next, hash, previous, retrieveMode, checkExpired, tableid, key, null); //493877
                if (entry != null) { // 493877 if entry is NOT null, the entry is found.
                    return entry;
                }
            }

            collisions++;
            //
            // Try for next object in bucket
            //
            previous = current;
            current = next;

            if (current != 0) { // optimize - don't read if we know we can't use it
                initReadBuffer(current);
                next = headerin.readLong();
                hash = headerin.readInt();
            }

        }

        //
        // If we fall through we did not find it
        //
        return null;
    }
255879
@Override
    public long[] validatePartitioning(long[] tableIds, byte[] hashinatorConfig) {
        ByteBuffer paramBuffer = m_ee.getParamBufferForExecuteTask(4 + (8 * tableIds.length) + 4 + hashinatorConfig.length);
        paramBuffer.putInt(tableIds.length);
        for (long tableId : tableIds) {
            paramBuffer.putLong(tableId);
        }
        paramBuffer.put(hashinatorConfig);

        ByteBuffer resultBuffer = ByteBuffer.wrap(m_ee.executeTask( TaskType.VALIDATE_PARTITIONING, paramBuffer));
        long mispartitionedRows[] = new long[tableIds.length];
        for (int ii = 0; ii < tableIds.length; ii++) {
            mispartitionedRows[ii] = resultBuffer.getLong();
        }
        return mispartitionedRows;
    }
1220286
private void compactPartition(int partitionNumber) throws IOException {
		// stop if no garbage exists
		if(this.partitions.get(partitionNumber).isCompacted()) {
			return;
		}
		// release all segments owned by compaction partition
		this.compactionMemory.clearAllMemory(availableMemory);
		this.compactionMemory.allocateSegments(1);
		T tempHolder = this.buildSideSerializer.createInstance();
		InMemoryPartition<T> partition = this.partitions.remove(partitionNumber);
		final int numPartitions = this.partitions.size() + 1; // dropped one earlier
		long pointer = 0L;
		int pointerOffset = 0;
		int bucketOffset = 0;
		final int bucketsPerSegment = this.bucketsPerSegmentMask + 1;
		for (int i = 0, bucket = partitionNumber; i < this.buckets.length && bucket < this.numBuckets; i++) {
			MemorySegment segment = this.buckets[i];
			// go over all buckets in the segment belonging to the partition
			for (int k = bucket % bucketsPerSegment; k < bucketsPerSegment && bucket < this.numBuckets; k += numPartitions, bucket += numPartitions) {
				bucketOffset = k * HASH_BUCKET_SIZE;
				if((int)segment.get(bucketOffset + HEADER_PARTITION_OFFSET) != partitionNumber) {
					throw new IOException("Accessed wrong bucket! ");
				}
				int count = segment.getInt(bucketOffset + HEADER_COUNT_OFFSET);
				for (int j = 0; j < NUM_ENTRIES_PER_BUCKET && j < count; j++) {
					pointerOffset = bucketOffset + BUCKET_POINTER_START_OFFSET + (j * POINTER_LEN);
					pointer = segment.getLong(pointerOffset);
					partition.readRecordAt(pointer, tempHolder);
					pointer = this.compactionMemory.appendRecord(tempHolder);
					segment.putLong(pointerOffset, pointer);
				}
				long overflowPointer = segment.getLong(bucketOffset + HEADER_FORWARD_OFFSET);
				if(overflowPointer != BUCKET_FORWARD_POINTER_NOT_SET) {
					// scan overflow buckets
					int current = NUM_ENTRIES_PER_BUCKET;
					bucketOffset = (int) (overflowPointer & 0xffffffff);
					pointerOffset = ((int) (overflowPointer & 0xffffffff)) + BUCKET_POINTER_START_OFFSET;
					int overflowSegNum = (int) (overflowPointer >>> 32);
					count += partition.overflowSegments[overflowSegNum].getInt(bucketOffset + HEADER_COUNT_OFFSET);
					while(current < count) {
						pointer = partition.overflowSegments[overflowSegNum].getLong(pointerOffset);
						partition.readRecordAt(pointer, tempHolder);
						pointer = this.compactionMemory.appendRecord(tempHolder);
						partition.overflowSegments[overflowSegNum].putLong(pointerOffset, pointer);
						current++;
						if(current % NUM_ENTRIES_PER_BUCKET == 0) {
							count += partition.overflowSegments[overflowSegNum].getInt(bucketOffset + HEADER_COUNT_OFFSET);
							overflowPointer = partition.overflowSegments[overflowSegNum].getLong(bucketOffset + HEADER_FORWARD_OFFSET);
							if(overflowPointer == BUCKET_FORWARD_POINTER_NOT_SET) {
								break;
							}
							overflowSegNum = (int) (overflowPointer >>> 32);
							bucketOffset = (int) (overflowPointer & 0xffffffff);
							pointerOffset = ((int) (overflowPointer & 0xffffffff)) + BUCKET_POINTER_START_OFFSET;
						} else {
							pointerOffset += POINTER_LEN;
						}
					}
				}
			}
		}
		// swap partition with compaction partition
		this.compactionMemory.setPartitionNumber(partitionNumber);
		this.partitions.add(partitionNumber, compactionMemory);
		this.compactionMemory = partition;
		this.partitions.get(partitionNumber).overflowSegments = this.compactionMemory.overflowSegments;
		this.partitions.get(partitionNumber).numOverflowSegments = this.compactionMemory.numOverflowSegments;
		this.partitions.get(partitionNumber).nextOverflowBucket = this.compactionMemory.nextOverflowBucket;
		this.partitions.get(partitionNumber).setCompaction(true);
		this.compactionMemory.resetRecordCounter();
		this.compactionMemory.setPartitionNumber(-1);
		// try to allocate maximum segment count
		int maxSegmentNumber = 0;
		for (InMemoryPartition<T> e : this.partitions) {
			if(e.getBlockCount() > maxSegmentNumber) {
				maxSegmentNumber = e.getBlockCount();
			}
		}
		this.compactionMemory.allocateSegments(maxSegmentNumber);
		if(this.compactionMemory.getBlockCount() > maxSegmentNumber) {
			this.compactionMemory.releaseSegments(maxSegmentNumber, availableMemory);
		}
	}
279992
public void setPartitionValueList(java.util.Collection<String> partitionValueList) {
        if (partitionValueList == null) {
            this.partitionValueList = null;
            return;
        }

        this.partitionValueList = new java.util.ArrayList<String>(partitionValueList);
    }
493188
def search_hash(self, searchterm):
        
        return self.__search(type_attribute=self.__misphashtypes(), value=searchterm)
1227321
private boolean getGoodNode(
      HashMap<String, HashSet<Node>> candidateNodesByRacks,
      boolean considerLoad,
      long blockSize,
      List<DatanodeDescriptor> results) {
    List<Map.Entry<String, HashSet<Node>>> sorted =
      new ArrayList<Map.Entry<String, HashSet<Node>>>();
    for (Map.Entry<String, HashSet<Node>> entry :
           candidateNodesByRacks.entrySet()) {
      sorted.add(entry);
    }
    Collections.sort(sorted, new RackComparator(blockSize));
    int count = sorted.size() / 4;
    Collections.shuffle(sorted.subList(0, count));
    for (Map.Entry<String, HashSet<Node>> e : sorted) {
      if (getGoodNode(e.getValue(), considerLoad, blockSize, results)) {
        return true;
      }
    }
    return false;
  }
971353
public int getPartition(Shard key, IntermediateForm value, int numPartitions) {
    int partition = map.get(key).intValue();
    if (partition < numPartitions) {
      return partition;
    } else {
      return numPartitions - 1;
    }
  }