lordgamez commented on code in PR #2203:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2203#discussion_r3775323082


##########
extensions/lmdb/LmdbWrapper.cpp:
##########
@@ -0,0 +1,267 @@
+/**
+ *
+ * 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 "LmdbWrapper.h"
+
+#include <filesystem>
+
+#include "minifi-cpp/utils/gsl.h"
+
+namespace org::apache::nifi::minifi::extensions::lmdb {
+
+bool LmdbWrapper::initialize(const std::string& directory, size_t max_db_size) 
{
+  if (const auto rc = mdb_env_create(&lmdb_env_); rc != MDB_SUCCESS) {
+    logger_->log_error("Failed to create LMDB environment: {}", 
mdb_strerror(rc));
+    return false;
+  }
+
+  logger_->log_info("Setting LMDB max DB size to {} bytes", max_db_size);
+  if (const auto rc = mdb_env_set_mapsize(lmdb_env_, max_db_size); rc != 
MDB_SUCCESS) {
+    logger_->log_error("Failed to set LMDB map size: {}", mdb_strerror(rc));
+    mdb_env_close(lmdb_env_);
+    lmdb_env_ = nullptr;
+    return false;
+  }
+
+  if (std::filesystem::exists(directory)) {
+    logger_->log_info("Using existing LMDB Repository directory at {}", 
directory);
+  } else {
+    logger_->log_info("Creating LMDB Repository directory at {}", directory);
+    if (!std::filesystem::create_directories(directory)) {
+      logger_->log_error("Failed to create LMDB Repository directory at {}", 
directory);
+      return false;
+    }

Review Comment:
   Updated in 
https://github.com/apache/nifi-minifi-cpp/pull/2203/commits/3ba06044ac47a43883c5e94932d392c91b45007b



##########
minifi-api/include/minifi-cpp/properties/Configuration.h:
##########
@@ -79,6 +79,7 @@ class Configuration : public virtual Properties {
   static constexpr const char *nifi_dbcontent_optimize_for_small_db_cache_size 
= "nifi.database.content.repository.optimize.for.small.db.cache.size";
 
   static constexpr const char *nifi_content_repository_lmdb_max_db_size = 
"nifi.content.repository.lmdb.max.db.size";
+  static constexpr const char *nifi_flowfile_repository_lmdb_max_db_size = 
"nifi.flowfile.repository.lmdb.max.db.size";

Review Comment:
   Updated in 
https://github.com/apache/nifi-minifi-cpp/pull/2203/commits/3ba06044ac47a43883c5e94932d392c91b45007b



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to