You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/04/01 01:09:45 UTC
[52/62] [abbrv] lucenenet git commit: Lucene.Net.Core.Index: Deleted
obsolete files that are no longer in use
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/FormatPostingsDocsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/FormatPostingsDocsWriter.cs b/src/Lucene.Net.Core/Index/FormatPostingsDocsWriter.cs
deleted file mode 100644
index a0d2d5f..0000000
--- a/src/Lucene.Net.Core/Index/FormatPostingsDocsWriter.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using IndexOutput = Lucene.Net.Store.IndexOutput;
-using UnicodeUtil = Lucene.Net.Util.UnicodeUtil;
-
-namespace Lucene.Net.Index
-{
- /// <summary>Consumes doc and freq, writing them using the current
- /// index file format
- /// </summary>
- sealed class FormatPostingsDocsWriter : FormatPostingsDocsConsumer, IDisposable
- {
-
- internal IndexOutput out_Renamed;
- internal FormatPostingsTermsWriter parent;
- internal FormatPostingsPositionsWriter posWriter;
- internal DefaultSkipListWriter skipListWriter;
- internal int skipInterval;
- internal int totalNumDocs;
-
- internal bool omitTermFreqAndPositions;
- internal bool storePayloads;
- internal long freqStart;
- internal FieldInfo fieldInfo;
-
- internal FormatPostingsDocsWriter(SegmentWriteState state, FormatPostingsTermsWriter parent):base()
- {
- this.parent = parent;
- System.String fileName = IndexFileNames.SegmentFileName(parent.parent.segment, IndexFileNames.FREQ_EXTENSION);
- state.flushedFiles.Add(fileName);
- out_Renamed = parent.parent.dir.CreateOutput(fileName);
- totalNumDocs = parent.parent.totalNumDocs;
-
- // TODO: abstraction violation
- skipInterval = parent.parent.termsOut.skipInterval;
- skipListWriter = parent.parent.skipListWriter;
- skipListWriter.SetFreqOutput(out_Renamed);
-
- posWriter = new FormatPostingsPositionsWriter(state, this);
- }
-
- internal void SetField(FieldInfo fieldInfo)
- {
- this.fieldInfo = fieldInfo;
- omitTermFreqAndPositions = fieldInfo.omitTermFreqAndPositions;
- storePayloads = fieldInfo.storePayloads;
- posWriter.SetField(fieldInfo);
- }
-
- internal int lastDocID;
- internal int df;
-
- /// <summary>Adds a new doc in this term. If this returns null
- /// then we just skip consuming positions/payloads.
- /// </summary>
- internal override FormatPostingsPositionsConsumer AddDoc(int docID, int termDocFreq)
- {
-
- int delta = docID - lastDocID;
-
- if (docID < 0 || (df > 0 && delta <= 0))
- throw new CorruptIndexException("docs out of order (" + docID + " <= " + lastDocID + " )");
-
- if ((++df % skipInterval) == 0)
- {
- // TODO: abstraction violation
- skipListWriter.SetSkipData(lastDocID, storePayloads, posWriter.lastPayloadLength);
- skipListWriter.BufferSkip(df);
- }
-
- System.Diagnostics.Debug.Assert(docID < totalNumDocs, "docID=" + docID + " totalNumDocs=" + totalNumDocs);
-
- lastDocID = docID;
- if (omitTermFreqAndPositions)
- out_Renamed.WriteVInt(delta);
- else if (1 == termDocFreq)
- out_Renamed.WriteVInt((delta << 1) | 1);
- else
- {
- out_Renamed.WriteVInt(delta << 1);
- out_Renamed.WriteVInt(termDocFreq);
- }
-
- return posWriter;
- }
-
- private TermInfo termInfo = new TermInfo(); // minimize consing
- internal UnicodeUtil.UTF8Result utf8 = new UnicodeUtil.UTF8Result();
-
- /// <summary>Called when we are done adding docs to this term </summary>
- internal override void Finish()
- {
- long skipPointer = skipListWriter.WriteSkip(out_Renamed);
-
- // TODO: this is abstraction violation -- we should not
- // peek up into parents terms encoding format
- termInfo.Set(df, parent.freqStart, parent.proxStart, (int) (skipPointer - parent.freqStart));
-
- // TODO: we could do this incrementally
- UnicodeUtil.UTF16toUTF8(parent.currentTerm, parent.currentTermStart, utf8);
-
- if (df > 0)
- {
- parent.termsOut.Add(fieldInfo.number, utf8.result, utf8.length, termInfo);
- }
-
- lastDocID = 0;
- df = 0;
- }
-
- public void Dispose()
- {
- // Move to protected method if class becomes unsealed
- out_Renamed.Dispose();
- posWriter.Dispose();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/FormatPostingsFieldsConsumer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/FormatPostingsFieldsConsumer.cs b/src/Lucene.Net.Core/Index/FormatPostingsFieldsConsumer.cs
deleted file mode 100644
index 1808a33..0000000
--- a/src/Lucene.Net.Core/Index/FormatPostingsFieldsConsumer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Lucene.Net.Index
-{
-
- /// <summary>Abstract API that consumes terms, doc, freq, prox and
- /// payloads postings. Concrete implementations of this
- /// actually do "something" with the postings (write it into
- /// the index in a specific format).
- ///
- /// NOTE: this API is experimental and will likely change
- /// </summary>
- abstract class FormatPostingsFieldsConsumer
- {
-
- /// <summary>Add a new field </summary>
- internal abstract FormatPostingsTermsConsumer AddField(FieldInfo field);
-
- /// <summary>Called when we are done adding everything. </summary>
- internal abstract void Finish();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/FormatPostingsFieldsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/FormatPostingsFieldsWriter.cs b/src/Lucene.Net.Core/Index/FormatPostingsFieldsWriter.cs
deleted file mode 100644
index 577cacf..0000000
--- a/src/Lucene.Net.Core/Index/FormatPostingsFieldsWriter.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-using Directory = Lucene.Net.Store.Directory;
-
-namespace Lucene.Net.Index
-{
-
- sealed class FormatPostingsFieldsWriter:FormatPostingsFieldsConsumer
- {
-
- internal Directory dir;
- internal System.String segment;
- internal TermInfosWriter termsOut;
- internal FieldInfos fieldInfos;
- internal FormatPostingsTermsWriter termsWriter;
- internal DefaultSkipListWriter skipListWriter;
- internal int totalNumDocs;
-
- public FormatPostingsFieldsWriter(SegmentWriteState state, FieldInfos fieldInfos):base()
- {
-
- dir = state.directory;
- segment = state.segmentName;
- totalNumDocs = state.numDocs;
- this.fieldInfos = fieldInfos;
- termsOut = new TermInfosWriter(dir, segment, fieldInfos, state.termIndexInterval);
-
- // TODO: this is a nasty abstraction violation (that we
- // peek down to find freqOut/proxOut) -- we need a
- // better abstraction here whereby these child consumers
- // can provide skip data or not
- skipListWriter = new DefaultSkipListWriter(termsOut.skipInterval, termsOut.maxSkipLevels, totalNumDocs, null, null);
-
- state.flushedFiles.Add(state.SegmentFileName(IndexFileNames.TERMS_EXTENSION));
- state.flushedFiles.Add(state.SegmentFileName(IndexFileNames.TERMS_INDEX_EXTENSION));
-
- termsWriter = new FormatPostingsTermsWriter(state, this);
- }
-
- /// <summary>Add a new field </summary>
- internal override FormatPostingsTermsConsumer AddField(FieldInfo field)
- {
- termsWriter.SetField(field);
- return termsWriter;
- }
-
- /// <summary>Called when we are done adding everything. </summary>
- internal override void Finish()
- {
- termsOut.Dispose();
- termsWriter.Dispose();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/FormatPostingsPositionsConsumer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/FormatPostingsPositionsConsumer.cs b/src/Lucene.Net.Core/Index/FormatPostingsPositionsConsumer.cs
deleted file mode 100644
index 2821ef4..0000000
--- a/src/Lucene.Net.Core/Index/FormatPostingsPositionsConsumer.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Lucene.Net.Index
-{
-
- abstract class FormatPostingsPositionsConsumer
- {
-
- /// <summary>Add a new position & payload. If payloadLength > 0
- /// you must read those bytes from the IndexInput.
- /// </summary>
- internal abstract void AddPosition(int position, byte[] payload, int payloadOffset, int payloadLength);
-
- /// <summary>Called when we are done adding positions & payloads </summary>
- internal abstract void Finish();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/FormatPostingsPositionsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/FormatPostingsPositionsWriter.cs b/src/Lucene.Net.Core/Index/FormatPostingsPositionsWriter.cs
deleted file mode 100644
index fc6e1e2..0000000
--- a/src/Lucene.Net.Core/Index/FormatPostingsPositionsWriter.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-using IndexInput = Lucene.Net.Store.IndexInput;
-using IndexOutput = Lucene.Net.Store.IndexOutput;
-
-namespace Lucene.Net.Index
-{
-
- sealed class FormatPostingsPositionsWriter:FormatPostingsPositionsConsumer
- {
- internal FormatPostingsDocsWriter parent;
- internal IndexOutput out_Renamed;
-
- internal bool omitTermFreqAndPositions;
- internal bool storePayloads;
- internal int lastPayloadLength = - 1;
-
- internal FormatPostingsPositionsWriter(SegmentWriteState state, FormatPostingsDocsWriter parent)
- {
- this.parent = parent;
- omitTermFreqAndPositions = parent.omitTermFreqAndPositions;
- if (parent.parent.parent.fieldInfos.HasProx())
- {
- // At least one field does not omit TF, so create the
- // prox file
- System.String fileName = IndexFileNames.SegmentFileName(parent.parent.parent.segment, IndexFileNames.PROX_EXTENSION);
- state.flushedFiles.Add(fileName);
- out_Renamed = parent.parent.parent.dir.CreateOutput(fileName);
- parent.skipListWriter.SetProxOutput(out_Renamed);
- }
- // Every field omits TF so we will write no prox file
- else
- out_Renamed = null;
- }
-
- internal int lastPosition;
-
- /// <summary>Add a new position & payload </summary>
- internal override void AddPosition(int position, byte[] payload, int payloadOffset, int payloadLength)
- {
- System.Diagnostics.Debug.Assert(!omitTermFreqAndPositions, "omitTermFreqAndPositions is true");
- System.Diagnostics.Debug.Assert(out_Renamed != null);
-
- int delta = position - lastPosition;
- lastPosition = position;
-
- if (storePayloads)
- {
- if (payloadLength != lastPayloadLength)
- {
- lastPayloadLength = payloadLength;
- out_Renamed.WriteVInt((delta << 1) | 1);
- out_Renamed.WriteVInt(payloadLength);
- }
- else
- out_Renamed.WriteVInt(delta << 1);
- if (payloadLength > 0)
- out_Renamed.WriteBytes(payload, payloadLength);
- }
- else
- out_Renamed.WriteVInt(delta);
- }
-
- internal void SetField(FieldInfo fieldInfo)
- {
- omitTermFreqAndPositions = fieldInfo.omitTermFreqAndPositions;
- storePayloads = omitTermFreqAndPositions?false:fieldInfo.storePayloads;
- }
-
- /// <summary>Called when we are done adding positions & payloads </summary>
- internal override void Finish()
- {
- lastPosition = 0;
- lastPayloadLength = - 1;
- }
-
- public void Dispose()
- {
- // Move to protected method if class becomes unsealed
- if (out_Renamed != null)
- out_Renamed.Close();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/FormatPostingsTermsConsumer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/FormatPostingsTermsConsumer.cs b/src/Lucene.Net.Core/Index/FormatPostingsTermsConsumer.cs
deleted file mode 100644
index eb26223..0000000
--- a/src/Lucene.Net.Core/Index/FormatPostingsTermsConsumer.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-using ArrayUtil = Lucene.Net.Util.ArrayUtil;
-
-namespace Lucene.Net.Index
-{
-
- /// <summary> NOTE: this API is experimental and will likely change</summary>
-
- abstract class FormatPostingsTermsConsumer
- {
-
- /// <summary>Adds a new term in this field; term ends with U+FFFF
- /// char
- /// </summary>
- internal abstract FormatPostingsDocsConsumer AddTerm(char[] text, int start);
-
- internal char[] termBuffer;
- internal virtual FormatPostingsDocsConsumer AddTerm(System.String text)
- {
- int len = text.Length;
- if (termBuffer == null || termBuffer.Length < 1 + len)
- termBuffer = new char[ArrayUtil.GetNextSize(1 + len)];
- for (int i = 0; i < len; i++)
- {
- termBuffer[i] = (char) text[i];
- }
- termBuffer[len] = (char) (0xffff);
- return AddTerm(termBuffer, 0);
- }
-
- /// <summary>Called when we are done adding terms to this field </summary>
- internal abstract void Finish();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/FormatPostingsTermsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/FormatPostingsTermsWriter.cs b/src/Lucene.Net.Core/Index/FormatPostingsTermsWriter.cs
deleted file mode 100644
index 7f3126c..0000000
--- a/src/Lucene.Net.Core/Index/FormatPostingsTermsWriter.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Lucene.Net.Index
-{
-
- sealed class FormatPostingsTermsWriter : FormatPostingsTermsConsumer, IDisposable
- {
- internal FormatPostingsFieldsWriter parent;
- internal FormatPostingsDocsWriter docsWriter;
- internal TermInfosWriter termsOut;
- internal FieldInfo fieldInfo;
-
- internal FormatPostingsTermsWriter(SegmentWriteState state, FormatPostingsFieldsWriter parent):base()
- {
- this.parent = parent;
- termsOut = parent.termsOut;
- docsWriter = new FormatPostingsDocsWriter(state, this);
- }
-
- internal void SetField(FieldInfo fieldInfo)
- {
- this.fieldInfo = fieldInfo;
- docsWriter.SetField(fieldInfo);
- }
-
- internal char[] currentTerm;
- internal int currentTermStart;
-
- internal long freqStart;
- internal long proxStart;
-
- /// <summary>Adds a new term in this field </summary>
- internal override FormatPostingsDocsConsumer AddTerm(char[] text, int start)
- {
- currentTerm = text;
- currentTermStart = start;
-
- // TODO: this is abstraction violation -- ideally this
- // terms writer is not so "invasive", looking for file
- // pointers in its child consumers.
- freqStart = docsWriter.out_Renamed.FilePointer;
- if (docsWriter.posWriter.out_Renamed != null)
- proxStart = docsWriter.posWriter.out_Renamed.FilePointer;
-
- parent.skipListWriter.ResetSkip();
-
- return docsWriter;
- }
-
- /// <summary>Called when we are done adding terms to this field </summary>
- internal override void Finish()
- {
- }
-
- public void Dispose()
- {
- docsWriter.Dispose();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/FreqProxFieldMergeState.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/FreqProxFieldMergeState.cs b/src/Lucene.Net.Core/Index/FreqProxFieldMergeState.cs
deleted file mode 100644
index c3bd35f..0000000
--- a/src/Lucene.Net.Core/Index/FreqProxFieldMergeState.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Lucene.Net.Support;
-
-namespace Lucene.Net.Index
-{
-
- // TODO FI: some of this is "generic" to TermsHash* so we
- // should factor it out so other consumers don't have to
- // duplicate this code
-
- /// <summary>Used by DocumentsWriter to merge the postings from
- /// multiple ThreadStates when creating a segment
- /// </summary>
- sealed class FreqProxFieldMergeState
- {
-
- internal FreqProxTermsWriterPerField field;
- internal int numPostings;
- internal CharBlockPool charPool;
- internal RawPostingList[] postings;
-
- private FreqProxTermsWriter.PostingList p;
- internal char[] text;
- internal int textOffset;
-
- private int postingUpto = - 1;
-
- internal ByteSliceReader freq = new ByteSliceReader();
- internal ByteSliceReader prox = new ByteSliceReader();
-
- internal int docID;
- internal int termFreq;
-
- public FreqProxFieldMergeState(FreqProxTermsWriterPerField field)
- {
- this.field = field;
- this.charPool = field.perThread.termsHashPerThread.charPool;
- this.numPostings = field.termsHashPerField.numPostings;
- this.postings = field.termsHashPerField.SortPostings();
- }
-
- internal bool NextTerm()
- {
- postingUpto++;
- if (postingUpto == numPostings)
- return false;
-
- p = (FreqProxTermsWriter.PostingList) postings[postingUpto];
- docID = 0;
-
- text = charPool.buffers[p.textStart >> DocumentsWriter.CHAR_BLOCK_SHIFT];
- textOffset = p.textStart & DocumentsWriter.CHAR_BLOCK_MASK;
-
- field.termsHashPerField.InitReader(freq, p, 0);
- if (!field.fieldInfo.omitTermFreqAndPositions)
- field.termsHashPerField.InitReader(prox, p, 1);
-
- // Should always be true
- bool result = NextDoc();
- System.Diagnostics.Debug.Assert(result);
-
- return true;
- }
-
- public bool NextDoc()
- {
- if (freq.Eof())
- {
- if (p.lastDocCode != - 1)
- {
- // Return last doc
- docID = p.lastDocID;
- if (!field.omitTermFreqAndPositions)
- termFreq = p.docFreq;
- p.lastDocCode = - 1;
- return true;
- }
- // EOF
- else
- return false;
- }
-
- int code = freq.ReadVInt();
- if (field.omitTermFreqAndPositions)
- docID += code;
- else
- {
- docID += Number.URShift(code, 1);
- if ((code & 1) != 0)
- termFreq = 1;
- else
- termFreq = freq.ReadVInt();
- }
-
- System.Diagnostics.Debug.Assert(docID != p.lastDocID);
-
- return true;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerThread.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerThread.cs b/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerThread.cs
deleted file mode 100644
index 1e4ac41..0000000
--- a/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerThread.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Lucene.Net.Index
-{
-
- sealed class FreqProxTermsWriterPerThread:TermsHashConsumerPerThread
- {
- internal TermsHashPerThread termsHashPerThread;
- internal DocumentsWriter.DocState docState;
-
- public FreqProxTermsWriterPerThread(TermsHashPerThread perThread)
- {
- docState = perThread.docState;
- termsHashPerThread = perThread;
- }
-
- public override TermsHashConsumerPerField AddField(TermsHashPerField termsHashPerField, FieldInfo fieldInfo)
- {
- return new FreqProxTermsWriterPerField(termsHashPerField, this, fieldInfo);
- }
-
- public override void StartDocument()
- {
- }
-
- public override DocumentsWriter.DocWriter FinishDocument()
- {
- return null;
- }
-
- public override void Abort()
- {
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/IndexFileNameFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/IndexFileNameFilter.cs b/src/Lucene.Net.Core/Index/IndexFileNameFilter.cs
deleted file mode 100644
index f8abe25..0000000
--- a/src/Lucene.Net.Core/Index/IndexFileNameFilter.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-
-namespace Lucene.Net.Index
-{
-
- /// <summary>Filename filter that accept filenames and extensions only created by Lucene. </summary>
- public class IndexFileNameFilter
- {
-
- private static IndexFileNameFilter singleton = new IndexFileNameFilter();
- private HashSet<String> extensions;
- private HashSet<String> extensionsInCFS;
-
- // Prevent instantiation.
- private IndexFileNameFilter()
- {
- extensions = new HashSet<String>();
- for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS.Length; i++)
- {
- extensions.Add(IndexFileNames.INDEX_EXTENSIONS[i]);
- }
- extensionsInCFS = new HashSet<String>();
- for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS_IN_COMPOUND_FILE.Length; i++)
- {
- extensionsInCFS.Add(IndexFileNames.INDEX_EXTENSIONS_IN_COMPOUND_FILE[i]);
- }
- }
-
- /* (non-Javadoc)
- * <see cref="java.io.FilenameFilter.accept(java.io.File, java.lang.String)"/>
- */
- public virtual bool Accept(System.IO.FileInfo dir, System.String name)
- {
- int i = name.LastIndexOf((System.Char) '.');
- if (i != - 1)
- {
- System.String extension = name.Substring(1 + i);
- if (extensions.Contains(extension))
- {
- return true;
- }
- else if (extension.StartsWith("f") && (new System.Text.RegularExpressions.Regex("f\\d+")).Match(extension).Success)
- {
- return true;
- }
- else if (extension.StartsWith("s") && (new System.Text.RegularExpressions.Regex("s\\d+")).Match(extension).Success)
- {
- return true;
- }
- }
- else
- {
- if (name.Equals(IndexFileNames.DELETABLE))
- return true;
- else if (name.StartsWith(IndexFileNames.SEGMENTS))
- return true;
- }
- return false;
- }
-
- /// <summary> Returns true if this is a file that would be contained
- /// in a CFS file. This function should only be called on
- /// files that pass the above "accept" (ie, are already
- /// known to be a Lucene index file).
- /// </summary>
- public virtual bool IsCFSFile(System.String name)
- {
- int i = name.LastIndexOf((System.Char) '.');
- if (i != - 1)
- {
- System.String extension = name.Substring(1 + i);
- if (extensionsInCFS.Contains(extension))
- {
- return true;
- }
- if (extension.StartsWith("f") && (new System.Text.RegularExpressions.Regex("f\\d+")).Match(extension).Success)
- {
- return true;
- }
- }
- return false;
- }
-
- public static IndexFileNameFilter Filter
- {
- get { return singleton; }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/IntBlockPool.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/IntBlockPool.cs b/src/Lucene.Net.Core/Index/IntBlockPool.cs
deleted file mode 100644
index 5b589e5..0000000
--- a/src/Lucene.Net.Core/Index/IntBlockPool.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Lucene.Net.Index
-{
-
- sealed class IntBlockPool
- {
- private void InitBlock()
- {
- intUpto = DocumentsWriter.INT_BLOCK_SIZE;
- }
-
- public int[][] buffers = new int[10][];
-
- internal int bufferUpto = - 1; // Which buffer we are upto
- public int intUpto; // Where we are in head buffer
-
- public int[] buffer; // Current head buffer
- public int intOffset = - DocumentsWriter.INT_BLOCK_SIZE; // Current head offset
-
- private DocumentsWriter docWriter;
- internal bool trackAllocations;
-
- public IntBlockPool(DocumentsWriter docWriter, bool trackAllocations)
- {
- InitBlock();
- this.docWriter = docWriter;
- this.trackAllocations = trackAllocations;
- }
-
- public void Reset()
- {
- if (bufferUpto != - 1)
- {
- if (bufferUpto > 0)
- // Recycle all but the first buffer
- docWriter.RecycleIntBlocks(buffers, 1, 1 + bufferUpto);
-
- // Reuse first buffer
- bufferUpto = 0;
- intUpto = 0;
- intOffset = 0;
- buffer = buffers[0];
- }
- }
-
- public void NextBuffer()
- {
- if (1 + bufferUpto == buffers.Length)
- {
- int[][] newBuffers = new int[(int) (buffers.Length * 1.5)][];
- Array.Copy(buffers, 0, newBuffers, 0, buffers.Length);
- buffers = newBuffers;
- }
- buffer = buffers[1 + bufferUpto] = docWriter.GetIntBlock(trackAllocations);
- bufferUpto++;
-
- intUpto = 0;
- intOffset += DocumentsWriter.INT_BLOCK_SIZE;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/InvertedDocConsumerPerThread.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/InvertedDocConsumerPerThread.cs b/src/Lucene.Net.Core/Index/InvertedDocConsumerPerThread.cs
deleted file mode 100644
index 5e0b6d1..0000000
--- a/src/Lucene.Net.Core/Index/InvertedDocConsumerPerThread.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Lucene.Net.Index
-{
-
- abstract class InvertedDocConsumerPerThread
- {
- public abstract void StartDocument();
- internal abstract InvertedDocConsumerPerField AddField(DocInverterPerField docInverterPerField, FieldInfo fieldInfo);
- public abstract DocumentsWriter.DocWriter FinishDocument();
- public abstract void Abort();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/InvertedDocEndConsumerPerThread.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/InvertedDocEndConsumerPerThread.cs b/src/Lucene.Net.Core/Index/InvertedDocEndConsumerPerThread.cs
deleted file mode 100644
index 4721566..0000000
--- a/src/Lucene.Net.Core/Index/InvertedDocEndConsumerPerThread.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-namespace Lucene.Net.Index
-{
-
- abstract class InvertedDocEndConsumerPerThread
- {
- internal abstract void StartDocument();
- internal abstract InvertedDocEndConsumerPerField AddField(DocInverterPerField docInverterPerField, FieldInfo fieldInfo);
- internal abstract void FinishDocument();
- internal abstract void Abort();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/MergeDocIDRemapper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/MergeDocIDRemapper.cs b/src/Lucene.Net.Core/Index/MergeDocIDRemapper.cs
deleted file mode 100644
index 5c06721..0000000
--- a/src/Lucene.Net.Core/Index/MergeDocIDRemapper.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Lucene.Net.Support;
-
-namespace Lucene.Net.Index
-{
-
- /// <summary>Remaps docIDs after a merge has completed, where the
- /// merged segments had at least one deletion. This is used
- /// to renumber the buffered deletes in IndexWriter when a
- /// merge of segments with deletions commits.
- /// </summary>
-
- sealed class MergeDocIDRemapper
- {
- internal int[] starts; // used for binary search of mapped docID
- internal int[] newStarts; // starts, minus the deletes
- internal int[][] docMaps; // maps docIDs in the merged set
- internal int minDocID; // minimum docID that needs renumbering
- internal int maxDocID; // 1+ the max docID that needs renumbering
- internal int docShift; // total # deleted docs that were compacted by this merge
-
- public MergeDocIDRemapper(SegmentInfos infos, int[][] docMaps, int[] delCounts, MergePolicy.OneMerge merge, int mergedDocCount)
- {
- this.docMaps = docMaps;
- SegmentInfo firstSegment = merge.segments.Info(0);
- int i = 0;
- while (true)
- {
- SegmentInfo info = infos.Info(i);
- if (info.Equals(firstSegment))
- break;
- minDocID += info.docCount;
- i++;
- }
-
- int numDocs = 0;
- for (int j = 0; j < docMaps.Length; i++, j++)
- {
- numDocs += infos.Info(i).docCount;
- System.Diagnostics.Debug.Assert(infos.Info(i).Equals(merge.segments.Info(j)));
- }
- maxDocID = minDocID + numDocs;
-
- starts = new int[docMaps.Length];
- newStarts = new int[docMaps.Length];
-
- starts[0] = minDocID;
- newStarts[0] = minDocID;
- for (i = 1; i < docMaps.Length; i++)
- {
- int lastDocCount = merge.segments.Info(i - 1).docCount;
- starts[i] = starts[i - 1] + lastDocCount;
- newStarts[i] = newStarts[i - 1] + lastDocCount - delCounts[i - 1];
- }
- docShift = numDocs - mergedDocCount;
-
- // There are rare cases when docShift is 0. It happens
- // if you try to delete a docID that's out of bounds,
- // because the SegmentReader still allocates deletedDocs
- // and pretends it has deletions ... so we can't make
- // this assert here
- // assert docShift > 0;
-
- // Make sure it all adds up:
- System.Diagnostics.Debug.Assert(docShift == maxDocID -(newStarts [docMaps.Length - 1] + merge.segments.Info(docMaps.Length - 1).docCount - delCounts [docMaps.Length - 1]));
- }
-
- public int Remap(int oldDocID)
- {
- if (oldDocID < minDocID)
- // Unaffected by merge
- return oldDocID;
- else if (oldDocID >= maxDocID)
- // This doc was "after" the merge, so simple shift
- return oldDocID - docShift;
- else
- {
- // Binary search to locate this document & find its new docID
- int lo = 0; // search starts array
- int hi = docMaps.Length - 1; // for first element less
-
- while (hi >= lo)
- {
- int mid = Number.URShift((lo + hi), 1);
- int midValue = starts[mid];
- if (oldDocID < midValue)
- hi = mid - 1;
- else if (oldDocID > midValue)
- lo = mid + 1;
- else
- {
- // found a match
- while (mid + 1 < docMaps.Length && starts[mid + 1] == midValue)
- {
- mid++; // scan to last match
- }
- if (docMaps[mid] != null)
- return newStarts[mid] + docMaps[mid][oldDocID - starts[mid]];
- else
- return newStarts[mid] + oldDocID - starts[mid];
- }
- }
- if (docMaps[hi] != null)
- return newStarts[hi] + docMaps[hi][oldDocID - starts[hi]];
- else
- return newStarts[hi] + oldDocID - starts[hi];
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/MultiLevelSkipListReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/MultiLevelSkipListReader.cs b/src/Lucene.Net.Core/Index/MultiLevelSkipListReader.cs
deleted file mode 100644
index 408ecfa..0000000
--- a/src/Lucene.Net.Core/Index/MultiLevelSkipListReader.cs
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-using BufferedIndexInput = Lucene.Net.Store.BufferedIndexInput;
-using IndexInput = Lucene.Net.Store.IndexInput;
-
-namespace Lucene.Net.Index
-{
-
- /// <summary> This abstract class reads skip lists with multiple levels.
- ///
- /// See <see cref="MultiLevelSkipListWriter" /> for the information about the encoding
- /// of the multi level skip lists.
- ///
- /// Subclasses must implement the abstract method <see cref="ReadSkipData(int, IndexInput)" />
- /// which defines the actual format of the skip data.
- /// </summary>
- abstract class MultiLevelSkipListReader : IDisposable
- {
- // the maximum number of skip levels possible for this index
- private readonly int maxNumberOfSkipLevels;
-
- // number of levels in this skip list
- private int numberOfSkipLevels;
-
- // Expert: defines the number of top skip levels to buffer in memory.
- // Reducing this number results in less memory usage, but possibly
- // slower performance due to more random I/Os.
- // Please notice that the space each level occupies is limited by
- // the skipInterval. The top level can not contain more than
- // skipLevel entries, the second top level can not contain more
- // than skipLevel^2 entries and so forth.
- private const int numberOfLevelsToBuffer = 1;
-
- private int docCount;
- private bool haveSkipped;
-
- private bool isDisposed;
-
- private readonly IndexInput[] skipStream; // skipStream for each level
- private readonly long[] skipPointer; // the start pointer of each skip level
- private readonly int[] skipInterval; // skipInterval of each level
- private readonly int[] numSkipped; // number of docs skipped per level
-
- private readonly int[] skipDoc; // doc id of current skip entry per level
- private int lastDoc; // doc id of last read skip entry with docId <= target
- private readonly long[] childPointer; // child pointer of current skip entry per level
- private long lastChildPointer; // childPointer of last read skip entry with docId <= target
-
- private readonly bool inputIsBuffered;
-
- protected MultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval)
- {
- this.skipStream = new IndexInput[maxSkipLevels];
- this.skipPointer = new long[maxSkipLevels];
- this.childPointer = new long[maxSkipLevels];
- this.numSkipped = new int[maxSkipLevels];
- this.maxNumberOfSkipLevels = maxSkipLevels;
- this.skipInterval = new int[maxSkipLevels];
- this.skipStream[0] = skipStream;
- this.inputIsBuffered = (skipStream is BufferedIndexInput);
- this.skipInterval[0] = skipInterval;
- for (int i = 1; i < maxSkipLevels; i++)
- {
- // cache skip intervals
- this.skipInterval[i] = this.skipInterval[i - 1] * skipInterval;
- }
- skipDoc = new int[maxSkipLevels];
- }
-
-
- /// <summary>Returns the id of the doc to which the last call of <see cref="SkipTo(int)" />
- /// has skipped.
- /// </summary>
- internal virtual int GetDoc()
- {
- return lastDoc;
- }
-
-
- /// <summary>Skips entries to the first beyond the current whose document number is
- /// greater than or equal to <i>target</i>. Returns the current doc count.
- /// </summary>
- internal virtual int SkipTo(int target)
- {
- if (!haveSkipped)
- {
- // first time, load skip levels
- LoadSkipLevels();
- haveSkipped = true;
- }
-
- // walk up the levels until highest level is found that has a skip
- // for this target
- int level = 0;
- while (level < numberOfSkipLevels - 1 && target > skipDoc[level + 1])
- {
- level++;
- }
-
- while (level >= 0)
- {
- if (target > skipDoc[level])
- {
- if (!LoadNextSkip(level))
- {
- continue;
- }
- }
- else
- {
- // no more skips on this level, go down one level
- if (level > 0 && lastChildPointer > skipStream[level - 1].FilePointer)
- {
- SeekChild(level - 1);
- }
- level--;
- }
- }
-
- return numSkipped[0] - skipInterval[0] - 1;
- }
-
- private bool LoadNextSkip(int level)
- {
- // we have to skip, the target document is greater than the current
- // skip list entry
- SetLastSkipData(level);
-
- numSkipped[level] += skipInterval[level];
-
- if (numSkipped[level] > docCount)
- {
- // this skip list is exhausted
- skipDoc[level] = System.Int32.MaxValue;
- if (numberOfSkipLevels > level)
- numberOfSkipLevels = level;
- return false;
- }
-
- // read next skip entry
- skipDoc[level] += ReadSkipData(level, skipStream[level]);
-
- if (level != 0)
- {
- // read the child pointer if we are not on the leaf level
- childPointer[level] = skipStream[level].ReadVLong() + skipPointer[level - 1];
- }
-
- return true;
- }
-
- /// <summary>Seeks the skip entry on the given level </summary>
- protected internal virtual void SeekChild(int level)
- {
- skipStream[level].Seek(lastChildPointer);
- numSkipped[level] = numSkipped[level + 1] - skipInterval[level + 1];
- skipDoc[level] = lastDoc;
- if (level > 0)
- {
- childPointer[level] = skipStream[level].ReadVLong() + skipPointer[level - 1];
- }
- }
-
- public void Dispose()
- {
- Dispose(true);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (isDisposed) return;
-
- if (disposing)
- {
- for (int i = 1; i < skipStream.Length; i++)
- {
- if (skipStream[i] != null)
- {
- skipStream[i].Close();
- }
- }
- }
-
- isDisposed = true;
- }
-
- /// <summary>initializes the reader </summary>
- internal virtual void Init(long skipPointer, int df)
- {
- this.skipPointer[0] = skipPointer;
- this.docCount = df;
- System.Array.Clear(skipDoc, 0, skipDoc.Length);
- System.Array.Clear(numSkipped, 0, numSkipped.Length);
- System.Array.Clear(childPointer, 0, childPointer.Length);
-
- haveSkipped = false;
- for (int i = 1; i < numberOfSkipLevels; i++)
- {
- skipStream[i] = null;
- }
- }
-
- /// <summary>Loads the skip levels </summary>
- private void LoadSkipLevels()
- {
- numberOfSkipLevels = docCount == 0?0:(int) System.Math.Floor(System.Math.Log(docCount) / System.Math.Log(skipInterval[0]));
- if (numberOfSkipLevels > maxNumberOfSkipLevels)
- {
- numberOfSkipLevels = maxNumberOfSkipLevels;
- }
-
- skipStream[0].Seek(skipPointer[0]);
-
- int toBuffer = numberOfLevelsToBuffer;
-
- for (int i = numberOfSkipLevels - 1; i > 0; i--)
- {
- // the length of the current level
- long length = skipStream[0].ReadVLong();
-
- // the start pointer of the current level
- skipPointer[i] = skipStream[0].FilePointer;
- if (toBuffer > 0)
- {
- // buffer this level
- skipStream[i] = new SkipBuffer(skipStream[0], (int) length);
- toBuffer--;
- }
- else
- {
- // clone this stream, it is already at the start of the current level
- skipStream[i] = (IndexInput) skipStream[0].Clone();
- if (inputIsBuffered && length < BufferedIndexInput.BUFFER_SIZE)
- {
- ((BufferedIndexInput) skipStream[i]).SetBufferSize((int) length);
- }
-
- // move base stream beyond the current level
- skipStream[0].Seek(skipStream[0].FilePointer + length);
- }
- }
-
- // use base stream for the lowest level
- skipPointer[0] = skipStream[0].FilePointer;
- }
-
- /// <summary> Subclasses must implement the actual skip data encoding in this method.
- ///
- /// </summary>
- /// <param name="level">the level skip data shall be read from
- /// </param>
- /// <param name="skipStream">the skip stream to read from
- /// </param>
- protected internal abstract int ReadSkipData(int level, IndexInput skipStream);
-
- /// <summary>Copies the values of the last read skip entry on this level </summary>
- protected internal virtual void SetLastSkipData(int level)
- {
- lastDoc = skipDoc[level];
- lastChildPointer = childPointer[level];
- }
-
-
- /// <summary>used to buffer the top skip levels </summary>
- private sealed class SkipBuffer : IndexInput
- {
- private byte[] data;
- private readonly long pointer;
- private int pos;
-
- private bool isDisposed;
-
- internal SkipBuffer(IndexInput input, int length)
- {
- data = new byte[length];
- pointer = input.FilePointer;
- input.ReadBytes(data, 0, length);
- }
-
- protected override void Dispose(bool disposing)
- {
- if (isDisposed) return;
- if (disposing)
- {
- data = null;
- }
-
- isDisposed = true;
- }
-
- public override long FilePointer
- {
- get { return pointer + pos; }
- }
-
- public override long Length()
- {
- return data.Length;
- }
-
- public override byte ReadByte()
- {
- return data[pos++];
- }
-
- public override void ReadBytes(byte[] b, int offset, int len)
- {
- Array.Copy(data, pos, b, offset, len);
- pos += len;
- }
-
- public override void Seek(long pos)
- {
- this.pos = (int) (pos - pointer);
- }
-
- override public System.Object Clone()
- {
- System.Diagnostics.Debug.Fail("Port issue:", "Lets see if we need this FilterIndexReader.Clone()"); // {{Aroush-2.9}}
- return null;
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/MultiLevelSkipListWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/MultiLevelSkipListWriter.cs b/src/Lucene.Net.Core/Index/MultiLevelSkipListWriter.cs
deleted file mode 100644
index 4afe04f..0000000
--- a/src/Lucene.Net.Core/Index/MultiLevelSkipListWriter.cs
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-using IndexOutput = Lucene.Net.Store.IndexOutput;
-using RAMOutputStream = Lucene.Net.Store.RAMOutputStream;
-
-namespace Lucene.Net.Index
-{
-
- /// <summary> This abstract class writes skip lists with multiple levels.
- ///
- /// Example for skipInterval = 3:
- /// c (skip level 2)
- /// c c c (skip level 1)
- /// x x x x x x x x x x (skip level 0)
- /// d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d (posting list)
- /// 3 6 9 12 15 18 21 24 27 30 (df)
- ///
- /// d - document
- /// x - skip data
- /// c - skip data with child pointer
- ///
- /// Skip level i contains every skipInterval-th entry from skip level i-1.
- /// Therefore the number of entries on level i is: floor(df / ((skipInterval ^ (i + 1))).
- ///
- /// Each skip entry on a level i>0 contains a pointer to the corresponding skip entry in list i-1.
- /// This guarantess a logarithmic amount of skips to find the target document.
- ///
- /// While this class takes care of writing the different skip levels,
- /// subclasses must define the actual format of the skip data.
- ///
- /// </summary>
- abstract class MultiLevelSkipListWriter
- {
- // number of levels in this skip list
- private int numberOfSkipLevels;
-
- // the skip interval in the list with level = 0
- private int skipInterval;
-
- // for every skip level a different buffer is used
- private RAMOutputStream[] skipBuffer;
-
- protected internal MultiLevelSkipListWriter(int skipInterval, int maxSkipLevels, int df)
- {
- this.skipInterval = skipInterval;
-
- // calculate the maximum number of skip levels for this document frequency
- numberOfSkipLevels = df == 0?0:(int) System.Math.Floor(System.Math.Log(df) / System.Math.Log(skipInterval));
-
- // make sure it does not exceed maxSkipLevels
- if (numberOfSkipLevels > maxSkipLevels)
- {
- numberOfSkipLevels = maxSkipLevels;
- }
- }
-
- protected internal virtual void Init()
- {
- skipBuffer = new RAMOutputStream[numberOfSkipLevels];
- for (int i = 0; i < numberOfSkipLevels; i++)
- {
- skipBuffer[i] = new RAMOutputStream();
- }
- }
-
- protected internal virtual void ResetSkip()
- {
- // creates new buffers or empties the existing ones
- if (skipBuffer == null)
- {
- Init();
- }
- else
- {
- for (int i = 0; i < skipBuffer.Length; i++)
- {
- skipBuffer[i].Reset();
- }
- }
- }
-
- /// <summary> Subclasses must implement the actual skip data encoding in this method.
- ///
- /// </summary>
- /// <param name="level">the level skip data shall be writting for
- /// </param>
- /// <param name="skipBuffer">the skip buffer to write to
- /// </param>
- protected internal abstract void WriteSkipData(int level, IndexOutput skipBuffer);
-
- /// <summary> Writes the current skip data to the buffers. The current document frequency determines
- /// the max level is skip data is to be written to.
- ///
- /// </summary>
- /// <param name="df">the current document frequency
- /// </param>
- /// <throws> IOException </throws>
- internal virtual void BufferSkip(int df)
- {
- int numLevels;
-
- // determine max level
- for (numLevels = 0; (df % skipInterval) == 0 && numLevels < numberOfSkipLevels; df /= skipInterval)
- {
- numLevels++;
- }
-
- long childPointer = 0;
-
- for (int level = 0; level < numLevels; level++)
- {
- WriteSkipData(level, skipBuffer[level]);
-
- long newChildPointer = skipBuffer[level].FilePointer;
-
- if (level != 0)
- {
- // store child pointers for all levels except the lowest
- skipBuffer[level].WriteVLong(childPointer);
- }
-
- //remember the childPointer for the next level
- childPointer = newChildPointer;
- }
- }
-
- /// <summary> Writes the buffered skip lists to the given output.
- ///
- /// </summary>
- /// <param name="output">the IndexOutput the skip lists shall be written to
- /// </param>
- /// <returns> the pointer the skip list starts
- /// </returns>
- internal virtual long WriteSkip(IndexOutput output)
- {
- long skipPointer = output.FilePointer;
- if (skipBuffer == null || skipBuffer.Length == 0)
- return skipPointer;
-
- for (int level = numberOfSkipLevels - 1; level > 0; level--)
- {
- long length = skipBuffer[level].FilePointer;
- if (length > 0)
- {
- output.WriteVLong(length);
- skipBuffer[level].WriteTo(output);
- }
- }
- skipBuffer[0].WriteTo(output);
-
- return skipPointer;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/MultipleTermPositions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/MultipleTermPositions.cs b/src/Lucene.Net.Core/Index/MultipleTermPositions.cs
deleted file mode 100644
index 34f3d65..0000000
--- a/src/Lucene.Net.Core/Index/MultipleTermPositions.cs
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Lucene.Net.Util;
-
-namespace Lucene.Net.Index
-{
-
- /// <summary> Allows you to iterate over the <see cref="TermPositions" /> for multiple <see cref="Term" />s as
- /// a single <see cref="TermPositions" />.
- ///
- /// </summary>
- public class MultipleTermPositions : TermPositions
- {
- private sealed class TermPositionsQueue : PriorityQueue<TermPositions>
- {
- internal TermPositionsQueue(LinkedList<TermPositions> termPositions)
- {
- Initialize(termPositions.Count);
-
- foreach(TermPositions tp in termPositions)
- if (tp.Next())
- Add(tp);
- }
-
- internal TermPositions Peek()
- {
- return Top();
- }
-
- public override bool LessThan(TermPositions a, TermPositions b)
- {
- return a.Doc < b.Doc;
- }
- }
-
- private sealed class IntQueue
- {
- public IntQueue()
- {
- InitBlock();
- }
- private void InitBlock()
- {
- _array = new int[_arraySize];
- }
- private int _arraySize = 16;
- private int _index = 0;
- private int _lastIndex = 0;
- private int[] _array;
-
- internal void add(int i)
- {
- if (_lastIndex == _arraySize)
- growArray();
-
- _array[_lastIndex++] = i;
- }
-
- internal int next()
- {
- return _array[_index++];
- }
-
- internal void sort()
- {
- System.Array.Sort(_array, _index, _lastIndex - _index);
- }
-
- internal void clear()
- {
- _index = 0;
- _lastIndex = 0;
- }
-
- internal int size()
- {
- return (_lastIndex - _index);
- }
-
- private void growArray()
- {
- int[] newArray = new int[_arraySize * 2];
- Array.Copy(_array, 0, newArray, 0, _arraySize);
- _array = newArray;
- _arraySize *= 2;
- }
- }
-
- private int _doc;
- private int _freq;
- private TermPositionsQueue _termPositionsQueue;
- private IntQueue _posList;
-
- private bool isDisposed;
- /// <summary> Creates a new <c>MultipleTermPositions</c> instance.
- ///
- /// </summary>
- /// <exception cref="System.IO.IOException">
- /// </exception>
- public MultipleTermPositions(IndexReader indexReader, Term[] terms)
- {
- var termPositions = new System.Collections.Generic.LinkedList<TermPositions>();
-
- for (int i = 0; i < terms.Length; i++)
- termPositions.AddLast(indexReader.TermPositions(terms[i]));
-
- _termPositionsQueue = new TermPositionsQueue(termPositions);
- _posList = new IntQueue();
- }
-
- public bool Next()
- {
- if (_termPositionsQueue.Size() == 0)
- return false;
-
- _posList.clear();
- _doc = _termPositionsQueue.Peek().Doc;
-
- TermPositions tp;
- do
- {
- tp = _termPositionsQueue.Peek();
-
- for (int i = 0; i < tp.Freq; i++)
- _posList.add(tp.NextPosition());
-
- if (tp.Next())
- _termPositionsQueue.UpdateTop();
- else
- {
- _termPositionsQueue.Pop();
- tp.Close();
- }
- }
- while (_termPositionsQueue.Size() > 0 && _termPositionsQueue.Peek().Doc == _doc);
-
- _posList.sort();
- _freq = _posList.size();
-
- return true;
- }
-
- public int NextPosition()
- {
- return _posList.next();
- }
-
- public bool SkipTo(int target)
- {
- while (_termPositionsQueue.Peek() != null && target > _termPositionsQueue.Peek().Doc)
- {
- TermPositions tp = _termPositionsQueue.Pop();
- if (tp.SkipTo(target))
- _termPositionsQueue.Add(tp);
- else
- tp.Close();
- }
- return Next();
- }
-
- public int Doc
- {
- get { return _doc; }
- }
-
- public int Freq
- {
- get { return _freq; }
- }
-
- [Obsolete("Use Dispose() instead")]
- public void Close()
- {
- Dispose();
- }
-
- public void Dispose()
- {
- Dispose(true);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (isDisposed) return;
-
- if (disposing)
- {
- while (_termPositionsQueue.Size() > 0)
- _termPositionsQueue.Pop().Close();
- }
-
- isDisposed = true;
- }
-
- /// <summary> Not implemented.</summary>
- /// <throws> UnsupportedOperationException </throws>
- public virtual void Seek(Term arg0)
- {
- throw new System.NotSupportedException();
- }
-
- /// <summary> Not implemented.</summary>
- /// <throws> UnsupportedOperationException </throws>
- public virtual void Seek(TermEnum termEnum)
- {
- throw new System.NotSupportedException();
- }
-
- /// <summary> Not implemented.</summary>
- /// <throws> UnsupportedOperationException </throws>
- public virtual int Read(int[] arg0, int[] arg1)
- {
- throw new System.NotSupportedException();
- }
-
-
- /// <summary> Not implemented.</summary>
- /// <throws> UnsupportedOperationException </throws>
- public virtual int PayloadLength
- {
- get { throw new System.NotSupportedException(); }
- }
-
- /// <summary> Not implemented.</summary>
- /// <throws> UnsupportedOperationException </throws>
- public virtual byte[] GetPayload(byte[] data, int offset)
- {
- throw new System.NotSupportedException();
- }
-
- /// <summary> </summary>
- /// <value> false </value>
-// TODO: Remove warning after API has been finalized
- public virtual bool IsPayloadAvailable
- {
- get { return false; }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/NormsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/NormsWriter.cs b/src/Lucene.Net.Core/Index/NormsWriter.cs
deleted file mode 100644
index 46bb941..0000000
--- a/src/Lucene.Net.Core/Index/NormsWriter.cs
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Collections.Generic;
-using Lucene.Net.Support;
-using IndexOutput = Lucene.Net.Store.IndexOutput;
-using Similarity = Lucene.Net.Search.Similarity;
-
-namespace Lucene.Net.Index
-{
-
- // TODO FI: norms could actually be stored as doc store
-
- /// <summary>Writes norms. Each thread X field accumulates the norms
- /// for the doc/fields it saw, then the flush method below
- /// merges all of these together into a single _X.nrm file.
- /// </summary>
-
- sealed class NormsWriter : InvertedDocEndConsumer
- {
-
- private static readonly byte defaultNorm;
- private FieldInfos fieldInfos;
- public override InvertedDocEndConsumerPerThread AddThread(DocInverterPerThread docInverterPerThread)
- {
- return new NormsWriterPerThread(docInverterPerThread, this);
- }
-
- public override void Abort()
- {
- }
-
- // We only write the _X.nrm file at flush
- internal void Files(ICollection<string> files)
- {
- }
-
- internal override void SetFieldInfos(FieldInfos fieldInfos)
- {
- this.fieldInfos = fieldInfos;
- }
-
- /// <summary>Produce _X.nrm if any document had a field with norms
- /// not disabled
- /// </summary>
- public override void Flush(IDictionary<InvertedDocEndConsumerPerThread,ICollection<InvertedDocEndConsumerPerField>> threadsAndFields, SegmentWriteState state)
- {
-
- IDictionary<FieldInfo, IList<NormsWriterPerField>> byField = new HashMap<FieldInfo, IList<NormsWriterPerField>>();
-
- // Typically, each thread will have encountered the same
- // field. So first we collate by field, ie, all
- // per-thread field instances that correspond to the
- // same FieldInfo
- foreach(var entry in threadsAndFields)
- {
- ICollection<InvertedDocEndConsumerPerField> fields = entry.Value;
- IEnumerator<InvertedDocEndConsumerPerField> fieldsIt = fields.GetEnumerator();
- var fieldsToRemove = new HashSet<NormsWriterPerField>();
- while (fieldsIt.MoveNext())
- {
- NormsWriterPerField perField = (NormsWriterPerField) fieldsIt.Current;
-
- if (perField.upto > 0)
- {
- // It has some norms
- IList<NormsWriterPerField> l = byField[perField.fieldInfo];
- if (l == null)
- {
- l = new List<NormsWriterPerField>();
- byField[perField.fieldInfo] = l;
- }
- l.Add(perField);
- }
- // Remove this field since we haven't seen it
- // since the previous flush
- else
- {
- fieldsToRemove.Add(perField);
- }
- }
- foreach (var field in fieldsToRemove)
- {
- fields.Remove(field);
- }
- }
-
- System.String normsFileName = state.segmentName + "." + IndexFileNames.NORMS_EXTENSION;
- state.flushedFiles.Add(normsFileName);
- IndexOutput normsOut = state.directory.CreateOutput(normsFileName);
-
- try
- {
- normsOut.WriteBytes(SegmentMerger.NORMS_HEADER, 0, SegmentMerger.NORMS_HEADER.Length);
-
- int numField = fieldInfos.Size();
-
- int normCount = 0;
-
- for (int fieldNumber = 0; fieldNumber < numField; fieldNumber++)
- {
-
- FieldInfo fieldInfo = fieldInfos.FieldInfo(fieldNumber);
-
- IList<NormsWriterPerField> toMerge = byField[fieldInfo];
- int upto = 0;
- if (toMerge != null)
- {
-
- int numFields = toMerge.Count;
-
- normCount++;
-
- NormsWriterPerField[] fields = new NormsWriterPerField[numFields];
- int[] uptos = new int[numFields];
-
- for (int j = 0; j < numFields; j++)
- fields[j] = toMerge[j];
-
- int numLeft = numFields;
-
- while (numLeft > 0)
- {
-
- System.Diagnostics.Debug.Assert(uptos [0] < fields [0].docIDs.Length, " uptos[0]=" + uptos [0] + " len=" +(fields [0].docIDs.Length));
-
- int minLoc = 0;
- int minDocID = fields[0].docIDs[uptos[0]];
-
- for (int j = 1; j < numLeft; j++)
- {
- int docID = fields[j].docIDs[uptos[j]];
- if (docID < minDocID)
- {
- minDocID = docID;
- minLoc = j;
- }
- }
-
- System.Diagnostics.Debug.Assert(minDocID < state.numDocs);
-
- // Fill hole
- for (; upto < minDocID; upto++)
- normsOut.WriteByte(defaultNorm);
-
- normsOut.WriteByte(fields[minLoc].norms[uptos[minLoc]]);
- (uptos[minLoc])++;
- upto++;
-
- if (uptos[minLoc] == fields[minLoc].upto)
- {
- fields[minLoc].Reset();
- if (minLoc != numLeft - 1)
- {
- fields[minLoc] = fields[numLeft - 1];
- uptos[minLoc] = uptos[numLeft - 1];
- }
- numLeft--;
- }
- }
-
- // Fill final hole with defaultNorm
- for (; upto < state.numDocs; upto++)
- normsOut.WriteByte(defaultNorm);
- }
- else if (fieldInfo.isIndexed && !fieldInfo.omitNorms)
- {
- normCount++;
- // Fill entire field with default norm:
- for (; upto < state.numDocs; upto++)
- normsOut.WriteByte(defaultNorm);
- }
-
- System.Diagnostics.Debug.Assert(4 + normCount * state.numDocs == normsOut.FilePointer, ".nrm file size mismatch: expected=" +(4 + normCount * state.numDocs) + " actual=" + normsOut.FilePointer);
- }
- }
- finally
- {
- normsOut.Close();
- }
- }
-
- internal override void CloseDocStore(SegmentWriteState state)
- {
- }
- static NormsWriter()
- {
- defaultNorm = Similarity.EncodeNorm(1.0f);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/228b970a/src/Lucene.Net.Core/Index/NormsWriterPerField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/NormsWriterPerField.cs b/src/Lucene.Net.Core/Index/NormsWriterPerField.cs
deleted file mode 100644
index 9d2153d..0000000
--- a/src/Lucene.Net.Core/Index/NormsWriterPerField.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-
-using ArrayUtil = Lucene.Net.Util.ArrayUtil;
-using Similarity = Lucene.Net.Search.Similarity;
-
-namespace Lucene.Net.Index
-{
-
- /// <summary>Taps into DocInverter, as an InvertedDocEndConsumer,
- /// which is called at the end of inverting each field. We
- /// just look at the length for the field (docState.length)
- /// and record the norm.
- /// </summary>
-
- sealed class NormsWriterPerField:InvertedDocEndConsumerPerField, System.IComparable<NormsWriterPerField>
- {
-
- internal NormsWriterPerThread perThread;
- internal FieldInfo fieldInfo;
- internal DocumentsWriter.DocState docState;
-
- // Holds all docID/norm pairs we've seen
- internal int[] docIDs = new int[1];
- internal byte[] norms = new byte[1];
- internal int upto;
-
- internal FieldInvertState fieldState;
-
- public void Reset()
- {
- // Shrink back if we are overallocated now:
- docIDs = ArrayUtil.Shrink(docIDs, upto);
- norms = ArrayUtil.Shrink(norms, upto);
- upto = 0;
- }
-
- public NormsWriterPerField(DocInverterPerField docInverterPerField, NormsWriterPerThread perThread, FieldInfo fieldInfo)
- {
- this.perThread = perThread;
- this.fieldInfo = fieldInfo;
- docState = perThread.docState;
- fieldState = docInverterPerField.fieldState;
- }
-
- internal override void Abort()
- {
- upto = 0;
- }
-
- public int CompareTo(NormsWriterPerField other)
- {
- return String.CompareOrdinal(fieldInfo.name, other.fieldInfo.name);
- }
-
- internal override void Finish()
- {
- System.Diagnostics.Debug.Assert(docIDs.Length == norms.Length);
- if (fieldInfo.isIndexed && !fieldInfo.omitNorms)
- {
- if (docIDs.Length <= upto)
- {
- System.Diagnostics.Debug.Assert(docIDs.Length == upto);
- docIDs = ArrayUtil.Grow(docIDs, 1 + upto);
- norms = ArrayUtil.Grow(norms, 1 + upto);
- }
- float norm = docState.similarity.ComputeNorm(fieldInfo.name, fieldState);
- norms[upto] = Similarity.EncodeNorm(norm);
- docIDs[upto] = docState.docID;
- upto++;
- }
- }
- }
-}
\ No newline at end of file