public void RocksdbGet() { for (int i = 0; i < 10; i++) { rocksdb.Get(new byte[] { 1 }.Concat(BitConverter.GetBytes(ldbGetCount++)).ToArray()); } }
private void LoadPrunedTip(RocksDbSharp.RocksDb rocksdb) { if (this.PrunedTip == null) { lock (this.blockRepository.Locker) { byte[] row = rocksdb.Get(DBH.Key(RocksdbBlockRepository.CommonTableName, prunedTipKey)); if (row != null) { this.PrunedTip = this.dataStoreSerializer.Deserialize <HashHeightPair>(row); } } } }
public Task Write(IList <MatcherEntry> entriesToPersist) { foreach (var entry in entriesToPersist) { var key = CreateKeyBuffer(entry.PeerId); FillKey(key, entry.PeerId, entry.MessageId.GetDateTime().Ticks, entry.MessageId.Value); if (entry.IsAck) { // Ack var bytes = _db.Get(key, _messagesColumnFamily); if (bytes != null) { // Acked message _db.Remove(key, _messagesColumnFamily); } else { // Ack before message _outOfOrderAcks.TryAdd(entry.MessageId, default); _db.Put(key, Array.Empty <byte>(), _acksColumnFamily); } } else { // Message if (!_outOfOrderAcks.TryRemove(entry.MessageId, out _)) { // Message before ack _db.Put(key, entry.MessageBytes, _messagesColumnFamily); } else { // Otherwise ignore the message and remove the ack as it has already been acked _db.Remove(key, _acksColumnFamily); } } } foreach (var entry in entriesToPersist.GroupBy(x => x.PeerId)) { UpdateNonAckedCounts(entry); } return(Task.CompletedTask); }
public static byte[] Get(this RocksDbSharp.RocksDb rocksDb, string key, ColumnFamilyHandle columnFamily) => rocksDb.Get(Encoding.UTF8.GetBytes(key), columnFamily);
public byte[] Get(byte[] key) { return(_db.Get(key)); }
public byte[] Get(byte[] key) => db.Get(key, columnFamilyHandle);
public static IEnumerable <KeyValuePair <byte[], byte[]> > Search(this RocksDbSharp.RocksDb database, byte[] indexKey, bool distinct, bool isSubKey) { Dictionary <ByteArray, bool> dictionary = new Dictionary <ByteArray, bool>(); using (var iterator = database.NewIterator()) { var it = iterator.Seek(indexKey); while (it.Valid()) { var iterKey = it.Key(); if (!iterKey.ContainsSequence32(indexKey)) { break; } if (isSubKey) { var key = it.Value(); if (key == null || key.Length == 0) { continue; } if (distinct) { var bKey = new ByteArray(key); if (dictionary.ContainsKey(bKey)) { continue; } dictionary[bKey] = true; } var value = database.Get(key); if (value == null || value.Length == 0) { continue; } yield return(new KeyValuePair <byte[], byte[]>(key, value)); } else { if (distinct) { var bKey = new ByteArray(iterKey); if (dictionary.ContainsKey(bKey)) { continue; } dictionary[bKey] = true; } var value = it.Value(); if (value == null || value.Length == 0) { continue; } yield return(new KeyValuePair <byte[], byte[]>(iterKey, value)); } it = it.Next(); } } }