You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2016/10/11 18:35:07 UTC
[22/47] lucenenet git commit: Added Codecs.Bloom tests + mocks to the
project
Added Codecs.Bloom tests + mocks to the project
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/c5d44a5b
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/c5d44a5b
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/c5d44a5b
Branch: refs/heads/master
Commit: c5d44a5b770fa7acdcbb9581858b880e5359b52c
Parents: aff260f
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Mon Oct 10 23:57:29 2016 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Tue Oct 11 00:26:22 2016 +0700
----------------------------------------------------------------------
.../Bloom/TestBloomFilteredLucene41Postings.cs | 68 ++++++++++++++++++++
.../Lucene.Net.TestFramework.csproj | 1 +
.../Bloom/TestBloomPostingsFormat.cs | 41 ++++++------
.../Lucene.Net.Tests.Codecs.csproj | 1 +
4 files changed, 90 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c5d44a5b/src/Lucene.Net.TestFramework/Codecs/Bloom/TestBloomFilteredLucene41Postings.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Codecs/Bloom/TestBloomFilteredLucene41Postings.cs b/src/Lucene.Net.TestFramework/Codecs/Bloom/TestBloomFilteredLucene41Postings.cs
new file mode 100644
index 0000000..78073b0
--- /dev/null
+++ b/src/Lucene.Net.TestFramework/Codecs/Bloom/TestBloomFilteredLucene41Postings.cs
@@ -0,0 +1,68 @@
+\ufeffusing Lucene.Net.Codecs.Lucene41;
+using Lucene.Net.Index;
+
+namespace Lucene.Net.Codecs.Bloom
+{
+ /**
+ * 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.
+ */
+
+ /// <summary>
+ /// A class used for testing {@link BloomFilteringPostingsFormat} with a concrete
+ /// delegate (Lucene41). Creates a Bloom filter on ALL fields and with tiny
+ /// amounts of memory reserved for the filter.DO NOT USE IN A PRODUCTION
+ /// APPLICATION This is not a realistic application of Bloom Filters as they
+ /// ordinarily are larger and operate on only primary key type fields.
+ /// </summary>
+ public class TestBloomFilteredLucene41Postings : PostingsFormat
+ {
+ private BloomFilteringPostingsFormat @delegate;
+
+ // Special class used to avoid OOM exceptions where Junit tests create many
+ // fields.
+ internal class LowMemoryBloomFactory : BloomFilterFactory
+ {
+ public override FuzzySet GetSetForField(SegmentWriteState state, FieldInfo info)
+ {
+ return FuzzySet.CreateSetBasedOnMaxMemory(1024);
+ }
+
+ public override bool IsSaturated(FuzzySet bloomFilter, FieldInfo fieldInfo)
+ {
+ // For test purposes always maintain the BloomFilter - even past the point
+ // of usefulness when all bits are set
+ return false;
+ }
+ }
+
+ public TestBloomFilteredLucene41Postings()
+ : base("TestBloomFilteredLucene41Postings")
+ {
+ @delegate = new BloomFilteringPostingsFormat(new Lucene41PostingsFormat(),
+ new LowMemoryBloomFactory());
+ }
+
+ public override FieldsConsumer FieldsConsumer(SegmentWriteState state)
+ {
+ return @delegate.FieldsConsumer(state);
+ }
+
+ public override FieldsProducer FieldsProducer(SegmentReadState state)
+ {
+ return @delegate.FieldsProducer(state);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c5d44a5b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
index cf0ba78..66be25c 100644
--- a/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
+++ b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
@@ -141,6 +141,7 @@
<Compile Include="Codecs\asserting\AssertingTermVectorsFormat.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Codecs\Bloom\TestBloomFilteredLucene41Postings.cs" />
<Compile Include="Codecs\compressing\CompressingCodec.cs">
<SubType>Code</SubType>
</Compile>
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c5d44a5b/src/Lucene.Net.Tests.Codecs/Bloom/TestBloomPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Codecs/Bloom/TestBloomPostingsFormat.cs b/src/Lucene.Net.Tests.Codecs/Bloom/TestBloomPostingsFormat.cs
index 2548f2b..d4e1286 100644
--- a/src/Lucene.Net.Tests.Codecs/Bloom/TestBloomPostingsFormat.cs
+++ b/src/Lucene.Net.Tests.Codecs/Bloom/TestBloomPostingsFormat.cs
@@ -1,7 +1,10 @@
-\ufeffnamespace org.apache.lucene.codecs.bloom
-{
+\ufeffusing Lucene.Net.Index;
+using Lucene.Net.Util;
+using NUnit.Framework;
- /*
+namespace Lucene.Net.Codecs.Bloom
+{
+ /*
* 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.
@@ -18,23 +21,19 @@
* limitations under the License.
*/
- using BasePostingsFormatTestCase = org.apache.lucene.index.BasePostingsFormatTestCase;
- using TestUtil = org.apache.lucene.util.TestUtil;
-
- /// <summary>
- /// Basic tests for BloomPostingsFormat
- /// </summary>
- public class TestBloomPostingsFormat : BasePostingsFormatTestCase
- {
- private readonly Codec codec = TestUtil.alwaysPostingsFormat(new TestBloomFilteredLucene41Postings());
-
- protected internal override Codec Codec
- {
- get
- {
- return codec;
- }
- }
- }
+ /// <summary>
+ /// Basic tests for BloomPostingsFormat
+ /// </summary>
+ public class TestBloomPostingsFormat : BasePostingsFormatTestCase
+ {
+ private readonly Codec codec = TestUtil.AlwaysPostingsFormat(new TestBloomFilteredLucene41Postings());
+ protected override Codec Codec
+ {
+ get
+ {
+ return codec;
+ }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c5d44a5b/src/Lucene.Net.Tests.Codecs/Lucene.Net.Tests.Codecs.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Codecs/Lucene.Net.Tests.Codecs.csproj b/src/Lucene.Net.Tests.Codecs/Lucene.Net.Tests.Codecs.csproj
index 90e9d38..b2f11cd 100644
--- a/src/Lucene.Net.Tests.Codecs/Lucene.Net.Tests.Codecs.csproj
+++ b/src/Lucene.Net.Tests.Codecs/Lucene.Net.Tests.Codecs.csproj
@@ -43,6 +43,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BlockTerms\TestFixedGapPostingsFormat.cs" />
+ <Compile Include="Bloom\TestBloomPostingsFormat.cs" />
<Compile Include="DiskDv\TestDiskDocValuesFormat.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SimpleText\TestSimpleTextDocValuesFormat.cs" />