Java Code Examples for it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap#defaultReturnValue()

The following examples show how to use it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap#defaultReturnValue() . 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: SetSimilarity.java    From RankSys with Mozilla Public License 2.0 6 votes vote down vote up
private Int2IntMap getFasterIntersectionMap(int uidx) {
    Int2IntOpenHashMap intersectionMap = new Int2IntOpenHashMap();
    intersectionMap.defaultReturnValue(0);

    IntIterator iidxs = data.getUidxIidxs(uidx);
    while (iidxs.hasNext()) {
        IntIterator vidxs = data.getIidxUidxs(iidxs.nextInt());
        while (vidxs.hasNext()) {
            intersectionMap.addTo(vidxs.nextInt(), 1);
        }
    }

    intersectionMap.remove(uidx);

    return intersectionMap;
}
 
Example 2
Source File: AnchorIndexer.java    From tagme with Apache License 2.0 5 votes vote down vote up
public AnchorIterator(File inputFile) throws IOException
{
	anchor = null;
	links = new Int2IntOpenHashMap(1024);
	links.defaultReturnValue(0);
	originals = new HashSet<String>(32);
	in = new FastBufferedReader(new InputStreamReader(new FileInputStream(inputFile), Charset.forName("UTF-8")));
	line = new MutableString(1024);
	in.readLine(line);
	lastAnchor = Chars.split(line, TextDataset.SEP_CHAR)[0].toString();
	scroll = 1;
	end = false;
}
 
Example 3
Source File: RedirectMap.java    From tagme with Apache License 2.0 5 votes vote down vote up
@Override
protected Int2IntMap parseSet() throws IOException
{
	final Object2IntMap<String> titles = new TitlesToWIDMap(lang).getDataset();
	final Int2IntOpenHashMap map = new Int2IntOpenHashMap(3000000);
	SQLWikiParser parser = new SQLWikiParser(log, "Titles NF") {
		@Override
		public boolean compute(ArrayList<String> values) throws IOException
		{
			int ns = Integer.parseInt(values.get(SQLWikiParser.REDIRECT_NS));
			if (ns == SQLWikiParser.NS_ARTICLE)
			{
				int idFrom = Integer.parseInt(values.get(SQLWikiParser.REDIRECT_ID_FROM));
				int idTo = titles.getInt(cleanPageName(values.get(SQLWikiParser.REDIRECT_TITLE_TO)));
				if (idTo >= 0)
					map.put(idFrom, idTo);
				else this.updateItem(0);
				
				return true;
			} else return false;
		}
	};

	File input = WikipediaFiles.REDIRECTS.getSourceFile(lang);
	InputStreamReader in = new InputStreamReader(new FileInputStream(input), Charset.forName("UTF-8"));
	parser.compute(in);
	in.close();
	
	map.defaultReturnValue(-1);
	map.trim();
	
	return map;

}
 
Example 4
Source File: SetSimilarity.java    From RankSys with Mozilla Public License 2.0 5 votes vote down vote up
private Int2IntMap getIntersectionMap(int idx1) {
    Int2IntOpenHashMap intersectionMap = new Int2IntOpenHashMap();
    intersectionMap.defaultReturnValue(0);

    data.getUidxPreferences(idx1)
            .forEach(ip -> data.getIidxPreferences(ip.v1)
                    .forEach(up -> intersectionMap.addTo(up.v1, 1)));

    intersectionMap.remove(idx1);

    return intersectionMap;
}
 
Example 5
Source File: OnHeapIntDictionary.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor for the class.
 * Populates the value <-> mappings.
 *
 * @param dataBuffer Pinot data buffer
 * @param length Length of the dictionary
 */
public OnHeapIntDictionary(PinotDataBuffer dataBuffer, int length) {
  super(dataBuffer, length, Integer.BYTES, (byte) 0);

  _valToDictId = new Int2IntOpenHashMap(length);
  _valToDictId.defaultReturnValue(NULL_VALUE_INDEX);
  _dictIdToVal = new int[length];

  for (int dictId = 0; dictId < length; dictId++) {
    int value = getInt(dictId);
    _dictIdToVal[dictId] = value;
    _valToDictId.put(value, dictId);
  }
}
 
Example 6
Source File: DictionaryBasedGroupKeyGenerator.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
public IntMapBasedHolder(int initialSize) {
  _rawKeyToGroupIdMap = new Int2IntOpenHashMap(initialSize);
  _rawKeyToGroupIdMap.defaultReturnValue(INVALID_ID);
}
 
Example 7
Source File: IntToIdMap.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
public IntToIdMap() {
  _valueToIdMap = new Int2IntOpenHashMap();
  _valueToIdMap.defaultReturnValue(INVALID_KEY);
  _idToValueMap = new IntArrayList();
}