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 org.apache.lucene.util.UnicodeUtil;
22 final class TermVectorsTermsWriterPerThread extends TermsHashConsumerPerThread {
24 final TermVectorsTermsWriter termsWriter;
25 final TermsHashPerThread termsHashPerThread;
26 final DocumentsWriter.DocState docState;
28 TermVectorsTermsWriter.PerDoc doc;
30 public TermVectorsTermsWriterPerThread(TermsHashPerThread termsHashPerThread, TermVectorsTermsWriter termsWriter) {
31 this.termsWriter = termsWriter;
32 this.termsHashPerThread = termsHashPerThread;
33 docState = termsHashPerThread.docState;
36 // Used by perField when serializing the term vectors
37 final ByteSliceReader vectorSliceReader = new ByteSliceReader();
39 final UnicodeUtil.UTF8Result utf8Results[] = {new UnicodeUtil.UTF8Result(),
40 new UnicodeUtil.UTF8Result()};
43 public void startDocument() {
44 assert clearLastVectorFieldName();
47 doc.docID = docState.docID;
52 public DocumentsWriter.DocWriter finishDocument() {
61 public TermsHashConsumerPerField addField(TermsHashPerField termsHashPerField, FieldInfo fieldInfo) {
62 return new TermVectorsTermsWriterPerField(termsHashPerField, this, fieldInfo);
73 // Called only by assert
74 final boolean clearLastVectorFieldName() {
75 lastVectorFieldName = null;
79 // Called only by assert
80 String lastVectorFieldName;
81 final boolean vectorFieldsInOrder(FieldInfo fi) {
83 if (lastVectorFieldName != null)
84 return lastVectorFieldName.compareTo(fi.name) < 0;
88 lastVectorFieldName = fi.name;