@Override public K get(final long i) { return list.get(i); } @Override
@Override public K get(final long i) { synchronized (sync) { return list.get(i); } } @Override
/** * Gets the term string for a given direct term ID. The term ID must have been * obtained from the direct index of this index. * @param termId the ID for the term being sought. * @return the string for the given term. */ public CharSequence getDirectTerm(long termId) { return directTerms.get(termId); }
@Override public K previous() { if (!hasPrevious()) throw new NoSuchElementException(); return l.get(from + (last = --pos)); } @Override
@Override public K get(long index) { ensureRestrictedIndex(index); return l.get(from + index); } @Override
@Override public K next() { if (!hasNext()) throw new NoSuchElementException(); return l.get(from + (last = pos++)); } @Override
@Deprecated @Override public Long get(final Object o) { final CharSequence s = (CharSequence)o; final long index = function.getLong(s); return index >= 0 && index < size && list.get((int)index).equals(s) ? Long.valueOf(index) : null; }
@Override public List<Binding> getDocumentHits(long rank) throws IndexOutOfBoundsException, IOException { long documentIndex = getDocumentIndex(rank); List<Binding> hits = documentHits.get(documentIndex); if(hits == null) { // hits not collected yet try { // find the Future working on it, or start a new one, // then wait for it to complete collectHits(new long[]{rank, rank + 1}).get(); hits = documentHits.get(documentIndex); } catch(Exception e) { logger.error("Exception while waiting for hits collection", e); throw new RuntimeException( "Exception while waiting for hits collection", e); } } return hits; }
/** Creates a new shift-add-xor signed string map using a given hash map. * * @param function a function mapping each string in <code>list</code> to its ordinal position. * @param list a list of strings. */ public LiterallySignedStringMap(final Object2LongFunction<? extends CharSequence> function, final ObjectBigList<? extends MutableString> list) { this.function = function; this.list = list; size = list.size64(); for(long i = 0; i < size; i++) if (function.getLong(list.get(i)) != i) throw new IllegalArgumentException("Function and list do not agree"); defRetValue = -1; }
/** * Shuffles the specified big list using the specified pseudorandom number * generator. * * @param l * the big list to be shuffled. * @param random * a pseudorandom number generator. * @return {@code l}. */ public static <K> ObjectBigList<K> shuffle(final ObjectBigList<K> l, final Random random) { for (long i = l.size64(); i-- != 0;) { final long p = (random.nextLong() & 0x7FFFFFFFFFFFFFFFL) % (i + 1); final K t = l.get(i); l.set(i, l.get(p)); l.set(p, t); } return l; } /**
@Override public long getLong(final Object o) { final CharSequence s = (CharSequence)o; final long index = function.getLong(s); return index >= 0 && index < size && list.get((int)index).equals(s) ? index : defRetValue; }
new MutableString( termMap.list().get( inputStream.readInt() ) ).writeSelfDelimUTF8( (OutputStream)outputStream ); outputStream.flush(); break;
new MutableString( prefixMap.list().get( inputStream.readLong() ) ).writeSelfDelimUTF8( (OutputStream)outputStream ); outputStream.flush(); break;
if ( termMap == null ) throw new IllegalStateException( "Index " + index + " has no term map" ); cutPointTerm[ 0 ] = termMap.list().get( 0 ); cutPointTerm[ numberOfLocalIndices ] = "\uFFFF"; LOGGER.info( "New term interval [" + left + ".." + i + "] (\"" + termMap.list().get( left ) + "\" -> " + ( i == terms ? "" : "\"" + termMap.list().get( i ) + "\"" ) + ")" ); cutPoint[ ++k ] = i; if ( i != terms ) cutPointTerm[ k ] = termMap.list().get( i ); left = i; count = 0;
if ( termMap == null ) throw new IllegalStateException( "Index " + index + " has no term map" ); cutPointTerm[ 0 ] = termMap.list().get( 0 ); cutPointTerm[ numberOfLocalIndices ] = "\uFFFF"; LOGGER.info( "New term interval [" + left + ".." + i + "] (" + termMap.list().get( left ) + " -> " + ( i == terms ? "" : termMap.list().get( i ) ) + ")" ); cutPoint[ ++k ] = i; if ( i != terms ) cutPointTerm[ k ] = termMap.list().get( i ); left = i; count = 0;
/** * Gets the occurrence count in the whole index for a given direct term, * specified by a direct term ID (which must have been obtained from the * direct index of this index). * * @param directTermId * @return * @throws IOException */ public long getDirectTermOccurenceCount(long directTermId) throws IOException { String termStr = directTerms.get(directTermId); // we need to sum up all the counts for this term in the inverted index long count = 0; IndexIterator idxItr = invertedIndex.documents(termStr); long docId = idxItr.nextDocument(); while(docId != IndexIterator.END_OF_LIST) { count += idxItr.count(); docId = idxItr.nextDocument(); } return count; }