1 package org.apache.lucene.index; 2 3 18 19 import java.io.IOException ; 20 21 import org.apache.lucene.store.IndexInput; 22 23 final class SegmentTermPositions 24 extends SegmentTermDocs implements TermPositions { 25 private IndexInput proxStream; 26 private int proxCount; 27 private int position; 28 29 SegmentTermPositions(SegmentReader p) { 30 super(p); 31 this.proxStream = (IndexInput)parent.proxStream.clone(); 32 } 33 34 final void seek(TermInfo ti) throws IOException { 35 super.seek(ti); 36 if (ti != null) 37 proxStream.seek(ti.proxPointer); 38 proxCount = 0; 39 } 40 41 public final void close() throws IOException { 42 super.close(); 43 proxStream.close(); 44 } 45 46 public final int nextPosition() throws IOException { 47 proxCount--; 48 return position += proxStream.readVInt(); 49 } 50 51 protected final void skippingDoc() throws IOException { 52 for (int f = freq; f > 0; f--) proxStream.readVInt(); 54 } 55 56 public final boolean next() throws IOException { 57 for (int f = proxCount; f > 0; f--) proxStream.readVInt(); 59 60 if (super.next()) { proxCount = freq; position = 0; return true; 64 } 65 return false; 66 } 67 68 public final int read(final int[] docs, final int[] freqs) { 69 throw new UnsupportedOperationException ("TermPositions does not support processing multiple documents in one call. Use TermDocs instead."); 70 } 71 72 73 74 protected void skipProx(long proxPointer) throws IOException { 75 proxStream.seek(proxPointer); 76 proxCount = 0; 77 } 78 79 } 80 | Popular Tags |