Java Code Examples for it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap#put()
The following examples show how to use
it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap#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: TaneAlgorithmFilterTreeEnd.java From metanome-algorithms with Apache License 2.0 | 5 votes |
private void generateNextLevel() { // System.out.println("Start generateNextLevel"); level0 = level1; level1 = null; System.gc(); Object2ObjectOpenHashMap<BitSet, CombinationHelper> new_level = new Object2ObjectOpenHashMap<BitSet, CombinationHelper>(); buildPrefixBlocks(); for (ObjectArrayList<BitSet> prefix_block_list : prefix_blocks.values()) { // continue only, if the prefix_block contains at least 2 elements if (prefix_block_list.size() < 2) { continue; } ObjectArrayList<BitSet[]> combinations = getListCombinations(prefix_block_list); for (BitSet[] c : combinations) { BitSet X = (BitSet) c[0].clone(); X.or(c[1]); if (checkSubsets(X)) { StrippedPartition st = multiply(level0.get(c[0]).getPartition(), level0.get(c[1]).getPartition()); BitSet rhsCandidates = new BitSet(); // rhsCandidates.set(1, numberAttributes+1); CombinationHelper ch = new CombinationHelper(); ch.setPartition(st); ch.setRhsCandidates(rhsCandidates); new_level.put(X, ch); } } } level1 = new_level; }
Example 2
Source File: TaneAlgorithmFilterTreeDirect.java From metanome-algorithms with Apache License 2.0 | 5 votes |
private void generateNextLevel() { // System.out.println("Start generateNextLevel"); level0 = level1; level1 = null; System.gc(); Object2ObjectOpenHashMap<BitSet, CombinationHelper> new_level = new Object2ObjectOpenHashMap<BitSet, CombinationHelper>(); buildPrefixBlocks(); for (ObjectArrayList<BitSet> prefix_block_list : prefix_blocks.values()) { // continue only, if the prefix_block contains at least 2 elements if (prefix_block_list.size() < 2) { continue; } ObjectArrayList<BitSet[]> combinations = getListCombinations(prefix_block_list); for (BitSet[] c : combinations) { BitSet X = (BitSet) c[0].clone(); X.or(c[1]); if (checkSubsets(X)) { StrippedPartition st = multiply(level0.get(c[0]).getPartition(), level0.get(c[1]).getPartition()); BitSet rhsCandidates = new BitSet(); // rhsCandidates.set(1, numberAttributes+1); CombinationHelper ch = new CombinationHelper(); ch.setPartition(st); ch.setRhsCandidates(rhsCandidates); new_level.put(X, ch); } } } level1 = new_level; // System.out.println("Finished generateNextLevel"); }
Example 3
Source File: KNearestNeighbor.java From StreamingRec with Apache License 2.0 | 5 votes |
@Override protected void trainInternal(List<Item> items, List<ClickData> clicks) { //iterate over sessions for (ClickData clickData : clicks) { //iterate over clicks in session for(Transaction click : clickData.session){ //find possible maps where this session needs to be stored Object2ObjectOpenHashMap<Date,List<List<Transaction>>> itemMap = itemToSessionByTimeMap.get(click.item.id); if(itemMap == null){ //if the map does not exist, create it itemMap = new Object2ObjectOpenHashMap<>(); itemToSessionByTimeMap.put(click.item.id, itemMap); } List<List<Transaction>> possiblePreviousSessions = itemMap.get(clickData.session.get(0).timestamp); //check for possible previous session by using //this session's first item's timestamp as an identifier if(possiblePreviousSessions==null){ //if the list does not exist, create it possiblePreviousSessions = new ArrayList<>(); itemMap.put(clickData.session.get(0).timestamp, possiblePreviousSessions); } for (Iterator<List<Transaction>> iterator = possiblePreviousSessions.iterator(); iterator.hasNext();) { List<Transaction> possiblePreviousSession = iterator.next(); if(possiblePreviousSession.get(0).userId==click.userId){//user and time are the same as a previous session? iterator.remove(); //(part of) the session is known -> remove/deduplicate //this also keeps the session from being added twice because of duplicate items in one session. } } //add the current session to the appropriate item's map possiblePreviousSessions.add(clickData.session); } } }
Example 4
Source File: GlobalVisitStats.java From fasten with Apache License 2.0 | 4 votes |
public static Result reaches(final KnowledgeBase kb, final long startSig, final int maxRevs, final ProgressLogger pl) { final LongOpenHashSet result = new LongOpenHashSet(); final Object2ObjectOpenHashMap<String, IntOpenHashSet> product2Revs = new Object2ObjectOpenHashMap<>(); final MutableLong totRevs = new MutableLong(); // Visit queue final LongArrayFIFOQueue queue = new LongArrayFIFOQueue(); queue.enqueue(startSig); result.add(startSig); String p = kb.callGraphs.get(index(startSig)).product; IntOpenHashSet revs = new IntOpenHashSet(); revs.add(index(startSig)); product2Revs.put(p, revs); totRevs.increment(); pl.itemsName = "nodes"; pl.info = new Object() { @Override public String toString() { return "[nodes: " + result.size() + " products: " + product2Revs.size() + " revisions: " + totRevs.getValue() + "]"; } }; pl.start("Visiting reachable nodes..."); while (!queue.isEmpty()) { final long node = queue.dequeueLong(); for (final long s : kb.successors(node)) if (!result.contains(s)) { p = kb.callGraphs.get(index(s)).product; final long gid = gid(s); if (badGIDs.contains(gid)) continue; final String targetNameSpace = kb.new Node(gid, index(s)).toFastenURI().getRawNamespace(); if (targetNameSpace.startsWith("java.") || targetNameSpace.startsWith("javax.") || targetNameSpace.startsWith("jdk.")) { badGIDs.add(gid); continue; } revs = product2Revs.get(p); if (revs == null) product2Revs.put(p, revs = new IntOpenHashSet()); if (revs.contains(index(s)) || revs.size() < maxRevs) { queue.enqueue(s); result.add(s); //System.out.println(kb.new Node(gid(node), index(node)).toFastenURI() + " -> " + kb.new Node(gid(s), index(s)).toFastenURI()); if (revs.add(index(s))) totRevs.increment(); } } pl.lightUpdate(); } pl.done(); return new Result(result, product2Revs.size(), totRevs.getValue().longValue()); }
Example 5
Source File: GlobalVisitStats.java From fasten with Apache License 2.0 | 4 votes |
public static Result coreaches(final KnowledgeBase kb, final long startSig, final int maxRevs, final ProgressLogger pl) { final LongOpenHashSet result = new LongOpenHashSet(); final Object2ObjectOpenHashMap<String, IntOpenHashSet> product2Revs = new Object2ObjectOpenHashMap<>(); final MutableLong totRevs = new MutableLong(); // Visit queue final LongArrayFIFOQueue queue = new LongArrayFIFOQueue(); queue.enqueue(startSig); result.add(startSig); String p = kb.callGraphs.get(index(startSig)).product; IntOpenHashSet revs = new IntOpenHashSet(); revs.add(index(startSig)); product2Revs.put(p, revs); totRevs.increment(); pl.itemsName = "nodes"; pl.info = new Object() { @Override public String toString() { return "[nodes: " + result.size() + " products: " + product2Revs.size() + " revisions: " + totRevs.getValue() + "]"; } }; pl.start("Visiting coreachable nodes..."); while (!queue.isEmpty()) { final long node = queue.dequeueLong(); for (final long s : kb.predecessors(node)) if (!result.contains(s)) { p = kb.callGraphs.get(index(s)).product; final String targetNameSpace = kb.new Node(gid(s), index(s)).toFastenURI().getRawNamespace(); if (targetNameSpace.startsWith("java.") || targetNameSpace.startsWith("javax.") || targetNameSpace.startsWith("jdk.")) continue; revs = product2Revs.get(p); if (revs == null) product2Revs.put(p, revs = new IntOpenHashSet()); if (revs.contains(index(s)) || revs.size() < maxRevs) { queue.enqueue(s); result.add(s); //System.out.println(kb.new Node(gid(node), index(node)).toFastenURI() + " -> " + kb.new Node(gid(s), index(s)).toFastenURI()); if (revs.add(index(s))) totRevs.increment(); } } pl.lightUpdate(); } pl.done(); return new Result(result, product2Revs.size(), totRevs.getValue().longValue()); }
Example 6
Source File: TaneAlgorithm.java From metanome-algorithms with Apache License 2.0 | 4 votes |
private void generateNextLevel() { level0 = level1; level1 = null; System.gc(); Object2ObjectOpenHashMap<BitSet, CombinationHelper> new_level = new Object2ObjectOpenHashMap<BitSet, CombinationHelper>(); buildPrefixBlocks(); for (ObjectArrayList<BitSet> prefix_block_list : prefix_blocks.values()) { // continue only, if the prefix_block contains at least 2 elements if (prefix_block_list.size() < 2) { continue; } ObjectArrayList<BitSet[]> combinations = getListCombinations(prefix_block_list); for (BitSet[] c : combinations) { BitSet X = (BitSet) c[0].clone(); X.or(c[1]); if (checkSubsets(X)) { StrippedPartition st = null; CombinationHelper ch = new CombinationHelper(); if (level0.get(c[0]).isValid() && level0.get(c[1]).isValid()) { st = multiply(level0.get(c[0]).getPartition(), level0.get(c[1]).getPartition()); } else { ch.setInvalid(); } BitSet rhsCandidates = new BitSet(); ch.setPartition(st); ch.setRhsCandidates(rhsCandidates); new_level.put(X, ch); } } } level1 = new_level; }