You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2016/10/02 10:16:42 UTC
[11/49] lucenenet git commit: .NETify FST: Private/protected fields
should be camelCase.
.NETify FST: Private/protected fields should be camelCase.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/b8db797b
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/b8db797b
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/b8db797b
Branch: refs/heads/master
Commit: b8db797ba917041dabe034e3ddf5960dd14fc04a
Parents: dfa2310
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Wed Sep 7 17:28:33 2016 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Thu Sep 8 06:40:52 2016 +0700
----------------------------------------------------------------------
src/Lucene.Net.Core/Util/Fst/Builder.cs | 164 +++++++--------
.../Util/Fst/ByteSequenceOutputs.cs | 4 +-
src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs | 44 ++--
src/Lucene.Net.Core/Util/Fst/BytesStore.cs | 180 ++++++++--------
.../Util/Fst/CharSequenceOutputs.cs | 4 +-
src/Lucene.Net.Core/Util/Fst/FST.cs | 206 ++++++++++---------
src/Lucene.Net.Core/Util/Fst/FSTEnum.cs | 190 ++++++++---------
.../Util/Fst/ForwardBytesReader.cs | 18 +-
.../Util/Fst/IntSequenceOutputs.cs | 4 +-
src/Lucene.Net.Core/Util/Fst/IntsRefFSTEnum.cs | 44 ++--
src/Lucene.Net.Core/Util/Fst/NoOutputs.cs | 4 +-
src/Lucene.Net.Core/Util/Fst/NodeHash.cs | 84 ++++----
src/Lucene.Net.Core/Util/Fst/PairOutputs.cs | 44 ++--
.../Util/Fst/ReverseBytesReader.cs | 16 +-
src/Lucene.Net.Core/Util/Fst/Util.cs | 54 ++---
15 files changed, 531 insertions(+), 529 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b8db797b/src/Lucene.Net.Core/Util/Fst/Builder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/Builder.cs b/src/Lucene.Net.Core/Util/Fst/Builder.cs
index a566625..540b913 100644
--- a/src/Lucene.Net.Core/Util/Fst/Builder.cs
+++ b/src/Lucene.Net.Core/Util/Fst/Builder.cs
@@ -49,36 +49,36 @@ namespace Lucene.Net.Util.Fst
public class Builder<T>
{
- private readonly NodeHash<T> DedupHash;
- private readonly FST<T> Fst;
+ private readonly NodeHash<T> dedupHash;
+ private readonly FST<T> fst;
private readonly T NO_OUTPUT;
// private static final boolean DEBUG = true;
// simplistic pruning: we prune node (and all following
// nodes) if less than this number of terms go through it:
- private readonly int MinSuffixCount1;
+ private readonly int minSuffixCount1;
// better pruning: we prune node (and all following
// nodes) if the prior node has less than this number of
// terms go through it:
- private readonly int MinSuffixCount2;
+ private readonly int minSuffixCount2;
- private readonly bool DoShareNonSingletonNodes;
- private readonly int ShareMaxTailLength;
+ private readonly bool doShareNonSingletonNodes;
+ private readonly int shareMaxTailLength;
- private readonly IntsRef LastInput = new IntsRef();
+ private readonly IntsRef lastInput = new IntsRef();
// for packing
- private readonly bool DoPackFST;
+ private readonly bool doPackFST;
- private readonly float AcceptableOverheadRatio;
+ private readonly float acceptableOverheadRatio;
// NOTE: cutting this over to ArrayList instead loses ~6%
// in build performance on 9.8M Wikipedia terms; so we
// left this as an array:
// current "frontier"
- private UnCompiledNode<T>[] Frontier;
+ private UnCompiledNode<T>[] frontier;
/// <summary>
/// Expert: this is invoked by Builder whenever a suffix
@@ -89,7 +89,7 @@ namespace Lucene.Net.Util.Fst
public abstract void Freeze(UnCompiledNode<S>[] frontier, int prefixLenPlus1, IntsRef prevInput);
}
- private readonly FreezeTail<T> FreezeTail_Renamed;
+ private readonly FreezeTail<T> freezeTail;
/// <summary>
/// Instantiates an FST/FSA builder without any pruning. A shortcut
@@ -154,29 +154,29 @@ namespace Lucene.Net.Util.Fst
/// bits = 32768 byte pages. </param>
public Builder(FST<T>.INPUT_TYPE inputType, int minSuffixCount1, int minSuffixCount2, bool doShareSuffix, bool doShareNonSingletonNodes, int shareMaxTailLength, Outputs<T> outputs, FreezeTail<T> freezeTail, bool doPackFST, float acceptableOverheadRatio, bool allowArrayArcs, int bytesPageBits)
{
- this.MinSuffixCount1 = minSuffixCount1;
- this.MinSuffixCount2 = minSuffixCount2;
- this.FreezeTail_Renamed = freezeTail;
- this.DoShareNonSingletonNodes = doShareNonSingletonNodes;
- this.ShareMaxTailLength = shareMaxTailLength;
- this.DoPackFST = doPackFST;
- this.AcceptableOverheadRatio = acceptableOverheadRatio;
- Fst = new FST<T>(inputType, outputs, doPackFST, acceptableOverheadRatio, allowArrayArcs, bytesPageBits);
+ this.minSuffixCount1 = minSuffixCount1;
+ this.minSuffixCount2 = minSuffixCount2;
+ this.freezeTail = freezeTail;
+ this.doShareNonSingletonNodes = doShareNonSingletonNodes;
+ this.shareMaxTailLength = shareMaxTailLength;
+ this.doPackFST = doPackFST;
+ this.acceptableOverheadRatio = acceptableOverheadRatio;
+ fst = new FST<T>(inputType, outputs, doPackFST, acceptableOverheadRatio, allowArrayArcs, bytesPageBits);
if (doShareSuffix)
{
- DedupHash = new NodeHash<T>(Fst, Fst.Bytes.GetReverseReader(false));
+ dedupHash = new NodeHash<T>(fst, fst.Bytes.GetReverseReader(false));
}
else
{
- DedupHash = null;
+ dedupHash = null;
}
NO_OUTPUT = outputs.NoOutput;
UnCompiledNode<T>[] f = (UnCompiledNode<T>[])new UnCompiledNode<T>[10];
- Frontier = f;
- for (int idx = 0; idx < Frontier.Length; idx++)
+ frontier = f;
+ for (int idx = 0; idx < frontier.Length; idx++)
{
- Frontier[idx] = new UnCompiledNode<T>(this, idx);
+ frontier[idx] = new UnCompiledNode<T>(this, idx);
}
}
@@ -184,7 +184,7 @@ namespace Lucene.Net.Util.Fst
{
get
{
- return Fst.nodeCount;
+ return fst.nodeCount;
}
}
@@ -192,7 +192,7 @@ namespace Lucene.Net.Util.Fst
{
get
{
- return Frontier[0].InputCount;
+ return frontier[0].InputCount;
}
}
@@ -200,27 +200,27 @@ namespace Lucene.Net.Util.Fst
{
get
{
- return DedupHash == null ? 0 : Fst.nodeCount;
+ return dedupHash == null ? 0 : fst.nodeCount;
}
}
private CompiledNode CompileNode(UnCompiledNode<T> nodeIn, int tailLength)
{
long node;
- if (DedupHash != null && (DoShareNonSingletonNodes || nodeIn.NumArcs <= 1) && tailLength <= ShareMaxTailLength)
+ if (dedupHash != null && (doShareNonSingletonNodes || nodeIn.NumArcs <= 1) && tailLength <= shareMaxTailLength)
{
if (nodeIn.NumArcs == 0)
{
- node = Fst.AddNode(nodeIn);
+ node = fst.AddNode(nodeIn);
}
else
{
- node = DedupHash.Add(nodeIn);
+ node = dedupHash.Add(nodeIn);
}
}
else
{
- node = Fst.AddNode(nodeIn);
+ node = fst.AddNode(nodeIn);
}
Debug.Assert(node != -2);
@@ -233,24 +233,24 @@ namespace Lucene.Net.Util.Fst
private void DoFreezeTail(int prefixLenPlus1)
{
- if (FreezeTail_Renamed != null)
+ if (freezeTail != null)
{
// Custom plugin:
- FreezeTail_Renamed.Freeze(Frontier, prefixLenPlus1, LastInput);
+ freezeTail.Freeze(frontier, prefixLenPlus1, lastInput);
}
else
{
//System.out.println(" compileTail " + prefixLenPlus1);
int downTo = Math.Max(1, prefixLenPlus1);
- for (int idx = LastInput.Length; idx >= downTo; idx--)
+ for (int idx = lastInput.Length; idx >= downTo; idx--)
{
bool doPrune = false;
bool doCompile = false;
- UnCompiledNode<T> node = Frontier[idx];
- UnCompiledNode<T> parent = Frontier[idx - 1];
+ UnCompiledNode<T> node = frontier[idx];
+ UnCompiledNode<T> parent = frontier[idx - 1];
- if (node.InputCount < MinSuffixCount1)
+ if (node.InputCount < minSuffixCount1)
{
doPrune = true;
doCompile = true;
@@ -258,7 +258,7 @@ namespace Lucene.Net.Util.Fst
else if (idx > prefixLenPlus1)
{
// prune if parent's inputCount is less than suffixMinCount2
- if (parent.InputCount < MinSuffixCount2 || (MinSuffixCount2 == 1 && parent.InputCount == 1 && idx > 1))
+ if (parent.InputCount < minSuffixCount2 || (minSuffixCount2 == 1 && parent.InputCount == 1 && idx > 1))
{
// my parent, about to be compiled, doesn't make the cut, so
// I'm definitely pruned
@@ -284,12 +284,12 @@ namespace Lucene.Net.Util.Fst
{
// if pruning is disabled (count is 0) we can always
// compile current node
- doCompile = MinSuffixCount2 == 0;
+ doCompile = minSuffixCount2 == 0;
}
//System.out.println(" label=" + ((char) lastInput.ints[lastInput.offset+idx-1]) + " idx=" + idx + " inputCount=" + frontier[idx].inputCount + " doCompile=" + doCompile + " doPrune=" + doPrune);
- if (node.InputCount < MinSuffixCount2 || (MinSuffixCount2 == 1 && node.InputCount == 1 && idx > 1))
+ if (node.InputCount < minSuffixCount2 || (minSuffixCount2 == 1 && node.InputCount == 1 && idx > 1))
{
// drop all arcs
for (int arcIdx = 0; arcIdx < node.NumArcs; arcIdx++)
@@ -304,13 +304,13 @@ namespace Lucene.Net.Util.Fst
{
// this node doesn't make it -- deref it
node.Clear();
- parent.DeleteLast(LastInput.Ints[LastInput.Offset + idx - 1], node);
+ parent.DeleteLast(lastInput.Ints[lastInput.Offset + idx - 1], node);
}
else
{
- if (MinSuffixCount2 != 0)
+ if (minSuffixCount2 != 0)
{
- CompileAllTargets(node, LastInput.Length - idx);
+ CompileAllTargets(node, lastInput.Length - idx);
}
T nextFinalOutput = node.Output;
@@ -326,18 +326,18 @@ namespace Lucene.Net.Util.Fst
// this node makes it and we now compile it. first,
// compile any targets that were previously
// undecided:
- parent.ReplaceLast(LastInput.Ints[LastInput.Offset + idx - 1], CompileNode(node, 1 + LastInput.Length - idx), nextFinalOutput, isFinal);
+ parent.ReplaceLast(lastInput.Ints[lastInput.Offset + idx - 1], CompileNode(node, 1 + lastInput.Length - idx), nextFinalOutput, isFinal);
}
else
{
// replaceLast just to install
// nextFinalOutput/isFinal onto the arc
- parent.ReplaceLast(LastInput.Ints[LastInput.Offset + idx - 1], node, nextFinalOutput, isFinal);
+ parent.ReplaceLast(lastInput.Ints[lastInput.Offset + idx - 1], node, nextFinalOutput, isFinal);
// this node will stay in play for now, since we are
// undecided on whether to prune it. later, it
// will be either compiled or pruned, so we must
// allocate a new node:
- Frontier[idx] = new UnCompiledNode<T>(this, idx);
+ frontier[idx] = new UnCompiledNode<T>(this, idx);
}
}
}
@@ -400,21 +400,21 @@ namespace Lucene.Net.Util.Fst
// format cannot represent the empty input since
// 'finalness' is stored on the incoming arc, not on
// the node
- Frontier[0].InputCount++;
- Frontier[0].IsFinal = true;
- Fst.EmptyOutput = output;
+ frontier[0].InputCount++;
+ frontier[0].IsFinal = true;
+ fst.EmptyOutput = output;
return;
}
// compare shared prefix length
int pos1 = 0;
int pos2 = input.Offset;
- int pos1Stop = Math.Min(LastInput.Length, input.Length);
+ int pos1Stop = Math.Min(lastInput.Length, input.Length);
while (true)
{
- Frontier[pos1].InputCount++;
+ frontier[pos1].InputCount++;
//System.out.println(" incr " + pos1 + " ct=" + frontier[pos1].inputCount + " n=" + frontier[pos1]);
- if (pos1 >= pos1Stop || LastInput.Ints[pos1] != input.Ints[pos2])
+ if (pos1 >= pos1Stop || lastInput.Ints[pos1] != input.Ints[pos2])
{
break;
}
@@ -423,15 +423,15 @@ namespace Lucene.Net.Util.Fst
}
int prefixLenPlus1 = pos1 + 1;
- if (Frontier.Length < input.Length + 1)
+ if (frontier.Length < input.Length + 1)
{
UnCompiledNode<T>[] next = new UnCompiledNode<T>[ArrayUtil.Oversize(input.Length + 1, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
- Array.Copy(Frontier, 0, next, 0, Frontier.Length);
- for (int idx = Frontier.Length; idx < next.Length; idx++)
+ Array.Copy(frontier, 0, next, 0, frontier.Length);
+ for (int idx = frontier.Length; idx < next.Length; idx++)
{
next[idx] = new UnCompiledNode<T>(this, idx);
}
- Frontier = next;
+ frontier = next;
}
// minimize/compile states from previous input's
@@ -441,12 +441,12 @@ namespace Lucene.Net.Util.Fst
// init tail states for current input
for (int idx = prefixLenPlus1; idx <= input.Length; idx++)
{
- Frontier[idx - 1].AddArc(input.Ints[input.Offset + idx - 1], Frontier[idx]);
- Frontier[idx].InputCount++;
+ frontier[idx - 1].AddArc(input.Ints[input.Offset + idx - 1], frontier[idx]);
+ frontier[idx].InputCount++;
}
- UnCompiledNode<T> lastNode = Frontier[input.Length];
- if (LastInput.Length != input.Length || prefixLenPlus1 != input.Length + 1)
+ UnCompiledNode<T> lastNode = frontier[input.Length];
+ if (lastInput.Length != input.Length || prefixLenPlus1 != input.Length + 1)
{
lastNode.IsFinal = true;
lastNode.Output = NO_OUTPUT;
@@ -456,8 +456,8 @@ namespace Lucene.Net.Util.Fst
// needed
for (int idx = 1; idx < prefixLenPlus1; idx++)
{
- UnCompiledNode<T> node = Frontier[idx];
- UnCompiledNode<T> parentNode = Frontier[idx - 1];
+ UnCompiledNode<T> node = frontier[idx];
+ UnCompiledNode<T> parentNode = frontier[idx - 1];
T lastOutput = parentNode.GetLastOutput(input.Ints[input.Offset + idx - 1]);
Debug.Assert(ValidOutput(lastOutput));
@@ -467,9 +467,9 @@ namespace Lucene.Net.Util.Fst
if (!lastOutput.Equals(NO_OUTPUT))
{
- commonOutputPrefix = Fst.Outputs.Common(output, lastOutput);
+ commonOutputPrefix = fst.Outputs.Common(output, lastOutput);
Debug.Assert(ValidOutput(commonOutputPrefix));
- wordSuffix = Fst.Outputs.Subtract(lastOutput, commonOutputPrefix);
+ wordSuffix = fst.Outputs.Subtract(lastOutput, commonOutputPrefix);
Debug.Assert(ValidOutput(wordSuffix));
parentNode.SetLastOutput(input.Ints[input.Offset + idx - 1], commonOutputPrefix);
node.PrependOutput(wordSuffix);
@@ -479,25 +479,25 @@ namespace Lucene.Net.Util.Fst
commonOutputPrefix = wordSuffix = NO_OUTPUT;
}
- output = Fst.Outputs.Subtract(output, commonOutputPrefix);
+ output = fst.Outputs.Subtract(output, commonOutputPrefix);
Debug.Assert(ValidOutput(output));
}
- if (LastInput.Length == input.Length && prefixLenPlus1 == 1 + input.Length)
+ if (lastInput.Length == input.Length && prefixLenPlus1 == 1 + input.Length)
{
// same input more than 1 time in a row, mapping to
// multiple outputs
- lastNode.Output = Fst.Outputs.Merge(lastNode.Output, output);
+ lastNode.Output = fst.Outputs.Merge(lastNode.Output, output);
}
else
{
// this new arc is private to this new input; set its
// arc output to the leftover output:
- Frontier[prefixLenPlus1 - 1].SetLastOutput(input.Ints[input.Offset + prefixLenPlus1 - 1], output);
+ frontier[prefixLenPlus1 - 1].SetLastOutput(input.Ints[input.Offset + prefixLenPlus1 - 1], output);
}
// save last input
- LastInput.CopyInts(input);
+ lastInput.CopyInts(input);
//System.out.println(" count[0]=" + frontier[0].inputCount);
}
@@ -513,17 +513,17 @@ namespace Lucene.Net.Util.Fst
/// </summary>
public virtual FST<T> Finish()
{
- UnCompiledNode<T> root = Frontier[0];
+ UnCompiledNode<T> root = frontier[0];
// minimize nodes in the last word's suffix
DoFreezeTail(0);
- if (root.InputCount < MinSuffixCount1 || root.InputCount < MinSuffixCount2 || root.NumArcs == 0)
+ if (root.InputCount < minSuffixCount1 || root.InputCount < minSuffixCount2 || root.NumArcs == 0)
{
- if (Fst.emptyOutput == null)
+ if (fst.emptyOutput == null)
{
return null;
}
- else if (MinSuffixCount1 > 0 || MinSuffixCount2 > 0)
+ else if (minSuffixCount1 > 0 || minSuffixCount2 > 0)
{
// empty string got pruned
return null;
@@ -531,21 +531,21 @@ namespace Lucene.Net.Util.Fst
}
else
{
- if (MinSuffixCount2 != 0)
+ if (minSuffixCount2 != 0)
{
- CompileAllTargets(root, LastInput.Length);
+ CompileAllTargets(root, lastInput.Length);
}
}
//if (DEBUG) System.out.println(" builder.finish root.isFinal=" + root.isFinal + " root.Output=" + root.Output);
- Fst.Finish(CompileNode(root, LastInput.Length).Node);
+ fst.Finish(CompileNode(root, lastInput.Length).Node);
- if (DoPackFST)
+ if (doPackFST)
{
- return Fst.Pack(3, Math.Max(10, (int)(Fst.NodeCount / 4)), AcceptableOverheadRatio);
+ return fst.Pack(3, Math.Max(10, (int)(fst.NodeCount / 4)), acceptableOverheadRatio);
}
else
{
- return Fst;
+ return fst;
}
}
@@ -590,7 +590,7 @@ namespace Lucene.Net.Util.Fst
public virtual long FstSizeInBytes()
{
- return Fst.SizeInBytes();
+ return fst.SizeInBytes();
}
public sealed class CompiledNode : Node
@@ -726,13 +726,13 @@ namespace Lucene.Net.Util.Fst
for (int arcIdx = 0; arcIdx < NumArcs; arcIdx++)
{
- Arcs[arcIdx].Output = Owner.Fst.Outputs.Add(outputPrefix, Arcs[arcIdx].Output);
+ Arcs[arcIdx].Output = Owner.fst.Outputs.Add(outputPrefix, Arcs[arcIdx].Output);
Debug.Assert(Owner.ValidOutput(Arcs[arcIdx].Output));
}
if (IsFinal)
{
- Output = Owner.Fst.Outputs.Add(outputPrefix, Output);
+ Output = Owner.fst.Outputs.Add(outputPrefix, Output);
Debug.Assert(Owner.ValidOutput(Output));
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b8db797b/src/Lucene.Net.Core/Util/Fst/ByteSequenceOutputs.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/ByteSequenceOutputs.cs b/src/Lucene.Net.Core/Util/Fst/ByteSequenceOutputs.cs
index 08ca319..1d09ce2 100644
--- a/src/Lucene.Net.Core/Util/Fst/ByteSequenceOutputs.cs
+++ b/src/Lucene.Net.Core/Util/Fst/ByteSequenceOutputs.cs
@@ -33,7 +33,7 @@ namespace Lucene.Net.Util.Fst
public sealed class ByteSequenceOutputs : Outputs<BytesRef>
{
private static readonly BytesRef NO_OUTPUT = new BytesRef();
- private static readonly ByteSequenceOutputs Singleton_Renamed = new ByteSequenceOutputs();
+ private static readonly ByteSequenceOutputs singleton = new ByteSequenceOutputs();
private ByteSequenceOutputs()
{
@@ -43,7 +43,7 @@ namespace Lucene.Net.Util.Fst
{
get
{
- return Singleton_Renamed;
+ return singleton;
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b8db797b/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs b/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs
index 9be4680..6774b21 100644
--- a/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs
+++ b/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs
@@ -28,9 +28,9 @@ namespace Lucene.Net.Util.Fst
public sealed class BytesRefFSTEnum<T> : FSTEnum<T>
{
- private readonly BytesRef Current_Renamed = new BytesRef(10);
- private readonly InputOutput<T> Result = new InputOutput<T>();
- private BytesRef Target;
+ private readonly BytesRef current = new BytesRef(10);
+ private readonly InputOutput<T> result = new InputOutput<T>();
+ private BytesRef target;
/// <summary>
/// Holds a single input (BytesRef) + output pair. </summary>
@@ -48,13 +48,13 @@ namespace Lucene.Net.Util.Fst
public BytesRefFSTEnum(FST<T> fst)
: base(fst)
{
- Result.Input = Current_Renamed;
- Current_Renamed.Offset = 1;
+ result.Input = current;
+ current.Offset = 1;
}
public InputOutput<T> Current()
{
- return Result;
+ return result;
}
public InputOutput<T> Next()
@@ -68,8 +68,8 @@ namespace Lucene.Net.Util.Fst
/// Seeks to smallest term that's >= target. </summary>
public InputOutput<T> SeekCeil(BytesRef target)
{
- this.Target = target;
- TargetLength = target.Length;
+ this.target = target;
+ targetLength = target.Length;
base.DoSeekCeil();
return SetResult();
}
@@ -78,8 +78,8 @@ namespace Lucene.Net.Util.Fst
/// Seeks to biggest term that's <= target. </summary>
public InputOutput<T> SeekFloor(BytesRef target)
{
- this.Target = target;
- TargetLength = target.Length;
+ this.target = target;
+ targetLength = target.Length;
base.DoSeekFloor();
return SetResult();
}
@@ -92,11 +92,11 @@ namespace Lucene.Net.Util.Fst
/// </summary>
public InputOutput<T> SeekExact(BytesRef target)
{
- this.Target = target;
- TargetLength = target.Length;
+ this.target = target;
+ targetLength = target.Length;
if (base.DoSeekExact())
{
- Debug.Assert(Upto == 1 + target.Length);
+ Debug.Assert(upto == 1 + target.Length);
return SetResult();
}
else
@@ -109,13 +109,13 @@ namespace Lucene.Net.Util.Fst
{
get
{
- if (Upto - 1 == Target.Length)
+ if (upto - 1 == target.Length)
{
return FST<T>.END_LABEL;
}
else
{
- return Target.Bytes[Target.Offset + Upto - 1] & 0xFF;
+ return target.Bytes[target.Offset + upto - 1] & 0xFF;
}
}
}
@@ -125,30 +125,30 @@ namespace Lucene.Net.Util.Fst
get
{
// current.offset fixed at 1
- return Current_Renamed.Bytes[Upto] & 0xFF;
+ return current.Bytes[upto] & 0xFF;
}
set
{
- Current_Renamed.Bytes[Upto] = (byte)value;
+ current.Bytes[upto] = (byte)value;
}
}
protected internal override void Grow()
{
- Current_Renamed.Bytes = ArrayUtil.Grow(Current_Renamed.Bytes, Upto + 1);
+ current.Bytes = ArrayUtil.Grow(current.Bytes, upto + 1);
}
private InputOutput<T> SetResult()
{
- if (Upto == 0)
+ if (upto == 0)
{
return null;
}
else
{
- Current_Renamed.Length = Upto - 1;
- Result.Output = Output[Upto];
- return Result;
+ current.Length = upto - 1;
+ result.Output = output[upto];
+ return result;
}
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b8db797b/src/Lucene.Net.Core/Util/Fst/BytesStore.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/BytesStore.cs b/src/Lucene.Net.Core/Util/Fst/BytesStore.cs
index b23da69..26bc85a 100644
--- a/src/Lucene.Net.Core/Util/Fst/BytesStore.cs
+++ b/src/Lucene.Net.Core/Util/Fst/BytesStore.cs
@@ -29,21 +29,21 @@ namespace Lucene.Net.Util.Fst
internal class BytesStore : DataOutput
{
- private readonly List<byte[]> Blocks = new List<byte[]>();
+ private readonly List<byte[]> blocks = new List<byte[]>();
- private readonly int BlockSize;
+ private readonly int blockSize;
private readonly int blockBits;
- private readonly int BlockMask;
+ private readonly int blockMask;
- private byte[] Current;
- private int NextWrite;
+ private byte[] current;
+ private int nextWrite;
public BytesStore(int blockBits)
{
this.blockBits = blockBits;
- BlockSize = 1 << blockBits;
- BlockMask = BlockSize - 1;
- NextWrite = BlockSize;
+ blockSize = 1 << blockBits;
+ blockMask = blockSize - 1;
+ nextWrite = blockSize;
}
/// <summary>
@@ -58,20 +58,20 @@ namespace Lucene.Net.Util.Fst
blockBits++;
}
this.blockBits = blockBits;
- this.BlockSize = blockSize;
- this.BlockMask = blockSize - 1;
+ this.blockSize = blockSize;
+ this.blockMask = blockSize - 1;
long left = numBytes;
while (left > 0)
{
int chunk = (int)Math.Min(blockSize, left);
byte[] block = new byte[chunk];
@in.ReadBytes(block, 0, block.Length);
- Blocks.Add(block);
+ blocks.Add(block);
left -= chunk;
}
// So .getPosition still works
- NextWrite = Blocks[Blocks.Count - 1].Length;
+ nextWrite = blocks[blocks.Count - 1].Length;
}
/// <summary>
@@ -81,43 +81,43 @@ namespace Lucene.Net.Util.Fst
public virtual void WriteByte(int dest, byte b)
{
int blockIndex = dest >> blockBits;
- byte[] block = Blocks[blockIndex];
- block[dest & BlockMask] = b;
+ byte[] block = blocks[blockIndex];
+ block[dest & blockMask] = b;
}
public override void WriteByte(byte b)
{
- if (NextWrite == BlockSize)
+ if (nextWrite == blockSize)
{
- Current = new byte[BlockSize];
- Blocks.Add(Current);
- NextWrite = 0;
+ current = new byte[blockSize];
+ blocks.Add(current);
+ nextWrite = 0;
}
- Current[NextWrite++] = b;
+ current[nextWrite++] = b;
}
public override void WriteBytes(byte[] b, int offset, int len)
{
while (len > 0)
{
- int chunk = BlockSize - NextWrite;
+ int chunk = blockSize - nextWrite;
if (len <= chunk)
{
- System.Buffer.BlockCopy(b, offset, Current, NextWrite, len);
- NextWrite += len;
+ System.Buffer.BlockCopy(b, offset, current, nextWrite, len);
+ nextWrite += len;
break;
}
else
{
if (chunk > 0)
{
- Array.Copy(b, offset, Current, NextWrite, chunk);
+ Array.Copy(b, offset, current, nextWrite, chunk);
offset += chunk;
len -= chunk;
}
- Current = new byte[BlockSize];
- Blocks.Add(Current);
- NextWrite = 0;
+ current = new byte[blockSize];
+ blocks.Add(current);
+ nextWrite = 0;
}
}
}
@@ -168,13 +168,13 @@ namespace Lucene.Net.Util.Fst
long end = dest + len;
int blockIndex = (int)(end >> blockBits);
- int downTo = (int)(end & BlockMask);
+ int downTo = (int)(end & blockMask);
if (downTo == 0)
{
blockIndex--;
- downTo = BlockSize;
+ downTo = blockSize;
}
- byte[] block = Blocks[blockIndex];
+ byte[] block = blocks[blockIndex];
while (len > 0)
{
@@ -191,8 +191,8 @@ namespace Lucene.Net.Util.Fst
//System.out.println(" partial: offset=" + (offset + len) + " len=" + downTo + " dest=0");
Array.Copy(b, offset + len, block, 0, downTo);
blockIndex--;
- block = Blocks[blockIndex];
- downTo = BlockSize;
+ block = blocks[blockIndex];
+ downTo = blockSize;
}
}
}
@@ -236,13 +236,13 @@ namespace Lucene.Net.Util.Fst
long end = src + len;
int blockIndex = (int)(end >> blockBits);
- int downTo = (int)(end & BlockMask);
+ int downTo = (int)(end & blockMask);
if (downTo == 0)
{
blockIndex--;
- downTo = BlockSize;
+ downTo = blockSize;
}
- byte[] block = Blocks[blockIndex];
+ byte[] block = blocks[blockIndex];
while (len > 0)
{
@@ -259,8 +259,8 @@ namespace Lucene.Net.Util.Fst
len -= downTo;
WriteBytes(dest + len, block, 0, downTo);
blockIndex--;
- block = Blocks[blockIndex];
- downTo = BlockSize;
+ block = blocks[blockIndex];
+ downTo = blockSize;
}
}
}
@@ -272,18 +272,18 @@ namespace Lucene.Net.Util.Fst
public virtual void WriteInt(long pos, int value)
{
int blockIndex = (int)(pos >> blockBits);
- int upto = (int)(pos & BlockMask);
- byte[] block = Blocks[blockIndex];
+ int upto = (int)(pos & blockMask);
+ byte[] block = blocks[blockIndex];
int shift = 24;
for (int i = 0; i < 4; i++)
{
block[upto++] = (byte)(value >> shift);
shift -= 8;
- if (upto == BlockSize)
+ if (upto == blockSize)
{
upto = 0;
blockIndex++;
- block = Blocks[blockIndex];
+ block = blocks[blockIndex];
}
}
}
@@ -297,12 +297,12 @@ namespace Lucene.Net.Util.Fst
//System.out.println("reverse src=" + srcPos + " dest=" + destPos);
int srcBlockIndex = (int)(srcPos >> blockBits);
- int src = (int)(srcPos & BlockMask);
- byte[] srcBlock = Blocks[srcBlockIndex];
+ int src = (int)(srcPos & blockMask);
+ byte[] srcBlock = blocks[srcBlockIndex];
int destBlockIndex = (int)(destPos >> blockBits);
- int dest = (int)(destPos & BlockMask);
- byte[] destBlock = Blocks[destBlockIndex];
+ int dest = (int)(destPos & blockMask);
+ byte[] destBlock = blocks[destBlockIndex];
//System.out.println(" srcBlock=" + srcBlockIndex + " destBlock=" + destBlockIndex);
int limit = (int)(destPos - srcPos + 1) / 2;
@@ -313,10 +313,10 @@ namespace Lucene.Net.Util.Fst
srcBlock[src] = destBlock[dest];
destBlock[dest] = b;
src++;
- if (src == BlockSize)
+ if (src == blockSize)
{
srcBlockIndex++;
- srcBlock = Blocks[srcBlockIndex];
+ srcBlock = blocks[srcBlockIndex];
//System.out.println(" set destBlock=" + destBlock + " srcBlock=" + srcBlock);
src = 0;
}
@@ -325,9 +325,9 @@ namespace Lucene.Net.Util.Fst
if (dest == -1)
{
destBlockIndex--;
- destBlock = Blocks[destBlockIndex];
+ destBlock = blocks[destBlockIndex];
//System.out.println(" set destBlock=" + destBlock + " srcBlock=" + srcBlock);
- dest = BlockSize - 1;
+ dest = blockSize - 1;
}
}
}
@@ -336,18 +336,18 @@ namespace Lucene.Net.Util.Fst
{
while (len > 0)
{
- int chunk = BlockSize - NextWrite;
+ int chunk = blockSize - nextWrite;
if (len <= chunk)
{
- NextWrite += len;
+ nextWrite += len;
break;
}
else
{
len -= chunk;
- Current = new byte[BlockSize];
- Blocks.Add(Current);
- NextWrite = 0;
+ current = new byte[blockSize];
+ blocks.Add(current);
+ nextWrite = 0;
}
}
}
@@ -356,7 +356,7 @@ namespace Lucene.Net.Util.Fst
{
get
{
- return ((long)Blocks.Count - 1) * BlockSize + NextWrite;
+ return ((long)blocks.Count - 1) * blockSize + nextWrite;
}
}
@@ -369,32 +369,32 @@ namespace Lucene.Net.Util.Fst
Debug.Assert(newLen <= Position);
Debug.Assert(newLen >= 0);
int blockIndex = (int)(newLen >> blockBits);
- NextWrite = (int)(newLen & BlockMask);
- if (NextWrite == 0)
+ nextWrite = (int)(newLen & blockMask);
+ if (nextWrite == 0)
{
blockIndex--;
- NextWrite = BlockSize;
+ nextWrite = blockSize;
}
- Blocks.RemoveRange(blockIndex + 1, Blocks.Count - (blockIndex + 1));
+ blocks.RemoveRange(blockIndex + 1, blocks.Count - (blockIndex + 1));
if (newLen == 0)
{
- Current = null;
+ current = null;
}
else
{
- Current = Blocks[blockIndex];
+ current = blocks[blockIndex];
}
Debug.Assert(newLen == Position);
}
public virtual void Finish()
{
- if (Current != null)
+ if (current != null)
{
- byte[] lastBuffer = new byte[NextWrite];
- Array.Copy(Current, 0, lastBuffer, 0, NextWrite);
- Blocks[Blocks.Count - 1] = lastBuffer;
- Current = null;
+ byte[] lastBuffer = new byte[nextWrite];
+ Array.Copy(current, 0, lastBuffer, 0, nextWrite);
+ blocks[blocks.Count - 1] = lastBuffer;
+ current = null;
}
}
@@ -402,7 +402,7 @@ namespace Lucene.Net.Util.Fst
/// Writes all of our bytes to the target <seealso cref="DataOutput"/>. </summary>
public virtual void WriteTo(DataOutput @out)
{
- foreach (byte[] block in Blocks)
+ foreach (byte[] block in blocks)
{
@out.WriteBytes(block, 0, block.Length);
}
@@ -412,9 +412,9 @@ namespace Lucene.Net.Util.Fst
{
get
{
- if (Blocks.Count == 1)
+ if (blocks.Count == 1)
{
- return new ForwardBytesReader(Blocks[0]);
+ return new ForwardBytesReader(blocks[0]);
}
return new ForwardBytesReaderAnonymousInner(this);
}
@@ -422,12 +422,12 @@ namespace Lucene.Net.Util.Fst
private class ForwardBytesReaderAnonymousInner : FST.BytesReader
{
- private readonly BytesStore OuterInstance;
+ private readonly BytesStore outerInstance;
public ForwardBytesReaderAnonymousInner(BytesStore outerInstance)
{
- this.OuterInstance = outerInstance;
- nextRead = outerInstance.BlockSize;
+ this.outerInstance = outerInstance;
+ nextRead = outerInstance.blockSize;
}
private byte[] Current;
@@ -436,9 +436,9 @@ namespace Lucene.Net.Util.Fst
public override byte ReadByte()
{
- if (nextRead == OuterInstance.BlockSize)
+ if (nextRead == outerInstance.blockSize)
{
- Current = OuterInstance.Blocks[nextBuffer++];
+ Current = outerInstance.blocks[nextBuffer++];
nextRead = 0;
}
return Current[nextRead++];
@@ -453,7 +453,7 @@ namespace Lucene.Net.Util.Fst
{
while (len > 0)
{
- int chunkLeft = OuterInstance.BlockSize - nextRead;
+ int chunkLeft = outerInstance.blockSize - nextRead;
if (len <= chunkLeft)
{
Array.Copy(Current, nextRead, b, offset, len);
@@ -468,7 +468,7 @@ namespace Lucene.Net.Util.Fst
offset += chunkLeft;
len -= chunkLeft;
}
- Current = OuterInstance.Blocks[nextBuffer++];
+ Current = outerInstance.blocks[nextBuffer++];
nextRead = 0;
}
}
@@ -478,14 +478,14 @@ namespace Lucene.Net.Util.Fst
{
get
{
- return ((long)nextBuffer - 1) * OuterInstance.BlockSize + nextRead;
+ return ((long)nextBuffer - 1) * outerInstance.blockSize + nextRead;
}
set
{
- int bufferIndex = (int)(value >> OuterInstance.blockBits);
+ int bufferIndex = (int)(value >> outerInstance.blockBits);
nextBuffer = bufferIndex + 1;
- Current = OuterInstance.Blocks[bufferIndex];
- nextRead = (int)(value & OuterInstance.BlockMask);
+ Current = outerInstance.blocks[bufferIndex];
+ nextRead = (int)(value & outerInstance.blockMask);
Debug.Assert(this.Position == value, "pos=" + value + " getPos()=" + this.Position);
}
}
@@ -506,21 +506,21 @@ namespace Lucene.Net.Util.Fst
internal virtual FST.BytesReader GetReverseReader(bool allowSingle)
{
- if (allowSingle && Blocks.Count == 1)
+ if (allowSingle && blocks.Count == 1)
{
- return new ReverseBytesReader(Blocks[0]);
+ return new ReverseBytesReader(blocks[0]);
}
return new ReverseBytesReaderAnonymousInner(this);
}
private class ReverseBytesReaderAnonymousInner : FST.BytesReader
{
- private readonly BytesStore OuterInstance;
+ private readonly BytesStore outerInstance;
public ReverseBytesReaderAnonymousInner(BytesStore outerInstance)
{
- this.OuterInstance = outerInstance;
- Current = outerInstance.Blocks.Count == 0 ? null : outerInstance.Blocks[0];
+ this.outerInstance = outerInstance;
+ Current = outerInstance.blocks.Count == 0 ? null : outerInstance.blocks[0];
nextBuffer = -1;
nextRead = 0;
}
@@ -533,8 +533,8 @@ namespace Lucene.Net.Util.Fst
{
if (nextRead == -1)
{
- Current = OuterInstance.Blocks[nextBuffer--];
- nextRead = OuterInstance.BlockSize - 1;
+ Current = outerInstance.blocks[nextBuffer--];
+ nextRead = outerInstance.blockSize - 1;
}
return Current[nextRead--];
}
@@ -556,7 +556,7 @@ namespace Lucene.Net.Util.Fst
{
get
{
- return ((long)nextBuffer + 1) * OuterInstance.BlockSize + nextRead;
+ return ((long)nextBuffer + 1) * outerInstance.blockSize + nextRead;
}
set
{
@@ -564,10 +564,10 @@ namespace Lucene.Net.Util.Fst
// setPosition(0), the next byte you read is
// bytes[0] ... but I would expect bytes[-1] (ie,
// EOF)...?
- int bufferIndex = (int)(value >> OuterInstance.blockBits);
+ int bufferIndex = (int)(value >> outerInstance.blockBits);
nextBuffer = bufferIndex - 1;
- Current = OuterInstance.Blocks[bufferIndex];
- nextRead = (int)(value & OuterInstance.BlockMask);
+ Current = outerInstance.blocks[bufferIndex];
+ nextRead = (int)(value & outerInstance.blockMask);
Debug.Assert(this.Position == value, "value=" + value + " this.Position=" + this.Position);
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b8db797b/src/Lucene.Net.Core/Util/Fst/CharSequenceOutputs.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/CharSequenceOutputs.cs b/src/Lucene.Net.Core/Util/Fst/CharSequenceOutputs.cs
index b541544..fc0b44f 100644
--- a/src/Lucene.Net.Core/Util/Fst/CharSequenceOutputs.cs
+++ b/src/Lucene.Net.Core/Util/Fst/CharSequenceOutputs.cs
@@ -33,7 +33,7 @@ namespace Lucene.Net.Util.Fst
public sealed class CharSequenceOutputs : Outputs<CharsRef>
{
private static readonly CharsRef NO_OUTPUT = new CharsRef();
- private static readonly CharSequenceOutputs Singleton_Renamed = new CharSequenceOutputs();
+ private static readonly CharSequenceOutputs singleton = new CharSequenceOutputs();
private CharSequenceOutputs()
{
@@ -43,7 +43,7 @@ namespace Lucene.Net.Util.Fst
{
get
{
- return Singleton_Renamed;
+ return singleton;
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b8db797b/src/Lucene.Net.Core/Util/Fst/FST.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/FST.cs b/src/Lucene.Net.Core/Util/Fst/FST.cs
index f0d7173..3350068 100644
--- a/src/Lucene.Net.Core/Util/Fst/FST.cs
+++ b/src/Lucene.Net.Core/Util/Fst/FST.cs
@@ -104,7 +104,7 @@ namespace Lucene.Net.Util.Fst
/// <seealso cref= #shouldExpand(UnCompiledNode) </seealso>
internal const int FIXED_ARRAY_NUM_ARCS_DEEP = 10;*/
- private int[] BytesPerArc = new int[0];
+ private int[] bytesPerArc = new int[0];
/*// Increment version to change it
private const string FILE_FORMAT_NAME = "FST";
@@ -144,7 +144,7 @@ namespace Lucene.Net.Util.Fst
internal readonly BytesStore Bytes;
- private long StartNode = -1;
+ private long startNode = -1;
public readonly Outputs<T> Outputs;
@@ -152,7 +152,7 @@ namespace Lucene.Net.Util.Fst
// instead of storing the address of the target node for
// a given arc, we mark a single bit noting that the next
// node in the byte[] is the target node):
- private long LastFrozenNode;
+ private long lastFrozenNode;
private readonly T NO_OUTPUT;
@@ -160,31 +160,33 @@ namespace Lucene.Net.Util.Fst
public long arcCount;
public long arcWithOutputCount;
- private readonly bool Packed;
- private PackedInts.Reader NodeRefToAddress;
+ private readonly bool packed;
+ private PackedInts.Reader nodeRefToAddress;
/// <summary>
/// If arc has this label then that arc is final/accepted </summary>
public static readonly int END_LABEL = -1;
- private readonly bool AllowArrayArcs;
+ private readonly bool allowArrayArcs;
- private Arc<T>[] CachedRootArcs;
- private Arc<T>[] AssertingCachedRootArcs; // only set wit assert
+ private Arc<T>[] cachedRootArcs;
+ private Arc<T>[] assertingCachedRootArcs; // only set wit assert
+
+ // LUCENENET NOTE: Arc<T> moved into FST class
internal static bool Flag(int flags, int bit)
{
return (flags & bit) != 0;
}
- private GrowableWriter NodeAddress;
+ private GrowableWriter nodeAddress;
// TODO: we could be smarter here, and prune periodically
// as we go; high in-count nodes will "usually" become
// clear early on:
- private GrowableWriter InCounts;
+ private GrowableWriter inCounts;
- private readonly int Version;
+ private readonly int version;
// make a new empty FST, for building; Builder invokes
// this ctor
@@ -192,8 +194,8 @@ namespace Lucene.Net.Util.Fst
{
this.inputType = inputType;
this.Outputs = outputs;
- this.AllowArrayArcs = allowArrayArcs;
- Version = VERSION_CURRENT;
+ this.allowArrayArcs = allowArrayArcs;
+ version = VERSION_CURRENT;
Bytes = new BytesStore(bytesPageBits);
// pad: ensure no node gets address 0 which is reserved to mean
// the stop state w/ no arcs
@@ -201,18 +203,18 @@ namespace Lucene.Net.Util.Fst
NO_OUTPUT = outputs.NoOutput;
if (willPackFST)
{
- NodeAddress = new GrowableWriter(15, 8, acceptableOverheadRatio);
- InCounts = new GrowableWriter(1, 8, acceptableOverheadRatio);
+ nodeAddress = new GrowableWriter(15, 8, acceptableOverheadRatio);
+ inCounts = new GrowableWriter(1, 8, acceptableOverheadRatio);
}
else
{
- NodeAddress = null;
- InCounts = null;
+ nodeAddress = null;
+ inCounts = null;
}
emptyOutput = default(T);
- Packed = false;
- NodeRefToAddress = null;
+ packed = false;
+ nodeRefToAddress = null;
}
public static readonly int DEFAULT_MAX_BLOCK_BITS = Constants.JRE_IS_64BIT ? 30 : 28;
@@ -239,8 +241,8 @@ namespace Lucene.Net.Util.Fst
// NOTE: only reads most recent format; we don't have
// back-compat promise for FSTs (they are experimental):
- Version = CodecUtil.CheckHeader(@in, FILE_FORMAT_NAME, VERSION_PACKED, VERSION_VINT_TARGET);
- Packed = @in.ReadByte() == 1;
+ version = CodecUtil.CheckHeader(@in, FILE_FORMAT_NAME, VERSION_PACKED, VERSION_VINT_TARGET);
+ packed = @in.ReadByte() == 1;
if (@in.ReadByte() == 1)
{
// accepts empty string
@@ -251,7 +253,7 @@ namespace Lucene.Net.Util.Fst
// De-serialize empty-string output:
BytesReader reader;
- if (Packed)
+ if (packed)
{
reader = emptyBytes.ForwardReader;
}
@@ -290,15 +292,15 @@ namespace Lucene.Net.Util.Fst
default:
throw new InvalidOperationException("invalid input type " + t);
}
- if (Packed)
+ if (packed)
{
- NodeRefToAddress = PackedInts.GetReader(@in);
+ nodeRefToAddress = PackedInts.GetReader(@in);
}
else
{
- NodeRefToAddress = null;
+ nodeRefToAddress = null;
}
- StartNode = @in.ReadVLong();
+ startNode = @in.ReadVLong();
nodeCount = @in.ReadVLong();
arcCount = @in.ReadVLong();
arcWithOutputCount = @in.ReadVLong();
@@ -313,7 +315,7 @@ namespace Lucene.Net.Util.Fst
// NOTE: bogus because this is only used during
// building; we need to break out mutable FST from
// immutable
- AllowArrayArcs = false;
+ allowArrayArcs = false;
/*
if (bytes.length == 665) {
@@ -338,21 +340,21 @@ namespace Lucene.Net.Util.Fst
public long SizeInBytes()
{
long size = Bytes.Position;
- if (Packed)
+ if (packed)
{
- size += NodeRefToAddress.RamBytesUsed();
+ size += nodeRefToAddress.RamBytesUsed();
}
- else if (NodeAddress != null)
+ else if (nodeAddress != null)
{
- size += NodeAddress.RamBytesUsed();
- size += InCounts.RamBytesUsed();
+ size += nodeAddress.RamBytesUsed();
+ size += inCounts.RamBytesUsed();
}
return size;
}
public void Finish(long newStartNode)
{
- if (StartNode != -1)
+ if (startNode != -1)
{
throw new InvalidOperationException("already finished");
}
@@ -360,7 +362,7 @@ namespace Lucene.Net.Util.Fst
{
newStartNode = 0;
}
- StartNode = newStartNode;
+ startNode = newStartNode;
Bytes.Finish();
CacheRootArcs();
@@ -368,10 +370,10 @@ namespace Lucene.Net.Util.Fst
private long GetNodeAddress(long node)
{
- if (NodeAddress != null)
+ if (nodeAddress != null)
{
// Deref
- return NodeAddress.Get((int)node);
+ return nodeAddress.Get((int)node);
}
else
{
@@ -383,10 +385,10 @@ namespace Lucene.Net.Util.Fst
// Caches first 128 labels
private void CacheRootArcs()
{
- CachedRootArcs = (Arc<T>[])new Arc<T>[0x80];
- ReadRootArcs(CachedRootArcs);
+ cachedRootArcs = (Arc<T>[])new Arc<T>[0x80];
+ ReadRootArcs(cachedRootArcs);
- Debug.Assert(SetAssertingRootArcs(CachedRootArcs));
+ Debug.Assert(SetAssertingRootArcs(cachedRootArcs));
Debug.Assert(AssertRootArcs());
}
@@ -401,7 +403,7 @@ namespace Lucene.Net.Util.Fst
while (true)
{
Debug.Assert(arc.Label != END_LABEL);
- if (arc.Label < CachedRootArcs.Length)
+ if (arc.Label < cachedRootArcs.Length)
{
arcs[arc.Label] = (new Arc<T>()).CopyFrom(arc);
}
@@ -420,19 +422,19 @@ namespace Lucene.Net.Util.Fst
private bool SetAssertingRootArcs(Arc<T>[] arcs)
{
- AssertingCachedRootArcs = (Arc<T>[])new Arc<T>[arcs.Length];
- ReadRootArcs(AssertingCachedRootArcs);
+ assertingCachedRootArcs = (Arc<T>[])new Arc<T>[arcs.Length];
+ ReadRootArcs(assertingCachedRootArcs);
return true;
}
private bool AssertRootArcs()
{
- Debug.Assert(CachedRootArcs != null);
- Debug.Assert(AssertingCachedRootArcs != null);
- for (int i = 0; i < CachedRootArcs.Length; i++)
+ Debug.Assert(cachedRootArcs != null);
+ Debug.Assert(assertingCachedRootArcs != null);
+ for (int i = 0; i < cachedRootArcs.Length; i++)
{
- Arc<T> root = CachedRootArcs[i];
- Arc<T> asserting = AssertingCachedRootArcs[i];
+ Arc<T> root = cachedRootArcs[i];
+ Arc<T> asserting = assertingCachedRootArcs[i];
if (root != null)
{
Debug.Assert(root.ArcIdx == asserting.ArcIdx);
@@ -491,20 +493,20 @@ namespace Lucene.Net.Util.Fst
public void Save(DataOutput @out)
{
- if (StartNode == -1)
+ if (startNode == -1)
{
throw new InvalidOperationException("call finish first");
}
- if (NodeAddress != null)
+ if (nodeAddress != null)
{
throw new InvalidOperationException("cannot save an FST pre-packed FST; it must first be packed");
}
- if (Packed && !(NodeRefToAddress is PackedInts.Mutable))
+ if (packed && !(nodeRefToAddress is PackedInts.Mutable))
{
throw new InvalidOperationException("cannot save a FST which has been loaded from disk ");
}
CodecUtil.WriteHeader(@out, FILE_FORMAT_NAME, VERSION_CURRENT);
- if (Packed)
+ if (packed)
{
@out.WriteByte(1);
}
@@ -526,7 +528,7 @@ namespace Lucene.Net.Util.Fst
var emptyOutputBytes = new byte[(int)ros.FilePointer];
ros.WriteTo(emptyOutputBytes, 0);
- if (!Packed)
+ if (!packed)
{
// reverse
int stopAt = emptyOutputBytes.Length / 2;
@@ -560,11 +562,11 @@ namespace Lucene.Net.Util.Fst
t = 2;
}
@out.WriteByte((byte)t);
- if (Packed)
+ if (packed)
{
- ((PackedInts.Mutable)NodeRefToAddress).Save(@out);
+ ((PackedInts.Mutable)nodeRefToAddress).Save(@out);
}
- @out.WriteVLong(StartNode);
+ @out.WriteVLong(startNode);
@out.WriteVLong(nodeCount);
@out.WriteVLong(arcCount);
@out.WriteVLong(arcWithOutputCount);
@@ -696,9 +698,9 @@ namespace Lucene.Net.Util.Fst
if (doFixedArray)
{
//System.out.println(" fixedArray");
- if (BytesPerArc.Length < nodeIn.NumArcs)
+ if (bytesPerArc.Length < nodeIn.NumArcs)
{
- BytesPerArc = new int[ArrayUtil.Oversize(nodeIn.NumArcs, 1)];
+ bytesPerArc = new int[ArrayUtil.Oversize(nodeIn.NumArcs, 1)];
}
}
@@ -720,7 +722,7 @@ namespace Lucene.Net.Util.Fst
flags += BIT_LAST_ARC;
}
- if (LastFrozenNode == target.Node && !doFixedArray)
+ if (lastFrozenNode == target.Node && !doFixedArray)
{
// TODO: for better perf (but more RAM used) we
// could avoid this except when arc is "near" the
@@ -747,9 +749,9 @@ namespace Lucene.Net.Util.Fst
{
flags += BIT_STOP_NODE;
}
- else if (InCounts != null)
+ else if (inCounts != null)
{
- InCounts.Set((int)target.Node, InCounts.Get((int)target.Node) + 1);
+ inCounts.Set((int)target.Node, inCounts.Get((int)target.Node) + 1);
}
if (!arc.Output.Equals(NO_OUTPUT))
@@ -787,9 +789,9 @@ namespace Lucene.Net.Util.Fst
// byte size:
if (doFixedArray)
{
- BytesPerArc[arcIdx] = (int)(Bytes.Position - lastArcStart);
+ bytesPerArc[arcIdx] = (int)(Bytes.Position - lastArcStart);
lastArcStart = Bytes.Position;
- maxBytesPerArc = Math.Max(maxBytesPerArc, BytesPerArc[arcIdx]);
+ maxBytesPerArc = Math.Max(maxBytesPerArc, bytesPerArc[arcIdx]);
//System.out.println(" bytes=" + bytesPerArc[arcIdx]);
}
}
@@ -844,13 +846,13 @@ namespace Lucene.Net.Util.Fst
for (int arcIdx = nodeIn.NumArcs - 1; arcIdx >= 0; arcIdx--)
{
destPos -= maxBytesPerArc;
- srcPos -= BytesPerArc[arcIdx];
+ srcPos -= bytesPerArc[arcIdx];
//System.out.println(" repack arcIdx=" + arcIdx + " srcPos=" + srcPos + " destPos=" + destPos);
if (srcPos != destPos)
{
//System.out.println(" copy len=" + bytesPerArc[arcIdx]);
- Debug.Assert(destPos > srcPos, "destPos=" + destPos + " srcPos=" + srcPos + " arcIdx=" + arcIdx + " maxBytesPerArc=" + maxBytesPerArc + " bytesPerArc[arcIdx]=" + BytesPerArc[arcIdx] + " nodeIn.numArcs=" + nodeIn.NumArcs);
- Bytes.CopyBytes(srcPos, destPos, BytesPerArc[arcIdx]);
+ Debug.Assert(destPos > srcPos, "destPos=" + destPos + " srcPos=" + srcPos + " arcIdx=" + arcIdx + " maxBytesPerArc=" + maxBytesPerArc + " bytesPerArc[arcIdx]=" + bytesPerArc[arcIdx] + " nodeIn.numArcs=" + nodeIn.NumArcs);
+ Bytes.CopyBytes(srcPos, destPos, bytesPerArc[arcIdx]);
}
}
}
@@ -865,22 +867,22 @@ namespace Lucene.Net.Util.Fst
// PackedInts uses int as the index, so we cannot handle
// > 2.1B nodes when packing:
- if (NodeAddress != null && nodeCount == int.MaxValue)
+ if (nodeAddress != null && nodeCount == int.MaxValue)
{
throw new InvalidOperationException("cannot create a packed FST with more than 2.1 billion nodes");
}
nodeCount++;
long node;
- if (NodeAddress != null)
+ if (nodeAddress != null)
{
// Nodes are addressed by 1+ord:
- if ((int)nodeCount == NodeAddress.Size())
+ if ((int)nodeCount == nodeAddress.Size())
{
- NodeAddress = NodeAddress.Resize(ArrayUtil.Oversize(NodeAddress.Size() + 1, NodeAddress.BitsPerValue));
- InCounts = InCounts.Resize(ArrayUtil.Oversize(InCounts.Size() + 1, InCounts.BitsPerValue));
+ nodeAddress = nodeAddress.Resize(ArrayUtil.Oversize(nodeAddress.Size() + 1, nodeAddress.BitsPerValue));
+ inCounts = inCounts.Resize(ArrayUtil.Oversize(inCounts.Size() + 1, inCounts.BitsPerValue));
}
- NodeAddress.Set((int)nodeCount, thisNodeAddress);
+ nodeAddress.Set((int)nodeCount, thisNodeAddress);
// System.out.println(" write nodeAddress[" + nodeCount + "] = " + endAddress);
node = nodeCount;
}
@@ -888,7 +890,7 @@ namespace Lucene.Net.Util.Fst
{
node = thisNodeAddress;
}
- LastFrozenNode = node;
+ lastFrozenNode = node;
//System.out.println(" ret node=" + node + " address=" + thisNodeAddress + " nodeAddress=" + nodeAddress);
return node;
@@ -918,7 +920,7 @@ namespace Lucene.Net.Util.Fst
// If there are no nodes, ie, the FST only accepts the
// empty string, then startNode is 0
- arc.Target = StartNode;
+ arc.Target = startNode;
return arc;
}
@@ -951,7 +953,7 @@ namespace Lucene.Net.Util.Fst
{
// array: jump straight to end
arc.NumArcs = @in.ReadVInt();
- if (Packed || Version >= VERSION_VINT_TARGET)
+ if (packed || version >= VERSION_VINT_TARGET)
{
arc.BytesPerArc = @in.ReadVInt();
}
@@ -987,7 +989,7 @@ namespace Lucene.Net.Util.Fst
else if (arc.Flag(BIT_TARGET_NEXT))
{
}
- else if (Packed)
+ else if (packed)
{
@in.ReadVLong();
}
@@ -1010,7 +1012,7 @@ namespace Lucene.Net.Util.Fst
private long ReadUnpackedNodeTarget(BytesReader @in)
{
long target;
- if (Version < VERSION_VINT_TARGET)
+ if (version < VERSION_VINT_TARGET)
{
target = @in.ReadInt();
}
@@ -1071,7 +1073,7 @@ namespace Lucene.Net.Util.Fst
//System.out.println(" fixedArray");
// this is first arc in a fixed-array
arc.NumArcs = @in.ReadVInt();
- if (Packed || Version >= VERSION_VINT_TARGET)
+ if (packed || version >= VERSION_VINT_TARGET)
{
arc.BytesPerArc = @in.ReadVInt();
}
@@ -1153,7 +1155,7 @@ namespace Lucene.Net.Util.Fst
@in.ReadVInt();
// Skip bytesPerArc:
- if (Packed || Version >= VERSION_VINT_TARGET)
+ if (packed || version >= VERSION_VINT_TARGET)
{
@in.ReadVInt();
}
@@ -1249,7 +1251,7 @@ namespace Lucene.Net.Util.Fst
arc.NextArc = @in.Position;
// TODO: would be nice to make this lazy -- maybe
// caller doesn't need the target and is scanning arcs...
- if (NodeAddress == null)
+ if (nodeAddress == null)
{
if (!arc.Flag(BIT_LAST_ARC))
{
@@ -1274,7 +1276,7 @@ namespace Lucene.Net.Util.Fst
}
else
{
- if (Packed)
+ if (packed)
{
long pos = @in.Position;
long code = @in.ReadVLong();
@@ -1284,10 +1286,10 @@ namespace Lucene.Net.Util.Fst
arc.Target = pos + code;
//System.out.println(" delta pos=" + pos + " delta=" + code + " target=" + arc.target);
}
- else if (code < NodeRefToAddress.Size())
+ else if (code < nodeRefToAddress.Size())
{
// Deref
- arc.Target = NodeRefToAddress.Get((int)code);
+ arc.Target = nodeRefToAddress.Get((int)code);
//System.out.println(" deref code=" + code + " target=" + arc.target);
}
else
@@ -1341,12 +1343,12 @@ namespace Lucene.Net.Util.Fst
}
// Short-circuit if this arc is in the root arc cache:
- if (follow.Target == StartNode && labelToMatch < CachedRootArcs.Length)
+ if (follow.Target == startNode && labelToMatch < cachedRootArcs.Length)
{
// LUCENE-5152: detect tricky cases where caller
// modified previously returned cached root-arcs:
Debug.Assert(AssertRootArcs());
- Arc<T> result = CachedRootArcs[labelToMatch];
+ Arc<T> result = cachedRootArcs[labelToMatch];
if (result == null)
{
return null;
@@ -1373,7 +1375,7 @@ namespace Lucene.Net.Util.Fst
{
// Arcs are full array; do binary search:
arc.NumArcs = @in.ReadVInt();
- if (Packed || Version >= VERSION_VINT_TARGET)
+ if (packed || version >= VERSION_VINT_TARGET)
{
arc.BytesPerArc = @in.ReadVInt();
}
@@ -1459,7 +1461,7 @@ namespace Lucene.Net.Util.Fst
if (!Flag(flags, BIT_STOP_NODE) && !Flag(flags, BIT_TARGET_NEXT))
{
- if (Packed)
+ if (packed)
{
@in.ReadVLong();
}
@@ -1517,7 +1519,7 @@ namespace Lucene.Net.Util.Fst
/// <seealso cref= Builder.UnCompiledNode#depth </seealso>
private bool ShouldExpand(Builder<T>.UnCompiledNode<T> node)
{
- return AllowArrayArcs && ((node.Depth <= FIXED_ARRAY_SHALLOW_DISTANCE && node.NumArcs >= FIXED_ARRAY_NUM_ARCS_SHALLOW) || node.NumArcs >= FIXED_ARRAY_NUM_ARCS_DEEP);
+ return allowArrayArcs && ((node.Depth <= FIXED_ARRAY_SHALLOW_DISTANCE && node.NumArcs >= FIXED_ARRAY_NUM_ARCS_SHALLOW) || node.NumArcs >= FIXED_ARRAY_NUM_ARCS_DEEP);
}
/// <summary>
@@ -1529,7 +1531,7 @@ namespace Lucene.Net.Util.Fst
get
{
FST.BytesReader @in;
- if (Packed)
+ if (packed)
{
@in = Bytes.ForwardReader;
}
@@ -1673,8 +1675,8 @@ namespace Lucene.Net.Util.Fst
// Creates a packed FST
private FST(INPUT_TYPE inputType, Outputs<T> outputs, int bytesPageBits)
{
- Version = VERSION_CURRENT;
- Packed = true;
+ version = VERSION_CURRENT;
+ packed = true;
this.inputType = inputType;
Bytes = new BytesStore(bytesPageBits);
this.Outputs = outputs;
@@ -1683,7 +1685,7 @@ namespace Lucene.Net.Util.Fst
// NOTE: bogus because this is only used during
// building; we need to break out mutable FST from
// immutable
- AllowArrayArcs = false;
+ allowArrayArcs = false;
}
/// <summary>
@@ -1715,7 +1717,7 @@ namespace Lucene.Net.Util.Fst
// - use spare bits in flags.... for top few labels /
// outputs / targets
- if (NodeAddress == null)
+ if (nodeAddress == null)
{
throw new System.ArgumentException("this FST was not built with willPackFST=true");
}
@@ -1724,34 +1726,34 @@ namespace Lucene.Net.Util.Fst
BytesReader r = BytesReader;
- int topN = Math.Min(maxDerefNodes, InCounts.Size());
+ int topN = Math.Min(maxDerefNodes, inCounts.Size());
// Find top nodes with highest number of incoming arcs:
NodeQueue q = new NodeQueue(topN);
// TODO: we could use more RAM efficient selection algo here...
NodeAndInCount bottom = null;
- for (int node = 0; node < InCounts.Size(); node++)
+ for (int node = 0; node < inCounts.Size(); node++)
{
- if (InCounts.Get(node) >= minInCountDeref)
+ if (inCounts.Get(node) >= minInCountDeref)
{
if (bottom == null)
{
- q.Add(new NodeAndInCount(node, (int)InCounts.Get(node)));
+ q.Add(new NodeAndInCount(node, (int)inCounts.Get(node)));
if (q.Size() == topN)
{
bottom = q.Top();
}
}
- else if (InCounts.Get(node) > bottom.Count)
+ else if (inCounts.Get(node) > bottom.Count)
{
- q.InsertWithOverflow(new NodeAndInCount(node, (int)InCounts.Get(node)));
+ q.InsertWithOverflow(new NodeAndInCount(node, (int)inCounts.Get(node)));
}
}
}
// Free up RAM:
- InCounts = null;
+ inCounts = null;
IDictionary<int, int> topNodeMap = new Dictionary<int, int>();
for (int downTo = q.Size() - 1; downTo >= 0; downTo--)
@@ -1767,7 +1769,7 @@ namespace Lucene.Net.Util.Fst
// Fill initial coarse guess:
for (int node = 1; node <= nodeCount; node++)
{
- newNodeAddress.Set(node, 1 + this.Bytes.Position - NodeAddress.Get(node));
+ newNodeAddress.Set(node, 1 + this.Bytes.Position - nodeAddress.Get(node));
}
int absCount;
@@ -2075,9 +2077,9 @@ namespace Lucene.Net.Util.Fst
{
nodeRefToAddressIn.Set(ent.Value, newNodeAddress.Get(ent.Key));
}
- fst.NodeRefToAddress = nodeRefToAddressIn;
+ fst.nodeRefToAddress = nodeRefToAddressIn;
- fst.StartNode = newNodeAddress.Get((int)StartNode);
+ fst.startNode = newNodeAddress.Get((int)startNode);
//System.out.println("new startNode=" + fst.startNode + " old startNode=" + startNode);
if (emptyOutput != null)