Skip to content

Commit 6898f30

Browse files
authored
Optimize ColumnDb MultiGet allocations (#9908)
* Update ColumnDb.cs * Update ColumnDb.cs
1 parent 0277e73 commit 6898f30

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Nethermind/Nethermind.Db.Rocks/ColumnDb.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System;
55
using System.Collections.Generic;
6-
using System.Linq;
76
using Nethermind.Core;
87
using Nethermind.Core.Crypto;
98
using RocksDbSharp;
@@ -62,8 +61,15 @@ public void Merge(ReadOnlySpan<byte> key, ReadOnlySpan<byte> value, WriteFlags w
6261
_mainDb.MergeWithColumnFamily(key, _columnFamily, value, writeFlags);
6362
}
6463

65-
public KeyValuePair<byte[], byte[]?>[] this[byte[][] keys] =>
66-
_rocksDb.MultiGet(keys, keys.Select(k => _columnFamily).ToArray());
64+
public KeyValuePair<byte[], byte[]?>[] this[byte[][] keys]
65+
{
66+
get
67+
{
68+
ColumnFamilyHandle[] columnFamilies = new ColumnFamilyHandle[keys.Length];
69+
Array.Fill(columnFamilies, _columnFamily);
70+
return _rocksDb.MultiGet(keys, columnFamilies);
71+
}
72+
}
6773

6874
public IEnumerable<KeyValuePair<byte[], byte[]?>> GetAll(bool ordered = false)
6975
{

0 commit comments

Comments
 (0)