@Override public int lookupId(String name) { return forwardMapping.get(baseIdLookup.lookupId(name)); }
@Override public int indexOf(Object rawValue) { int value = getValue(rawValue); return _valToDictId.get(value); }
private int getGroupId(int rawKey) { int groupId = _rawKeyToGroupIdMap.get(rawKey); if (groupId == INVALID_ID) { if (_numGroups < _globalGroupIdUpperBound) { groupId = _numGroups; _rawKeyToGroupIdMap.put(rawKey, _numGroups++); } } return groupId; }
/** * Helper method to swap keys for the specified indices. * @param index1 First index * @param index2 Second index */ protected void swapKeys(int index1, int index2) { int key1 = _indexToKeyMap.get(index1); int key2 = _indexToKeyMap.get(index2); updateKeyIndexMap(key1, index2); updateKeyIndexMap(key2, index1); }
@Override public boolean matches() { final IndexedInts baseRow = selector.getRow(); final int baseRowSize = baseRow.size(); boolean nullRow = true; for (int i = 0; i < baseRowSize; ++i) { int forwardedValue = forwardMapping.get(baseRow.get(i)); if (forwardedValue >= 0) { if (valueIds.get(forwardedValue)) { return true; } nullRow = false; } } // null should match empty rows in multi-value columns return nullRow && matchNull; }
@Override public boolean matches() { final IndexedInts baseRow = selector.getRow(); final int baseRowSize = baseRow.size(); boolean nullRow = true; for (int i = 0; i < baseRowSize; i++) { int forwardedValue = forwardMapping.get(baseRow.get(i)); if (forwardedValue >= 0) { // Make the following check after the `forwardedValue >= 0` check, because if forwardedValue is -1 and // valueId is -1, we don't want to return true from matches(). if (forwardedValue == valueId) { return true; } nullRow = false; } } // null should match empty rows in multi-value columns return nullRow && value == null; }
/** * Returns the key+value pair with the max priority (min for minHeap mode) * <ul> * <li> key+value pair is not removed from the priority queue. </li> * <li> Throws runtime exception if the priority queue is empty. </li> * <li> Runtime complexity of O(1). </li> * </ul> * * @return Key+Value pair */ public IntDoublePair peek() { if (_values.isEmpty()) { throw new RuntimeException("Empty collection"); } _reusablePair.setIntValue(_indexToKeyMap.get(0)); _reusablePair.setDoubleValue(_values.getDouble(0)); return _reusablePair; }
/** * Returns the key+value pair with the max priority (min for minHeap mode) * <ul> * <li> key+value pair is not removed from the priority queue. </li> * <li> Returns null if the priority queue is empty. </li> * <li> Runtime complexity of O(1). </li> * </ul> * * @return Key+Value pair */ public IntObjectPair<T> peek() { if (_values.isEmpty()) { return null; } _reusablePair.setIntValue(_indexToKeyMap.get(0)); _reusablePair.setObjectValue(_values.get(0)); return _reusablePair; }
/** * Returns the value for the specified key. * <ul> * <li> Returns null if the specified key does not exist. </li> * <li> Runtime complexity of O(1). </li> * </ul> * * @param key Key for which to return the value * @return Value for the key */ public IntObjectPair get(int key) { if (!_keyToIndexMap.containsKey(key)) { return null; } int index = _keyToIndexMap.get(key); T value = _values.get(index); _reusablePair.setIntValue(index); _reusablePair.setObjectValue(value); return _reusablePair; }
/** * Returns the value for the specified key. * <ul> * <li> Returns null if the specified key does not exist. </li> * <li> Runtime complexity of O(1). </li> * </ul> * * @param key Key for which to return the value * @return Value for the key */ public IntDoublePair get(int key) { if (!_keyToIndexMap.containsKey(key)) { return null; } int index = _keyToIndexMap.get(key); double value = _values.getDouble(index); _reusablePair.setIntValue(index); _reusablePair.setDoubleValue(value); return _reusablePair; }
case INT: for (int i = 0; i < multiValues.length; i++) { indexes[i] = _intValueToIndexMap.get((int) multiValues[i]);
@Override public IndexedInts getRow() { IndexedInts baseRow = selector.getRow(); int baseRowSize = baseRow.size(); row.ensureSize(baseRowSize); int resultSize = 0; for (int i = 0; i < baseRowSize; i++) { int forwardedValue = forwardMapping.get(baseRow.get(i)); if (forwardedValue >= 0) { row.setValue(resultSize, forwardedValue); resultSize++; } } row.setSize(resultSize); return row; }
public int indexOfSV(Object value) { switch (_fieldSpec.getDataType()) { case INT: return _intValueToIndexMap.get((int) value); case LONG: return _longValueToIndexMap.get((long) value); case FLOAT: return _floatValueToIndexMap.get((float) value); case DOUBLE: return _doubleValueToIndexMap.get((double) value); case STRING: return _stringValueToIndexMap.getInt(value); case BYTES: return _bytesValueToIndexMap.get(new ByteArray((byte[]) value)); default: throw new UnsupportedOperationException("Unsupported data type : " + _fieldSpec.getDataType()); } }
/** * Returns the key+value pair with the max priority (min for minHeap mode) * <ul> * <li> key+value pair is removed from the priority queue. </li> * <li> Throws runtime exception if the priority queue is empty. </li> * <li> Runtime complexity of O(1). </li> * </ul> * * @return Key+Value pair */ public IntObjectPair<T> poll() { if (isEmpty()) { throw new RuntimeException("Empty collection, nothing to remove"); } else { IntObjectPair<T> poll = peek(); int lastIndex = _values.size() - 1; swapValues(0, lastIndex); _values.remove(lastIndex); _keyToIndexMap.remove(_indexToKeyMap.get(lastIndex)); _indexToKeyMap.remove(lastIndex); if (!_values.isEmpty()) { siftDown(0); } return poll; } }
/** * Puts the element into the priority queue. * <ul> * <li> If key does not exist, it is added to the priority queue. </li> * <li> If key exists, then the value is updated, and the priority queue ordering is maintained. </li> * <li> Runtime complexity of {@code O(log(n)}). </li> * </ul> * @param key Integer key for the value * @param value Double value of the key */ public void put(int key, double value) { if (!_keyToIndexMap.containsKey(key)) { _values.add(value); int last = _values.size() - 1; updateKeyIndexMap(key, last); siftUp(last); } else { int index = _keyToIndexMap.get(key); _values.set(index, value); // Sift the value up or down, as the case may be. if (!siftDown(index)) { siftUp(index); } } }
/** * Puts the element into the priority queue. * <ul> * <li> If key does not exist, it is added to the priority queue. </li> * <li> If key exists, then the value is updated, and the priority queue ordering is maintained. </li> * <li> Runtime complexity of {@code O(log(n)}). </li> * </ul> * @param key Integer key for the value * @param value Value of the key */ @SuppressWarnings("unchecked") public void put(int key, T value) { if (!_keyToIndexMap.containsKey(key)) { _values.add(value); int last = _values.size() - 1; updateKeyIndexMap(key, last); siftUp(last); } else { int index = _keyToIndexMap.get(key); _values.set(index, value); // Sift the value up or down, as the case may be. if (!siftDown(index)) { siftUp(index); } } }
/** * Returns the key+value pair with the max priority (min for minHeap mode) * <ul> * <li> key+value pair is removed from the priority queue. </li> * <li> Returns null if the priority queue is empty. </li> * <li> Runtime complexity of O(1). </li> * </ul> * * @return Key+Value pair */ public IntDoublePair poll() { if (isEmpty()) { return null; } IntDoublePair poll = peek(); int lastIndex = _values.size() - 1; swapValues(0, lastIndex); _values.removeDouble(lastIndex); _keyToIndexMap.remove(_indexToKeyMap.get(lastIndex)); _indexToKeyMap.remove(lastIndex); if (!_values.isEmpty()) { siftDown(0); } return poll; }
for (Vector.VectorEntry vectorEntry : tempRowVector) { columnToRowPositionMap[columnIndex][vectorEntry.position()] = rowPositionMap.get(vectorEntry.index()).get(columnIndex); for (Vector.VectorEntry vectorEntry : tempRowVector) { rowToColumnPositionMap[rowIndex][vectorEntry.position()] = columnPositionMap.get(vectorEntry.index()).get(rowIndex);
public IndexNode getChildNode(int groupUniqueId) { if (positions.containsKey(groupUniqueId)) { return children.get(positions.get(groupUniqueId)); } return null; }
@Override public double get(int i) { if(!reverseMap.containsValue(i)) { return 0; } return values.getDouble(reverseMap.get(i)); }