Java Code Examples for it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap#put()

The following examples show how to use it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap#put() . 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: FDTree.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
public void generalize() {
	int maxLevel = this.numAttributes;
	
	// Build an index level->nodes for the top-down, level-wise traversal
	Int2ObjectOpenHashMap<ArrayList<ElementLhsPair>> level2elements = new Int2ObjectOpenHashMap<>(maxLevel);
	for (int level = 0; level < maxLevel; level++)
		level2elements.put(level, new ArrayList<ElementLhsPair>());
	this.addToIndex(level2elements, 0, new BitSet(this.numAttributes));
	
	// Traverse the levels top-down and add all direct generalizations
	for (int level = maxLevel - 1; level >= 0; level--) {
		for (ElementLhsPair pair : level2elements.get(level)) {
			// Remove isFDs, because we will mark valid FDs later on
			pair.element.removeAllFds();
			
			// Generate and add generalizations
			for (int lhsAttr = pair.lhs.nextSetBit(0); lhsAttr >= 0; lhsAttr = pair.lhs.nextSetBit(lhsAttr + 1)) {
				pair.lhs.clear(lhsAttr);
				de.metanome.algorithms.cfdfinder.structures.FDTreeElement generalization = this.addGeneralization(pair.lhs, pair.element.getRhsAttributes());
				if (generalization != null)
					level2elements.get(level - 1).add(new ElementLhsPair(generalization, (BitSet) pair.lhs.clone()));
				pair.lhs.set(lhsAttr);
			}
		}
	}
}
 
Example 2
Source File: SPIDER.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
private void output() throws CouldNotReceiveResultException, ColumnNameMismatchException {
	// Read the discovered INDs from the attributes
	Int2ObjectOpenHashMap<IntList> dep2ref = new Int2ObjectOpenHashMap<IntList>(this.numColumns);
	for (Attribute spiderAttribute : this.attributeId2attributeObject.values())
		if (!spiderAttribute.getReferenced().isEmpty())
			dep2ref.put(spiderAttribute.getAttributeId(), new IntArrayList(spiderAttribute.getReferenced()));
	
	// Write the result to the resultReceiver
	for (int dep : dep2ref.keySet()) {
		String depTableName = this.getTableNameFor(dep, this.tableColumnStartIndexes);
		String depColumnName = this.columnNames.get(dep);
		
		for (int ref : dep2ref.get(dep)) {
			String refTableName = this.getTableNameFor(ref, this.tableColumnStartIndexes);
			String refColumnName = this.columnNames.get(ref);
			
			this.resultReceiver.receiveResult(new InclusionDependency(new ColumnPermutation(new ColumnIdentifier(depTableName, depColumnName)), new ColumnPermutation(new ColumnIdentifier(refTableName, refColumnName))));
			this.numUnaryINDs++;
		}
	}
}
 
Example 3
Source File: FDTree.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
public void generalize() {
	int maxLevel = this.numAttributes;
	
	// Build an index level->nodes for the top-down, level-wise traversal
	Int2ObjectOpenHashMap<ArrayList<ElementLhsPair>> level2elements = new Int2ObjectOpenHashMap<>(maxLevel);
	for (int level = 0; level < maxLevel; level++)
		level2elements.put(level, new ArrayList<ElementLhsPair>());
	this.addToIndex(level2elements, 0, new BitSet(this.numAttributes));
	
	// Traverse the levels top-down and add all direct generalizations
	for (int level = maxLevel - 1; level >= 0; level--) {
		for (ElementLhsPair pair : level2elements.get(level)) {
			// Remove isFDs, because we will mark valid FDs later on
			pair.element.removeAllFds();
			
			// Generate and add generalizations
			for (int lhsAttr = pair.lhs.nextSetBit(0); lhsAttr >= 0; lhsAttr = pair.lhs.nextSetBit(lhsAttr + 1)) {
				pair.lhs.clear(lhsAttr);
				FDTreeElement generalization = this.addGeneralization(pair.lhs, pair.element.getRhsAttributes());
				if (generalization != null)
					level2elements.get(level - 1).add(new ElementLhsPair(generalization, (BitSet) pair.lhs.clone()));
				pair.lhs.set(lhsAttr);
			}
		}
	}
}
 
Example 4
Source File: FDTree.java    From winter with Apache License 2.0 6 votes vote down vote up
public void generalize() {
	int maxLevel = this.numAttributes;
	
	// Build an index level->nodes for the top-down, level-wise traversal
	Int2ObjectOpenHashMap<ArrayList<ElementLhsPair>> level2elements = new Int2ObjectOpenHashMap<>(maxLevel);
	for (int level = 0; level < maxLevel; level++)
		level2elements.put(level, new ArrayList<ElementLhsPair>());
	this.addToIndex(level2elements, 0, new OpenBitSet(this.numAttributes));
	
	// Traverse the levels top-down and add all direct generalizations
	for (int level = maxLevel - 1; level >= 0; level--) {
		for (ElementLhsPair pair : level2elements.get(level)) {
			// Remove isFDs, because we will mark valid FDs later on
			pair.element.removeAllFds();
			
			// Generate and add generalizations
			for (int lhsAttr = pair.lhs.nextSetBit(0); lhsAttr >= 0; lhsAttr = pair.lhs.nextSetBit(lhsAttr + 1)) {
				pair.lhs.clear(lhsAttr);
				FDTreeElement generalization = this.addGeneralization(pair.lhs, pair.element.getRhsAttributes());
				if (generalization != null)
					level2elements.get(level - 1).add(new ElementLhsPair(generalization, pair.lhs.clone()));
				pair.lhs.set(lhsAttr);
			}
		}
	}
}
 
Example 5
Source File: TextureUtil.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
protected void calculateLayerArrays() {
    Int2ObjectOpenHashMap<char[]> colorLayerMap = new Int2ObjectOpenHashMap<>();
    for (int i = 0; i < validBlockIds.length; i++) {
        int color = validColors[i];
        int combined = validBlockIds[i];
        if (hasAlpha(color)) {
            for (int j = 0; j < validBlockIds.length; j++) {
                int colorOther = validColors[j];
                if (!hasAlpha(colorOther)) {
                    int combinedOther = validBlockIds[j];
                    int combinedColor = combineTransparency(color, colorOther);
                    colorLayerMap.put(combinedColor, new char[]{(char) combined, (char) combinedOther});
                }
            }
        }
    }
    this.validLayerColors = new int[colorLayerMap.size()];
    this.validLayerBlocks = new char[colorLayerMap.size()][];
    int index = 0;
    for (Int2ObjectMap.Entry<char[]> entry : colorLayerMap.int2ObjectEntrySet()) {
        validLayerColors[index] = entry.getIntKey();
        validLayerBlocks[index++] = entry.getValue();
    }
}
 
Example 6
Source File: MToNSimple.java    From twister2 with Apache License 2.0 5 votes vote down vote up
private RoutingParameters sendRoutingParameters(int source, int path) {
  Int2ObjectOpenHashMap p = routingParamCache.get(source);
  if (p.containsKey(path)) {
    return (RoutingParameters) p.get(path);
  } else {
    RoutingParameters routingParameters = new RoutingParameters();
    routingParameters.setDestinationId(path);
    routingParameters.addInteranlRoute(source);
    p.put(path, routingParameters);
    return routingParameters;
  }
}
 
Example 7
Source File: DiskStorageHistory.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public Map<Integer, Integer> getBlocks() {
    Int2ObjectOpenHashMap<Integer> map = new Int2ObjectOpenHashMap<>();
    for (int i = 0; i < blocks.length; i++) {
        if (blocks[i] != 0) {
            map.put(i, (Integer) blocks[i]);
        }
    }
    return map;
}
 
Example 8
Source File: DiskStorageHistory.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public Map<Integer, Double> getPercents() {
    Map<Integer, Integer> map = getBlocks();
    int count = getSize();
    Int2ObjectOpenHashMap<Double> newMap = new Int2ObjectOpenHashMap<Double>();
    for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
        int id = entry.getKey();
        int changes = entry.getValue();
        double percent = ((changes * 1000l) / count) / 10d;
        newMap.put(id, (Double) percent);
    }
    return newMap;
}
 
Example 9
Source File: FastUtilIntObjectMapTest.java    From hashmapTest with The Unlicense 5 votes vote down vote up
@Override
public int test() {
    final Int2ObjectOpenHashMap<Integer> m_map = new Int2ObjectOpenHashMap<>( m_keys.length, m_fillFactor );
    for ( int i = 0; i < m_keys.length; ++i )
        m_map.put( m_keys[ i ], null );
    for ( int i = 0; i < m_keys.length; ++i )
        m_map.put( m_keys[ i ], null );
    return m_map.size();
}
 
Example 10
Source File: FastUtilIntObjectMapTest.java    From hashmapTest with The Unlicense 5 votes vote down vote up
@Override
public int test() {
    final Int2ObjectOpenHashMap<Integer> m_map = new Int2ObjectOpenHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
    final Integer value = 1;
    int add = 0, remove = 0;
    while ( add < m_keys.length )
    {
        m_map.put( m_keys[ add ], value );
        ++add;
        m_map.put( m_keys[ add ], value );
        ++add;
        m_map.remove( m_keys[ remove++ ] );
    }
    return m_map.size();
}