private int getGroupId(IntArray rawKey) { int groupId = _rawKeyToGroupIdMap.getInt(rawKey); if (groupId == INVALID_ID) { if (_numGroups < _globalGroupIdUpperBound) { groupId = _numGroups; _rawKeyToGroupIdMap.put(rawKey, _numGroups++); } } return groupId; }
/** * Add a mapping that we have recovered from disk */ public void addMapping(int id, Object object) { // Store the mapping idToObject.put(id, object); objectToID.put(object, id); // increase the next canonical id the recovered id is higher than it. highestID = highestID < id ? id : highestID; }
private void put(int key, String value) { keyToValue.put(key, value); valueToKey.put(value, key); }
/** * Helper method to get or create group-id for a group key. * * @param keyList Group key, that is a list of objects to be grouped * @return Group id */ private int getGroupIdForKey(FixedIntArray keyList) { int groupId = _groupKeyMap.getInt(keyList); if (groupId == INVALID_ID) { if (_numGroups < _globalGroupIdUpperBound) { groupId = _numGroups; _groupKeyMap.put(keyList, _numGroups++); } } return groupId; }
/** * Create an id of the given object. * * @return the id generated for this object. */ public int createId(Object object) { assert !objectToID.containsKey(object); int id = ++highestID; objectToID.put(object, id); idToObject.put(id, object); return id; }
@Override public Object getOnlyValue(ColumnValueSelector selector) { final DimensionSelector dimSelector = (DimensionSelector) selector; final IndexedInts row = dimSelector.getRow(); Preconditions.checkState(row.size() < 2, "Not supported for multi-value dimensions"); if (row.size() == 0) { return GROUP_BY_MISSING_VALUE; } final String value = dimSelector.lookupName(row.get(0)); final int dictId = reverseDictionary.getInt(value); if (dictId < 0) { dictionary.add(value); reverseDictionary.put(value, nextId); return nextId++; } else { return dictId; } } }
out.writeByte(FLAG_TAG_WITH_NEW_ID); idNumber = ++idCount; ids.put(id, idNumber); InternalDataSerializer.invokeToData(tag, out); } else {
@Override public void initColumnValues(ColumnValueSelector selector, int columnIndex, Object[] valuess) { final DimensionSelector dimSelector = (DimensionSelector) selector; final IndexedInts row = dimSelector.getRow(); ArrayBasedIndexedInts newRow = (ArrayBasedIndexedInts) valuess[columnIndex]; if (newRow == null) { newRow = new ArrayBasedIndexedInts(); valuess[columnIndex] = newRow; } int rowSize = row.size(); newRow.ensureSize(rowSize); for (int i = 0; i < rowSize; i++) { final String value = dimSelector.lookupName(row.get(i)); final int dictId = reverseDictionary.getInt(value); if (dictId < 0) { dictionary.add(value); reverseDictionary.put(value, nextId); newRow.setValue(i, nextId); nextId++; } else { newRow.setValue(i, dictId); } } newRow.setSize(rowSize); }
for (int i = 0; i < numValues; i++) { String value = sortedStrings[i]; _stringValueToIndexMap.put(value, i); byte[] valueBytes = StringUtil.encodeUtf8(value); sortedStringBytes[i] = valueBytes; _bytesValueToIndexMap.put(value, i); _numBytesPerEntry = Math.max(_numBytesPerEntry, value.getBytes().length);
@Override public int set(K k, int v) { int rv = counts.put(k, v); sumOfCounts = sumOfCounts - rv + v; return rv; }
/** * @deprecated use offer instead */ @Deprecated @Override public int put(String k, int v) { return super.put(k, v); }
/** * @deprecated use offer instead */ @Deprecated @Override public Integer put(String ok, Integer ov) { return super.put(ok, ov); }
private static Object2IntOpenHashMap<RowSnapshot> buildHashMap(List<RowSnapshot> rssList) { Object2IntOpenHashMap<RowSnapshot> hMap = new Object2IntOpenHashMap<RowSnapshot>(); rssList.forEach(rss -> hMap.put(rss, 0)); return hMap; }
/** * Add a mapping that we have recovered from disk */ public void addMapping(int id, Object object) { //Store the mapping idToObject.put(id, object); objectToID.put(object, id); //increase the next canonical id the recovered id is higher than it. highestID = highestID < id ? id : highestID; }
@Override public void setup(int[] keys, float fillFactor, final int oneFailureOutOf ) { super.setup(keys, fillFactor, oneFailureOutOf); m_map = new Object2IntOpenHashMap<>( keys.length, fillFactor ); for ( Integer key : keys ) m_map.put( new Integer( key % oneFailureOutOf == 0 ? key + 1 : key), key.intValue() ); }
/** * Returns a map of discovered ItemSets and their support, where the support is the number of times the combination * appears in the input data */ public Object2IntOpenHashMap<int[]> supportMap() { List<ItemSet> itemSets = learn(); Object2IntOpenHashMap<int[]> confidenceMap = new Object2IntOpenHashMap<>(itemSets.size()); for (ItemSet itemSet : itemSets) { confidenceMap.put(itemSet.items, itemSet.support); } return confidenceMap; }
public static boolean addFuel(String fluidName, int energy) { if (!FluidRegistry.isFluidRegistered(fluidName) || energy < 10000 || energy > 200000000) { return false; } if (fuelMap.containsKey(fluidName)) { return false; } fuelMap.put(fluidName, energy); return true; }
/** * Create an id of the given object. * @param object * @return the id generated for this object. */ public int createId(Object object) { assert !objectToID.containsKey(object); int id = ++highestID; objectToID.put(object, id); idToObject.put(id, object); return id; }
int encode(@Nullable String value) { final int ret = this.intEncoding.getOrDefault(value, KEY_NOT_FOUND); if (ret != KEY_NOT_FOUND) return ret; int encoding = this.intEncoding.size(); this.intEncoding.put(value, encoding); this.intDecoding.put(encoding, value); return encoding; }
public void rescale() { for (ObjectIterator<Object2IntMap.Entry<RowSnapshot>> it = this.hMap.object2IntEntrySet(). fastIterator(); it.hasNext(); ) { final Object2IntMap.Entry<RowSnapshot> entry = it.next(); this.hMap.put(entry.getKey(), (int) (entry.getIntValue() * ((double) this.totalRows)/this.sampleSize)); } } }