Remove debug spew
[beagle.git] / beagled / Lucene.Net / upstream-changes / 03_fields_enumerable.patch
blob57489be4a80c05a83e099752fbdf5f8b14b08e9d
1 From: Debajyoti Bera <dbera.web@gmail.com>
3 Patch lucene.net from upstream. Make Fields() return IEnumerable to make iteration easier.
4 This was introduced in 1.9 and 1.9.1 but later reverted in 0.2-alpha.
6 Index: Document/Document.cs
7 ===================================================================
8 RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Document/Document.cs,v
9 retrieving revision 1.3.4.4
10 diff -u -3 -p -r1.3.4.4 Document.cs
11 --- Document/Document.cs 25 Sep 2006 22:36:28 -0000 1.3.4.4
12 +++ Document/Document.cs 30 Sep 2006 01:34:09 -0000
13 @@ -169,9 +169,9 @@ namespace Lucene.Net.Documents
16 /// <summary>Returns an Enumeration of all the fields in a document. </summary>
17 - public System.Collections.IEnumerator Fields()
18 + public System.Collections.IEnumerable Fields()
20 - return ((System.Collections.ArrayList) fields).GetEnumerator();
21 + return fields;
24 /// <summary> Returns an array of {@link Field}s with the given name.
25 @@ -309,4 +309,4 @@ namespace Lucene.Net.Documents
26 return buffer.ToString();
30 \ No newline at end of file
32 Index: Index/DocumentWriter.cs
33 ===================================================================
34 RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Index/DocumentWriter.cs,v
35 retrieving revision 1.3.4.4
36 diff -u -3 -p -r1.3.4.4 DocumentWriter.cs
37 --- Index/DocumentWriter.cs 25 Sep 2006 22:36:29 -0000 1.3.4.4
38 +++ Index/DocumentWriter.cs 30 Sep 2006 01:34:13 -0000
39 @@ -138,10 +138,8 @@ namespace Lucene.Net.Index
40 // Tokenizes the fields of a document into Postings.
41 private void InvertDocument(Document doc)
43 - System.Collections.IEnumerator fields = doc.Fields();
44 - while (fields.MoveNext())
45 + foreach(Field field in doc.Fields())
47 - Field field = (Field) fields.Current;
48 System.String fieldName = field.Name();
49 int fieldNumber = fieldInfos.FieldNumber(fieldName);
51 @@ -513,4 +511,4 @@ namespace Lucene.Net.Index
52 offsets = null;
56 \ No newline at end of file
58 Index: Index/FieldInfos.cs
59 ===================================================================
60 RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Index/FieldInfos.cs,v
61 retrieving revision 1.5.4.5
62 diff -u -3 -p -r1.5.4.5 FieldInfos.cs
63 --- Index/FieldInfos.cs 25 Sep 2006 22:36:29 -0000 1.5.4.5
64 +++ Index/FieldInfos.cs 30 Sep 2006 01:34:13 -0000
65 @@ -70,10 +70,8 @@ namespace Lucene.Net.Index
66 /// <summary>Adds field info for a Document. </summary>
67 public void Add(Document doc)
69 - System.Collections.IEnumerator fields = doc.Fields();
70 - while (fields.MoveNext())
71 - {
72 - Field field = (Field) fields.Current;
73 + foreach(Field field in doc.Fields())
74 + {
75 Add(field.Name(), field.IsIndexed(), field.IsTermVectorStored(), field.IsStorePositionWithTermVector(), field.IsStoreOffsetWithTermVector(), field.GetOmitNorms());
78 @@ -356,4 +354,4 @@ namespace Lucene.Net.Index
83 \ No newline at end of file
85 Index: Index/FieldsWriter.cs
86 ===================================================================
87 RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Index/FieldsWriter.cs,v
88 retrieving revision 1.3.4.4
89 diff -u -3 -p -r1.3.4.4 FieldsWriter.cs
90 --- Index/FieldsWriter.cs 25 Sep 2006 22:36:29 -0000 1.3.4.4
91 +++ Index/FieldsWriter.cs 30 Sep 2006 01:34:13 -0000
92 @@ -53,19 +53,15 @@ namespace Lucene.Net.Index
93 indexStream.WriteLong(fieldsStream.GetFilePointer());
95 int storedCount = 0;
96 - System.Collections.IEnumerator fields = doc.Fields();
97 - while (fields.MoveNext())
98 - {
99 - Field field = (Field) fields.Current;
100 + foreach(Field field in doc.Fields())
102 if (field.IsStored())
103 storedCount++;
105 fieldsStream.WriteVInt(storedCount);
107 - fields = doc.Fields();
108 - while (fields.MoveNext())
109 + foreach(Field field in doc.Fields())
111 - Field field = (Field) fields.Current;
112 if (field.IsStored())
114 fieldsStream.WriteVInt(fieldInfos.FieldNumber(field.Name()));
115 @@ -121,4 +117,4 @@ namespace Lucene.Net.Index
116 return SupportClass.CompressionSupport.Compress(input);
120 \ No newline at end of file
122 Index: Index/ParallelReader.cs
123 ===================================================================
124 RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Index/Attic/ParallelReader.cs,v
125 retrieving revision 1.1.2.4
126 diff -u -3 -p -r1.1.2.4 ParallelReader.cs
127 --- Index/ParallelReader.cs 25 Sep 2006 22:36:29 -0000 1.1.2.4
128 +++ Index/ParallelReader.cs 30 Sep 2006 01:34:13 -0000
129 @@ -152,10 +152,9 @@ namespace Lucene.Net.Index
130 for (int i = 0; i < storedFieldReaders.Count; i++)
132 IndexReader reader = (IndexReader) storedFieldReaders[i];
133 - System.Collections.IEnumerator fields = reader.Document(n).Fields();
134 - while (fields.MoveNext())
135 + foreach(Field field in reader.Document(n).Fields())
137 - result.Add((Field) fields.Current);
138 + result.Add(field);
141 return result;
142 @@ -500,4 +499,4 @@ namespace Lucene.Net.Index
147 \ No newline at end of file