private Alphabet (int capacity) { this.map = new TLongIntHashMap(capacity); numEntries = 0; }
private Alphabet (int capacity) { this.map = new TLongIntHashMap(capacity); numEntries = 0; }
public HashLongLongArray() { // Create and initialize hash hash = new TLongIntHashMap(); // Create and initialize buckets buckets = new long[INITIAL_NUMBER_OF_BUCKETS][]; bucketFirstAvailable = new int[INITIAL_NUMBER_OF_BUCKETS]; // Bucket number zero is reserved (in the hash zero means 'not found') buckets[0] = new long[0]; bucketsUsed = 1; }
public NmerCount(int nmerSize) { this.nmerSize = nmerSize; hash = new TLongIntHashMap(); }
public PwmAndSeqs(int len) { super(len); countSeqs = new TLongIntHashMap(); countRsIds = new TLongIntHashMap(); nmer = new Nmer(len); }
/** * Constructor * @param initialSize the initial size for this index */ IndexOfLongs(int initialSize) { super(Array.of(Long.class, initialSize)); this.indexMap = new TLongIntHashMap(initialSize, 0.75f, -1, -1); }
/** * Creates an empty {@code Counter}. */ public PairCounter() { counts = new TLongIntHashMap(); elementIndices = new HashIndexer<T>(); sum = 0; }
/** * Creates an empty {@code Counter}. */ public PairCounter() { counts = new TLongIntHashMap(); elementIndices = new HashIndexer<T>(); sum = 0; }
/** * Constructor for empty index with initial capacity * @param type the array type * @param coding the coding for this index * @param capacity the initial capacity for this index */ IndexWithLongCoding(Class<T> type, LongCoding<T> coding, int capacity) { super(Array.of(type, capacity)); this.coding = coding; this.indexMap = new TLongIntHashMap(capacity, 0.75f, -1L, -1); }
public long getExpectedPosition() { TLongIntMap map = new TLongIntHashMap(); for (Support s : support) { map.adjustOrPutValue(s.expectedLinearPosition, s.weight, s.weight); } return getKeyWithMaxValue(map); } public long getExpectedReferencePosition() {
@Override @SuppressWarnings("unchecked") public final Index<T> copy() { try { final IndexWithLongCoding<T> clone = (IndexWithLongCoding<T>)super.copy(); clone.indexMap = new TLongIntHashMap(indexMap); clone.coding = coding; return clone; } catch (Exception ex) { throw new IndexException("Failed to clone index", ex); } }
@Override public final Index<Long> copy() { try { final IndexOfLongs clone = (IndexOfLongs)super.copy(); clone.indexMap = new TLongIntHashMap(indexMap); return clone; } catch (Exception ex) { throw new IndexException("Failed to clone index", ex); } }
private TLongIntMap getPhraseLinkCounts() { Iterator<Pair<String, PrunedCounts<Integer>>> phraseIter = phraseDao.getAllPhraseCounts(lang); TLongIntMap counts = new TLongIntHashMap(); while (phraseIter.hasNext()) { Pair<String, PrunedCounts<Integer>> pair = phraseIter.next(); String phrase = cleanString(pair.getLeft()); long hash = hashCode(phrase); int n = pair.getRight().getTotal(); counts.adjustOrPutValue(hash, n, n); } return counts; }
public long getExpectedReferencePosition() { if (!isReference()) throw new IllegalStateException("No reference kmer support"); TLongIntMap map = new TLongIntHashMap(); for (Support s : support) { if (s.isReference) { map.adjustOrPutValue(s.expectedLinearPosition, s.weight, s.weight); } } return getKeyWithMaxValue(map); } public static <T extends DeBruijnNodeBase> long getExpectedReferencePosition(Iterable<T> nodes) {
public static <T extends DeBruijnNodeBase> long getExpectedReferencePosition(Iterable<T> nodes) { TLongIntMap map = new TLongIntHashMap(); for (DeBruijnNodeBase n : nodes) { for (Support s : n.support) { if (s.isReference) { map.adjustOrPutValue(s.expectedLinearPosition, s.weight, s.weight); } } } if (map.isEmpty()) throw new IllegalStateException("No reference support"); return getKeyWithMaxValue(map); } private static long getKeyWithMaxValue(TLongIntMap map) {
private void readPhraseIds() throws IOException { BufferedReader reader = WpIOUtils.openBufferedReader(getPhraseIdPath()); try { phraseIds = new TLongIntHashMap(); while (true) { String line = reader.readLine(); if (line == null) { break; } String tokens[] = line.split("\t", 2); int wpId = Integer.parseInt(tokens[0]); String phrase = tokens[1].trim(); phraseIds.put(hashWord(phrase), wpId); } } finally { IOUtils.closeQuietly(reader); } }
/** * Constructor * @param iterable the keys for index */ IndexOfLongs(Iterable<Long> iterable) { super(iterable); this.indexMap = new TLongIntHashMap(keyArray().length(), 0.75f, -1, -1); this.keyArray().sequential().forEachValue(v -> { final int index = v.index(); final long key = v.getLong(); final int existing = indexMap.put(key, index); if (existing >= 0) { throw new IndexException("Cannot have duplicate keys in index: " + v.getValue()); } }); }
/** * Constructor * @param iterable the keys for this index * @param coding the coding for this index */ IndexWithLongCoding(Iterable<T> iterable, LongCoding<T> coding) { super(iterable); this.coding = coding; this.indexMap = new TLongIntHashMap(keyArray().length(), 0.75f, -1L, -1); this.keyArray().sequential().forEachValue(v -> { final int index = v.index(); final long code = v.getLong(); final int existing = indexMap.put(code, index); if (existing >= 0) { throw new IndexException("Cannot have duplicate keys in index: " + v.getValue()); } }); }
/** * Constructor * @param iterable the keys for index * @param parent the parent index to initialize from */ private IndexOfLongs(Iterable<Long> iterable, IndexOfLongs parent) { super(iterable, parent); this.indexMap = new TLongIntHashMap(keyArray().length(), 0.75f, -1, -1); this.keyArray().sequential().forEachValue(v -> { final long key = v.getLong(); final int index = parent.indexMap.get(key); if (index < 0) throw new IndexException("No match for key: " + v.getValue()); final int existing = indexMap.put(key, index); if (existing >= 0) { throw new IndexException("Cannot have duplicate keys in index: " + v.getValue()); } }); }
/** * Constructor * @param iterable the keys for index * @param coding the coding for this index * @param parent the parent index to initialize from */ private IndexWithLongCoding(Iterable<T> iterable, LongCoding<T> coding, IndexWithLongCoding<T> parent) { super(iterable, parent); this.coding = coding; this.indexMap = new TLongIntHashMap(keyArray().length(), 0.75f, -1L, -1); this.keyArray().sequential().forEachValue(v -> { final long code = v.getLong(); final int index = parent.indexMap.get(code); if (index < 0) throw new IndexException("No match for key: " + v.getValue()); final int existing = indexMap.put(code, index); if (existing >= 0) { throw new IndexException("Cannot have duplicate keys in index: " + v.getValue()); } }); }