コード例 #1
0
ファイル: SkipListFacts.cs プロジェクト: vchirikov/TrimDB
        public void SkipListPutWorking()
        {
            var string1 = Encoding.UTF8.GetBytes("This is the first test string");
            var string2 = Encoding.UTF8.GetBytes("This is the second test string");
            var string3 = Encoding.UTF8.GetBytes("This is the missing test string");
            var value1  = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            var value2  = new byte[] { 10, 11, 12, 13, 14, 15 };

            _ = new byte[] { 16, 17, 18, 19, 20 };

            var allocator = new NativeAllocator(4096, 5);
            var skipList  = new SkipList.SkipList(allocator);

            skipList.Put(string1, value1);
            skipList.Put(string2, value2);
            var result = skipList.TryGet(string1, out _);

            Assert.Equal(SearchResult.Found, result);
            var result2 = skipList.TryGet(string2, out _);

            Assert.Equal(SearchResult.Found, result2);
            var result3 = skipList.TryGet(string3, out _);

            Assert.Equal(SearchResult.NotFound, result3);
        }
コード例 #2
0
        public NativeArray(int length)
        {
            var tuple = NativeAllocator.Alloc <T>(length);

            this.ptr    = tuple.ptr;
            this.bytes  = tuple.bytes;
            this.length = length;
        }
コード例 #3
0
ファイル: SkipListInsert.cs プロジェクト: vchirikov/TrimDB
        public async Task NativeAllocator()
        {
            using var simpleAllocator = new NativeAllocator(4096 * 1024 * 2, TableHeight);
            var skipList = new SkipList(simpleAllocator);
            var tasks    = new Task[Environment.ProcessorCount];

            for (var i = 0; i < tasks.Length; i++)
            {
                tasks[i] = Task.Run(() => ThreadedPut(skipList));
            }
            await Task.WhenAll(tasks);
        }
コード例 #4
0
 public void Free()
 {
     NativeAllocator.Free(this.ptr);
 }