~ubuntu-branches/ubuntu/jaunty/beagle/jaunty-security

« back to all changes in this revision

Viewing changes to beagled/Lucene.Net/Index/DocumentWriter.cs

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2008-05-04 00:31:32 UTC
  • mfrom: (1.1.21 upstream)
  • Revision ID: james.westby@ubuntu.com-20080504003132-2tkm5o8moo5952ri
Tags: 0.3.7-2ubuntu1
 * Merge from Debian unstable. (LP: #225746) Remaining Ubuntu changes:
  - debian/control:
    + Rename ice{weasel,dove}-beagle to {mozilla,thunderbird}-beagle and
      and update the dependencies accordingly.
    + Change Maintainer to Ubuntu Mono Team.
  - debian/rules:
    + Install the mozilla-beagle and thunderbird-beagle extensions.
  - ice{dove,weasel}.dirs:
    + Renamed to {mozilla,thunderbird}-beagle.dirs.
    + Fixed paths to point to usr/lib/{firefox,thunderbird}

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2004 The Apache Software Foundation
3
 
 * 
4
 
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 
 * you may not use this file except in compliance with the License.
6
 
 * You may obtain a copy of the License at
 
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 * contributor license agreements.  See the NOTICE file distributed with
 
4
 * this work for additional information regarding copyright ownership.
 
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
6
 * (the "License"); you may not use this file except in compliance with
 
7
 * the License.  You may obtain a copy of the License at
7
8
 * 
8
9
 * http://www.apache.org/licenses/LICENSE-2.0
9
10
 * 
19
20
using Token = Lucene.Net.Analysis.Token;
20
21
using TokenStream = Lucene.Net.Analysis.TokenStream;
21
22
using Document = Lucene.Net.Documents.Document;
22
 
using Field = Lucene.Net.Documents.Field;
 
23
using Fieldable = Lucene.Net.Documents.Fieldable;
23
24
using Similarity = Lucene.Net.Search.Similarity;
24
25
using Directory = Lucene.Net.Store.Directory;
25
26
using IndexOutput = Lucene.Net.Store.IndexOutput;
71
72
                        this.termIndexInterval = writer.GetTermIndexInterval();
72
73
                }
73
74
                
74
 
                public /*internal*/ void  AddDocument(System.String segment, Document doc)
 
75
                public void  AddDocument(System.String segment, Document doc)
75
76
                {
76
77
                        // write field names
77
78
                        fieldInfos = new FieldInfos();
96
97
                        fieldOffsets = new int[fieldInfos.Size()]; // init fieldOffsets
97
98
                        
98
99
                        fieldBoosts = new float[fieldInfos.Size()]; // init fieldBoosts
99
 
            float boost = doc.GetBoost();
100
 
            for (int i = 0; i < fieldBoosts.Length; i++)
101
 
            {
102
 
                fieldBoosts[i] = boost;
103
 
            }
 
100
                        float boost = doc.GetBoost();
 
101
                        for (int i = 0; i < fieldBoosts.Length; i++)
 
102
                        {
 
103
                                fieldBoosts[i] = boost;
 
104
                        }
104
105
                        
105
106
                        InvertDocument(doc);
106
107
                        
138
139
                // Tokenizes the fields of a document into Postings.
139
140
                private void  InvertDocument(Document doc)
140
141
                {
141
 
                        foreach(Field field in doc.Fields())
 
142
                        System.Collections.IEnumerator fieldIterator = doc.GetFields().GetEnumerator();
 
143
                        while (fieldIterator.MoveNext())
142
144
                        {
 
145
                                Fieldable field = (Fieldable) fieldIterator.Current;
143
146
                                System.String fieldName = field.Name();
144
147
                                int fieldNumber = fieldInfos.FieldNumber(fieldName);
145
148
                                
187
190
                                                                        AddPosition(fieldName, t.TermText(), position++, null);
188
191
                                                                
189
192
                                                                lastToken = t;
190
 
                                                                if (++length > maxFieldLength)
 
193
                                                                if (++length >= maxFieldLength)
191
194
                                                                {
192
195
                                                                        if (infoStream != null)
193
196
                                                                                infoStream.WriteLine("maxFieldLength " + maxFieldLength + " reached, ignoring following tokens");
228
231
                                        // positions array is full
229
232
                                        int[] newPositions = new int[freq * 2]; // double size
230
233
                                        int[] positions = ti.positions;
231
 
                                        for (int i = 0; i < freq; i++)
232
 
                                        // copy old positions to new
233
 
                                                newPositions[i] = positions[i];
 
234
                                        Array.Copy(positions, 0, newPositions, 0, freq);
234
235
                                        ti.positions = newPositions;
235
236
                                }
236
237
                                ti.positions[freq] = position; // add new position
241
242
                                        {
242
243
                                                TermVectorOffsetInfo[] newOffsets = new TermVectorOffsetInfo[freq * 2];
243
244
                                                TermVectorOffsetInfo[] offsets = ti.offsets;
244
 
                                                for (int i = 0; i < freq; i++)
245
 
                                                {
246
 
                                                        newOffsets[i] = offsets[i];
247
 
                                                }
 
245
                                                Array.Copy(offsets, 0, newOffsets, 0, freq);
248
246
                                                ti.offsets = newOffsets;
249
247
                                        }
250
248
                                        ti.offsets[freq] = offset;
511
509
                                offsets = null;
512
510
                }
513
511
        }
514
 
}
 
512
}
 
 
b'\\ No newline at end of file'