1 package org.apache.lucene.index;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import java.io.Closeable;
21 import java.io.IOException;
23 final class FormatPostingsTermsWriter extends FormatPostingsTermsConsumer implements Closeable {
25 final FormatPostingsFieldsWriter parent;
26 final FormatPostingsDocsWriter docsWriter;
27 final TermInfosWriter termsOut;
30 FormatPostingsTermsWriter(SegmentWriteState state, FormatPostingsFieldsWriter parent) throws IOException {
32 termsOut = parent.termsOut;
33 docsWriter = new FormatPostingsDocsWriter(state, this);
36 void setField(FieldInfo fieldInfo) {
37 this.fieldInfo = fieldInfo;
38 docsWriter.setField(fieldInfo);
47 /** Adds a new term in this field */
49 FormatPostingsDocsConsumer addTerm(char[] text, int start) {
51 currentTermStart = start;
53 // TODO: this is abstraction violation -- ideally this
54 // terms writer is not so "invasive", looking for file
55 // pointers in its child consumers.
56 freqStart = docsWriter.out.getFilePointer();
57 if (docsWriter.posWriter.out != null)
58 proxStart = docsWriter.posWriter.out.getFilePointer();
60 parent.skipListWriter.resetSkip();
65 /** Called when we are done adding terms to this field */
70 public void close() throws IOException {