You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by pn...@apache.org on 2014/12/02 18:41:37 UTC
[1/4] lucenenet git commit: Merge pull request #1 from apache/master
Repository: lucenenet
Updated Branches:
refs/heads/master eec73d5c1 -> 2d7533d4e
Merge pull request #1 from apache/master
Pulling in updates from apache mirror
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/a7d71c26
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/a7d71c26
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/a7d71c26
Branch: refs/heads/master
Commit: a7d71c26eb2e70377e48fd33f72b2844bafd49be
Parents: 9971717 bcff24d
Author: Prescott Nasser <ge...@hotmail.com>
Authored: Sat Nov 8 15:49:49 2014 -0800
Committer: Prescott Nasser <ge...@hotmail.com>
Committed: Sat Nov 8 15:49:49 2014 -0800
----------------------------------------------------------------------
.../Memory/DirectDocValuesConsumer.cs | 16 +-
.../Memory/DirectPostingsFormat.cs | 5343 +++++++++---------
.../Memory/FSTOrdPostingsFormat.cs | 153 +-
.../Memory/FSTOrdTermsWriter.cs | 837 ++-
.../Memory/FSTPostingsFormat.cs | 152 +-
src/Lucene.Net.Codecs/Memory/FSTTermsWriter.cs | 14 +-
.../Memory/MemoryDocValuesConsumer.cs | 987 ++--
.../Memory/MemoryDocValuesProducer.cs | 1717 +++---
.../Memory/MemoryPostingsFormat.cs | 101 +-
.../Util/Fst/PositiveIntOutputs.cs | 1 -
10 files changed, 4577 insertions(+), 4744 deletions(-)
----------------------------------------------------------------------
[3/4] lucenenet git commit: finished conversion of
Lucene.Net.Codes.Intblock
Posted by pn...@apache.org.
finished conversion of Lucene.Net.Codes.Intblock
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/df4afdc3
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/df4afdc3
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/df4afdc3
Branch: refs/heads/master
Commit: df4afdc3ee75fc664525402a49756dcf8acd8102
Parents: a33ca52
Author: Prescott Nasser <pn...@apache.org>
Authored: Sat Nov 29 16:03:22 2014 -0800
Committer: Prescott Nasser <pn...@apache.org>
Committed: Sat Nov 29 16:03:22 2014 -0800
----------------------------------------------------------------------
.../Intblock/FixedIntBlockIndexInput.cs | 45 ++--
.../Intblock/FixedIntBlockIndexOutput.cs | 153 +++++--------
src/Lucene.Net.Codecs/Intblock/IBlockReader.cs | 10 +-
src/Lucene.Net.Codecs/Intblock/Index.cs | 78 -------
.../Intblock/IntBlockIndexInput.cs | 84 ++++++++
.../Intblock/IntBlockIndexOutput.cs | 85 ++++++++
.../Intblock/IntBlockIndexReader.cs | 100 +++++++++
src/Lucene.Net.Codecs/Intblock/Reader.cs | 81 -------
.../Intblock/VariableIntBlockIndexInput.cs | 216 +++++--------------
.../Intblock/VariableIntBlockIndexOutput.cs | 113 +++-------
src/Lucene.Net.Codecs/Lucene.Net.Codecs.csproj | 5 +-
src/Lucene.Net.Codecs/Sep/IntIndexOutput.cs | 2 +
12 files changed, 435 insertions(+), 537 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/df4afdc3/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexInput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexInput.cs b/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexInput.cs
index dc7b558..f992c77 100644
--- a/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexInput.cs
+++ b/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexInput.cs
@@ -1,4 +1,4 @@
-/*
+/*
* 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.
@@ -15,22 +15,25 @@
* limitations under the License.
*/
-using Lucene.Net.Codecs.Sep;
-using Lucene.Net.Store;
-
namespace Lucene.Net.Codecs.Intblock
{
+ using Sep;
+ using IntIndexInput = Sep.IntIndexInput;
+ using IndexInput = Store.IndexInput;
+
/// <summary>
/// Naive int block API that writes vInts. This is
- /// expected to give poor performance; it's really only for
- /// testing the pluggability. One should typically use pfor instead. */
- ///
+ /// expected to give poor performance; it's really only for
+ /// testing the pluggability. One should typically use pfor instead.
+ /// </summary>
+
+ /// <summary>
/// Abstract base class that reads fixed-size blocks of ints
- /// from an IndexInput. While this is a simple approach, a
- /// more performant approach would directly create an impl
- /// of IntIndexInput inside Directory. Wrapping a generic
- /// IndexInput will likely cost performance.
+ /// from an IndexInput. While this is a simple approach, a
+ /// more performant approach would directly create an impl
+ /// of IntIndexInput inside Directory. Wrapping a generic
+ /// IndexInput will likely cost performance.
///
/// @lucene.experimental
/// </summary>
@@ -38,21 +41,20 @@ namespace Lucene.Net.Codecs.Intblock
{
private readonly IndexInput _input;
- private readonly int _blockSize;
+ protected internal readonly int BLOCK_SIZE;
- protected FixedIntBlockIndexInput(IndexInput input)
+ public FixedIntBlockIndexInput(IndexInput @in)
{
- _input = input;
- _blockSize = input.ReadVInt();
+ _input = @in;
+ BLOCK_SIZE = @in.ReadVInt();
}
public override IntIndexInputReader Reader()
{
- var buffer = new int[_blockSize];
- var clone = (IndexInput)_input.Clone();
-
+ var buffer = new int[BLOCK_SIZE];
+ var clone = (IndexInput) _input.Clone();
// TODO: can this be simplified?
- return new Reader(clone, buffer, BlockReader(clone, buffer));
+ return new IntBlockIndexReader(clone, buffer, GetBlockReader(clone, buffer));
}
public override void Dispose()
@@ -62,10 +64,11 @@ namespace Lucene.Net.Codecs.Intblock
public override IntIndexInputIndex Index()
{
- return new Index();
+ return new IntBlockIndexInput(this);
}
- protected abstract VariableIntBlockIndexInput.BlockReader BlockReader(IndexInput input, int[] buffer);
+ protected internal abstract IBlockReader GetBlockReader(IndexInput @in, int[] buffer);
}
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/df4afdc3/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexOutput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexOutput.cs b/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexOutput.cs
index b19a0a3..96d08d1 100644
--- a/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexOutput.cs
+++ b/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexOutput.cs
@@ -1,4 +1,4 @@
-/*
+/*
* 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.
@@ -15,127 +15,74 @@
* limitations under the License.
*/
-/** Naive int block API that writes vInts. This is
- * expected to give poor performance; it's really only for
- * testing the pluggability. One should typically use pfor instead. */
+namespace Lucene.Net.Codecs.Intblock
+{
+ using Sep;
+ using IntIndexOutput = Sep.IntIndexOutput;
+ using IndexOutput = Store.IndexOutput;
-using System;
-using System.Diagnostics;
-using Lucene.Net.Codecs.Sep;
-using Lucene.Net.Store;
+ /// <summary>
+ /// Naive int block API that writes vInts. This is
+ /// expected to give poor performance; it's really only for
+ /// testing the pluggability. One should typically use pfor instead.
+ /// </summary>
-/// <summary>
-/// Abstract base class that writes fixed-size blocks of ints to an
-/// IndexOutput. While this is a simple approach, a more
-/// performant approach would directly create an impl of
-/// IntIndexOutput inside Directory. Wrapping a generic IndexInput
-/// will likely cost performance.
-///
-/// * @lucene.experimental
-/// </summary>
-public abstract class FixedIntBlockIndexOutput : IntIndexOutput {
-
- protected IndexOutput out;
- private int blockSize;
- protected int int[] buffer;
- private int upto;
-
- protected FixedIntBlockIndexOutput(IndexOutput out, int fixedBlockSize) {
- blockSize = fixedBlockSize;
- this.out = out;
- out.WriteVInt(blockSize);
- buffer = new int[blockSize];
- }
-
- protected abstract void flushBlock() ;
+ /// <summary>
+ /// Abstract base class that writes fixed-size blocks of ints
+ /// to an IndexOutput. While this is a simple approach, a
+ /// more performant approach would directly create an impl
+ /// of IntIndexOutput inside Directory. Wrapping a generic
+ /// IndexInput will likely cost performance.
+ ///
+ /// @lucene.experimental
+ /// </summary>
+ public abstract class FixedIntBlockIndexOutput : IntIndexOutput
+ {
+ private readonly int _blockSize;
+ protected internal readonly int[] BUFFER;
- public override IntIndexOutputIndex index() {
- return new Index();
- }
+ protected internal FixedIntBlockIndexOutput(IndexOutput output, int fixedBlockSize)
+ {
+ _blockSize = fixedBlockSize;
+ OUTPUT = output;
+ output.WriteVInt(_blockSize);
+ BUFFER = new int[_blockSize];
+ }
- private class Index : IntIndexOutputIndex
- {
- private long fp;
- private int upto;
- private long lastFP;
- private int lastUpto;
+ protected internal abstract void FlushBlock();
- public override void Mark()
+ public override IntIndexOutputIndex Index()
{
- fp =out.
- FilePointer;
- upto = FixedIntBlockIndexOutput.
- this.upto;
+ return new IntBlockIndexOuput(this);
}
- public override void CopyFrom(IntIndexOutputIndex other, bool copyLast)
+ public override void Write(int v)
{
- Index idx = (Index) other;
- fp = idx.fp;
- upto = idx.upto;
- if (copyLast)
+ BUFFER[_upto++] = v;
+ if (_upto == _blockSize)
{
- lastFP = fp;
- lastUpto = upto;
+ FlushBlock();
+ _upto = 0;
}
}
- public override void Write(DataOutput indexOut, bool absolute)
+ public override void Dispose()
{
- if (absolute)
+ try
{
- indexOut.WriteVInt(upto);
- indexOut.WriteVLong(fp);
+ if (_upto > 0)
+ {
+ // NOTE: entries in the block after current upto are
+ // invalid
+ FlushBlock();
+ }
}
- else if (fp == lastFP)
+ finally
{
- // same block
- Debug.Assert(upto >= lastUpto);
- var uptoDelta = upto - lastUpto;
- indexOut.WriteVInt(uptoDelta << 1 | 1);
+ OUTPUT.Dispose();
}
- else
- {
- // new block
- indexOut.WriteVInt(upto << 1);
- indexOut.WriteVLong(fp - lastFP);
- }
- lastUpto = upto;
- lastFP = fp;
- }
-
- public override String ToString()
- {
- return String.Format("fp={0} upto={1}", fp, upto);
}
}
- public override void Write(int v)
- {
- buffer[upto++] = v;
- if (upto == blockSize)
- {
- flushBlock();
- upto = 0;
- }
- }
-
- public override void Dispose()
- {
- try
- {
- if (upto > 0)
- {
- // NOTE: entries in the block after current upto are
- // invalid
- flushBlock();
- }
- }
- finally
- {
- out.
- Dispose();
- }
- }
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/df4afdc3/src/Lucene.Net.Codecs/Intblock/IBlockReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/IBlockReader.cs b/src/Lucene.Net.Codecs/Intblock/IBlockReader.cs
index adf14ec..6218502 100644
--- a/src/Lucene.Net.Codecs/Intblock/IBlockReader.cs
+++ b/src/Lucene.Net.Codecs/Intblock/IBlockReader.cs
@@ -18,12 +18,14 @@
namespace Lucene.Net.Codecs.Intblock
{
/// <summary>
- /// Interface for fixed-size block decoders
- ///
- /// Implementations should decode into the buffer in {@link #ReadBlock}
+ /// Interface for variable-size block decoders.
+ /// <para>
+ /// Implementations should decode into the buffer in <seealso cref="#readBlock"/>.
+ /// </para>
/// </summary>
public interface IBlockReader
{
- void ReadBlock();
+ int ReadBlock();
+ void Seek(long pos);
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/df4afdc3/src/Lucene.Net.Codecs/Intblock/Index.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/Index.cs b/src/Lucene.Net.Codecs/Intblock/Index.cs
deleted file mode 100644
index d2bd9a9..0000000
--- a/src/Lucene.Net.Codecs/Intblock/Index.cs
+++ /dev/null
@@ -1,78 +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.Codecs.Intblock
-{
- using Sep;
- using Store;
- using System;
- using System.Diagnostics;
-
- internal class Index : IntIndexInputIndex
- {
- private long _fp;
- private int _upto;
-
- public override void Read(DataInput indexIn, bool absolute)
- {
- if (absolute)
- {
- _upto = indexIn.ReadVInt();
- _fp = indexIn.ReadVLong();
- }
- else
- {
- var uptoDelta = indexIn.ReadVInt();
- if ((uptoDelta & 1) == 1)
- {
- // same block
- _upto += (int)((uint)uptoDelta >> 1);
- }
- else
- {
- // new block
- _upto = (int)((uint)uptoDelta >> 1);
- _fp += indexIn.ReadVLong();
- }
- }
- Debug.Assert(_upto < BlockSize);
- }
-
- public override void Seek(IntIndexInputReader other)
- {
- ((Reader) other).Seek(_fp, _upto);
- }
-
- public override void CopyFrom(IntIndexInputIndex other)
- {
- var idx = (Index) other;
- _fp = idx._fp;
- _upto = idx._upto;
- }
-
- public override IntIndexInputIndex Clone()
- {
- return new Index {_fp = _fp, _upto = _upto};
- }
-
- public override String ToString()
- {
- return String.Format("fp={0} upto={1}", _fp, _upto);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/df4afdc3/src/Lucene.Net.Codecs/Intblock/IntBlockIndexInput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/IntBlockIndexInput.cs b/src/Lucene.Net.Codecs/Intblock/IntBlockIndexInput.cs
new file mode 100644
index 0000000..0e3e67f
--- /dev/null
+++ b/src/Lucene.Net.Codecs/Intblock/IntBlockIndexInput.cs
@@ -0,0 +1,84 @@
+/*
+ * 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.Codecs.Intblock
+{
+ using Sep;
+ using Store;
+
+ internal class IntBlockIndexInput : IntIndexInputIndex
+ {
+ private readonly IntIndexInput _outerInstance;
+ private long _fp;
+ private int _upto;
+
+ public IntBlockIndexInput(IntIndexInput outerInstance)
+ {
+ _outerInstance = outerInstance;
+ }
+
+ public override void Read(DataInput indexIn, bool absolute)
+ {
+ if (absolute)
+ {
+ _upto = indexIn.ReadVInt();
+ _fp = indexIn.ReadVLong();
+ }
+ else
+ {
+ int uptoDelta = indexIn.ReadVInt();
+ if ((uptoDelta & 1) == 1)
+ {
+ // same block
+ _upto += (int) ((uint) uptoDelta >> 1);
+ }
+ else
+ {
+ // new block
+ _upto = (int) ((uint) uptoDelta >> 1);
+ _fp += indexIn.ReadVLong();
+ }
+ }
+ // TODO: we can't do this assert because non-causal
+ // int encoders can have upto over the buffer size
+ //assert upto < maxBlockSize: "upto=" + upto + " max=" + maxBlockSize;
+ }
+
+ public override string ToString()
+ {
+ return "VarIntBlock.Index fp=" + _fp + " upto=" + _upto;
+ }
+
+ public override void Seek(IntIndexInputReader other)
+ {
+ ((IntBlockIndexReader)other).Seek(_fp, _upto);
+ }
+
+ public override void CopyFrom(IntIndexInputIndex other)
+ {
+ var idx = (IntBlockIndexInput)other;
+ _fp = idx._fp;
+ _upto = idx._upto;
+ }
+
+ public override IntIndexInputIndex Clone()
+ {
+ var other = new IntBlockIndexInput(_outerInstance) {_fp = _fp, _upto = _upto};
+ return other;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/df4afdc3/src/Lucene.Net.Codecs/Intblock/IntBlockIndexOutput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/IntBlockIndexOutput.cs b/src/Lucene.Net.Codecs/Intblock/IntBlockIndexOutput.cs
new file mode 100644
index 0000000..b5cec95
--- /dev/null
+++ b/src/Lucene.Net.Codecs/Intblock/IntBlockIndexOutput.cs
@@ -0,0 +1,85 @@
+/*
+ * 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.Codecs.Intblock
+{
+ using Sep;
+ using Store;
+ using System.Diagnostics;
+
+ internal class IntBlockIndexOuput : IntIndexOutputIndex
+ {
+ private readonly IntIndexOutput _outerInstance;
+ private long _fp;
+ private int _upto;
+ private long _lastFp;
+ private int _lastUpto;
+
+ public IntBlockIndexOuput(IntIndexOutput outerInstance)
+ {
+ _outerInstance = outerInstance;
+ }
+
+ public override void Mark()
+ {
+ _fp = _outerInstance.OUTPUT.FilePointer;
+ _upto = _outerInstance._upto;
+ }
+
+ public override void CopyFrom(IntIndexOutputIndex other, bool copyLast)
+ {
+ var idx = (IntBlockIndexOuput)other;
+ _fp = idx._fp;
+ _upto = idx._upto;
+ if (copyLast)
+ {
+ _lastFp = _fp;
+ _lastUpto = _upto;
+ }
+ }
+
+ public override void Write(DataOutput indexOut, bool absolute)
+ {
+ Debug.Assert(_upto >= 0);
+ if (absolute)
+ {
+ indexOut.WriteVInt(_upto);
+ indexOut.WriteVLong(_fp);
+ }
+ else if (_fp == _lastFp)
+ {
+ // same block
+ Debug.Assert(_upto >= _lastUpto);
+ var uptoDelta = _upto - _lastUpto;
+ indexOut.WriteVInt(uptoDelta << 1 | 1);
+ }
+ else
+ {
+ // new block
+ indexOut.WriteVInt(_upto << 1);
+ indexOut.WriteVLong(_fp - _lastFp);
+ }
+ _lastUpto = _upto;
+ _lastFp = _fp;
+ }
+
+ public override string ToString()
+ {
+ return "fp=" + _fp + " upto=" + _upto;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/df4afdc3/src/Lucene.Net.Codecs/Intblock/IntBlockIndexReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/IntBlockIndexReader.cs b/src/Lucene.Net.Codecs/Intblock/IntBlockIndexReader.cs
new file mode 100644
index 0000000..22a4aa7
--- /dev/null
+++ b/src/Lucene.Net.Codecs/Intblock/IntBlockIndexReader.cs
@@ -0,0 +1,100 @@
+/*
+ * 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.Codecs.Intblock
+{
+ using Sep;
+ using Store;
+ using System.Diagnostics;
+
+ internal class IntBlockIndexReader : IntIndexInputReader
+ {
+ private readonly IndexInput _input;
+
+ public readonly int[] PENDING;
+ private int _upto;
+
+ private bool _seekPending;
+ private long _pendingFp;
+ private int _pendingUpto;
+ private long _lastBlockFp;
+ private int _blockSize;
+ private readonly IBlockReader _blockReader;
+
+ public IntBlockIndexReader(IndexInput input, int[] pending, IBlockReader blockReader)
+ {
+ _input = input;
+ PENDING = pending;
+ _blockReader = blockReader;
+ _blockSize = pending.Length;
+ _upto = _blockSize;
+ }
+
+ internal virtual void Seek(long fp, int upto)
+ {
+ // TODO: should we do this in real-time, not lazy?
+ _pendingFp = fp;
+ _pendingUpto = upto;
+ Debug.Assert(_pendingUpto >= 0, "pendingUpto=" + _pendingUpto);
+ _seekPending = true;
+ }
+
+ internal void MaybeSeek()
+ {
+ if (!_seekPending) return;
+
+ if (_pendingFp != _lastBlockFp)
+ {
+ // need new block
+ _input.Seek(_pendingFp);
+ _lastBlockFp = _pendingFp;
+ _blockReader.Seek(_pendingFp);
+ _blockSize = _blockReader.ReadBlock();
+ }
+ _upto = _pendingUpto;
+
+ // TODO: if we were more clever when writing the
+ // index, such that a seek point wouldn't be written
+ // until the int encoder "committed", we could avoid
+ // this (likely minor) inefficiency:
+
+ // This is necessary for int encoders that are
+ // non-causal, ie must see future int values to
+ // encode the current ones.
+ while (_upto >= _blockSize)
+ {
+ _upto -= _blockSize;
+ _lastBlockFp = _input.FilePointer;
+ _blockSize = _blockReader.ReadBlock();
+ }
+ _seekPending = false;
+ }
+
+ public override int Next()
+ {
+ MaybeSeek();
+ if (_upto == _blockSize)
+ {
+ _lastBlockFp = _input.FilePointer;
+ _blockSize = _blockReader.ReadBlock();
+ _upto = 0;
+ }
+
+ return PENDING[_upto++];
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/df4afdc3/src/Lucene.Net.Codecs/Intblock/Reader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/Reader.cs b/src/Lucene.Net.Codecs/Intblock/Reader.cs
deleted file mode 100644
index 4966c14..0000000
--- a/src/Lucene.Net.Codecs/Intblock/Reader.cs
+++ /dev/null
@@ -1,81 +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.Diagnostics;
-using Lucene.Net.Codecs.Sep;
-using Lucene.Net.Store;
-
-namespace Lucene.Net.Codecs.Intblock
-{
- internal class Reader : IntIndexInputReader
- {
-
- private readonly IndexInput _input;
- private readonly VariableIntBlockIndexInput.BlockReader _blockReader;
- private readonly int _blockSize;
- private readonly int[] _pending;
-
- private int _upto;
- private bool _seekPending;
- private long _pendingFp;
- private long _lastBlockFp = -1;
-
- public Reader(IndexInput input, int[] pending, VariableIntBlockIndexInput.BlockReader blockReader)
- {
- _input = input;
- _pending = pending;
- _blockSize = pending.Length;
- _blockReader = blockReader;
- _upto = _blockSize;
- }
-
- private void Seek(long fp, int upto)
- {
- Debug.Assert(upto < _blockSize);
-
- if (_seekPending || fp != _lastBlockFp)
- {
- _pendingFp = fp;
- _seekPending = true;
- }
-
- _upto = upto;
- }
-
- public override int Next()
- {
- if (_seekPending)
- {
- // Seek & load new block
- _input.Seek(_pendingFp);
- _lastBlockFp = _pendingFp;
- _blockReader.readBlock();
- _seekPending = false;
- }
- else if (_upto == _blockSize)
- {
- // Load new block
- _lastBlockFp = _input.FilePointer;
- _blockReader.readBlock();
- _upto = 0;
- }
-
- return _pending[_upto++];
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/df4afdc3/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexInput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexInput.cs b/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexInput.cs
index cc0b6f1..2ed4c47 100644
--- a/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexInput.cs
+++ b/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexInput.cs
@@ -1,4 +1,4 @@
-/*
+/*
* 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.
@@ -15,180 +15,60 @@
* limitations under the License.
*/
-/** Naive int block API that writes vInts. This is
- * expected to give poor performance; it's really only for
- * testing the pluggability. One should typically use pfor instead. */
-
-// TODO: much of this can be shared code w/ the fixed case
-
-/** Abstract base class that reads variable-size blocks of ints
- * from an IndexInput. While this is a simple approach, a
- * more performant approach would directly create an impl
- * of IntIndexInput inside Directory. Wrapping a generic
- * IndexInput will likely cost performance.
- *
- * @lucene.experimental
- */
-
-using Lucene.Net.Codecs.Sep;
-using Lucene.Net.Store;
-
-public abstract class VariableIntBlockIndexInput : IntIndexInput {
-
- protected final IndexInput in;
- protected final int maxBlockSize;
-
- protected VariableIntBlockIndexInput(final IndexInput in) {
- this.in = in;
- maxBlockSize = in.readInt();
- }
-
- @Override
- public IntIndexInput.Reader reader() {
- final int[] buffer = new int[maxBlockSize];
- final IndexInput clone = in.clone();
- // TODO: can this be simplified?
- return new Reader(clone, buffer, this.getBlockReader(clone, buffer));
- }
-
- @Override
- public void close() {
- in.close();
- }
-
- @Override
- public IntIndexInput.Index index() {
- return new Index();
- }
-
- protected abstract BlockReader getBlockReader(IndexInput in, int[] buffer) ;
-
- /**
- * Interface for variable-size block decoders.
- * <p>
- * Implementations should decode into the buffer in {@link #readBlock}.
- */
- public interface BlockReader {
- public int readBlock() ;
- public void seek(long pos) ;
- }
-
- private static class Reader : IntIndexInputReader {
- private final IndexInput in;
-
- public final int[] pending;
- int upto;
-
- private bool seekPending;
- private long pendingFP;
- private int pendingUpto;
- private long lastBlockFP;
- private int blockSize;
- private final BlockReader blockReader;
-
- public Reader(final IndexInput in, final int[] pending, final BlockReader blockReader) {
- this.in = in;
- this.pending = pending;
- this.blockReader = blockReader;
- }
-
- void seek(final long fp, final int upto) {
- // TODO: should we do this in real-time, not lazy?
- pendingFP = fp;
- pendingUpto = upto;
- Debug.Assert( pendingUpto >= 0: "pendingUpto=" + pendingUpto;
- seekPending = true;
- }
-
- private final void maybeSeek() {
- if (seekPending) {
- if (pendingFP != lastBlockFP) {
- // need new block
- in.seek(pendingFP);
- blockReader.seek(pendingFP);
- lastBlockFP = pendingFP;
- blockSize = blockReader.readBlock();
+namespace Lucene.Net.Codecs.Intblock
+{
+ using Sep;
+ using IntIndexInput = Sep.IntIndexInput;
+ using IndexInput = Store.IndexInput;
+
+ /// <summary>
+ /// Naive int block API that writes vInts. This is
+ /// expected to give poor performance; it's really only for
+ /// testing the pluggability. One should typically use pfor instead.
+ /// </summary>
+
+ // TODO: much of this can be shared code w/ the fixed case
+
+ /// <summary>
+ /// Abstract base class that reads variable-size blocks of ints
+ /// from an IndexInput. While this is a simple approach, a
+ /// more performant approach would directly create an impl
+ /// of IntIndexInput inside Directory. Wrapping a generic
+ /// IndexInput will likely cost performance.
+ ///
+ /// @lucene.experimental
+ /// </summary>
+ public abstract class VariableIntBlockIndexInput : IntIndexInput
+ {
+ private readonly IndexInput _input;
+ protected internal readonly int MAX_BLOCK_SIZE;
+
+ protected internal VariableIntBlockIndexInput(IndexInput input)
+ {
+ _input = input;
+ MAX_BLOCK_SIZE = input.ReadInt();
}
- upto = pendingUpto;
-
- // TODO: if we were more clever when writing the
- // index, such that a seek point wouldn't be written
- // until the int encoder "committed", we could avoid
- // this (likely minor) inefficiency:
- // This is necessary for int encoders that are
- // non-causal, ie must see future int values to
- // encode the current ones.
- while(upto >= blockSize) {
- upto -= blockSize;
- lastBlockFP = in.getFilePointer();
- blockSize = blockReader.readBlock();
+ public override IntIndexInputReader Reader()
+ {
+ var buffer = new int[MAX_BLOCK_SIZE];
+ var clone = (IndexInput)_input.Clone();
+ // TODO: can this be simplified?
+ return new IntBlockIndexReader(clone, buffer, GetBlockReader(clone, buffer));
}
- seekPending = false;
- }
- }
-
- @Override
- public int next() {
- this.maybeSeek();
- if (upto == blockSize) {
- lastBlockFP = in.getFilePointer();
- blockSize = blockReader.readBlock();
- upto = 0;
- }
- return pending[upto++];
- }
- }
-
- private class Index : IntIndexInputIndex {
- private long fp;
- private int upto;
-
- @Override
- public void read(final DataInput indexIn, final bool absolute) {
- if (absolute) {
- upto = indexIn.readVInt();
- fp = indexIn.readVLong();
- } else {
- final int uptoDelta = indexIn.readVInt();
- if ((uptoDelta & 1) == 1) {
- // same block
- upto += uptoDelta >>> 1;
- } else {
- // new block
- upto = uptoDelta >>> 1;
- fp += indexIn.readVLong();
+ public override void Dispose()
+ {
+ _input.Dispose();
}
- }
- // TODO: we can't do this Debug.Assert( because non-causal
- // int encoders can have upto over the buffer size
- //Debug.Assert( upto < maxBlockSize: "upto=" + upto + " max=" + maxBlockSize;
- }
- @Override
- public String toString() {
- return "VarIntBlock.Index fp=" + fp + " upto=" + upto + " maxBlock=" + maxBlockSize;
- }
+ public override IntIndexInputIndex Index()
+ {
+ return new IntBlockIndexInput(this);
+ }
- @Override
- public void seek(final IntIndexInput.Reader other) {
- ((Reader) other).seek(fp, upto);
- }
+ protected internal abstract IBlockReader GetBlockReader(IndexInput @in, int[] buffer);
- @Override
- public void copyFrom(final IntIndexInput.Index other) {
- final Index idx = (Index) other;
- fp = idx.fp;
- upto = idx.upto;
}
- @Override
- public Index clone() {
- Index other = new Index();
- other.fp = fp;
- other.upto = upto;
- return other;
- }
- }
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/df4afdc3/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexOutput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexOutput.cs b/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexOutput.cs
index a5de4ca..dd30ba7 100644
--- a/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexOutput.cs
+++ b/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexOutput.cs
@@ -1,4 +1,4 @@
-/*
+/*
* 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.
@@ -19,53 +19,56 @@ namespace Lucene.Net.Codecs.Intblock
{
using System.Diagnostics;
- using Store;
using Sep;
+ using IntIndexOutput = Sep.IntIndexOutput;
+ using IndexOutput = Store.IndexOutput;
+
+ /// <summary>
+ /// Naive int block API that writes vInts. This is
+ /// expected to give poor performance; it's really only for
+ /// testing the pluggability. One should typically use pfor instead.
+ /// </summary>
+
+
+ // TODO: much of this can be shared code w/ the fixed case
/// <summary>
- /// Naive int block API that writes vInts. This is expected to give poor
- /// performance; it's really only for testing the pluggability. One
- /// should typically use pfor instead.
- ///
- /// TODO: much of this can be shared code w/ the fixed case
- ///
/// Abstract base class that writes variable-size blocks of ints
- /// to an IndexOutput. While this is a simple approach, a
- /// more performant approach would directly create an impl
- /// of IntIndexOutput inside Directory. Wrapping a generic
- /// IndexInput will likely cost performance.
+ /// to an IndexOutput. While this is a simple approach, a
+ /// more performant approach would directly create an impl
+ /// of IntIndexOutput inside Directory. Wrapping a generic
+ /// IndexInput will likely cost performance.
///
/// @lucene.experimental
/// </summary>
public abstract class VariableIntBlockIndexOutput : IntIndexOutput
{
- private readonly IndexOutput _output;
- private int _upto;
private bool _hitExcDuringWrite;
- /// <Remarks>
- /// TODO what Var-Var codecs exist in practice, and what are their blocksizes like?
- /// If it's less than 128 should we set that as max and use byte?
- ///
- /// NOTE: maxblockSize must be the maxium block size plus the max non-causal lookahed
- /// of your codec. EG Simple9 requires lookahead=1 becuase on seeing the Nth value it
- /// knows it must now encode the N-1 values before it
- /// </Remarks>
- protected VariableIntBlockIndexOutput(IndexOutput output, int maxBlockSize)
+ // TODO what Var-Var codecs exist in practice... and what are there blocksizes like?
+ // if its less than 128 we should set that as max and use byte?
+
+ /// <summary>
+ /// NOTE: maxBlockSize must be the maximum block size
+ /// plus the max non-causal lookahead of your codec. EG Simple9
+ /// requires lookahead=1 because on seeing the Nth value
+ /// it knows it must now encode the N-1 values before it.
+ /// </summary>
+ protected internal VariableIntBlockIndexOutput(IndexOutput output, int maxBlockSize)
{
- _output = output;
- _output.WriteInt(maxBlockSize);
+ OUTPUT = output;
+ output.WriteInt(maxBlockSize);
}
/// <summary>
- /// Called one value at a time. Return the number of
- /// buffered input values that have been written out
+ /// Called one value at a time. Return the number of
+ /// buffered input values that have been written to out.
/// </summary>
- protected abstract int Add(int value);
+ protected internal abstract int Add(int value);
public override IntIndexOutputIndex Index()
{
- return new VariableIntBlockIndexOutputIndex();
+ return new IntBlockIndexOuput(this);
}
public override void Write(int v)
@@ -93,59 +96,9 @@ namespace Lucene.Net.Codecs.Intblock
}
finally
{
- _output.Dispose();
+ OUTPUT.Dispose();
}
}
}
- internal class VariableIntBlockIndexOutputIndex : IntIndexOutputIndex
- {
- private long _fp;
- private int _upto;
- private long _lastFp;
- private int _lastUpto;
-
- public override void Mark()
- {
- _fp = output.FilePointer;
- _upto = VariableIntBlockIndexOutput.
- this._upto;
- }
-
- public override void CopyFrom(IntIndexOutputIndex other, bool copyLast)
- {
- var idx = (Index)other;
- _fp = idx.fp;
- _upto = idx.upto;
- if (!copyLast) return;
-
- _lastFp = _fp;
- _lastUpto = _upto;
- }
-
- public override void Write(DataOutput indexOut, bool absolute)
- {
- Debug.Assert(_upto >= 0);
- if (absolute)
- {
- indexOut.WriteVInt(_upto);
- indexOut.WriteVLong(_fp);
- }
- else if (_fp == _lastFp)
- {
- // same block
- Debug.Assert(_upto >= _lastUpto);
- var uptoDelta = _upto - _lastUpto;
- indexOut.WriteVInt(uptoDelta << 1 | 1);
- }
- else
- {
- // new block
- indexOut.WriteVInt(_upto << 1);
- indexOut.WriteVLong(_fp - _lastFp);
- }
- _lastUpto = _upto;
- _lastFp = _fp;
- }
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/df4afdc3/src/Lucene.Net.Codecs/Lucene.Net.Codecs.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Lucene.Net.Codecs.csproj b/src/Lucene.Net.Codecs/Lucene.Net.Codecs.csproj
index f9500ef..ee2ff66 100644
--- a/src/Lucene.Net.Codecs/Lucene.Net.Codecs.csproj
+++ b/src/Lucene.Net.Codecs/Lucene.Net.Codecs.csproj
@@ -65,8 +65,9 @@
<Compile Include="Intblock\FixedIntBlockIndexInput.cs" />
<Compile Include="Intblock\FixedIntBlockIndexOutput.cs" />
<Compile Include="Intblock\IBlockReader.cs" />
- <Compile Include="Intblock\Index.cs" />
- <Compile Include="Intblock\Reader.cs" />
+ <Compile Include="Intblock\IntBlockIndexInput.cs" />
+ <Compile Include="Intblock\IntBlockIndexOutput.cs" />
+ <Compile Include="Intblock\IntBlockIndexReader.cs" />
<Compile Include="Intblock\VariableIntBlockIndexInput.cs" />
<Compile Include="Intblock\VariableIntBlockIndexOutput.cs" />
<Compile Include="Memory\DirectDocValuesConsumer.cs" />
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/df4afdc3/src/Lucene.Net.Codecs/Sep/IntIndexOutput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Sep/IntIndexOutput.cs b/src/Lucene.Net.Codecs/Sep/IntIndexOutput.cs
index 901dbe1..e7c51e9 100644
--- a/src/Lucene.Net.Codecs/Sep/IntIndexOutput.cs
+++ b/src/Lucene.Net.Codecs/Sep/IntIndexOutput.cs
@@ -34,6 +34,8 @@ namespace Lucene.Net.Codecs.Sep
/// </remarks>
public abstract class IntIndexOutput : IDisposable
{
+ protected internal IndexOutput OUTPUT;
+ protected internal int _upto;
/// <summary>
/// Write an int to the primary file. The value must be
[2/4] lucenenet git commit: More updates to IntBlock and SimpleText
codecs
Posted by pn...@apache.org.
More updates to IntBlock and SimpleText codecs
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/a33ca521
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/a33ca521
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/a33ca521
Branch: refs/heads/master
Commit: a33ca521eea62cf14dd50b44cfc7be27afc67a3d
Parents: a7d71c2
Author: Prescott Nasser <pn...@apache.org>
Authored: Sun Nov 23 14:36:47 2014 -0800
Committer: Prescott Nasser <pn...@apache.org>
Committed: Sun Nov 23 14:36:47 2014 -0800
----------------------------------------------------------------------
.../Intblock/FixedIntBlockIndexInput.cs | 43 +-
.../Intblock/FixedIntBlockIndexOutput.cs | 189 +++----
src/Lucene.Net.Codecs/Intblock/Index.cs | 69 ++-
src/Lucene.Net.Codecs/Intblock/Reader.cs | 94 ++--
.../Intblock/VariableIntBlockIndexInput.cs | 18 +-
.../Intblock/VariableIntBlockIndexOutput.cs | 235 +++++----
.../SimpleText/SimpleTextCodec.cs | 106 ++--
.../SimpleText/SimpleTextDocValuesReader.cs | 504 +++++++++----------
.../SimpleText/SimpleTextDocValuesWriter.cs | 39 +-
.../SimpleText/SimpleTextFieldsReader.cs | 15 +-
10 files changed, 668 insertions(+), 644 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a33ca521/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexInput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexInput.cs b/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexInput.cs
index 3594005..dc7b558 100644
--- a/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexInput.cs
+++ b/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexInput.cs
@@ -15,11 +15,12 @@
* limitations under the License.
*/
+using Lucene.Net.Codecs.Sep;
using Lucene.Net.Store;
namespace Lucene.Net.Codecs.Intblock
{
-
+
/// <summary>
/// Naive int block API that writes vInts. This is
/// expected to give poor performance; it's really only for
@@ -33,36 +34,38 @@ namespace Lucene.Net.Codecs.Intblock
///
/// @lucene.experimental
/// </summary>
-public abstract class FixedIntBlockIndexInput : IntIndexInput {
+ public abstract class FixedIntBlockIndexInput : IntIndexInput
+ {
- private readonly IndexInput input;
- protected readonly int BlockSize;
+ private readonly IndexInput _input;
+ private readonly int _blockSize;
protected FixedIntBlockIndexInput(IndexInput input)
{
- this.input = input;
- BlockSize = input.ReadVInt();
+ _input = input;
+ _blockSize = input.ReadVInt();
}
- public override IntIndexInput.Reader reader() {
- final int[] buffer = new int[BlockSize];
- final IndexInput clone = in.clone();
+ public override IntIndexInputReader Reader()
+ {
+ var buffer = new int[_blockSize];
+ var clone = (IndexInput)_input.Clone();
- // TODO: can this be simplified?
- return new Reader(clone, buffer, this.GetBlockReader(clone, buffer));
- }
+ // TODO: can this be simplified?
+ return new Reader(clone, buffer, BlockReader(clone, buffer));
+ }
- public override void Close()
+ public override void Dispose()
{
- input.Close();
+ _input.Dispose();
}
- public override IntIndexInput.Index Index() {
- return new Index();
- }
+ public override IntIndexInputIndex Index()
+ {
+ return new Index();
+ }
- protected abstract BlockReader getBlockReader(IndexInput in, int[] buffer);
+ protected abstract VariableIntBlockIndexInput.BlockReader BlockReader(IndexInput input, int[] buffer);
-
-}
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a33ca521/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexOutput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexOutput.cs b/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexOutput.cs
index db74098..b19a0a3 100644
--- a/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexOutput.cs
+++ b/src/Lucene.Net.Codecs/Intblock/FixedIntBlockIndexOutput.cs
@@ -1,5 +1,3 @@
-package codecs.intblock;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -21,108 +19,123 @@ package codecs.intblock;
* expected to give poor performance; it's really only for
* testing the pluggability. One should typically use pfor instead. */
-import java.io.IOException;
-
-import codecs.sep.IntIndexOutput;
-import store.DataOutput;
-import store.IndexOutput;
-
-/** Abstract base class that writes fixed-size blocks of ints
- * to an IndexOutput. While this is a simple approach, a
- * more performant approach would directly create an impl
- * of IntIndexOutput inside Directory. Wrapping a generic
- * IndexInput will likely cost performance.
- *
- * @lucene.experimental
- */
-public abstract class FixedIntBlockIndexOutput extends IntIndexOutput {
-
- protected final IndexOutput out;
- private final int blockSize;
- protected final int[] buffer;
+using System;
+using System.Diagnostics;
+using Lucene.Net.Codecs.Sep;
+using Lucene.Net.Store;
+
+
+/// <summary>
+/// Abstract base class that writes fixed-size blocks of ints to an
+/// IndexOutput. While this is a simple approach, a more
+/// performant approach would directly create an impl of
+/// IntIndexOutput inside Directory. Wrapping a generic IndexInput
+/// will likely cost performance.
+///
+/// * @lucene.experimental
+/// </summary>
+public abstract class FixedIntBlockIndexOutput : IntIndexOutput {
+
+ protected IndexOutput out;
+ private int blockSize;
+ protected int int[] buffer;
private int upto;
protected FixedIntBlockIndexOutput(IndexOutput out, int fixedBlockSize) {
blockSize = fixedBlockSize;
this.out = out;
- out.writeVInt(blockSize);
+ out.WriteVInt(blockSize);
buffer = new int[blockSize];
}
protected abstract void flushBlock() ;
- @Override
- public IntIndexOutput.Index index() {
+ public override IntIndexOutputIndex index() {
return new Index();
}
- private class Index extends IntIndexOutput.Index {
- long fp;
- int upto;
- long lastFP;
- int lastUpto;
-
- @Override
- public void mark() {
- fp = out.getFilePointer();
- upto = FixedIntBlockIndexOutput.this.upto;
- }
-
- @Override
- public void copyFrom(IntIndexOutput.Index other, bool copyLast) {
- Index idx = (Index) other;
- fp = idx.fp;
- upto = idx.upto;
- if (copyLast) {
- lastFP = fp;
- lastUpto = upto;
- }
- }
-
- @Override
- public void write(DataOutput indexOut, bool absolute) {
- if (absolute) {
- indexOut.writeVInt(upto);
- indexOut.writeVLong(fp);
- } else if (fp == lastFP) {
- // same block
- Debug.Assert( upto >= lastUpto;
- int uptoDelta = upto - lastUpto;
- indexOut.writeVInt(uptoDelta << 1 | 1);
- } else {
- // new block
- indexOut.writeVInt(upto << 1);
- indexOut.writeVLong(fp - lastFP);
- }
- lastUpto = upto;
- lastFP = fp;
- }
-
- @Override
- public String toString() {
- return "fp=" + fp + " upto=" + upto;
+ private class Index : IntIndexOutputIndex
+ {
+ private long fp;
+ private int upto;
+ private long lastFP;
+ private int lastUpto;
+
+ public override void Mark()
+ {
+ fp =out.
+ FilePointer;
+ upto = FixedIntBlockIndexOutput.
+ this.upto;
+ }
+
+ public override void CopyFrom(IntIndexOutputIndex other, bool copyLast)
+ {
+ Index idx = (Index) other;
+ fp = idx.fp;
+ upto = idx.upto;
+ if (copyLast)
+ {
+ lastFP = fp;
+ lastUpto = upto;
+ }
+ }
+
+ public override void Write(DataOutput indexOut, bool absolute)
+ {
+ if (absolute)
+ {
+ indexOut.WriteVInt(upto);
+ indexOut.WriteVLong(fp);
+ }
+ else if (fp == lastFP)
+ {
+ // same block
+ Debug.Assert(upto >= lastUpto);
+ var uptoDelta = upto - lastUpto;
+ indexOut.WriteVInt(uptoDelta << 1 | 1);
+ }
+ else
+ {
+ // new block
+ indexOut.WriteVInt(upto << 1);
+ indexOut.WriteVLong(fp - lastFP);
+ }
+ lastUpto = upto;
+ lastFP = fp;
+ }
+
+ public override String ToString()
+ {
+ return String.Format("fp={0} upto={1}", fp, upto);
+ }
}
- }
- @Override
- public void write(int v) {
- buffer[upto++] = v;
- if (upto == blockSize) {
- flushBlock();
- upto = 0;
+ public override void Write(int v)
+ {
+ buffer[upto++] = v;
+ if (upto == blockSize)
+ {
+ flushBlock();
+ upto = 0;
+ }
}
- }
- @Override
- public void close() {
- try {
- if (upto > 0) {
- // NOTE: entries in the block after current upto are
- // invalid
- flushBlock();
- }
- } finally {
- out.close();
+ public override void Dispose()
+ {
+ try
+ {
+ if (upto > 0)
+ {
+ // NOTE: entries in the block after current upto are
+ // invalid
+ flushBlock();
+ }
+ }
+ finally
+ {
+ out.
+ Dispose();
+ }
}
- }
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a33ca521/src/Lucene.Net.Codecs/Intblock/Index.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/Index.cs b/src/Lucene.Net.Codecs/Intblock/Index.cs
index 67710a6..d2bd9a9 100644
--- a/src/Lucene.Net.Codecs/Intblock/Index.cs
+++ b/src/Lucene.Net.Codecs/Intblock/Index.cs
@@ -17,64 +17,61 @@
namespace Lucene.Net.Codecs.Intblock
{
+ using Sep;
+ using Store;
using System;
- using Lucene.Net.Codecs.Intblock;
-
- internal class Index : IntIndexInput.Index
+ using System.Diagnostics;
+
+ internal class Index : IntIndexInputIndex
{
- private long fp;
- private int upto;
+ private long _fp;
+ private int _upto;
- public override void Read(final DataInput indexIn, final bool absolute)
- {
- if (absolute)
+ public override void Read(DataInput indexIn, bool absolute)
{
- upto = indexIn.readVInt();
- fp = indexIn.readVLong();
- }
- else
- {
- final
- int uptoDelta = indexIn.readVInt();
- if ((uptoDelta & 1) == 1)
+ if (absolute)
{
- // same block
- upto += uptoDelta >> > 1;
+ _upto = indexIn.ReadVInt();
+ _fp = indexIn.ReadVLong();
}
else
{
- // new block
- upto = uptoDelta >> > 1;
- fp += indexIn.readVLong();
+ var uptoDelta = indexIn.ReadVInt();
+ if ((uptoDelta & 1) == 1)
+ {
+ // same block
+ _upto += (int)((uint)uptoDelta >> 1);
+ }
+ else
+ {
+ // new block
+ _upto = (int)((uint)uptoDelta >> 1);
+ _fp += indexIn.ReadVLong();
+ }
}
+ Debug.Assert(_upto < BlockSize);
}
- Debug.Assert(
- upto < blockSize;
- }
- public override void Seek(final IntIndexInput .Reader other)
+ public override void Seek(IntIndexInputReader other)
{
- ((Reader) other).seek(fp, upto);
+ ((Reader) other).Seek(_fp, _upto);
}
- public override void CopyFrom(IntIndexInput.Index other)
+ public override void CopyFrom(IntIndexInputIndex other)
{
- Index idx = (Index) other;
- fp = idx.fp;
- upto = idx.upto;
+ var idx = (Index) other;
+ _fp = idx._fp;
+ _upto = idx._upto;
}
- public override Index Clone()
+ public override IntIndexInputIndex Clone()
{
- Index other = new Index();
- other.fp = fp;
- other.upto = upto;
- return other;
+ return new Index {_fp = _fp, _upto = _upto};
}
public override String ToString()
{
- return "fp=" + fp + " upto=" + upto;
+ return String.Format("fp={0} upto={1}", _fp, _upto);
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a33ca521/src/Lucene.Net.Codecs/Intblock/Reader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/Reader.cs b/src/Lucene.Net.Codecs/Intblock/Reader.cs
index 8e0eb1d..4966c14 100644
--- a/src/Lucene.Net.Codecs/Intblock/Reader.cs
+++ b/src/Lucene.Net.Codecs/Intblock/Reader.cs
@@ -15,53 +15,67 @@
* limitations under the License.
*/
+using System.Diagnostics;
+using Lucene.Net.Codecs.Sep;
+using Lucene.Net.Store;
+
namespace Lucene.Net.Codecs.Intblock
{
- internal static class Reader : IntIndexInput.Reader
+ internal class Reader : IntIndexInputReader
{
- private final IndexInput in;
- private final BlockReader blockReader;
- private final int blockSize;
- private final int[] pending;
+ private readonly IndexInput _input;
+ private readonly VariableIntBlockIndexInput.BlockReader _blockReader;
+ private readonly int _blockSize;
+ private readonly int[] _pending;
- private int upto;
- private bool seekPending;
- private long pendingFP;
- private long lastBlockFP = -1;
+ private int _upto;
+ private bool _seekPending;
+ private long _pendingFp;
+ private long _lastBlockFp = -1;
- public Reader(final IndexInput in, final int[] pending, final BlockReader blockReader) {
- this.in = in;
- this.pending = pending;
- this.blockSize = pending.length;
- this.blockReader = blockReader;
- upto = blockSize;
- }
+ public Reader(IndexInput input, int[] pending, VariableIntBlockIndexInput.BlockReader blockReader)
+ {
+ _input = input;
+ _pending = pending;
+ _blockSize = pending.Length;
+ _blockReader = blockReader;
+ _upto = _blockSize;
+ }
- void Seek(final long fp, final int upto) {
- Debug.Assert( upto < blockSize;
- if (seekPending || fp != lastBlockFP) {
- pendingFP = fp;
- seekPending = true;
- }
- this.upto = upto;
- }
+ private void Seek(long fp, int upto)
+ {
+ Debug.Assert(upto < _blockSize);
+
+ if (_seekPending || fp != _lastBlockFp)
+ {
+ _pendingFp = fp;
+ _seekPending = true;
+ }
+
+ _upto = upto;
+ }
- public override int Next() {
- if (seekPending) {
- // Seek & load new block
- in.seek(pendingFP);
- lastBlockFP = pendingFP;
- blockReader.readBlock();
- seekPending = false;
- } else if (upto == blockSize) {
- // Load new block
- lastBlockFP = in.getFilePointer();
- blockReader.readBlock();
- upto = 0;
- }
- return pending[upto++];
- }
- }
+ public override int Next()
+ {
+ if (_seekPending)
+ {
+ // Seek & load new block
+ _input.Seek(_pendingFp);
+ _lastBlockFp = _pendingFp;
+ _blockReader.readBlock();
+ _seekPending = false;
+ }
+ else if (_upto == _blockSize)
+ {
+ // Load new block
+ _lastBlockFp = _input.FilePointer;
+ _blockReader.readBlock();
+ _upto = 0;
+ }
+
+ return _pending[_upto++];
+ }
}
}
+
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a33ca521/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexInput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexInput.cs b/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexInput.cs
index 1ce9712..cc0b6f1 100644
--- a/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexInput.cs
+++ b/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexInput.cs
@@ -1,5 +1,3 @@
-package codecs.intblock;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -21,12 +19,6 @@ package codecs.intblock;
* expected to give poor performance; it's really only for
* testing the pluggability. One should typically use pfor instead. */
-import java.io.IOException;
-
-import codecs.sep.IntIndexInput;
-import store.DataInput;
-import store.IndexInput;
-
// TODO: much of this can be shared code w/ the fixed case
/** Abstract base class that reads variable-size blocks of ints
@@ -37,7 +29,11 @@ import store.IndexInput;
*
* @lucene.experimental
*/
-public abstract class VariableIntBlockIndexInput extends IntIndexInput {
+
+using Lucene.Net.Codecs.Sep;
+using Lucene.Net.Store;
+
+public abstract class VariableIntBlockIndexInput : IntIndexInput {
protected final IndexInput in;
protected final int maxBlockSize;
@@ -77,7 +73,7 @@ public abstract class VariableIntBlockIndexInput extends IntIndexInput {
public void seek(long pos) ;
}
- private static class Reader extends IntIndexInput.Reader {
+ private static class Reader : IntIndexInputReader {
private final IndexInput in;
public final int[] pending;
@@ -145,7 +141,7 @@ public abstract class VariableIntBlockIndexInput extends IntIndexInput {
}
}
- private class Index extends IntIndexInput.Index {
+ private class Index : IntIndexInputIndex {
private long fp;
private int upto;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a33ca521/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexOutput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexOutput.cs b/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexOutput.cs
index b76f69e..a5de4ca 100644
--- a/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexOutput.cs
+++ b/src/Lucene.Net.Codecs/Intblock/VariableIntBlockIndexOutput.cs
@@ -1,5 +1,3 @@
-package codecs.intblock;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,120 +15,137 @@ package codecs.intblock;
* limitations under the License.
*/
-/** Naive int block API that writes vInts. This is
- * expected to give poor performance; it's really only for
- * testing the pluggability. One should typically use pfor instead. */
-
-import java.io.IOException;
-
-import codecs.sep.IntIndexOutput;
-import store.DataOutput;
-import store.IndexOutput;
-
-// TODO: much of this can be shared code w/ the fixed case
-
-/** Abstract base class that writes variable-size blocks of ints
- * to an IndexOutput. While this is a simple approach, a
- * more performant approach would directly create an impl
- * of IntIndexOutput inside Directory. Wrapping a generic
- * IndexInput will likely cost performance.
- *
- * @lucene.experimental
- */
-public abstract class VariableIntBlockIndexOutput extends IntIndexOutput {
-
- protected final IndexOutput out;
-
- private int upto;
- private bool hitExcDuringWrite;
-
- // TODO what Var-Var codecs exist in practice... and what are there blocksizes like?
- // if its less than 128 we should set that as max and use byte?
-
- /** NOTE: maxBlockSize must be the maximum block size
- * plus the max non-causal lookahead of your codec. EG Simple9
- * requires lookahead=1 because on seeing the Nth value
- * it knows it must now encode the N-1 values before it. */
- protected VariableIntBlockIndexOutput(IndexOutput out, int maxBlockSize) {
- this.out = out;
- out.writeInt(maxBlockSize);
- }
-
- /** Called one value at a time. Return the number of
- * buffered input values that have been written to out. */
- protected abstract int add(int value) ;
-
- @Override
- public IntIndexOutput.Index index() {
- return new Index();
- }
+namespace Lucene.Net.Codecs.Intblock
+{
+
+ using System.Diagnostics;
+ using Store;
+ using Sep;
+
+ /// <summary>
+ /// Naive int block API that writes vInts. This is expected to give poor
+ /// performance; it's really only for testing the pluggability. One
+ /// should typically use pfor instead.
+ ///
+ /// TODO: much of this can be shared code w/ the fixed case
+ ///
+ /// Abstract base class that writes variable-size blocks of ints
+ /// to an IndexOutput. While this is a simple approach, a
+ /// more performant approach would directly create an impl
+ /// of IntIndexOutput inside Directory. Wrapping a generic
+ /// IndexInput will likely cost performance.
+ ///
+ /// @lucene.experimental
+ /// </summary>
+ public abstract class VariableIntBlockIndexOutput : IntIndexOutput
+ {
+ private readonly IndexOutput _output;
+ private int _upto;
+ private bool _hitExcDuringWrite;
+
+ /// <Remarks>
+ /// TODO what Var-Var codecs exist in practice, and what are their blocksizes like?
+ /// If it's less than 128 should we set that as max and use byte?
+ ///
+ /// NOTE: maxblockSize must be the maxium block size plus the max non-causal lookahed
+ /// of your codec. EG Simple9 requires lookahead=1 becuase on seeing the Nth value it
+ /// knows it must now encode the N-1 values before it
+ /// </Remarks>
+ protected VariableIntBlockIndexOutput(IndexOutput output, int maxBlockSize)
+ {
+ _output = output;
+ _output.WriteInt(maxBlockSize);
+ }
- private class Index extends IntIndexOutput.Index {
- long fp;
- int upto;
- long lastFP;
- int lastUpto;
+ /// <summary>
+ /// Called one value at a time. Return the number of
+ /// buffered input values that have been written out
+ /// </summary>
+ protected abstract int Add(int value);
- @Override
- public void mark() {
- fp = out.getFilePointer();
- upto = VariableIntBlockIndexOutput.this.upto;
- }
+ public override IntIndexOutputIndex Index()
+ {
+ return new VariableIntBlockIndexOutputIndex();
+ }
- @Override
- public void copyFrom(IntIndexOutput.Index other, bool copyLast) {
- Index idx = (Index) other;
- fp = idx.fp;
- upto = idx.upto;
- if (copyLast) {
- lastFP = fp;
- lastUpto = upto;
- }
- }
+ public override void Write(int v)
+ {
+ _hitExcDuringWrite = true;
+ _upto -= Add(v) - 1;
+ _hitExcDuringWrite = false;
+ Debug.Assert(_upto >= 0);
+ }
- @Override
- public void write(DataOutput indexOut, bool absolute) {
- Debug.Assert( upto >= 0;
- if (absolute) {
- indexOut.writeVInt(upto);
- indexOut.writeVLong(fp);
- } else if (fp == lastFP) {
- // same block
- Debug.Assert( upto >= lastUpto;
- int uptoDelta = upto - lastUpto;
- indexOut.writeVInt(uptoDelta << 1 | 1);
- } else {
- // new block
- indexOut.writeVInt(upto << 1);
- indexOut.writeVLong(fp - lastFP);
- }
- lastUpto = upto;
- lastFP = fp;
+ public override void Dispose()
+ {
+ try
+ {
+ if (_hitExcDuringWrite) return;
+
+ // stuff 0s in until the "real" data is flushed:
+ var stuffed = 0;
+ while (_upto > stuffed)
+ {
+ _upto -= Add(0) - 1;
+ Debug.Assert(_upto >= 0);
+ stuffed += 1;
+ }
+ }
+ finally
+ {
+ _output.Dispose();
+ }
+ }
}
- }
- @Override
- public void write(int v) {
- hitExcDuringWrite = true;
- upto -= add(v)-1;
- hitExcDuringWrite = false;
- Debug.Assert( upto >= 0;
- }
+ internal class VariableIntBlockIndexOutputIndex : IntIndexOutputIndex
+ {
+ private long _fp;
+ private int _upto;
+ private long _lastFp;
+ private int _lastUpto;
+
+ public override void Mark()
+ {
+ _fp = output.FilePointer;
+ _upto = VariableIntBlockIndexOutput.
+ this._upto;
+ }
+
+ public override void CopyFrom(IntIndexOutputIndex other, bool copyLast)
+ {
+ var idx = (Index)other;
+ _fp = idx.fp;
+ _upto = idx.upto;
+ if (!copyLast) return;
+
+ _lastFp = _fp;
+ _lastUpto = _upto;
+ }
- @Override
- public void close() {
- try {
- if (!hitExcDuringWrite) {
- // stuff 0s in until the "real" data is flushed:
- int stuffed = 0;
- while(upto > stuffed) {
- upto -= add(0)-1;
- Debug.Assert( upto >= 0;
- stuffed += 1;
+ public override void Write(DataOutput indexOut, bool absolute)
+ {
+ Debug.Assert(_upto >= 0);
+ if (absolute)
+ {
+ indexOut.WriteVInt(_upto);
+ indexOut.WriteVLong(_fp);
+ }
+ else if (_fp == _lastFp)
+ {
+ // same block
+ Debug.Assert(_upto >= _lastUpto);
+ var uptoDelta = _upto - _lastUpto;
+ indexOut.WriteVInt(uptoDelta << 1 | 1);
+ }
+ else
+ {
+ // new block
+ indexOut.WriteVInt(_upto << 1);
+ indexOut.WriteVLong(_fp - _lastFp);
+ }
+ _lastUpto = _upto;
+ _lastFp = _fp;
}
- }
- } finally {
- out.close();
}
- }
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a33ca521/src/Lucene.Net.Codecs/SimpleText/SimpleTextCodec.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextCodec.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextCodec.cs
index d173137..1141939 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextCodec.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextCodec.cs
@@ -18,67 +18,67 @@
namespace Lucene.Net.Codecs.SimpleText
{
- /// <summary>
- /// plain text index format.
- /// <para>
- /// <b><font color="red">FOR RECREATIONAL USE ONLY</font></B>
- /// @lucene.experimental
- /// </para>
- /// </summary>
- public sealed class SimpleTextCodec : Codec
- {
- private readonly PostingsFormat _postings = new SimpleTextPostingsFormat();
- private readonly StoredFieldsFormat _storedFields = new SimpleTextStoredFieldsFormat();
- private readonly SegmentInfoFormat _segmentInfos = new SimpleTextSegmentInfoFormat();
- private readonly FieldInfosFormat _fieldInfosFormatRenamed = new SimpleTextFieldInfosFormat();
- private readonly TermVectorsFormat _vectorsFormat = new SimpleTextTermVectorsFormat();
- private readonly NormsFormat _normsFormatRenamed = new SimpleTextNormsFormat();
- private readonly LiveDocsFormat _liveDocs = new SimpleTextLiveDocsFormat();
- private readonly DocValuesFormat _dvFormat = new SimpleTextDocValuesFormat();
+ /// <summary>
+ /// plain text index format.
+ /// <para>
+ /// <b><font color="red">FOR RECREATIONAL USE ONLY</font></B>
+ /// @lucene.experimental
+ /// </para>
+ /// </summary>
+ public sealed class SimpleTextCodec : Codec
+ {
+ private readonly PostingsFormat _postings = new SimpleTextPostingsFormat();
+ private readonly StoredFieldsFormat _storedFields = new SimpleTextStoredFieldsFormat();
+ private readonly SegmentInfoFormat _segmentInfos = new SimpleTextSegmentInfoFormat();
+ private readonly FieldInfosFormat _fieldInfosFormatRenamed = new SimpleTextFieldInfosFormat();
+ private readonly TermVectorsFormat _vectorsFormat = new SimpleTextTermVectorsFormat();
+ private readonly NormsFormat _normsFormatRenamed = new SimpleTextNormsFormat();
+ private readonly LiveDocsFormat _liveDocs = new SimpleTextLiveDocsFormat();
+ private readonly DocValuesFormat _dvFormat = new SimpleTextDocValuesFormat();
- public SimpleTextCodec() : base("SimpleText")
- {
- }
+ public SimpleTextCodec() : base("SimpleText")
+ {
+ }
- public override PostingsFormat PostingsFormat()
- {
- return _postings;
- }
+ public override PostingsFormat PostingsFormat()
+ {
+ return _postings;
+ }
- public override StoredFieldsFormat StoredFieldsFormat()
- {
- return _storedFields;
- }
+ public override StoredFieldsFormat StoredFieldsFormat()
+ {
+ return _storedFields;
+ }
- public override TermVectorsFormat TermVectorsFormat()
- {
- return _vectorsFormat;
- }
+ public override TermVectorsFormat TermVectorsFormat()
+ {
+ return _vectorsFormat;
+ }
- public override FieldInfosFormat FieldInfosFormat()
- {
- return _fieldInfosFormatRenamed;
- }
+ public override FieldInfosFormat FieldInfosFormat()
+ {
+ return _fieldInfosFormatRenamed;
+ }
- public override SegmentInfoFormat SegmentInfoFormat()
- {
- return _segmentInfos;
- }
+ public override SegmentInfoFormat SegmentInfoFormat()
+ {
+ return _segmentInfos;
+ }
- public override NormsFormat NormsFormat()
- {
- return _normsFormatRenamed;
- }
+ public override NormsFormat NormsFormat()
+ {
+ return _normsFormatRenamed;
+ }
- public override LiveDocsFormat LiveDocsFormat()
- {
- return _liveDocs;
- }
+ public override LiveDocsFormat LiveDocsFormat()
+ {
+ return _liveDocs;
+ }
- public override DocValuesFormat DocValuesFormat()
- {
- return _dvFormat;
- }
- }
+ public override DocValuesFormat DocValuesFormat()
+ {
+ return _dvFormat;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a33ca521/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
index 4ac5623..478f69b 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
@@ -42,7 +42,6 @@ namespace Lucene.Net.Codecs.SimpleText
public class SimpleTextDocValuesReader : DocValuesProducer
{
-
internal class OneField
{
public long DataStartFilePointer { get; set; }
@@ -151,47 +150,66 @@ namespace Lucene.Net.Codecs.SimpleText
return new NumericDocValuesAnonymousInnerClassHelper(this, field, @in, scratch);
}
- private class NumericDocValuesAnonymousInnerClassHelper : NumericDocValues
+ public override BinaryDocValues GetBinary(FieldInfo fieldInfo)
{
- private readonly SimpleTextDocValuesReader _outerInstance;
+ var field = FIELDS[fieldInfo.Name];
+ Debug.Assert(field != null);
+ var input = (IndexInput)DATA.Clone();
+ var scratch = new BytesRef();
- private readonly OneField _field;
- private readonly IndexInput _input;
- private readonly BytesRef _scratch;
+ return new BinaryDocValuesAnonymousInnerClassHelper(this, field, input, scratch);
+ }
- public NumericDocValuesAnonymousInnerClassHelper(SimpleTextDocValuesReader outerInstance,
- OneField field, IndexInput @in, BytesRef scratch)
- {
- _outerInstance = outerInstance;
- _field = field;
- _input = @in;
- _scratch = scratch;
- }
+ public override SortedDocValues GetSorted(FieldInfo fieldInfo)
+ {
+ var field = FIELDS[fieldInfo.Name];
- public override long Get(int docId)
- {
- if (docId < 0 || docId >= _outerInstance.MAX_DOC)
- throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) +
- "; got " + docId);
+ // SegmentCoreReaders already verifies this field is valid:
+ Debug.Assert(field != null);
+ var input = (IndexInput)DATA.Clone();
+ var scratch = new BytesRef();
- _input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2)*docId);
- SimpleTextUtil.ReadLine(_input, _scratch);
+ return new SortedDocValuesAnonymousInnerClassHelper(this, field, input, scratch);
+ }
- long bd;
- try
- {
- bd = long.Parse(_scratch.Utf8ToString());
- }
- catch (FormatException ex)
- {
- throw new CorruptIndexException("failed to parse long value (resource=" + _input + ")", ex);
- }
+ public override SortedSetDocValues GetSortedSet(FieldInfo fieldInfo)
+ {
+ var field = FIELDS[fieldInfo.Name];
- SimpleTextUtil.ReadLine(_input, _scratch); // read the line telling us if its real or not
- return _field.MinValue + bd;
+ // SegmentCoreReaders already verifies this field is
+ // valid:
+ Debug.Assert(field != null);
+
+ var input = (IndexInput) DATA.Clone();
+ var scratch = new BytesRef();
+
+ return new SortedSetDocValuesAnonymousInnerClassHelper(this, field, input, scratch);
+ }
+
+ public override Bits GetDocsWithField(FieldInfo field)
+ {
+ switch (field.DocValuesType)
+ {
+ case FieldInfo.DocValuesType_e.SORTED_SET:
+ return DocValues.DocsWithValue(GetSortedSet(field), MAX_DOC);
+ case FieldInfo.DocValuesType_e.SORTED:
+ return DocValues.DocsWithValue(GetSorted(field), MAX_DOC);
+ case FieldInfo.DocValuesType_e.BINARY:
+ return GetBinaryDocsWithField(field);
+ case FieldInfo.DocValuesType_e.NUMERIC:
+ return GetNumericDocsWithField(field);
+ default:
+ throw new InvalidEnumArgumentException();
}
}
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing) return;
+
+ DATA.Dispose();
+ }
+
private Bits GetNumericDocsWithField(FieldInfo fieldInfo)
{
var field = FIELDS[fieldInfo.Name];
@@ -200,17 +218,57 @@ namespace Lucene.Net.Codecs.SimpleText
return new BitsAnonymousInnerClassHelper(this, field, input, scratch);
}
- public override BinaryDocValues GetBinary(FieldInfo fieldInfo)
+ private Bits GetBinaryDocsWithField(FieldInfo fieldInfo)
{
var field = FIELDS[fieldInfo.Name];
- Debug.Assert(field != null);
var input = (IndexInput)DATA.Clone();
var scratch = new BytesRef();
-
- return new BinaryDocValuesAnonymousInnerClassHelper(this, field, input, scratch);
+
+ return new BitsAnonymousInnerClassHelper2(this, field, input, scratch);
}
- private class BinaryDocValuesAnonymousInnerClassHelper : BinaryDocValues
+ /// <summary> Used only in ctor: </summary>
+ private void ReadLine()
+ {
+ SimpleTextUtil.ReadLine(DATA, SCRATCH);
+ }
+
+ /// <summary> Used only in ctor: </summary>
+ private bool StartsWith(BytesRef prefix)
+ {
+ return StringHelper.StartsWith(SCRATCH, prefix);
+ }
+
+ /// <summary> Used only in ctor: </summary>
+ private string StripPrefix(BytesRef prefix)
+ {
+ return SCRATCH.Bytes.SubList(SCRATCH.Offset + prefix.Length, SCRATCH.Length - prefix.Length).ToString();
+ }
+
+ public override long RamBytesUsed()
+ {
+ return 0;
+ }
+
+ public override void CheckIntegrity()
+ {
+ var iScratch = new BytesRef();
+ var clone = (IndexInput) DATA.Clone();
+ clone.Seek(0);
+ ChecksumIndexInput input = new BufferedChecksumIndexInput(clone);
+ while (true)
+ {
+ SimpleTextUtil.ReadLine(input, iScratch);
+ if (!iScratch.Equals(SimpleTextDocValuesWriter.END)) continue;
+
+ SimpleTextUtil.CheckFooter(input);
+ break;
+ }
+ }
+
+
+
+ private class BitsAnonymousInnerClassHelper : Bits
{
private readonly SimpleTextDocValuesReader _outerInstance;
@@ -218,50 +276,27 @@ namespace Lucene.Net.Codecs.SimpleText
private readonly IndexInput _input;
private readonly BytesRef _scratch;
- public BinaryDocValuesAnonymousInnerClassHelper(SimpleTextDocValuesReader outerInstance, OneField field,
- IndexInput input, BytesRef scratch)
+ public BitsAnonymousInnerClassHelper(SimpleTextDocValuesReader outerInstance,
+ OneField field, IndexInput @in, BytesRef scratch)
{
_outerInstance = outerInstance;
_field = field;
- _input = input;
+ _input = @in;
_scratch = scratch;
}
- public override void Get(int docId, BytesRef result)
+ public bool Get(int index)
{
- if (docId < 0 || docId >= _outerInstance.MAX_DOC)
- throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) +
- "; got " + docId);
-
- _input.Seek(_field.DataStartFilePointer + (9 + _field.Pattern.Length + _field.MaxLength + 2)*docId);
- SimpleTextUtil.ReadLine(_input, _scratch);
- Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH));
- int len;
- try
- {
- len = int.Parse(_scratch.Bytes.SubList(
- _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
- _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString());
- }
- catch (FormatException ex)
- {
- throw new CorruptIndexException("failed to parse int value (resource=" + _input + ")", ex);
- }
-
- result.Bytes = new sbyte[len];
- result.Offset = 0;
- result.Length = len;
- _input.ReadBytes(result.Bytes, 0, len);
+ _input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2) * index);
+ SimpleTextUtil.ReadLine(_input, _scratch); // data
+ SimpleTextUtil.ReadLine(_input, _scratch); // 'T' or 'F'
+ return _scratch.Bytes[_scratch.Offset] == (sbyte)'T';
}
- }
- private Bits GetBinaryDocsWithField(FieldInfo fieldInfo)
- {
- var field = FIELDS[fieldInfo.Name];
- var input = (IndexInput)DATA.Clone();
- var scratch = new BytesRef();
-
- return new BitsAnonymousInnerClassHelper2(this, field, input, scratch);
+ public int Length()
+ {
+ return _outerInstance.MAX_DOC;
+ }
}
private class BitsAnonymousInnerClassHelper2 : Bits
@@ -272,7 +307,7 @@ namespace Lucene.Net.Codecs.SimpleText
private readonly IndexInput _input;
private readonly BytesRef _scratch;
- public BitsAnonymousInnerClassHelper2(SimpleTextDocValuesReader outerInstance, OneField field,
+ public BitsAnonymousInnerClassHelper2(SimpleTextDocValuesReader outerInstance, OneField field,
IndexInput input, BytesRef scratch)
{
_outerInstance = outerInstance;
@@ -283,13 +318,13 @@ namespace Lucene.Net.Codecs.SimpleText
public bool Get(int index)
{
- _input.Seek(_field.DataStartFilePointer + (9 + _field.Pattern.Length + _field.MaxLength + 2)*index);
+ _input.Seek(_field.DataStartFilePointer + (9 + _field.Pattern.Length + _field.MaxLength + 2) * index);
SimpleTextUtil.ReadLine(_input, _scratch);
Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH));
int len;
try
{
- len = int.Parse(_scratch.Bytes.SubList( _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
+ len = int.Parse(_scratch.Bytes.SubList(_scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
_scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString());
}
catch (FormatException ex)
@@ -302,7 +337,7 @@ namespace Lucene.Net.Codecs.SimpleText
_input.ReadBytes(bytes, 0, len);
SimpleTextUtil.ReadLine(_input, _scratch); // newline
SimpleTextUtil.ReadLine(_input, _scratch); // 'T' or 'F'
- return _scratch.Bytes[_scratch.Offset] == (sbyte) 'T';
+ return _scratch.Bytes[_scratch.Offset] == (sbyte)'T';
}
public int Length()
@@ -311,279 +346,214 @@ namespace Lucene.Net.Codecs.SimpleText
}
}
- public override SortedDocValues GetSorted(FieldInfo fieldInfo)
- {
- var field = FIELDS[fieldInfo.Name];
-
- // SegmentCoreReaders already verifies this field is valid:
- Debug.Assert(field != null);
- IndexInput @in = (IndexInput)DATA.Clone();
- BytesRef scratch = new BytesRef();
-
- DecimalFormat decoder = new DecimalFormat(field.Pattern, new DecimalFormatSymbols(Locale.ROOT));
- DecimalFormat ordDecoder = new DecimalFormat(field.OrdPattern, new DecimalFormatSymbols(Locale.ROOT));
-
- return new SortedDocValuesAnonymousInnerClassHelper(this, field, @in, scratch, decoder, ordDecoder);
- }
-
private class SortedDocValuesAnonymousInnerClassHelper : SortedDocValues
{
- private readonly SimpleTextDocValuesReader outerInstance;
+ private readonly SimpleTextDocValuesReader _outerInstance;
- private Lucene.Net.Codecs.SimpleText.SimpleTextDocValuesReader.OneField field;
- private IndexInput @in;
- private BytesRef scratch;
- private DecimalFormat decoder;
- private DecimalFormat ordDecoder;
+ private readonly OneField _field;
+ private readonly IndexInput _input;
+ private readonly BytesRef _scratch;
+ private readonly string _decoderFormat;
+ private readonly string _ordDecoderFormat;
public SortedDocValuesAnonymousInnerClassHelper(SimpleTextDocValuesReader outerInstance,
- Lucene.Net.Codecs.SimpleText.SimpleTextDocValuesReader.OneField field, IndexInput @in, BytesRef scratch,
- DecimalFormat decoder, DecimalFormat ordDecoder)
+ OneField field, IndexInput input, BytesRef scratch)
{
- this.outerInstance = outerInstance;
- this.field = field;
- this.@in = @in;
- this.scratch = scratch;
- this.decoder = decoder;
- this.ordDecoder = ordDecoder;
+ _outerInstance = outerInstance;
+ _field = field;
+ _input = input;
+ _scratch = scratch;
+ _decoderFormat = field.Pattern;
+ _ordDecoderFormat = field.OrdPattern;
}
- public override int GetOrd(int docID)
+ public override int GetOrd(int docId)
{
- if (docID < 0 || docID >= outerInstance.MAX_DOC)
+ if (docId < 0 || docId >= _outerInstance.MAX_DOC)
{
- throw new IndexOutOfRangeException("docID must be 0 .. " + (outerInstance.MAX_DOC - 1) + "; got " +
- docID);
+ throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) + "; got " +
+ docId);
}
- @in.Seek(field.DataStartFilePointer + field.NumValues*(9 + field.Pattern.Length + field.MaxLength) +
- docID*(1 + field.OrdPattern.Length));
- SimpleTextUtil.ReadLine(@in, scratch);
+ _input.Seek(_field.DataStartFilePointer + _field.NumValues * (9 + _field.Pattern.Length + _field.MaxLength) +
+ docId * (1 + _field.OrdPattern.Length));
+ SimpleTextUtil.ReadLine(_input, _scratch);
try
{
- return (long) (int) ordDecoder.Parse(scratch.Utf8ToString()) - 1;
+ return _scratch.Utf8ToString().ToString(_ordDecoderFormat) - 1;
}
- catch (ParseException pe)
+ catch (Exception pe)
{
- CorruptIndexException e = new CorruptIndexException("failed to parse ord (resource=" + @in + ")");
- e.initCause(pe);
+ var e = new CorruptIndexException("failed to parse ord (resource=" + _input + ")", pe);
throw e;
}
}
public override void LookupOrd(int ord, BytesRef result)
{
- if (ord < 0 || ord >= field.NumValues)
+ if (ord < 0 || ord >= _field.NumValues)
{
- throw new System.IndexOutOfRangeException("ord must be 0 .. " + (field.NumValues - 1) + "; got " +
+ throw new IndexOutOfRangeException("ord must be 0 .. " + (_field.NumValues - 1) + "; got " +
ord);
}
- @in.Seek(field.DataStartFilePointer + ord*(9 + field.Pattern.Length + field.MaxLength));
- SimpleTextUtil.ReadLine(@in, scratch);
- Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextDocValuesWriter.LENGTH),
- "got " + scratch.Utf8ToString() + " in=" + @in);
+ _input.Seek(_field.DataStartFilePointer + ord * (9 + _field.Pattern.Length + _field.MaxLength));
+ SimpleTextUtil.ReadLine(_input, _scratch);
+ Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH),
+ "got " + _scratch.Utf8ToString() + " in=" + _input);
int len;
try
{
len =
(int)
- decoder.parse(scratch.Bytes.SubList(
- scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
- scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString());
+ Decimal.Parse(_scratch.Bytes.SubList(
+ _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
+ _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString()).ToString(_decoderFormat);
}
- catch (ParseException pe)
+ catch (Exception pe)
{
- CorruptIndexException e =
- new CorruptIndexException("failed to parse int length (resource=" + @in + ")");
- e.initCause(pe);
+ var e = new CorruptIndexException("failed to parse int length (resource=" + _input + ")", pe);
throw e;
}
+
result.Bytes = new sbyte[len];
result.Offset = 0;
result.Length = len;
- @in.ReadBytes(result.Bytes, 0, len);
+ _input.ReadBytes(result.Bytes, 0, len);
}
public override int ValueCount
{
- get { return (int) field.NumValues; }
+ get { return (int)_field.NumValues; }
}
}
- public override SortedSetDocValues GetSortedSet(FieldInfo fieldInfo)
- {
- OneField field = FIELDS[fieldInfo.Name];
-
- // SegmentCoreReaders already verifies this field is
- // valid:
- Debug.Assert(field != null);
-
- IndexInput @in = (IndexInput) DATA.Clone();
- BytesRef scratch = new BytesRef();
- DecimalFormat decoder = new DecimalFormat(field.Pattern, new DecimalFormatSymbols(Locale.ROOT));
-
- return new SortedSetDocValuesAnonymousInnerClassHelper(this, field, @in, scratch, decoder);
- }
-
private class SortedSetDocValuesAnonymousInnerClassHelper : SortedSetDocValues
{
- private readonly SimpleTextDocValuesReader outerInstance;
+ private readonly SimpleTextDocValuesReader _outerInstance;
- private Lucene.Net.Codecs.SimpleText.SimpleTextDocValuesReader.OneField field;
- private IndexInput @in;
- private BytesRef scratch;
- private DecimalFormat decoder;
+ private readonly OneField _field;
+ private readonly IndexInput _input;
+ private readonly BytesRef _scratch;
+ private readonly string _decoderFormat;
public SortedSetDocValuesAnonymousInnerClassHelper(SimpleTextDocValuesReader outerInstance,
- Lucene.Net.Codecs.SimpleText.SimpleTextDocValuesReader.OneField field, IndexInput @in, BytesRef scratch,
- DecimalFormat decoder)
+ OneField field, IndexInput input, BytesRef scratch)
{
- this.outerInstance = outerInstance;
- this.field = field;
- this.@in = @in;
- this.scratch = scratch;
- this.decoder = decoder;
- currentOrds = new string[0];
- currentIndex = 0;
+ _outerInstance = outerInstance;
+ _field = field;
+ _input = input;
+ _scratch = scratch;
+ _decoderFormat = field.Pattern;
+ _currentOrds = new string[0];
+ _currentIndex = 0;
}
- internal string[] currentOrds;
- internal int currentIndex;
+ private string[] _currentOrds;
+ private int _currentIndex;
public override long NextOrd()
{
- return currentIndex == currentOrds.Length ? NO_MORE_ORDS : Convert.ToInt64(currentOrds[currentIndex++]);
+ return _currentIndex == _currentOrds.Length ? NO_MORE_ORDS : Convert.ToInt64(_currentOrds[_currentIndex++]);
}
public override int Document
{
set
{
- if (value < 0 || value >= outerInstance.MAX_DOC)
- throw new IndexOutOfRangeException("docID must be 0 .. " + (outerInstance.MAX_DOC - 1) + "; got " +
+ if (value < 0 || value >= _outerInstance.MAX_DOC)
+ throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) + "; got " +
value);
- @in.Seek(field.DataStartFilePointer + field.NumValues*(9 + field.Pattern.Length + field.MaxLength) +
- value*(1 + field.OrdPattern.Length));
- SimpleTextUtil.ReadLine(@in, scratch);
- string ordList = scratch.Utf8ToString().Trim();
- if (ordList.Length == 0)
- {
- currentOrds = new string[0];
- }
- else
- {
- currentOrds = ordList.Split(",", true);
- }
- currentIndex = 0;
+ _input.Seek(_field.DataStartFilePointer + _field.NumValues * (9 + _field.Pattern.Length + _field.MaxLength) +
+ value * (1 + _field.OrdPattern.Length));
+ SimpleTextUtil.ReadLine(_input, _scratch);
+ var ordList = _scratch.Utf8ToString().Trim();
+ _currentOrds = ordList.Length == 0 ? new string[0] : ordList.Split(",", true);
+ _currentIndex = 0;
}
}
public override void LookupOrd(long ord, BytesRef result)
{
- if (ord < 0 || ord >= field.NumValues)
+ if (ord < 0 || ord >= _field.NumValues)
{
- throw new IndexOutOfRangeException("ord must be 0 .. " + (field.NumValues - 1) + "; got " + ord);
+ throw new IndexOutOfRangeException("ord must be 0 .. " + (_field.NumValues - 1) + "; got " + ord);
}
- @in.Seek(field.DataStartFilePointer + ord*(9 + field.Pattern.Length + field.MaxLength));
- SimpleTextUtil.ReadLine(@in, scratch);
- Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextDocValuesWriter.LENGTH),
- "got " + scratch.Utf8ToString() + " in=" + @in);
+ _input.Seek(_field.DataStartFilePointer + ord * (9 + _field.Pattern.Length + _field.MaxLength));
+ SimpleTextUtil.ReadLine(_input, _scratch);
+ Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH),
+ "got " + _scratch.Utf8ToString() + " in=" + _input);
int len;
try
{
len =
(int)
- decoder.parse(scratch.Bytes.SubList(
- scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
- scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString());
+ _decoderFormat.parse(_scratch.Bytes.SubList(
+ _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
+ _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString());
}
- catch (ParseException pe)
+ catch (Exception pe)
{
- CorruptIndexException e =
- new CorruptIndexException("failed to parse int length (resource=" + @in + ")");
- e.initCause(pe);
+ var e = new CorruptIndexException("failed to parse int length (resource=" + _input + ")", pe);
throw e;
}
+
result.Bytes = new sbyte[len];
result.Offset = 0;
result.Length = len;
- @in.ReadBytes(result.Bytes, 0, len);
-
+ _input.ReadBytes(result.Bytes, 0, len);
}
public override long ValueCount
{
- get { return field.NumValues; }
+ get { return _field.NumValues; }
}
}
- public override Bits GetDocsWithField(FieldInfo field)
- {
- switch (field.DocValuesType)
- {
- case FieldInfo.DocValuesType_e.SORTED_SET:
- return DocValues.DocsWithValue(GetSortedSet(field), MAX_DOC);
- case FieldInfo.DocValuesType_e.SORTED:
- return DocValues.DocsWithValue(GetSorted(field), MAX_DOC);
- case FieldInfo.DocValuesType_e.BINARY:
- return GetBinaryDocsWithField(field);
- case FieldInfo.DocValuesType_e.NUMERIC:
- return GetNumericDocsWithField(field);
- default:
- throw new InvalidEnumArgumentException();
- }
- }
-
- protected override void Dispose(bool disposing)
+ private class NumericDocValuesAnonymousInnerClassHelper : NumericDocValues
{
- if (disposing) return;
-
- DATA.Dispose();
- }
+ private readonly SimpleTextDocValuesReader _outerInstance;
- /// <summary> Used only in ctor: </summary>
- private void ReadLine()
- {
- SimpleTextUtil.ReadLine(DATA, SCRATCH);
- }
+ private readonly OneField _field;
+ private readonly IndexInput _input;
+ private readonly BytesRef _scratch;
- /// <summary> Used only in ctor: </summary>
- private bool StartsWith(BytesRef prefix)
- {
- return StringHelper.StartsWith(SCRATCH, prefix);
- }
+ public NumericDocValuesAnonymousInnerClassHelper(SimpleTextDocValuesReader outerInstance,
+ OneField field, IndexInput input, BytesRef scratch)
+ {
+ _outerInstance = outerInstance;
+ _field = field;
+ _input = input;
+ _scratch = scratch;
+ }
- /// <summary> Used only in ctor: </summary>
- private string StripPrefix(BytesRef prefix)
- {
- return SCRATCH.Bytes.SubList(SCRATCH.Offset + prefix.Length, SCRATCH.Length - prefix.Length).ToString();
- }
+ public override long Get(int docId)
+ {
+ if (docId < 0 || docId >= _outerInstance.MAX_DOC)
+ throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) +
+ "; got " + docId);
- public override long RamBytesUsed()
- {
- return 0;
- }
+ _input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2) * docId);
+ SimpleTextUtil.ReadLine(_input, _scratch);
- public override void CheckIntegrity()
- {
- var iScratch = new BytesRef();
- var clone = (IndexInput) DATA.Clone();
- clone.Seek(0);
- ChecksumIndexInput input = new BufferedChecksumIndexInput(clone);
- while (true)
- {
- SimpleTextUtil.ReadLine(input, iScratch);
- if (!iScratch.Equals(SimpleTextDocValuesWriter.END)) continue;
+ long bd;
+ try
+ {
+ bd = long.Parse(_scratch.Utf8ToString());
+ }
+ catch (FormatException ex)
+ {
+ throw new CorruptIndexException("failed to parse long value (resource=" + _input + ")", ex);
+ }
- SimpleTextUtil.CheckFooter(input);
- break;
+ SimpleTextUtil.ReadLine(_input, _scratch); // read the line telling us if its real or not
+ return _field.MinValue + bd;
}
}
- private class BitsAnonymousInnerClassHelper : Bits
+ private class BinaryDocValuesAnonymousInnerClassHelper : BinaryDocValues
{
private readonly SimpleTextDocValuesReader _outerInstance;
@@ -591,26 +561,40 @@ namespace Lucene.Net.Codecs.SimpleText
private readonly IndexInput _input;
private readonly BytesRef _scratch;
- public BitsAnonymousInnerClassHelper(SimpleTextDocValuesReader outerInstance,
- OneField field, IndexInput @in, BytesRef scratch)
+ public BinaryDocValuesAnonymousInnerClassHelper(SimpleTextDocValuesReader outerInstance, OneField field,
+ IndexInput input, BytesRef scratch)
{
_outerInstance = outerInstance;
_field = field;
- _input = @in;
+ _input = input;
_scratch = scratch;
}
- public bool Get(int index)
+ public override void Get(int docId, BytesRef result)
{
- _input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2) * index);
- SimpleTextUtil.ReadLine(_input, _scratch); // data
- SimpleTextUtil.ReadLine(_input, _scratch); // 'T' or 'F'
- return _scratch.Bytes[_scratch.Offset] == (sbyte)'T';
- }
+ if (docId < 0 || docId >= _outerInstance.MAX_DOC)
+ throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) +
+ "; got " + docId);
- public int Length()
- {
- return _outerInstance.MAX_DOC;
+ _input.Seek(_field.DataStartFilePointer + (9 + _field.Pattern.Length + _field.MaxLength + 2) * docId);
+ SimpleTextUtil.ReadLine(_input, _scratch);
+ Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH));
+ int len;
+ try
+ {
+ len = int.Parse(_scratch.Bytes.SubList(
+ _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
+ _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString());
+ }
+ catch (FormatException ex)
+ {
+ throw new CorruptIndexException("failed to parse int value (resource=" + _input + ")", ex);
+ }
+
+ result.Bytes = new sbyte[len];
+ result.Offset = 0;
+ result.Length = len;
+ _input.ReadBytes(result.Bytes, 0, len);
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a33ca521/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
index c3f8fa4..b322f1d 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
@@ -99,8 +99,7 @@ namespace Lucene.Net.Codecs.SimpleText
SimpleTextUtil.WriteNewline(data);
var patternString = sb.ToString();
- DecimalFormat encoder = new DecimalFormat(patternString, new DecimalFormatSymbols(Locale.ROOT));
-
+
int numDocsWritten = 0;
// second pass to write the values
@@ -109,7 +108,7 @@ namespace Lucene.Net.Codecs.SimpleText
Debug.Assert(value >= minValue);
var delta = value - minValue;
- string s = encoder.format(delta);
+ string s = delta.ToString(patternString);
Debug.Assert(s.Length == patternString.Length);
SimpleTextUtil.Write(data, s, scratch);
SimpleTextUtil.WriteNewline(data);
@@ -151,14 +150,13 @@ namespace Lucene.Net.Codecs.SimpleText
SimpleTextUtil.Write(data, sb.ToString(), scratch);
SimpleTextUtil.WriteNewline(data);
- DecimalFormat encoder = new DecimalFormat(sb.ToString(), new DecimalFormatSymbols(Locale.ROOT));
-
+
int numDocsWritten = 0;
foreach (BytesRef value in values)
{
int length = value == null ? 0 : value.Length;
SimpleTextUtil.Write(data, LENGTH);
- SimpleTextUtil.Write(data, encoder.format(length), scratch);
+ SimpleTextUtil.Write(data, length.ToString(sb.ToString()), scratch);
SimpleTextUtil.WriteNewline(data);
// write bytes -- don't use SimpleText.Write
@@ -217,8 +215,8 @@ namespace Lucene.Net.Codecs.SimpleText
SimpleTextUtil.Write(data, PATTERN);
SimpleTextUtil.Write(data, sb.ToString(), scratch);
SimpleTextUtil.WriteNewline(data);
-
- DecimalFormat encoder = new DecimalFormat(sb.ToString(), new DecimalFormatSymbols(Locale.ROOT));
+
+ var encoderFormat = sb.ToString();
int maxOrdBytes = Convert.ToString(valueCount + 1L).Length;
sb.Length = 0;
@@ -231,8 +229,8 @@ namespace Lucene.Net.Codecs.SimpleText
SimpleTextUtil.Write(data, ORDPATTERN);
SimpleTextUtil.Write(data, sb.ToString(), scratch);
SimpleTextUtil.WriteNewline(data);
-
- DecimalFormat ordEncoder = new DecimalFormat(sb.ToString(), new DecimalFormatSymbols(Locale.ROOT));
+
+ var ordEncoderFormat = sb.ToString();
// for asserts:
int valuesSeen = 0;
@@ -241,7 +239,7 @@ namespace Lucene.Net.Codecs.SimpleText
{
// write length
SimpleTextUtil.Write(data, LENGTH);
- SimpleTextUtil.Write(data, encoder.format(value.Length), scratch);
+ SimpleTextUtil.Write(data, value.Length.ToString(encoderFormat), scratch);
SimpleTextUtil.WriteNewline(data);
// write bytes -- don't use SimpleText.Write
@@ -262,7 +260,7 @@ namespace Lucene.Net.Codecs.SimpleText
foreach (var ord in docToOrd)
{
- SimpleTextUtil.Write(data, ordEncoder.format(ord + 1), scratch);
+ SimpleTextUtil.Write(data, (ord + 1).ToString(ordEncoderFormat), scratch);
SimpleTextUtil.WriteNewline(data);
}
}
@@ -276,7 +274,7 @@ namespace Lucene.Net.Codecs.SimpleText
long valueCount = 0;
int maxLength = 0;
- foreach (BytesRef value in values)
+ foreach (var value in values)
{
maxLength = Math.Max(maxLength, value.Length);
valueCount++;
@@ -304,7 +302,7 @@ namespace Lucene.Net.Codecs.SimpleText
SimpleTextUtil.Write(data, sb.ToString(), scratch);
SimpleTextUtil.WriteNewline(data);
- DecimalFormat encoder = new DecimalFormat(sb.ToString(), new DecimalFormatSymbols(Locale.ROOT));
+ string encoderFormat = sb.ToString();
// compute ord pattern: this is funny, we encode all values for all docs to find the maximum length
var maxOrdListLength = 0;
@@ -316,7 +314,9 @@ namespace Lucene.Net.Codecs.SimpleText
int count = (int) n;
for (int i = 0; i < count; i++)
{
- long ord = (long) ordStream.next();
+ ordStream.MoveNext();
+
+ var ord = ordStream.Current;
if (sb2.Length > 0)
{
sb2.Append(",");
@@ -340,11 +340,11 @@ namespace Lucene.Net.Codecs.SimpleText
// for asserts:
long valuesSeen = 0;
- foreach (BytesRef value in values)
+ foreach (var value in values)
{
// write length
SimpleTextUtil.Write(data, LENGTH);
- SimpleTextUtil.Write(data, encoder.format(value.Length), scratch);
+ SimpleTextUtil.Write(data, value.Length.ToString(encoderFormat), scratch);
SimpleTextUtil.WriteNewline(data);
// write bytes -- don't use SimpleText.Write
@@ -352,7 +352,7 @@ namespace Lucene.Net.Codecs.SimpleText
data.WriteBytes(value.Bytes, value.Offset, value.Length);
// pad to fit
- for (int i = value.Length; i < maxLength; i++)
+ for (var i = value.Length; i < maxLength; i++)
{
data.WriteByte((sbyte) ' ');
}
@@ -372,7 +372,8 @@ namespace Lucene.Net.Codecs.SimpleText
var count = (int) n;
for (var i = 0; i < count; i++)
{
- var ord = (long) ordStream.Next();
+ ordStream.MoveNext();
+ var ord = ordStream.Current;
if (sb2.Length > 0)
sb2.Append(",");
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a33ca521/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldsReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldsReader.cs
index b896ac5..9d2f6ff 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldsReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldsReader.cs
@@ -45,7 +45,7 @@ namespace Lucene.Net.Codecs.SimpleText
using IntsRef = Util.IntsRef;
using StringHelper = Util.StringHelper;
using UnicodeUtil = Util.UnicodeUtil;
- using BytesRefFSTEnum = Util.Fst.BytesRefFSTEnum<Util.Fst.PairOutputs<long,long>.Pair<long, Util.Fst.PairOutputs<long,long>.Pair<long, long>>>;
+ using BytesRefFSTEnum = Util.Fst.BytesRefFSTEnum<Util.Fst.PairOutputs<long,long>.Pair>;
using FST = Util.Fst.FST;
using PairOutputs = Util.Fst.PairOutputs<long,long>;
using PositiveIntOutputs = Util.Fst.PositiveIntOutputs;
@@ -115,14 +115,14 @@ namespace Lucene.Net.Codecs.SimpleText
private long _totalTermFreq;
private long _docsStart;
- private readonly BytesRefFSTEnum<PairOutputs<long, PairOutputs.Pair<long, long>>.Pair<long, PairOutputs.Pair<long, long>>> _fstEnum;
+ private readonly BytesRefFSTEnum<PairOutputs<long, PairOutputs.Pair>.Pair> _fstEnum;
public SimpleTextTermsEnum(SimpleTextFieldsReader outerInstance,
- FST<PairOutputs<long, PairOutputs.Pair<long, long>>.Pair<long, PairOutputs.Pair<long, long>>> fst, IndexOptions indexOptions)
+ FST<PairOutputs<long, PairOutputs.Pair>.Pair> fst, IndexOptions indexOptions)
{
_outerInstance = outerInstance;
_indexOptions = indexOptions;
- _fstEnum = new BytesRefFSTEnum<PairOutputs<long, PairOutputs.Pair<long, long>>.Pair<long, PairOutputs.Pair<long, long>>>(fst);
+ _fstEnum = new BytesRefFSTEnum<PairOutputs<long, PairOutputs.Pair>.Pair>(fst);
}
public override bool SeekExact(BytesRef text)
@@ -583,7 +583,7 @@ namespace Lucene.Net.Codecs.SimpleText
private long _sumTotalTermFreq;
private long _sumDocFreq;
private int _docCount;
- private FST<PairOutputs<long, PairOutputs.Pair<long, long>>.Pair<long, PairOutputs.Pair<long, long>>> _fst;
+ private FST<PairOutputs<long, PairOutputs.Pair>.Pair> _fst;
private int _termCount;
private readonly BytesRef _scratch = new BytesRef(10);
private readonly CharsRef _scratchUtf16 = new CharsRef(10);
@@ -601,10 +601,11 @@ namespace Lucene.Net.Codecs.SimpleText
{
var posIntOutputs = PositiveIntOutputs.Singleton;
var outputsInner = new PairOutputs<long, long>(posIntOutputs, posIntOutputs);
- var outputs = new PairOutputs<long, PairOutputs.Pair<long, long>>(posIntOutputs, outputsInner);
+ //var outputs = new PairOutputs<long, PairOutputs.Pair<long, long>>(posIntOutputs, outputsInner);
+ var outputs = new PairOutputs<long, PairOutputs.Pair>(posIntOutputs, outputsInner);
// honestly, wtf kind of generic mess is this.
- var b = new Builder<PairOutputs<long, PairOutputs.Pair<long, long>>.Pair<long, PairOutputs.Pair<long, long>>>(FST.INPUT_TYPE.BYTE1, outputs);
+ var b = new Builder<PairOutputs<long, PairOutputs.Pair>.Pair>(FST.INPUT_TYPE.BYTE1, outputs);
var input = (IndexInput) _outerInstance._input.Clone();
input.Seek(_termsStart);
[4/4] lucenenet git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/lucenenet
Posted by pn...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/lucenenet
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/2d7533d4
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/2d7533d4
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/2d7533d4
Branch: refs/heads/master
Commit: 2d7533d4e5a3278f242c2915c6f8dfd10ea77847
Parents: df4afdc eec73d5
Author: Prescott Nasser <pn...@apache.org>
Authored: Tue Dec 2 09:41:08 2014 -0800
Committer: Prescott Nasser <pn...@apache.org>
Committed: Tue Dec 2 09:41:08 2014 -0800
----------------------------------------------------------------------
Lucene.Net.sln | 14 +-
README.md | 21 +-
src/BUILD.txt | 23 -
.../Analysis/CharFilter/BaseCharFilter.cs | 161 ++-
.../Analysis/CharFilter/MappingCharFilter.cs | 36 +-
.../CharFilter/MappingCharFilterFactory.cs | 20 +-
.../Analysis/CharFilter/NormalizeCharMap.cs | 2 +-
.../Analysis/CommonGrams/CommonGramsFilter.cs | 67 +-
.../CommonGrams/CommonGramsFilterFactory.cs | 4 +-
.../CommonGrams/CommonGramsQueryFilter.cs | 26 +-
.../Compound/CompoundWordTokenFilterBase.cs | 36 +-
.../DictionaryCompoundWordTokenFilter.cs | 259 ++--
.../DictionaryCompoundWordTokenFilterFactory.cs | 136 +-
.../HyphenationCompoundWordTokenFilter.cs | 497 ++++---
...HyphenationCompoundWordTokenFilterFactory.cs | 25 +-
.../Analysis/Core/KeywordAnalyzer.cs | 2 +-
.../Analysis/Core/LowerCaseFilter.cs | 1 +
.../Analysis/Core/StopAnalyzer.cs | 5 +-
.../Analysis/Core/StopFilterFactory.cs | 286 ++--
.../Analysis/Core/UpperCaseFilter.cs | 3 +-
.../Analysis/Core/UpperCaseFilterFactory.cs | 124 +-
.../Analysis/Core/WhitespaceAnalyzer.cs | 2 +-
.../Miscellaneous/ASCIIFoldingFilter.cs | 56 +-
.../Miscellaneous/ASCIIFoldingFilterFactory.cs | 12 +-
.../Miscellaneous/CapitalizationFilter.cs | 31 +-
.../CapitalizationFilterFactory.cs | 207 ++-
.../Analysis/Miscellaneous/KeepWordFilter.cs | 88 +-
.../Miscellaneous/KeepWordFilterFactory.cs | 194 ++-
.../Miscellaneous/KeywordMarkerFilterFactory.cs | 172 ++-
.../Miscellaneous/KeywordRepeatFilterFactory.cs | 87 +-
.../Lucene47WordDelimiterFilter.cs | 3 +-
.../Analysis/Miscellaneous/PatternAnalyzer.cs | 5 +-
.../RemoveDuplicatesTokenFilter.cs | 131 +-
.../RemoveDuplicatesTokenFilterFactory.cs | 11 +-
.../Miscellaneous/ScandinavianFoldingFilter.cs | 6 +-
.../ScandinavianNormalizationFilter.cs | 6 +-
.../Miscellaneous/SetKeywordMarkerFilter.cs | 107 +-
.../StemmerOverrideFilterFactory.cs | 168 ++-
.../Miscellaneous/WordDelimiterFilter.cs | 3 +-
.../Miscellaneous/WordDelimiterFilterFactory.cs | 34 +-
.../Analysis/Ngram/EdgeNGramFilterFactory.cs | 105 +-
.../Analysis/Ngram/EdgeNGramTokenFilter.cs | 97 +-
.../Analysis/Ngram/EdgeNGramTokenizerFactory.cs | 19 +-
.../Analysis/Ngram/NGramTokenFilter.cs | 6 +-
.../Analysis/Ngram/NGramTokenizer.cs | 3 +-
.../DelimitedPayloadTokenFilterFactory.cs | 147 +-
.../Analysis/Position/PositionFilter.cs | 25 +-
.../Analysis/Position/PositionFilterFactory.cs | 119 +-
.../Analysis/Query/QueryAutoStopWordAnalyzer.cs | 401 +++---
.../Analysis/Standard/ClassicAnalyzer.cs | 8 +-
.../Analysis/Standard/StandardAnalyzer.cs | 8 +-
.../Analysis/Standard/UAX29URLEmailAnalyzer.cs | 6 +-
.../Analysis/Synonym/FSTSynonymFilterFactory.cs | 12 +-
.../Analysis/Synonym/SlowSynonymFilter.cs | 22 +-
.../Synonym/SlowSynonymFilterFactory.cs | 1 +
.../Analysis/Synonym/SlowSynonymMap.cs | 10 +-
.../Analysis/Synonym/SynonymFilterFactory.cs | 173 ++-
.../Analysis/Util/AnalysisSPILoader.cs | 9 +-
.../Analysis/Util/CharArrayMap.cs | 57 +-
.../Analysis/Util/CharArraySet.cs | 54 +-
.../Analysis/Util/CharacterUtils.cs | 14 +-
.../Analysis/Util/ClasspathResourceLoader.cs | 11 +-
.../Analysis/Util/ElisionFilter.cs | 141 +-
.../Analysis/Util/FilesystemResourceLoader.cs | 7 +-
.../Analysis/Util/FilteringTokenFilter.cs | 6 +-
.../Analysis/Util/MultiTermAwareComponent.cs | 67 +-
.../Analysis/Util/OpenStringBuilder.cs | 2 +-
.../Analysis/Util/ResourceLoader.cs | 87 +-
.../Analysis/Util/ResourceLoaderAware.cs | 33 +-
.../Analysis/Util/RollingCharBuffer.cs | 364 +++--
.../Analysis/Util/SegmentingTokenizerBase.cs | 113 +-
.../Analysis/Util/StemmerUtil.cs | 271 ++--
.../Analysis/Util/StopwordAnalyzerBase.cs | 53 +-
.../Analysis/Util/WordlistLoader.cs | 39 +-
.../Collation/CollationKeyAnalyzer.cs | 19 +-
src/Lucene.Net.Core/Analysis/Analyzer.cs | 2 +-
src/Lucene.Net.Core/Analysis/AnalyzerWrapper.cs | 8 +-
.../Analysis/CachingTokenFilter.cs | 4 +-
src/Lucene.Net.Core/Analysis/CharFilter.cs | 8 +-
src/Lucene.Net.Core/Analysis/TokenFilter.cs | 10 +-
.../Codecs/BlockTreeTermsReader.cs | 10 +-
.../Codecs/BlockTreeTermsWriter.cs | 4 +-
.../CompressingStoredFieldsReader.cs | 4 +-
.../Compressing/CompressingTermVectorsWriter.cs | 2 +-
.../Codecs/Compressing/CompressionMode.cs | 14 +-
.../Codecs/Compressing/Compressor.cs | 2 +-
src/Lucene.Net.Core/Codecs/Compressing/LZ4.cs | 33 +-
.../Codecs/Lucene3x/Lucene3xFields.cs | 56 +-
.../Lucene3x/Lucene3xStoredFieldsReader.cs | 4 +-
.../Codecs/Lucene40/Lucene40DocValuesReader.cs | 2 +-
.../Codecs/Lucene40/Lucene40PostingsReader.cs | 2 +-
.../Lucene40/Lucene40StoredFieldsReader.cs | 2 +-
.../Lucene40/Lucene40TermVectorsReader.cs | 32 +-
src/Lucene.Net.Core/Codecs/Lucene41/ForUtil.cs | 7 +-
.../Codecs/Lucene41/Lucene41PostingsReader.cs | 16 +-
.../Codecs/Lucene41/Lucene41PostingsWriter.cs | 4 +-
.../Lucene42/Lucene42DocValuesProducer.cs | 6 +-
.../Lucene45/Lucene45DocValuesProducer.cs | 6 +-
src/Lucene.Net.Core/Codecs/TermVectorsWriter.cs | 2 +-
.../Document/CompressionTools.cs | 28 +-
.../Document/DocumentStoredFieldVisitor.cs | 2 +-
src/Lucene.Net.Core/Document/Field.cs | 33 +-
src/Lucene.Net.Core/Document/StoredField.cs | 4 +-
src/Lucene.Net.Core/Index/AutomatonTermsEnum.cs | 10 +-
.../Index/BinaryDocValuesFieldUpdates.cs | 4 +-
src/Lucene.Net.Core/Index/ByteSliceReader.cs | 2 +-
src/Lucene.Net.Core/Index/ByteSliceWriter.cs | 6 +-
.../Index/ConcurrentMergeScheduler.cs | 2 +-
.../Index/FreqProxTermsWriterPerField.cs | 2 +-
.../Index/NumericDocValuesFieldUpdates.cs | 4 +-
src/Lucene.Net.Core/Index/ReaderManager.cs | 8 +-
.../Index/SortedDocValuesTermsEnum.cs | 4 +-
.../Index/SortedSetDocValuesTermsEnum.cs | 4 +-
src/Lucene.Net.Core/Index/StoredFieldVisitor.cs | 2 +-
src/Lucene.Net.Core/Index/TermsHashPerField.cs | 9 +-
src/Lucene.Net.Core/Lucene.Net.csproj | 3 +
.../Search/CachingWrapperFilter.cs | 2 +-
src/Lucene.Net.Core/Search/DocIdSetIterator.cs | 2 +-
src/Lucene.Net.Core/Search/FieldComparator.cs | 4 +-
.../Search/NumericRangeFilter.cs | 16 +-
src/Lucene.Net.Core/Search/NumericRangeQuery.cs | 20 +-
.../Search/Payloads/PayloadNearQuery.cs | 27 +-
.../Search/Payloads/PayloadSpanUtil.cs | 15 +-
src/Lucene.Net.Core/Search/PhraseQuery.cs | 22 +-
src/Lucene.Net.Core/Search/Query.cs | 3 +-
src/Lucene.Net.Core/Search/ReferenceManager.cs | 8 +-
src/Lucene.Net.Core/Search/SearcherManager.cs | 8 +-
.../Search/Similarities/IBSimilarity.cs | 2 +-
.../Search/Spans/NearSpansOrdered.cs | 24 +-
.../Search/Spans/NearSpansUnordered.cs | 10 +-
.../Search/Spans/SpanNearPayloadCheckQuery.cs | 12 +-
.../Search/Spans/SpanNotQuery.cs | 10 +-
src/Lucene.Net.Core/Search/Spans/SpanOrQuery.cs | 6 +-
.../Search/Spans/SpanPayloadCheckQuery.cs | 12 +-
.../Search/Spans/SpanPositionCheckQuery.cs | 8 +-
src/Lucene.Net.Core/Search/Spans/Spans.cs | 5 +-
src/Lucene.Net.Core/Search/Spans/TermSpans.cs | 10 +-
src/Lucene.Net.Core/Store/DataOutput.cs | 9 +-
src/Lucene.Net.Core/Store/Directory.cs | 4 +-
src/Lucene.Net.Core/Store/FSDirectory.cs | 2 +-
.../Store/NativeFSLockFactory.cs | 2 +-
src/Lucene.Net.Core/Store/RAMOutputStream.cs | 2 +-
.../Compatibility/BinaryWriterDataOutput.cs | 31 +
.../Support/ConcurrentHashMapWrapper.cs | 5 +-
src/Lucene.Net.Core/Support/Number.cs | 27 +-
src/Lucene.Net.Core/Support/StreamUtils.cs | 40 +
src/Lucene.Net.Core/Support/StringSupport.cs | 5 +-
src/Lucene.Net.Core/Util/Accountable.cs | 36 +
.../Util/ArrayInPlaceMergeSorter.cs | 4 +-
src/Lucene.Net.Core/Util/ArrayIntroSorter.cs | 4 +-
src/Lucene.Net.Core/Util/ArrayTimSorter.cs | 4 +-
src/Lucene.Net.Core/Util/ArrayUtil.cs | 13 +-
.../Util/Automaton/ByteRunAutomaton.cs | 8 +-
.../Util/Automaton/CompiledAutomaton.cs | 10 +-
.../Util/Automaton/SpecialOperations.cs | 4 +-
src/Lucene.Net.Core/Util/BitUtil.cs | 12 +-
src/Lucene.Net.Core/Util/ByteBlockPool.cs | 52 +-
src/Lucene.Net.Core/Util/BytesRef.cs | 42 +-
src/Lucene.Net.Core/Util/BytesRefArray.cs | 4 +-
src/Lucene.Net.Core/Util/BytesRefHash.cs | 16 +-
src/Lucene.Net.Core/Util/CollectionUtil.cs | 8 +-
src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs | 2 +-
src/Lucene.Net.Core/Util/Fst/FST.cs | 4 +-
src/Lucene.Net.Core/Util/Fst/Util.cs | 2 +-
.../Util/GrowableByteArrayDataOutput.cs | 6 +-
src/Lucene.Net.Core/Util/IOUtils.cs | 2 +-
src/Lucene.Net.Core/Util/NumericUtils.cs | 18 +-
src/Lucene.Net.Core/Util/OfflineSorter.cs | 134 +-
src/Lucene.Net.Core/Util/OpenBitSetIterator.cs | 2 +-
src/Lucene.Net.Core/Util/PForDeltaDocIdSet.cs | 18 +-
.../Util/Packed/AbstractBlockPackedWriter.cs | 4 +-
.../Util/Packed/BlockPackedReaderIterator.cs | 6 +-
.../Util/Packed/BulkOperation.cs | 12 +-
.../Util/Packed/BulkOperationPacked.cs | 16 +-
.../Util/Packed/BulkOperationPacked1.cs | 8 +-
.../Util/Packed/BulkOperationPacked10.cs | 4 +-
.../Util/Packed/BulkOperationPacked11.cs | 4 +-
.../Util/Packed/BulkOperationPacked12.cs | 4 +-
.../Util/Packed/BulkOperationPacked13.cs | 4 +-
.../Util/Packed/BulkOperationPacked14.cs | 4 +-
.../Util/Packed/BulkOperationPacked15.cs | 4 +-
.../Util/Packed/BulkOperationPacked16.cs | 4 +-
.../Util/Packed/BulkOperationPacked17.cs | 4 +-
.../Util/Packed/BulkOperationPacked18.cs | 4 +-
.../Util/Packed/BulkOperationPacked19.cs | 4 +-
.../Util/Packed/BulkOperationPacked2.cs | 8 +-
.../Util/Packed/BulkOperationPacked20.cs | 4 +-
.../Util/Packed/BulkOperationPacked21.cs | 4 +-
.../Util/Packed/BulkOperationPacked22.cs | 4 +-
.../Util/Packed/BulkOperationPacked23.cs | 4 +-
.../Util/Packed/BulkOperationPacked24.cs | 4 +-
.../Util/Packed/BulkOperationPacked3.cs | 4 +-
.../Util/Packed/BulkOperationPacked4.cs | 8 +-
.../Util/Packed/BulkOperationPacked5.cs | 4 +-
.../Util/Packed/BulkOperationPacked6.cs | 4 +-
.../Util/Packed/BulkOperationPacked7.cs | 4 +-
.../Util/Packed/BulkOperationPacked8.cs | 4 +-
.../Util/Packed/BulkOperationPacked9.cs | 4 +-
.../Packed/BulkOperationPackedSingleBlock.cs | 15 +-
src/Lucene.Net.Core/Util/Packed/PackedInts.cs | 8 +-
.../Util/Packed/PackedReaderIterator.cs | 6 +-
src/Lucene.Net.Core/Util/Packed/PackedWriter.cs | 4 +-
src/Lucene.Net.Core/Util/PagedBytes.cs | 48 +-
.../Util/RecyclingByteBlockAllocator.cs | 14 +-
src/Lucene.Net.Core/Util/Sorter.cs | 4 +-
src/Lucene.Net.Core/Util/StringHelper.cs | 14 +-
src/Lucene.Net.Core/Util/ToStringUtils.cs | 2 +-
src/Lucene.Net.Core/Util/UnicodeUtil.cs | 75 +-
src/Lucene.Net.Facet/DrillDownQuery.cs | 388 +++++
src/Lucene.Net.Facet/DrillSideways.cs | 295 ++++
src/Lucene.Net.Facet/DrillSidewaysQuery.cs | 316 +++++
src/Lucene.Net.Facet/DrillSidewaysScorer.cs | 826 +++++++++++
src/Lucene.Net.Facet/FacetField.cs | 91 ++
src/Lucene.Net.Facet/FacetResult.cs | 104 ++
src/Lucene.Net.Facet/Facets.cs | 64 +
src/Lucene.Net.Facet/FacetsCollector.cs | 372 +++++
src/Lucene.Net.Facet/FacetsConfig.cs | 712 ++++++++++
src/Lucene.Net.Facet/LabelAndValue.cs | 66 +
src/Lucene.Net.Facet/Lucene.Net.Facet.csproj | 123 ++
src/Lucene.Net.Facet/MultiFacets.cs | 103 ++
src/Lucene.Net.Facet/Properties/AssemblyInfo.cs | 36 +
.../RandomSamplingFacetsCollector.cs | 323 +++++
src/Lucene.Net.Facet/Range/DoubleRange.cs | 243 ++++
.../Range/DoubleRangeFacetCounts.cs | 160 +++
src/Lucene.Net.Facet/Range/LongRange.cs | 239 ++++
src/Lucene.Net.Facet/Range/LongRangeCounter.cs | 385 +++++
.../Range/LongRangeFacetCounts.cs | 143 ++
src/Lucene.Net.Facet/Range/Range.cs | 90 ++
src/Lucene.Net.Facet/Range/RangeFacetCounts.cs | 99 ++
.../DefaultSortedSetDocValuesReaderState.cs | 158 +++
.../SortedSet/SortedSetDocValuesFacetCounts.cs | 350 +++++
.../SortedSet/SortedSetDocValuesFacetField.cs | 65 +
.../SortedSet/SortedSetDocValuesReaderState.cs | 103 ++
.../Taxonomy/AssociationFacetField.cs | 91 ++
.../Taxonomy/CachedOrdinalsReader.cs | 208 +++
src/Lucene.Net.Facet/Taxonomy/CategoryPath.cs | 316 +++++
.../Taxonomy/Directory/Consts.cs | 34 +
.../Directory/DirectoryTaxonomyReader.cs | 450 ++++++
.../Directory/DirectoryTaxonomyWriter.cs | 1202 ++++++++++++++++
.../Taxonomy/Directory/TaxonomyIndexArrays.cs | 252 ++++
.../Taxonomy/DocValuesOrdinalsReader.cs | 130 ++
src/Lucene.Net.Facet/Taxonomy/FacetLabel.cs | 219 +++
.../Taxonomy/FastTaxonomyFacetCounts.cs | 105 ++
.../Taxonomy/FloatAssociationFacetField.cs | 65 +
.../Taxonomy/FloatTaxonomyFacets.cs | 183 +++
.../Taxonomy/IntAssociationFacetField.cs | 75 +
.../Taxonomy/IntTaxonomyFacets.cs | 189 +++
src/Lucene.Net.Facet/Taxonomy/LRUHashMap.cs | 154 ++
src/Lucene.Net.Facet/Taxonomy/OrdinalsReader.cs | 68 +
.../Taxonomy/ParallelTaxonomyArrays.cs | 74 +
.../Taxonomy/PrintTaxonomyStats.cs | 121 ++
.../Taxonomy/SearcherTaxonomyManager.cs | 179 +++
.../Taxonomy/TaxonomyFacetCounts.cs | 77 +
.../TaxonomyFacetSumFloatAssociations.cs | 98 ++
.../Taxonomy/TaxonomyFacetSumIntAssociations.cs | 96 ++
.../Taxonomy/TaxonomyFacetSumValueSource.cs | 247 ++++
src/Lucene.Net.Facet/Taxonomy/TaxonomyFacets.cs | 137 ++
src/Lucene.Net.Facet/Taxonomy/TaxonomyReader.cs | 316 +++++
src/Lucene.Net.Facet/Taxonomy/TaxonomyWriter.cs | 125 ++
.../Taxonomy/WriterCache/CategoryPathUtils.cs | 99 ++
.../Taxonomy/WriterCache/CharBlockArray.cs | 234 +++
.../WriterCache/Cl2oTaxonomyWriterCache.cs | 123 ++
.../Taxonomy/WriterCache/CollisionMap.cs | 311 ++++
.../WriterCache/CompactLabelToOrdinal.cs | 522 +++++++
.../Taxonomy/WriterCache/LabelToOrdinal.cs | 83 ++
.../WriterCache/LruTaxonomyWriterCache.cs | 149 ++
.../Taxonomy/WriterCache/NameHashIntCacheLRU.cs | 49 +
.../Taxonomy/WriterCache/NameIntCacheLRU.cs | 167 +++
.../Taxonomy/WriterCache/TaxonomyWriterCache.cs | 105 ++
src/Lucene.Net.Facet/TopOrdAndFloatQueue.cs | 73 +
src/Lucene.Net.Facet/TopOrdAndIntQueue.cs | 76 +
src/Lucene.Net.Queries/TermsFilter.cs | 4 +-
.../Suggest/Analyzing/FreeTextSuggester.cs | 13 +-
.../Suggest/Analyzing/SuggestStopFilter.cs | 6 +-
.../Suggest/Fst/WFSTCompletionLookup.cs | 32 +-
.../Suggest/Jaspell/JaspellLookup.cs | 38 +-
.../Analysis/LookaheadTokenFilter.cs | 4 +-
.../Analysis/MockAnalyzer.cs | 2 +-
.../Analysis/MockBytesAnalyzer.cs | 2 +-
.../Analysis/MockCharFilter.cs | 2 +-
.../Analysis/MockFixedLengthPayloadFilter.cs | 6 +-
.../Analysis/MockHoleInjectingTokenFilter.cs | 2 +-
.../Analysis/MockPayloadAnalyzer.cs | 4 +-
.../Analysis/MockTokenFilter.cs | 2 +-
.../Analysis/MockTokenizer.cs | 6 +-
.../Analysis/MockUTF16TermAttributeImpl.cs | 2 +-
.../Analysis/MockVariableLengthPayloadFilter.cs | 4 +-
.../Analysis/ValidatingTokenFilter.cs | 2 +-
.../compressing/dummy/DummyCompressingCodec.cs | 4 +-
.../lucene42/Lucene42DocValuesConsumer.cs | 2 +-
.../Codecs/ramonly/RAMOnlyPostingsFormat.cs | 12 +-
.../Index/BaseDocValuesFormatTestCase.cs | 52 +-
.../Index/BaseIndexFileFormatTestCase.cs | 6 +-
.../Index/BasePostingsFormatTestCase.cs | 2 +-
.../Index/BaseStoredFieldsFormatTestCase.cs | 28 +-
.../Index/BaseTermVectorsFormatTestCase.cs | 2 +-
src/Lucene.Net.TestFramework/Index/DocHelper.cs | 2 +-
.../Index/FieldFilterAtomicReader.cs | 4 +-
.../ThreadedIndexingAndSearchingTestCase.cs | 36 +-
.../Randomized/Generators/RandomInts.cs | 4 +-
.../Search/SearchEquivalenceTestBase.cs | 6 +-
.../Search/ShardSearchingTestBase.cs | 6 +-
.../Util/LuceneTestCase.cs | 11 +-
src/Lucene.Net.TestFramework/Util/TestUtil.cs | 9 +-
.../Util/fst/FSTTester.cs | 2 +-
src/Lucene.Net.Tests/Lucene.Net.Tests.csproj | 36 +
.../core/Analysis/TestCharFilter.cs | 4 +-
.../core/Analysis/TestGraphTokenizers.cs | 18 +-
.../core/Analysis/TestLookaheadTokenFilter.cs | 6 +-
.../core/Analysis/TestMockAnalyzer.cs | 6 +-
.../core/Analysis/TestMockCharFilter.cs | 2 +-
src/Lucene.Net.Tests/core/Analysis/TestToken.cs | 4 +-
src/Lucene.Net.Tests/core/App.config | 3 +
src/Lucene.Net.Tests/core/AssemblyInfo.cs | 3 +
.../Compressing/AbstractTestCompressionMode.cs | 60 +-
.../AbstractTestLZ4CompressionMode.cs | 14 +-
.../Compressing/TestFastDecompressionMode.cs | 6 +-
.../Codecs/Lucene41/TestBlockPostingsFormat3.cs | 4 +-
.../core/Codecs/Lucene41/TestForUtil.cs | 4 +-
.../core/Document/TestBinaryDocument.cs | 6 +-
.../core/Document/TestDocument.cs | 2 +-
src/Lucene.Net.Tests/core/Document/TestField.cs | 2 +-
.../Facet/AssertingSubDocsAtOnceCollector.cs | 85 ++
.../core/Facet/FacetTestCase.cs | 293 ++++
.../core/Facet/Range/TestRangeFacetCounts.cs | 1174 +++++++++++++++
.../core/Facet/SlowRAMDirectory.cs | 261 ++++
.../SortedSet/TestSortedSetDocValuesFacets.cs | 394 ++++++
.../Facet/Taxonomy/Directory/TestAddTaxonomy.cs | 323 +++++
.../Directory/TestConcurrentFacetedIndexing.cs | 228 +++
.../Directory/TestDirectoryTaxonomyReader.cs | 624 ++++++++
.../Directory/TestDirectoryTaxonomyWriter.cs | 588 ++++++++
.../Facet/Taxonomy/TestCachedOrdinalsReader.cs | 116 ++
.../core/Facet/Taxonomy/TestFacetLabel.cs | 360 +++++
.../core/Facet/Taxonomy/TestLRUHashMap.cs | 65 +
.../Taxonomy/TestSearcherTaxonomyManager.cs | 398 ++++++
.../core/Facet/Taxonomy/TestTaxonomyCombined.cs | 1185 ++++++++++++++++
.../Taxonomy/TestTaxonomyFacetAssociations.cs | 278 ++++
.../Facet/Taxonomy/TestTaxonomyFacetCounts.cs | 851 +++++++++++
.../Facet/Taxonomy/TestTaxonomyFacetCounts2.cs | 403 ++++++
.../Taxonomy/TestTaxonomyFacetSumValueSource.cs | 610 ++++++++
.../Taxonomy/WriterCache/TestCharBlockArray.cs | 110 ++
.../WriterCache/TestCompactLabelToOrdinal.cs | 151 ++
.../core/Facet/TestDrillDownQuery.cs | 282 ++++
.../core/Facet/TestDrillSideways.cs | 1332 ++++++++++++++++++
.../core/Facet/TestFacetsConfig.cs | 131 ++
.../core/Facet/TestMultipleIndexFields.cs | 300 ++++
.../Facet/TestRandomSamplingFacetsCollector.cs | 154 ++
.../core/Index/Test2BBinaryDocValues.cs | 24 +-
.../core/Index/Test2BSortedDocValues.cs | 28 +-
src/Lucene.Net.Tests/core/Index/Test2BTerms.cs | 2 +-
.../core/Index/Test4GBStoredFields.cs | 4 +-
.../core/Index/TestBinaryDocValuesUpdates.cs | 6 +-
.../core/Index/TestBinaryTerms.cs | 10 +-
src/Lucene.Net.Tests/core/Index/TestCodecs.cs | 4 +-
.../core/Index/TestConsistentFieldNumbers.cs | 4 +-
.../core/Index/TestDirectoryReader.cs | 2 +-
.../Index/TestDocInverterPerFieldErrorInfo.cs | 2 +-
.../core/Index/TestDocValuesIndexing.cs | 8 +-
.../core/Index/TestDocumentWriter.cs | 8 +-
.../core/Index/TestIndexWriter.cs | 12 +-
.../core/Index/TestIndexWriterCommit.cs | 4 +-
.../core/Index/TestIndexWriterDelete.cs | 2 +-
.../core/Index/TestIndexWriterExceptions.cs | 20 +-
.../core/Index/TestIndexWriterUnicode.cs | 4 +-
.../core/Index/TestIndexableField.cs | 4 +-
.../core/Index/TestLazyProxSkipping.cs | 2 +-
.../core/Index/TestMultiLevelSkipList.cs | 6 +-
.../core/Index/TestNRTThreads.cs | 6 +-
src/Lucene.Net.Tests/core/Index/TestPayloads.cs | 54 +-
.../core/Index/TestTermVectorsReader.cs | 2 +-
.../core/Index/TestTermdocPerf.cs | 2 +-
.../core/Search/FuzzyTermOnShortTermsTest.cs | 2 +-
.../core/Search/Payloads/PayloadHelper.cs | 10 +-
.../Search/Payloads/TestPayloadNearQuery.cs | 8 +-
.../Search/Payloads/TestPayloadTermQuery.cs | 12 +-
.../core/Search/Spans/JustCompileSearchSpans.cs | 4 +-
.../core/Search/Spans/MultiSpansWrapper.cs | 10 +-
.../core/Search/Spans/TestBasics.cs | 14 +-
.../core/Search/Spans/TestPayloadSpans.cs | 38 +-
.../core/Search/TestPhraseQuery.cs | 2 +-
.../core/Search/TestPositionIncrement.cs | 12 +-
.../core/Search/TestSearcherManager.cs | 8 +-
.../core/Search/TestShardSearching.cs | 2 +-
.../core/Search/TestTermRangeQuery.cs | 2 +-
.../core/Store/TestMultiMMap.cs | 26 +-
.../Util/Automaton/TestDeterminizeLexicon.cs | 2 +-
.../core/Util/Automaton/TestUTF32ToUTF8.cs | 6 +-
src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs | 4 +-
.../core/Util/Test2BPagedBytes.cs | 4 +-
src/Lucene.Net.Tests/core/Util/TestBytesRef.cs | 6 +-
.../core/Util/TestBytesRefHash.cs | 4 +-
.../core/Util/TestQueryBuilder.cs | 10 +-
.../Util/TestRecyclingByteBlockAllocator.cs | 22 +-
.../core/Util/TestUnicodeUtil.cs | 8 +-
src/mainpage.dox | 9 -
395 files changed, 27639 insertions(+), 4098 deletions(-)
----------------------------------------------------------------------