Skip to content

Commit e185b62

Browse files
committed
refactor: Remove obsolete import and export functions
1 parent dfec1f2 commit e185b62

File tree

3 files changed

+1
-202
lines changed

3 files changed

+1
-202
lines changed

src/BloomFilter/Configurations/FilterMemoryOptions.cs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections;
1+
using System.Collections;
32
using System.Collections.Generic;
43

54
namespace BloomFilter.Configurations;
@@ -26,35 +25,11 @@ public class FilterMemoryOptions
2625
/// </summary>
2726
public HashMethod Method { get; set; } = HashMethod.Murmur3;
2827

29-
/// <summary>
30-
/// Sets the bit value
31-
/// </summary>
32-
[Obsolete("Use Buckets")]
33-
public BitArray Bits { get; set; } = default!;
34-
35-
/// <summary>
36-
/// Sets more the bit value
37-
/// </summary>
38-
[Obsolete("Use Buckets")]
39-
public BitArray? BitsMore { get; set; }
40-
4128
/// <summary>
4229
/// Multiple bitmap
4330
/// </summary>
4431
public BitArray[]? Buckets { get; set; }
4532

46-
/// <summary>
47-
/// Sets the bit value
48-
/// </summary>
49-
[Obsolete("Use BucketBytes")]
50-
public byte[] Bytes { get; set; } = default!;
51-
52-
/// <summary>
53-
/// Sets more the bit value
54-
/// </summary>
55-
[Obsolete("Use BucketBytes")]
56-
public byte[]? BytesMore { get; set; }
57-
5833
/// <summary>
5934
/// Multiple bitmap from bytes
6035
/// </summary>

src/BloomFilter/FilterMemory.cs

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class FilterMemory : Filter
2727
public FilterMemory(FilterMemoryOptions options)
2828
: base(options.Name, options.ExpectedElements, options.ErrorRate, HashFunction.Functions[options.Method])
2929
{
30-
3130
if (options.Buckets is not null)
3231
{
3332
Import(options.Buckets);
@@ -36,28 +35,6 @@ public FilterMemory(FilterMemoryOptions options)
3635
{
3736
Import(options.BucketBytes);
3837
}
39-
else if (options.Bits is not null)
40-
{
41-
if (options.BitsMore is not null)
42-
{
43-
Import([options.Bits, options.BitsMore]);
44-
}
45-
else
46-
{
47-
Import([options.Bits]);
48-
}
49-
}
50-
else if (options.Bytes is not null)
51-
{
52-
if (options.BytesMore is not null)
53-
{
54-
Import([options.Bytes, options.BytesMore]);
55-
}
56-
else
57-
{
58-
Import([options.Bytes]);
59-
}
60-
}
6138
else
6239
{
6340
Init();
@@ -140,25 +117,6 @@ public void Import(BitArray[] buckets)
140117
}
141118
}
142119

143-
/// <summary>
144-
/// Importing bitmap
145-
/// </summary>
146-
/// <param name="bits">Sets the bit value</param>
147-
/// <param name="bits2">Sets the bit value</param>
148-
[Obsolete("Use Import(BitArray[])")]
149-
[MemberNotNull(nameof(_buckets))]
150-
public void Import(BitArray bits, BitArray? bits2 = null)
151-
{
152-
if (bits2 is null)
153-
{
154-
Import([bits]);
155-
}
156-
else
157-
{
158-
Import([bits, bits2]);
159-
}
160-
}
161-
162120
/// <summary>
163121
/// Importing bitmap
164122
/// </summary>
@@ -175,26 +133,6 @@ public void Import(IList<byte[]> bucketBytes)
175133
Import(bucketBytes.Select(s => new BitArray(s)).ToArray());
176134
}
177135

178-
/// <summary>
179-
/// Importing bitmap
180-
/// </summary>
181-
/// <param name="bits">Sets the bit value</param>
182-
/// <param name="more">Sets more the bit value</param>
183-
[MemberNotNull(nameof(_buckets))]
184-
[Obsolete("Use Import(IList<byte[]>)")]
185-
public void Import(byte[] bits, byte[]? more = null)
186-
{
187-
if (more is null)
188-
{
189-
Import([bits]);
190-
}
191-
else
192-
{
193-
Import([bits, more]);
194-
}
195-
}
196-
197-
198136
/// <summary>
199137
/// Exporting bitmap
200138
/// </summary>
@@ -206,29 +144,6 @@ public BitArray[] Export()
206144
}
207145
}
208146

209-
/// <summary>
210-
/// Exporting bitmap
211-
/// </summary>
212-
/// <param name="bits">Gets the bit value</param>
213-
/// <param name="more">Gets more the bit value</param>
214-
[Obsolete("Use Export()")]
215-
public void Export(out BitArray bits, out BitArray? more)
216-
{
217-
more = null;
218-
219-
lock (sync)
220-
{
221-
bits = new BitArray(_buckets[0]);
222-
223-
if (_buckets.Length > 1)
224-
{
225-
more = new BitArray(_buckets[1]);
226-
}
227-
}
228-
}
229-
230-
231-
232147
/// <summary>
233148
/// Exporting bitmap
234149
/// </summary>
@@ -251,23 +166,6 @@ public IList<byte[]> ExportToBytes()
251166
return result;
252167
}
253168

254-
/// <summary>
255-
/// Exporting bitmap
256-
/// </summary>
257-
/// <param name="bits">Gets the bit value</param>
258-
/// <param name="more">Gets more the bit value</param>
259-
[Obsolete("Use ExportToBytes()")]
260-
public void Export(out byte[] bits, out byte[]? more)
261-
{
262-
more = null;
263-
var result = ExportToBytes();
264-
bits = result[0];
265-
if (result.Count > 1)
266-
{
267-
more = result[1];
268-
}
269-
}
270-
271169
/// <summary>
272170
/// Adds the passed value to the filter.
273171
/// </summary>

test/BloomFilterTest/ImportExportTest.cs

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -10,58 +10,6 @@ namespace BloomFilterTest
1010
{
1111
public class ImportExportTest
1212
{
13-
[Fact]
14-
public void Bytes_Import_OutOfRangeExceptione()
15-
{
16-
var bits1 = new byte[11981];
17-
18-
Assert.Throws<ArgumentOutOfRangeException>(() =>
19-
{
20-
var bf2 = (FilterMemory)FilterBuilder.Build(new FilterMemoryOptions
21-
{
22-
Bytes = bits1,
23-
ExpectedElements = 10000,
24-
ErrorRate = 0.01
25-
});
26-
});
27-
}
28-
29-
[Fact]
30-
public void BitArray_Import_OutOfRangeException()
31-
{
32-
var bits1 = new BitArray(95850);
33-
34-
Assert.Throws<ArgumentOutOfRangeException>(() =>
35-
{
36-
var bf2 = (FilterMemory)FilterBuilder.Build(new FilterMemoryOptions
37-
{
38-
Bits = bits1,
39-
ExpectedElements = 10000,
40-
ErrorRate = 0.01
41-
});
42-
});
43-
}
44-
45-
[Fact]
46-
public void Bytes_Export_And_Import()
47-
{
48-
var bf = (FilterMemory)FilterBuilder.Build(10000, 0.01);
49-
50-
bf.Add("Export_And_Import");
51-
52-
bf.Export(out byte[] bits, out byte[] more);
53-
54-
var bf2 = (FilterMemory)FilterBuilder.Build(new FilterMemoryOptions
55-
{
56-
Bytes = bits,
57-
BytesMore = more,
58-
ExpectedElements = 10000,
59-
ErrorRate = 0.01
60-
});
61-
62-
63-
Assert.True(bf2.Contains("Export_And_Import"));
64-
}
6513

6614
[Fact]
6715
public void ExportToBytes_And_Import()
@@ -83,28 +31,6 @@ public void ExportToBytes_And_Import()
8331
Assert.True(bf2.Contains("ExportToBytes_And_Import"));
8432
}
8533

86-
87-
[Fact]
88-
public void BitArray_Export_And_Import()
89-
{
90-
var bf = (FilterMemory)FilterBuilder.Build(10000, 0.01);
91-
92-
bf.Add("Export_And_Import");
93-
94-
bf.Export(out BitArray bits, out BitArray more);
95-
96-
var bf2 = (FilterMemory)FilterBuilder.Build(new FilterMemoryOptions
97-
{
98-
Bits = bits,
99-
BitsMore = more,
100-
ExpectedElements = 10000,
101-
ErrorRate = 0.01
102-
});
103-
104-
105-
Assert.True(bf2.Contains("Export_And_Import"));
106-
}
107-
10834
[Fact]
10935
public void Export_BitArray_And_Import()
11036
{

0 commit comments

Comments
 (0)