Skip to content

Commit 1b9a611

Browse files
committed
Merge branch 'v5.17'
# Conflicts: # RocksDbNative/pack/RocksDbNative.targets # RocksDbSharp/ColumnFamilyOptions.cs # RocksDbSharp/DbOptions.cs # RocksDbSharp/Native.Raw.cs # RocksDbSharp/WriteBatch.cs # RocksDbSharp/WriteBatchWithIndex.cs # tests/RocksDbSharpTest/FunctionalTests.cs
2 parents ead54c1 + 95f06ff commit 1b9a611

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

RocksDbSharp/ColumnFamilyOptions.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,37 @@ public ColumnFamilyOptions SetUint64addMergeOperator()
391391
/// and L4 using compression_per_level[3]. Compaction for each level can
392392
/// change when data grows.
393393
/// </summary>
394+
public ColumnFamilyOptions SetCompressionPerLevel(Compression[] levelValues, ulong numLevels)
395+
{
396+
var values = levelValues.Select(x => (int)x).ToArray();
397+
Native.Instance.rocksdb_options_set_compression_per_level(Handle, values, (UIntPtr)numLevels);
398+
return this;
399+
}
400+
401+
/// <summary>
402+
/// Different levels can have different compression policies. There
403+
/// are cases where most lower levels would like to use quick compression
404+
/// algorithms while the higher levels (which have more data) use
405+
/// compression algorithms that have better compression but could
406+
/// be slower. This array, if non-empty, should have an entry for
407+
/// each level of the database; these override the value specified in
408+
/// the previous field 'compression'.
409+
///
410+
/// NOTICE if level_compaction_dynamic_level_bytes=true,
411+
/// compression_per_level[0] still determines L0, but other elements
412+
/// of the array are based on base level (the level L0 files are merged
413+
/// to), and may not match the level users see from info log for metadata.
414+
/// If L0 files are merged to level-n, then, for i>0, compression_per_level[i]
415+
/// determines compaction type for level n+i-1.
416+
/// For example, if we have three 5 levels, and we determine to merge L0
417+
/// data to L4 (which means L1..L3 will be empty), then the new files go to
418+
/// L4 uses compression type compression_per_level[1].
419+
/// If now L0 is merged to L2. Data goes to L2 will be compressed
420+
/// according to compression_per_level[1], L3 using compression_per_level[2]
421+
/// and L4 using compression_per_level[3]. Compaction for each level can
422+
/// change when data grows.
423+
/// </summary>
424+
[Obsolete("Use Compression enum")]
394425
public ColumnFamilyOptions SetCompressionPerLevel(Compression[] levelValues, UIntPtr numLevels)
395426
{
396427
Native.Instance.rocksdb_options_set_compression_per_level(Handle, levelValues, numLevels);

tests/RocksDbSharpTest/FunctionalTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,28 @@ public void FunctionalTest()
357357
}
358358
}
359359

360+
// Test that GC does not cause access violation on Comparers
361+
{
362+
if (Directory.Exists("test-av-error"))
363+
Directory.Delete("test-av-error", true);
364+
options = new RocksDbSharp.DbOptions()
365+
.SetCreateIfMissing(true)
366+
.SetCreateMissingColumnFamilies(true);
367+
var sc = new RocksDbSharp.StringComparator(StringComparer.InvariantCultureIgnoreCase);
368+
columnFamilies = new RocksDbSharp.ColumnFamilies
369+
{
370+
{ "cf1", new RocksDbSharp.ColumnFamilyOptions()
371+
.SetComparator(sc)
372+
},
373+
};
374+
GC.Collect();
375+
using (var db = RocksDbSharp.RocksDb.Open(options, "test-av-error", columnFamilies))
376+
{
377+
}
378+
if (Directory.Exists("test-av-error"))
379+
Directory.Delete("test-av-error", true);
380+
}
381+
360382
// Smoke test various options
361383
{
362384
var dbname = "test-options";

0 commit comments

Comments
 (0)