Skip to content

Commit 148d501

Browse files
committed
Update number of last range possible streams.
1 parent 9391009 commit 148d501

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using ApacheOrcDotNet.OptimizedReader.Infrastructure;
2+
using BenchmarkDotNet.Attributes;
3+
using System;
4+
using System.Collections.Generic;
5+
6+
/*
7+
| Method | Mean | Error | StdDev | Rank | Allocated |
8+
|------------------------------------ |----------:|----------:|----------:|-----:|----------:|
9+
| ArrayEquality | 7.720 ns | 0.0755 ns | 0.0706 ns | 1 | - |
10+
| DictionaryContainsKeyAndEquality | 12.429 ns | 0.0690 ns | 0.0645 ns | 2 | - |
11+
| DictionaryTryGetValue | 13.052 ns | 0.0677 ns | 0.0633 ns | 3 | - |
12+
*/
13+
14+
namespace MicroBenchmarks
15+
{
16+
[RankColumn]
17+
[MemoryDiagnoser]
18+
public class ComparisonBenchmarks
19+
{
20+
private const int size = 255;
21+
private readonly StreamRange[] _buffer = new StreamRange[size];
22+
private readonly Dictionary<int, StreamRange> _buffer2 = new();
23+
private readonly StreamRange _testRange = new StreamRange(255, 255, 255);
24+
25+
public ComparisonBenchmarks()
26+
{
27+
for (int i = 0; i < size; i++)
28+
{
29+
_buffer[i] = new StreamRange(i, i, i);
30+
_buffer2.Add(i, new StreamRange(i, i, i));
31+
}
32+
}
33+
34+
[Benchmark]
35+
public bool ArrayEquality() => _buffer[128] == _testRange;
36+
37+
[Benchmark]
38+
public bool DictionaryContainsKeyAndEquality() => _buffer2.ContainsKey(128) && _buffer[128] == _testRange;
39+
40+
[Benchmark]
41+
public bool DictionaryTryGetValue() => _buffer2.TryGetValue(128, out var range) && range == _testRange;
42+
}
43+
}

src/ApacheOrcDotNet.OptimizedReader/_Constants.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using ApacheOrcDotNet.Protocol;
2-
using System;
1+
using System;
32

43
namespace ApacheOrcDotNet.OptimizedReader
54
{
@@ -9,7 +8,7 @@ public static class Constants
98
public static DateTime UnixEpochUtc = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
109
public static DateTime UnixEpochUnspecified = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Unspecified);
1110

12-
public static int NumPossibleStreams = Enum.GetValues<StreamKind>().Length;
11+
public static int NumPossibleStreams = byte.MaxValue;
1312

1413
public const int RleBufferMaxLength = ushort.MaxValue + 1;
1514
public const int NumCompressedBlocksToPreLoad = 2;

0 commit comments

Comments
 (0)