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 2015/02/11 00:25:32 UTC
[8/8] lucenenet git commit: Cleanup and fixes to L.N.Codecs
Cleanup and fixes to L.N.Codecs
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/5a8c736f
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/5a8c736f
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/5a8c736f
Branch: refs/heads/master
Commit: 5a8c736fdb14505e1cef9c1c4641b680b06889ac
Parents: 92a69f0
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Wed Feb 11 01:23:49 2015 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Wed Feb 11 01:23:49 2015 +0200
----------------------------------------------------------------------
Lucene.Net.sln | 24 ++++++
.../Memory/DirectPostingsFormat.cs | 91 +++++++++-----------
.../Index/BaseIndexFileFormatTestCase.cs | 2 +-
.../DiskDv/TestDiskDocValuesFormat.cs | 5 +-
.../Lucene.Net.Codecs.Tests.csproj | 10 +++
src/Lucene.Net.Tests.Codecs/packages.config | 4 +
6 files changed, 80 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5a8c736f/Lucene.Net.sln
----------------------------------------------------------------------
diff --git a/Lucene.Net.sln b/Lucene.Net.sln
index e50e6a5..18f70a3 100644
--- a/Lucene.Net.sln
+++ b/Lucene.Net.sln
@@ -34,6 +34,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Tests.Expression
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Tests.Queries", "src\Lucene.Net.Tests.Queries\Lucene.Net.Tests.Queries.csproj", "{D7276EA2-71BE-4208-889B-B1BD48DBE023}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Codecs", "src\Lucene.Net.Codecs\Lucene.Net.Codecs.csproj", "{3F79B6D4-4359-4F83-B64F-07F4F6262425}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Codecs.Tests", "src\Lucene.Net.Tests.Codecs\Lucene.Net.Codecs.Tests.csproj", "{351B75B1-BBD5-4E32-8036-7BED4E0135A6}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -155,6 +159,26 @@ Global
{D7276EA2-71BE-4208-889B-B1BD48DBE023}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{D7276EA2-71BE-4208-889B-B1BD48DBE023}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{D7276EA2-71BE-4208-889B-B1BD48DBE023}.Release|x86.ActiveCfg = Release|Any CPU
+ {3F79B6D4-4359-4F83-B64F-07F4F6262425}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3F79B6D4-4359-4F83-B64F-07F4F6262425}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3F79B6D4-4359-4F83-B64F-07F4F6262425}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {3F79B6D4-4359-4F83-B64F-07F4F6262425}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {3F79B6D4-4359-4F83-B64F-07F4F6262425}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {3F79B6D4-4359-4F83-B64F-07F4F6262425}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3F79B6D4-4359-4F83-B64F-07F4F6262425}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3F79B6D4-4359-4F83-B64F-07F4F6262425}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {3F79B6D4-4359-4F83-B64F-07F4F6262425}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {3F79B6D4-4359-4F83-B64F-07F4F6262425}.Release|x86.ActiveCfg = Release|Any CPU
+ {351B75B1-BBD5-4E32-8036-7BED4E0135A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {351B75B1-BBD5-4E32-8036-7BED4E0135A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {351B75B1-BBD5-4E32-8036-7BED4E0135A6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {351B75B1-BBD5-4E32-8036-7BED4E0135A6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {351B75B1-BBD5-4E32-8036-7BED4E0135A6}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {351B75B1-BBD5-4E32-8036-7BED4E0135A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {351B75B1-BBD5-4E32-8036-7BED4E0135A6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {351B75B1-BBD5-4E32-8036-7BED4E0135A6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {351B75B1-BBD5-4E32-8036-7BED4E0135A6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {351B75B1-BBD5-4E32-8036-7BED4E0135A6}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5a8c736f/src/Lucene.Net.Codecs/Memory/DirectPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Memory/DirectPostingsFormat.cs b/src/Lucene.Net.Codecs/Memory/DirectPostingsFormat.cs
index 1556c7b..dc36b6b 100644
--- a/src/Lucene.Net.Codecs/Memory/DirectPostingsFormat.cs
+++ b/src/Lucene.Net.Codecs/Memory/DirectPostingsFormat.cs
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+using System.Linq;
+
namespace Lucene.Net.Codecs.Memory
{
@@ -131,7 +133,7 @@ namespace Lucene.Net.Codecs.Memory
private sealed class DirectFields : FieldsProducer
{
- internal readonly IDictionary<string, DirectField> fields = new SortedDictionary<string, DirectField>();
+ private readonly IDictionary<string, DirectField> fields = new SortedDictionary<string, DirectField>();
public DirectFields(SegmentReadState state, Fields fields, int minSkipCount, int lowFreqCutoff)
{
@@ -161,12 +163,7 @@ namespace Lucene.Net.Codecs.Memory
{
get
{
- long numTerms = 0;
- foreach (DirectField field in fields.Values)
- {
- numTerms += field.terms.Length;
- }
- return numTerms;
+ return fields.Values.Aggregate<DirectField, long>(0, (current, field) => current + field.terms.Length);
}
}
@@ -194,7 +191,6 @@ namespace Lucene.Net.Codecs.Memory
private sealed class DirectField : Terms
{
-
internal abstract class TermAndSkip
{
public int[] skips;
@@ -277,34 +273,34 @@ namespace Lucene.Net.Codecs.Memory
}
}
- internal readonly byte[] termBytes;
- internal readonly int[] termOffsets;
+ private readonly byte[] termBytes;
+ private readonly int[] termOffsets;
- internal readonly int[] skips;
- internal readonly int[] skipOffsets;
+ private readonly int[] skips;
+ private readonly int[] skipOffsets;
internal readonly TermAndSkip[] terms;
- internal readonly bool hasFreq;
- internal readonly bool hasPos;
- internal readonly bool hasOffsets_Renamed;
- internal readonly bool hasPayloads_Renamed;
- internal readonly long sumTotalTermFreq;
- internal readonly int docCount;
- internal readonly long sumDocFreq;
- internal int skipCount;
+ private readonly bool hasFreq;
+ private readonly bool hasPos;
+ private readonly bool hasOffsets_Renamed;
+ private readonly bool hasPayloads_Renamed;
+ private readonly long sumTotalTermFreq;
+ private readonly int docCount;
+ private readonly long sumDocFreq;
+ private int skipCount;
// TODO: maybe make a separate builder? These are only
// used during load:
- internal int count;
- internal int[] sameCounts = new int[10];
- internal readonly int minSkipCount;
+ private readonly int count;
+ private int[] sameCounts = new int[10];
+ private readonly int minSkipCount;
private sealed class IntArrayWriter
{
- internal int[] ints = new int[10];
- internal int upto;
+ private int[] ints = new int[10];
+ private int upto;
- public void add(int value)
+ public void Add(int value)
{
if (ints.Length == upto)
{
@@ -313,11 +309,9 @@ namespace Lucene.Net.Codecs.Memory
ints[upto++] = value;
}
- public int[] get()
+ public int[] Get()
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int[] arr = new int[upto];
- int[] arr = new int[upto];
+ var arr = new int[upto];
Array.Copy(ints, 0, arr, 0, upto);
upto = 0;
return arr;
@@ -395,14 +389,7 @@ namespace Lucene.Net.Codecs.Memory
TermAndSkip ent;
DocsEnum docsEnum2;
- if (hasPos)
- {
- docsEnum2 = docsAndPositionsEnum;
- }
- else
- {
- docsEnum2 = docsEnum;
- }
+ docsEnum2 = hasPos ? docsAndPositionsEnum : docsEnum;
int docID;
@@ -414,32 +401,32 @@ namespace Lucene.Net.Codecs.Memory
// Pack postings for low-freq terms into a single int[]:
while ((docID = docsEnum2.NextDoc()) != DocsEnum.NO_MORE_DOCS)
{
- scratch.add(docID);
+ scratch.Add(docID);
if (hasFreq)
{
int freq = docsEnum2.Freq();
- scratch.add(freq);
+ scratch.Add(freq);
if (hasPos)
{
for (int pos = 0; pos < freq; pos++)
{
- scratch.add(docsAndPositionsEnum.NextPosition());
+ scratch.Add(docsAndPositionsEnum.NextPosition());
if (hasOffsets_Renamed)
{
- scratch.add(docsAndPositionsEnum.StartOffset());
- scratch.add(docsAndPositionsEnum.EndOffset());
+ scratch.Add(docsAndPositionsEnum.StartOffset());
+ scratch.Add(docsAndPositionsEnum.EndOffset());
}
if (hasPayloads_Renamed)
{
BytesRef payload = docsAndPositionsEnum.Payload;
if (payload != null)
{
- scratch.add(payload.Length);
+ scratch.Add(payload.Length);
ros.WriteBytes(payload.Bytes, payload.Offset, payload.Length);
}
else
{
- scratch.add(0);
+ scratch.Add(0);
}
}
}
@@ -460,13 +447,13 @@ namespace Lucene.Net.Codecs.Memory
payloads = null;
}
- int[] postings = scratch.get();
+ int[] postings = scratch.Get();
ent = new LowFreqTerm(postings, payloads, docFreq, (int) totalTermFreq);
}
else
{
- int[] docs = new int[docFreq];
+ var docs = new int[docFreq];
int[] freqs;
int[][] positions;
byte[][][] payloads;
@@ -613,7 +600,7 @@ namespace Lucene.Net.Codecs.Memory
}
// Compares in unicode (UTF8) order:
- internal int Compare(int ord, BytesRef other)
+ private int Compare(int ord, BytesRef other)
{
byte[] otherBytes = other.Bytes;
@@ -635,7 +622,7 @@ namespace Lucene.Net.Codecs.Memory
return termLen - other.Length;
}
- internal void SetSkips(int termOrd, sbyte[] termBytes)
+ private void SetSkips(int termOrd, sbyte[] termBytes)
{
int termLength = termOffsets[termOrd + 1] - termOffsets[termOrd];
@@ -699,7 +686,7 @@ namespace Lucene.Net.Codecs.Memory
}
}
- internal void FinishSkips()
+ private void FinishSkips()
{
Debug.Assert(count == terms.Length);
int lastTermOffset = termOffsets[count - 1];
@@ -826,8 +813,8 @@ namespace Lucene.Net.Codecs.Memory
{
private readonly DirectPostingsFormat.DirectField outerInstance;
- internal readonly BytesRef scratch = new BytesRef();
- internal int termOrd;
+ private readonly BytesRef scratch = new BytesRef();
+ private int termOrd;
public DirectTermsEnum(DirectPostingsFormat.DirectField outerInstance)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5a8c736f/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
index 0b31695..d65a88b 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
@@ -35,7 +35,7 @@ namespace Lucene.Net.Index
{
/// <summary>
/// Returns the codec to run tests against </summary>
- protected internal abstract Codec Codec { get; }
+ protected abstract Codec Codec { get; }
private Codec SavedCodec;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5a8c736f/src/Lucene.Net.Tests.Codecs/DiskDv/TestDiskDocValuesFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Codecs/DiskDv/TestDiskDocValuesFormat.cs b/src/Lucene.Net.Tests.Codecs/DiskDv/TestDiskDocValuesFormat.cs
index 01889ae..42eae1f 100644
--- a/src/Lucene.Net.Tests.Codecs/DiskDv/TestDiskDocValuesFormat.cs
+++ b/src/Lucene.Net.Tests.Codecs/DiskDv/TestDiskDocValuesFormat.cs
@@ -28,9 +28,9 @@ namespace Lucene.Net.Codecs.DiskDV
/// </summary>
public class TestDiskDocValuesFormat : BaseCompressingDocValuesFormatTestCase
{
- private readonly Codec codec = TestUtil.alwaysDocValuesFormat(new DiskDocValuesFormat());
+ private readonly Codec codec = TestUtil.AlwaysDocValuesFormat(new DiskDocValuesFormat());
- protected internal override Codec Codec
+ protected override Codec Codec
{
get
{
@@ -38,5 +38,4 @@ namespace Lucene.Net.Codecs.DiskDV
}
}
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5a8c736f/src/Lucene.Net.Tests.Codecs/Lucene.Net.Codecs.Tests.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Codecs/Lucene.Net.Codecs.Tests.csproj b/src/Lucene.Net.Tests.Codecs/Lucene.Net.Codecs.Tests.csproj
index 12eb5c6..0bf8ba8 100644
--- a/src/Lucene.Net.Tests.Codecs/Lucene.Net.Codecs.Tests.csproj
+++ b/src/Lucene.Net.Tests.Codecs/Lucene.Net.Codecs.Tests.csproj
@@ -30,6 +30,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="nunit.framework">
+ <HintPath>..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -51,11 +54,18 @@
<Project>{5d4ad9be-1ffb-41ab-9943-25737971bf57}</Project>
<Name>Lucene.Net</Name>
</ProjectReference>
+ <ProjectReference Include="..\Lucene.Net.TestFramework\Lucene.Net.TestFramework.csproj">
+ <Project>{b2c0d749-ce34-4f62-a15e-00cb2ff5ddb3}</Project>
+ <Name>Lucene.Net.TestFramework</Name>
+ </ProjectReference>
<ProjectReference Include="..\Lucene.Net.Tests\Lucene.Net.Tests.csproj">
<Project>{de63db10-975f-460d-af85-572c17a91284}</Project>
<Name>Lucene.Net.Tests</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5a8c736f/src/Lucene.Net.Tests.Codecs/packages.config
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Codecs/packages.config b/src/Lucene.Net.Tests.Codecs/packages.config
new file mode 100644
index 0000000..139d513
--- /dev/null
+++ b/src/Lucene.Net.Tests.Codecs/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="NUnit" version="2.6.3" targetFramework="net451" />
+</packages>
\ No newline at end of file