adamdebreceni commented on a change in pull request #1071:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1071#discussion_r647380261



##########
File path: extensions/rocksdb-repos/database/OpenRocksDb.cpp
##########
@@ -0,0 +1,116 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "OpenRocksDb.h"
+#include "ColumnHandle.h"
+#include "RocksDbInstance.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace internal {
+
+OpenRocksDb::OpenRocksDb(RocksDbInstance& db, 
gsl::not_null<std::shared_ptr<rocksdb::DB>> impl, 
gsl::not_null<std::shared_ptr<ColumnHandle>> column)
+    : db_(&db), impl_(std::move(impl)), column_(std::move(column)) {}
+
+rocksdb::Status OpenRocksDb::Put(const rocksdb::WriteOptions& options, const 
rocksdb::Slice& key, const rocksdb::Slice& value) {
+  rocksdb::Status result = impl_->Put(options, column_->handle.get(), key, 
value);
+  if (result == rocksdb::Status::NoSpace()) {
+    db_->invalidate();
+  }
+  return result;
+}
+
+rocksdb::Status OpenRocksDb::Get(const rocksdb::ReadOptions& options, const 
rocksdb::Slice& key, std::string* value) {
+  rocksdb::Status result = impl_->Get(options, column_->handle.get(), key, 
value);
+  if (result == rocksdb::Status::NoSpace()) {
+    db_->invalidate();
+  }
+  return result;
+}
+
+std::vector<rocksdb::Status> OpenRocksDb::MultiGet(const rocksdb::ReadOptions& 
options, const std::vector<rocksdb::Slice>& keys, std::vector<std::string>* 
values) {
+  std::vector<rocksdb::Status> results = impl_->MultiGet(
+      options, std::vector<rocksdb::ColumnFamilyHandle*>(keys.size(), 
column_->handle.get()), keys, values);
+  for (const auto& result : results) {
+    if (result == rocksdb::Status::NoSpace()) {

Review comment:
       I vaguely recall encountering no space errors even during get but I 
cannot say for sure, `NoSpace` error is special in that we have to reopen the 
database even if the storage shortcomings have been addressed, if we were to 
break on other errors we might miss the subsequent `NoSpace` error (not like 
the `NoSpace` error wound be our biggest concern then)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to