Java Code Examples for it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap#put()

The following examples show how to use it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap#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: PositionListIndex.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
public boolean refines(int[][] lhsInvertedPlis, int[] rhs) {
	for (IntArrayList cluster : this.clusters) {
		Object2IntOpenHashMap<IntArrayList> clustersMap = new Object2IntOpenHashMap<>(cluster.size());
		
		// Check if all subclusters of this cluster point into the same other clusters
		for (int recordId : cluster) {
			IntArrayList additionalLhsCluster = this.buildClusterIdentifier(recordId, lhsInvertedPlis);
			if (additionalLhsCluster == null)
				continue;
			
			if (clustersMap.containsKey(additionalLhsCluster)) {
				if ((rhs[recordId] == -1) || (clustersMap.getInt(additionalLhsCluster) != rhs[recordId]))
					return false;
			}
			else {
				clustersMap.put(additionalLhsCluster, rhs[recordId]);
			}
		}
	}
	return true;
}
 
Example 2
Source File: PositionListIndex.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
public boolean isUniqueWith(int[][] compressedRecords, BitSet otherAttrs, List<IntegerPair> comparisonSuggestions) {
	int attrsSize = otherAttrs.cardinality();
	
	for (IntArrayList cluster : this.clusters) {
		Object2IntOpenHashMap<ClusterIdentifier> value2record = new Object2IntOpenHashMap<>(cluster.size());
		for (int recordId : cluster) {
			ClusterIdentifier value = this.buildClusterIdentifier(otherAttrs, attrsSize, compressedRecords[recordId]);
			if (value == null)
				continue;
			if (value2record.containsKey(value)) {
				comparisonSuggestions.add(new IntegerPair(recordId, value2record.getInt(value)));
				return false;
			}
			value2record.put(value, recordId);
		}
	}
	return true;
}
 
Example 3
Source File: PositionListIndex.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
public boolean refines(int[][] lhsInvertedPlis, int[] rhs) {
	for (IntArrayList cluster : this.clusters) {
		Object2IntOpenHashMap<IntArrayList> clustersMap = new Object2IntOpenHashMap<>(cluster.size());
		
		// Check if all subclusters of this cluster point into the same other clusters
		for (int recordId : cluster) {
			IntArrayList additionalLhsCluster = this.buildClusterIdentifier(recordId, lhsInvertedPlis);
			if (additionalLhsCluster == null)
				continue;
			
			if (clustersMap.containsKey(additionalLhsCluster)) {
				if ((rhs[recordId] == -1) || (clustersMap.getInt(additionalLhsCluster) != rhs[recordId]))
					return false;
			}
			else {
				clustersMap.put(additionalLhsCluster, rhs[recordId]);
			}
		}
	}
	return true;
}
 
Example 4
Source File: PositionListIndex.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
public boolean refines(int[][] lhsInvertedPlis, int[] rhs) {
	for (IntArrayList cluster : this.clusters) {
		Object2IntOpenHashMap<IntArrayList> clustersMap = new Object2IntOpenHashMap<>(cluster.size());
		
		// Check if all subclusters of this cluster point into the same other clusters
		for (int recordId : cluster) {
			IntArrayList additionalLhsCluster = this.buildClusterIdentifier(recordId, lhsInvertedPlis);
			if (additionalLhsCluster == null)
				continue;
			
			if (clustersMap.containsKey(additionalLhsCluster)) {
				if ((rhs[recordId] == -1) || (clustersMap.getInt(additionalLhsCluster) != rhs[recordId]))
					return false;
			}
			else {
				clustersMap.put(additionalLhsCluster, rhs[recordId]);
			}
		}
	}
	return true;
}
 
Example 5
Source File: PositionListIndex.java    From winter with Apache License 2.0 6 votes vote down vote up
public boolean refines(int[][] lhsInvertedPlis, int[] rhs) {
	for (IntArrayList cluster : this.clusters) {
		Object2IntOpenHashMap<IntArrayList> clustersMap = new Object2IntOpenHashMap<>(cluster.size());
		
		// Check if all subclusters of this cluster point into the same other clusters
		for (int recordId : cluster) {
			IntArrayList additionalLhsCluster = this.buildClusterIdentifier(recordId, lhsInvertedPlis);
			if (additionalLhsCluster == null)
				continue;
			
			if (clustersMap.containsKey(additionalLhsCluster)) {
				if ((rhs[recordId] == -1) || (clustersMap.getInt(additionalLhsCluster) != rhs[recordId]))
					return false;
			}
			else {
				clustersMap.put(additionalLhsCluster, rhs[recordId]);
			}
		}
	}
	return true;
}
 
Example 6
Source File: HLA.java    From kourami with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public int processRecord(SAMRecord sr, Object2IntOpenHashMap<String> readLoadingSet){
int totalOp = 0;
String hlagene = HLA.extractHLAGeneName(sr.getReferenceName());
HLAGraph hg = this.hlaName2Graph.get(hlagene);
//hg.traverse();
if(hg != null){
    if(hg.isClassI()){
	boolean qc = this.qcCheck(sr);
	if(!qc)
	    return 0;
    }
    int readnum = readLoadingSet.getInt(sr.getReadName());
    //no such read has been read. return value of 0 means the hashSet doesn't have the read
    if(readnum == 0){
	readnum = sr.getFirstOfPairFlag() ? HLA.readNum : 0-HLA.readNum;
	
	readLoadingSet.put(sr.getReadName(), HLA.readNum);
	HLA.readNum++;
    }else
	readnum = sr.getFirstOfPairFlag() ? readnum : 0-readnum;

    totalOp += hg.addWeight(sr, readnum);//HLA.readNum);
    //HLA.readNum++;
}else{
    ;//HLA.log.appendln("UNKNOWN HLA GENE: " + hlagene);
}
return totalOp;
   }
 
Example 7
Source File: CategoriesToWIDMap.java    From tagme with Apache License 2.0 5 votes vote down vote up
@Override
protected Object2IntMap<String> parseSet() throws IOException
{
	final Object2IntOpenHashMap<String> map = new Object2IntOpenHashMap<String>(3000000);
	File input = WikipediaFiles.TITLES.getSourceFile(lang);
	
	SQLWikiParser parser = new SQLWikiParser(log) {
		@Override
		public boolean compute(ArrayList<String> values) throws IOException {
			if (values.get(SQLWikiParser.PAGE_NS).equals(SQLWikiParser.NS_CATEGORY_STRING)){
				
				String category = cleanPageName(values.get(SQLWikiParser.PAGE_TITLE));
				map.put(category, Integer.parseInt(values.get(SQLWikiParser.PAGE_ID)));
				return true;
			} else return false;
		}
		
	};
	InputStreamReader reader = new InputStreamReader(new FileInputStream(input), Charset.forName("UTF-8"));
	parser.compute(reader);
	reader.close();
	
	map.defaultReturnValue(-1);
	map.trim();
	
	return map;
}
 
Example 8
Source File: TitlesToWIDMap.java    From tagme with Apache License 2.0 5 votes vote down vote up
@Override
protected Object2IntMap<String> parseSet() throws IOException
{
	final Object2IntOpenHashMap<String> map = new Object2IntOpenHashMap<String>(3000000);
	File input = WikipediaFiles.TITLES.getSourceFile(lang);
	
	SQLWikiParser parser = new SQLWikiParser(log) {
		@Override
		public boolean compute(ArrayList<String> values) throws IOException {
			if (values.get(SQLWikiParser.PAGE_NS).equals(SQLWikiParser.NS_ARTICLE_STRING)){
				
				String title = cleanPageName(values.get(SQLWikiParser.PAGE_TITLE));
				map.put(title, Integer.parseInt(values.get(SQLWikiParser.PAGE_ID)));
				return true;
			} else return false;
		}
		
	};
	InputStreamReader reader = new InputStreamReader(new FileInputStream(input), Charset.forName("UTF-8"));
	parser.compute(reader);
	reader.close();
	
	map.defaultReturnValue(-1);
	map.trim();
	
	return map;
}
 
Example 9
Source File: FastUtilObjectIntMapTest.java    From hashmapTest with The Unlicense 5 votes vote down vote up
@Override
public int test() {
    final Object2IntOpenHashMap<Integer> m_map = new Object2IntOpenHashMap<>( m_keys.length, m_fillFactor );
    for ( int i = 0; i < m_keys.length; ++i )
        m_map.put( m_keys[ i ], i );
    for ( int i = 0; i < m_keys2.length; ++i )
        m_map.put( m_keys2[ i ], i );
    return m_map.size();
}
 
Example 10
Source File: FastUtilObjectIntMapTest.java    From hashmapTest with The Unlicense 5 votes vote down vote up
@Override
public int test() {
    final Object2IntOpenHashMap<Integer> m_map = new Object2IntOpenHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
    int add = 0, remove = 0;
    while ( add < m_keys.length )
    {
        m_map.put( m_keys[ add ], add );
        ++add;
        m_map.put( m_keys[ add ], add );
        ++add;
        m_map.removeInt( m_keys[ remove++ ] );
    }
    return m_map.size();
}
 
Example 11
Source File: DistinctTable.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor of the main DistinctTable which can be used to add records and merge other DistinctTables.
 */
public DistinctTable(DataSchema dataSchema, @Nullable List<OrderByExpressionContext> orderByExpressions, int limit) {
  _dataSchema = dataSchema;
  _limit = limit;

  // TODO: see if 10k is the right max initial capacity to use
  // NOTE: When LIMIT is smaller than or equal to the MAX_INITIAL_CAPACITY, no resize is required.
  int initialCapacity = Math.min(limit, MAX_INITIAL_CAPACITY);
  _uniqueRecords = new ObjectOpenHashSet<>(initialCapacity);
  if (orderByExpressions != null) {
    String[] columns = dataSchema.getColumnNames();
    int numColumns = columns.length;
    Object2IntOpenHashMap<String> columnIndexMap = new Object2IntOpenHashMap<>(numColumns);
    for (int i = 0; i < numColumns; i++) {
      columnIndexMap.put(columns[i], i);
    }
    int numOrderByColumns = orderByExpressions.size();
    int[] orderByColumnIndexes = new int[numOrderByColumns];
    boolean[] orderByAsc = new boolean[numOrderByColumns];
    for (int i = 0; i < numOrderByColumns; i++) {
      OrderByExpressionContext orderByExpression = orderByExpressions.get(i);
      orderByColumnIndexes[i] = columnIndexMap.getInt(orderByExpression.getExpression().toString());
      orderByAsc[i] = orderByExpression.isAsc();
    }
    _sortedRecords = new PriorityQueue<>(initialCapacity, (record1, record2) -> {
      Object[] values1 = record1.getValues();
      Object[] values2 = record2.getValues();
      for (int i = 0; i < numOrderByColumns; i++) {
        Comparable valueToCompare1 = (Comparable) values1[orderByColumnIndexes[i]];
        Comparable valueToCompare2 = (Comparable) values2[orderByColumnIndexes[i]];
        int result =
            orderByAsc[i] ? valueToCompare2.compareTo(valueToCompare1) : valueToCompare1.compareTo(valueToCompare2);
        if (result != 0) {
          return result;
        }
      }
      return 0;
    });
  } else {
    _sortedRecords = null;
  }
  _records = null;
}