~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/src/java/org/apache/lucene/index/FormatPostingsTermsWriter.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.lucene.index;
2
 
 
3
 
/**
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
10
 
 *
11
 
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 
 *
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.
18
 
 */
19
 
 
20
 
import java.io.Closeable;
21
 
import java.io.IOException;
22
 
 
23
 
final class FormatPostingsTermsWriter extends FormatPostingsTermsConsumer implements Closeable {
24
 
 
25
 
  final FormatPostingsFieldsWriter parent;
26
 
  final FormatPostingsDocsWriter docsWriter;
27
 
  final TermInfosWriter termsOut;
28
 
  FieldInfo fieldInfo;
29
 
 
30
 
  FormatPostingsTermsWriter(SegmentWriteState state, FormatPostingsFieldsWriter parent) throws IOException {
31
 
    this.parent = parent;
32
 
    termsOut = parent.termsOut;
33
 
    docsWriter = new FormatPostingsDocsWriter(state, this);
34
 
  }
35
 
 
36
 
  void setField(FieldInfo fieldInfo) {
37
 
    this.fieldInfo = fieldInfo;
38
 
    docsWriter.setField(fieldInfo);
39
 
  }
40
 
 
41
 
  char[] currentTerm;
42
 
  int currentTermStart;
43
 
 
44
 
  long freqStart;
45
 
  long proxStart;
46
 
 
47
 
  /** Adds a new term in this field */
48
 
  @Override
49
 
  FormatPostingsDocsConsumer addTerm(char[] text, int start) {
50
 
    currentTerm = text;
51
 
    currentTermStart = start;
52
 
 
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();
59
 
 
60
 
    parent.skipListWriter.resetSkip();
61
 
 
62
 
    return docsWriter;
63
 
  }
64
 
 
65
 
  /** Called when we are done adding terms to this field */
66
 
  @Override
67
 
  void finish() {
68
 
  }
69
 
 
70
 
  public void close() throws IOException {
71
 
    docsWriter.close();
72
 
  }
73
 
}