public SegmentTermsEnum(BlockTreeTermsReader.FieldReader outerInstance) { this.OuterInstance = outerInstance; //if (DEBUG) System.out.println("BTTR.init seg=" + segment); Stack = new Frame[0]; // Used to hold seek by TermState, or cached seek StaticFrame = new Frame(this, -1); if (outerInstance.Index == null) { FstReader = null; } else { FstReader = OuterInstance.Index.BytesReader; } // Init w/ root block; don't use index since it may // not (and need not) have been loaded for (int arcIdx = 0; arcIdx < Arcs.Length; arcIdx++) { Arcs[arcIdx] = new FST<BytesRef>.Arc<BytesRef>(); } CurrentFrame = StaticFrame; FST<BytesRef>.Arc<BytesRef> arc; if (outerInstance.Index != null) { arc = outerInstance.Index.GetFirstArc(Arcs[0]); // Empty string prefix must have an output in the index! Debug.Assert(arc.Final); } else { arc = null; } CurrentFrame = StaticFrame; //currentFrame = pushFrame(arc, rootCode, 0); //currentFrame.loadBlock(); ValidIndexPrefix = 0; // if (DEBUG) { // System.out.println("init frame state " + currentFrame.ord); // printSeekState(); // } //System.out.println(); // computeBlockStats().print(System.out); }
// TODO: in some cases we can filter by length? eg // regexp foo*bar must be at least length 6 bytes public IntersectEnum(BlockTreeTermsReader.FieldReader outerInstance, CompiledAutomaton compiled, BytesRef startTerm) { this.OuterInstance = outerInstance; // if (DEBUG) { // System.out.println("\nintEnum.init seg=" + segment + " commonSuffix=" + brToString(compiled.commonSuffixRef)); // } runAutomaton = compiled.RunAutomaton; CompiledAutomaton = compiled; @in = (IndexInput)[email protected](); Stack = new Frame[5]; for (int idx = 0; idx < Stack.Length; idx++) { Stack[idx] = new Frame(this, idx); } for (int arcIdx = 0; arcIdx < Arcs.Length; arcIdx++) { Arcs[arcIdx] = new FST<BytesRef>.Arc<BytesRef>(); } if (outerInstance.Index == null) { FstReader = null; } else { FstReader = outerInstance.Index.BytesReader; } // TODO: if the automaton is "smallish" we really // should use the terms index to seek at least to // the initial term and likely to subsequent terms // (or, maybe just fallback to ATE for such cases). // Else the seek cost of loading the frames will be // too costly. FST<BytesRef>.Arc<BytesRef> arc = outerInstance.Index.GetFirstArc(Arcs[0]); // Empty string prefix must have an output in the index! Debug.Assert(arc.Final); // Special pushFrame since it's the first one: Frame f = Stack[0]; f.Fp = f.FpOrig = outerInstance.RootBlockFP; f.Prefix = 0; f.State = runAutomaton.InitialState; f.Arc = arc; f.OutputPrefix = arc.Output; f.Load(outerInstance.RootCode); // for assert: Debug.Assert(SetSavedStartTerm(startTerm)); CurrentFrame = f; if (startTerm != null) { SeekToStartTerm(startTerm); } }