http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/libminifi/test/unit/ProvenanceTests.cpp ---------------------------------------------------------------------- diff --git a/libminifi/test/unit/ProvenanceTests.cpp b/libminifi/test/unit/ProvenanceTests.cpp deleted file mode 100644 index 97cb646..0000000 --- a/libminifi/test/unit/ProvenanceTests.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/** - * - * 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. - */ - -#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file -#include "../TestBase.h" -#include <utility> -#include <memory> -#include <string> -#include <map> -#include "ProvenanceTestHelper.h" -#include "provenance/Provenance.h" -#include "FlowFileRecord.h" -#include "core/Core.h" -#include "core/repository/AtomicRepoEntries.h" -#include "core/repository/VolatileProvenanceRepository.h" - -TEST_CASE("Test Provenance record create", "[Testprovenance::ProvenanceEventRecord]") { - provenance::ProvenanceEventRecord record1(provenance::ProvenanceEventRecord::ProvenanceEventType::CREATE, "blah", "blahblah"); - REQUIRE(record1.getAttributes().size() == 0); - REQUIRE(record1.getAlternateIdentifierUri().length() == 0); -} - -TEST_CASE("Test Provenance record serialization", "[Testprovenance::ProvenanceEventRecordSerializeDeser]") { - provenance::ProvenanceEventRecord record1(provenance::ProvenanceEventRecord::ProvenanceEventType::CREATE, "componentid", "componenttype"); - - std::string eventId = record1.getEventId(); - - std::string smileyface = ":)"; - record1.setDetails(smileyface); - - uint64_t sample = 65555; - std::shared_ptr<core::Repository> testRepository = std::make_shared<TestRepository>(); - record1.setEventDuration(sample); - - record1.Serialize(testRepository); - provenance::ProvenanceEventRecord record2; - record2.setEventId(eventId); - REQUIRE(record2.DeSerialize(testRepository) == true); - REQUIRE(record2.getEventId() == record1.getEventId()); - REQUIRE(record2.getComponentId() == record1.getComponentId()); - REQUIRE(record2.getComponentType() == record1.getComponentType()); - REQUIRE(record2.getDetails() == record1.getDetails()); - REQUIRE(record2.getDetails() == smileyface); - REQUIRE(record2.getEventDuration() == sample); -} - -TEST_CASE("Test Flowfile record added to provenance", "[TestFlowAndProv1]") { - provenance::ProvenanceEventRecord record1(provenance::ProvenanceEventRecord::ProvenanceEventType::CLONE, "componentid", "componenttype"); - std::shared_ptr<core::ContentRepository> content_repo = std::make_shared<core::repository::VolatileContentRepository>(); - std::string eventId = record1.getEventId(); - std::map<std::string, std::string> attributes; - attributes.insert(std::pair<std::string, std::string>("potato", "potatoe")); - attributes.insert(std::pair<std::string, std::string>("tomato", "tomatoe")); - std::shared_ptr<core::repository::FlowFileRepository> frepo = std::make_shared<core::repository::FlowFileRepository>("ff", "./content_repository", 0, 0, 0); - std::shared_ptr<minifi::FlowFileRecord> ffr1 = std::make_shared<minifi::FlowFileRecord>(frepo, content_repo, attributes); - - record1.addChildFlowFile(ffr1); - - uint64_t sample = 65555; - std::shared_ptr<core::Repository> testRepository = std::make_shared<TestRepository>(); - record1.setEventDuration(sample); - - record1.Serialize(testRepository); - provenance::ProvenanceEventRecord record2; - record2.setEventId(eventId); - REQUIRE(record2.DeSerialize(testRepository) == true); - REQUIRE(record1.getChildrenUuids().size() == 1); - REQUIRE(record2.getChildrenUuids().size() == 1); - std::string childId = record2.getChildrenUuids().at(0); - REQUIRE(childId == ffr1->getUUIDStr()); - record2.removeChildUuid(childId); - REQUIRE(record2.getChildrenUuids().size() == 0); -} - -TEST_CASE("Test Provenance record serialization Volatile", "[Testprovenance::ProvenanceEventRecordSerializeDeser]") { - provenance::ProvenanceEventRecord record1(provenance::ProvenanceEventRecord::ProvenanceEventType::CREATE, "componentid", "componenttype"); - - std::string eventId = record1.getEventId(); - - std::string smileyface = ":)"; - record1.setDetails(smileyface); - - uint64_t sample = 65555; - - std::shared_ptr<core::Repository> testRepository = std::make_shared<core::repository::VolatileProvenanceRepository>(); - testRepository->initialize(0); - record1.setEventDuration(sample); - - record1.Serialize(testRepository); - provenance::ProvenanceEventRecord record2; - record2.setEventId(eventId); - REQUIRE(record2.DeSerialize(testRepository) == true); - REQUIRE(record2.getEventId() == record1.getEventId()); - REQUIRE(record2.getComponentId() == record1.getComponentId()); - REQUIRE(record2.getComponentType() == record1.getComponentType()); - REQUIRE(record2.getDetails() == record1.getDetails()); - REQUIRE(record2.getDetails() == smileyface); - REQUIRE(record2.getEventDuration() == sample); -} - -TEST_CASE("Test Flowfile record added to provenance using Volatile Repo", "[TestFlowAndProv1]") { - provenance::ProvenanceEventRecord record1(provenance::ProvenanceEventRecord::ProvenanceEventType::CLONE, "componentid", "componenttype"); - std::shared_ptr<core::ContentRepository> content_repo = std::make_shared<core::repository::VolatileContentRepository>(); - std::string eventId = record1.getEventId(); - std::map<std::string, std::string> attributes; - attributes.insert(std::pair<std::string, std::string>("potato", "potatoe")); - attributes.insert(std::pair<std::string, std::string>("tomato", "tomatoe")); - std::shared_ptr<core::Repository> frepo = std::make_shared<core::repository::VolatileProvenanceRepository>(); - frepo->initialize(0); - std::shared_ptr<minifi::FlowFileRecord> ffr1 = std::make_shared<minifi::FlowFileRecord>(frepo, content_repo, attributes); - - record1.addChildFlowFile(ffr1); - - uint64_t sample = 65555; - std::shared_ptr<core::Repository> testRepository = std::make_shared<core::repository::VolatileProvenanceRepository>(); - testRepository->initialize(0); - record1.setEventDuration(sample); - - record1.Serialize(testRepository); - provenance::ProvenanceEventRecord record2; - record2.setEventId(eventId); - REQUIRE(record2.DeSerialize(testRepository) == true); - REQUIRE(record1.getChildrenUuids().size() == 1); - REQUIRE(record2.getChildrenUuids().size() == 1); - std::string childId = record2.getChildrenUuids().at(0); - REQUIRE(childId == ffr1->getUUIDStr()); - record2.removeChildUuid(childId); - REQUIRE(record2.getChildrenUuids().size() == 0); -} - -TEST_CASE("Test Provenance record serialization NoOp", "[Testprovenance::ProvenanceEventRecordSerializeDeser]") { - provenance::ProvenanceEventRecord record1(provenance::ProvenanceEventRecord::ProvenanceEventType::CREATE, "componentid", "componenttype"); - - std::string eventId = record1.getEventId(); - - std::string smileyface = ":)"; - record1.setDetails(smileyface); - - uint64_t sample = 65555; - - std::shared_ptr<core::Repository> testRepository = std::make_shared<core::Repository>(); - testRepository->initialize(0); - record1.setEventDuration(sample); - - REQUIRE(record1.Serialize(testRepository) == true); - provenance::ProvenanceEventRecord record2; - record2.setEventId(eventId); - REQUIRE(record2.DeSerialize(testRepository) == false); -}
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/libminifi/test/unit/RepoTests.cpp ---------------------------------------------------------------------- diff --git a/libminifi/test/unit/RepoTests.cpp b/libminifi/test/unit/RepoTests.cpp deleted file mode 100644 index 6ee690b..0000000 --- a/libminifi/test/unit/RepoTests.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/** - * - * 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. - */ -#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file -#include "../TestBase.h" -#include <memory> -#include <string> -#include <map> -#include "ProvenanceTestHelper.h" -#include "provenance/Provenance.h" -#include "FlowFileRecord.h" -#include "core/Core.h" -#include "core/repository/FlowFileRepository.h" -#include "../../include/core/repository/AtomicRepoEntries.h" -#include "properties/Configure.h" - -TEST_CASE("Test Repo Empty Value Attribute", "[TestFFR1]") { - TestController testController; - char format[] = "/tmp/testRepo.XXXXXX"; - char *dir = testController.createTempDirectory(format); - std::shared_ptr<core::repository::FlowFileRepository> repository = std::make_shared<core::repository::FlowFileRepository>("ff", dir, 0, 0, 1); - - repository->initialize(std::make_shared<minifi::Configure>()); - - std::shared_ptr<core::ContentRepository> content_repo = std::make_shared<core::repository::VolatileContentRepository>(); - minifi::FlowFileRecord record(repository, content_repo); - - record.addAttribute("keyA", ""); - - REQUIRE(true == record.Serialize()); - - repository->stop(); -} - -TEST_CASE("Test Repo Empty Key Attribute ", "[TestFFR2]") { - TestController testController; - char format[] = "/tmp/testRepo.XXXXXX"; - char *dir = testController.createTempDirectory(format); - std::shared_ptr<core::repository::FlowFileRepository> repository = std::make_shared<core::repository::FlowFileRepository>("ff", dir, 0, 0, 1); - - repository->initialize(std::make_shared<minifi::Configure>()); - std::shared_ptr<core::ContentRepository> content_repo = std::make_shared<core::repository::VolatileContentRepository>(); - minifi::FlowFileRecord record(repository, content_repo); - - record.addAttribute("keyA", "hasdgasdgjsdgasgdsgsadaskgasd"); - - record.addAttribute("", "hasdgasdgjsdgasgdsgsadaskgasd"); - - REQUIRE(true == record.Serialize()); - - repository->stop(); -} - -TEST_CASE("Test Repo Key Attribute Verify ", "[TestFFR3]") { - TestController testController; - char format[] = "/tmp/testRepo.XXXXXX"; - char *dir = testController.createTempDirectory(format); - std::shared_ptr<core::repository::FlowFileRepository> repository = std::make_shared<core::repository::FlowFileRepository>("ff", dir, 0, 0, 1); - - repository->initialize(std::make_shared<org::apache::nifi::minifi::Configure>()); - - std::shared_ptr<core::ContentRepository> content_repo = std::make_shared<core::repository::VolatileContentRepository>(); - minifi::FlowFileRecord record(repository, content_repo); - - minifi::FlowFileRecord record2(repository, content_repo); - - std::string uuid = record.getUUIDStr(); - - record.addAttribute("keyA", "hasdgasdgjsdgasgdsgsadaskgasd"); - - record.addAttribute("keyB", ""); - - record.addAttribute("", ""); - - record.updateAttribute("", "hasdgasdgjsdgasgdsgsadaskgasd2"); - - record.addAttribute("", "sdgsdg"); - - REQUIRE(true == record.Serialize()); - - repository->stop(); - - record2.DeSerialize(uuid); - - std::string value; - REQUIRE(true == record2.getAttribute("", value)); - - REQUIRE("hasdgasdgjsdgasgdsgsadaskgasd2" == value); - - REQUIRE(false == record2.getAttribute("key", value)); - REQUIRE(true == record2.getAttribute("keyA", value)); - REQUIRE("hasdgasdgjsdgasgdsgsadaskgasd" == value); - - REQUIRE(true == record2.getAttribute("keyB", value)); - REQUIRE("" == value); -} - -TEST_CASE("Test Delete Content ", "[TestFFR4]") { - TestController testController; - char format[] = "/tmp/testRepo.XXXXXX"; - LogTestController::getInstance().setDebug<core::ContentRepository>(); - LogTestController::getInstance().setDebug<core::repository::FileSystemRepository>(); - LogTestController::getInstance().setDebug<core::repository::FlowFileRepository>(); - - char *dir = testController.createTempDirectory(format); - - std::shared_ptr<core::repository::FlowFileRepository> repository = std::make_shared<core::repository::FlowFileRepository>("ff", dir, 0, 0, 1); - - std::map<std::string, std::string> attributes; - - std::fstream file; - std::stringstream ss; - ss << dir << "/" << "tstFile.ext"; - file.open(ss.str(), std::ios::out); - file << "tempFile"; - file.close(); - - std::shared_ptr<core::ContentRepository> content_repo = std::make_shared<core::repository::FileSystemRepository>(); - - repository->initialize(std::make_shared<minifi::Configure>()); - - repository->loadComponent(content_repo); - - std::shared_ptr<minifi::ResourceClaim> claim = std::make_shared<minifi::ResourceClaim>(ss.str(), content_repo); - - minifi::FlowFileRecord record(repository, content_repo, attributes, claim); - - record.addAttribute("keyA", "hasdgasdgjsdgasgdsgsadaskgasd"); - - record.addAttribute("", "hasdgasdgjsdgasgdsgsadaskgasd"); - - REQUIRE(true == record.Serialize()); - - claim->decreaseFlowFileRecordOwnedCount(); - - claim->decreaseFlowFileRecordOwnedCount(); - - repository->Delete(record.getUUIDStr()); - - repository->flush(); - - repository->stop(); - - std::ifstream fileopen(ss.str()); - REQUIRE(false == fileopen.good()); - - LogTestController::getInstance().reset(); -} http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/main/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 249dd8e..ef2bbbc 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -23,7 +23,18 @@ IF(POLICY CMP0048) CMAKE_POLICY(SET CMP0048 OLD) ENDIF(POLICY CMP0048) -include_directories(../libminifi/include ../libminifi/include/c2 ../libminifi/include/c2/protocols/ ../libminifi/include/core/state ./libminifi/include/core/statemanagement/metrics ../libminifi/include/core/yaml ../libminifi/include/core ../thirdparty/spdlog-20170710/include ../thirdparty/concurrentqueue ../thirdparty/yaml-cpp-yaml-cpp-0.5.3/include ../thirdparty/civetweb-1.9.1/include ../thirdparty/jsoncpp/include ../thirdparty/leveldb-1.18/include ../thirdparty/) +include_directories(../libminifi/include ../libminifi/include/c2 ../libminifi/include/c2/protocols/ ../libminifi/include/core/state ./libminifi/include/core/statemanagement/metrics ../libminifi/include/core/yaml ../libminifi/include/core ../thirdparty/spdlog-20170710/include ../thirdparty/concurrentqueue ../thirdparty/yaml-cpp-yaml-cpp-0.5.3/include ../thirdparty/civetweb-1.9.1/include ../thirdparty/jsoncpp/include ../thirdparty/) + +include(CheckCXXCompilerFlag) +CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) +CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) +if(COMPILER_SUPPORTS_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Os") +elseif(COMPILER_SUPPORTS_CXX0X) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Os") +else() + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") +endif() find_package(Boost REQUIRED) include_directories(${Boost_INCLUDE_DIRS}) @@ -43,23 +54,28 @@ find_package(UUID REQUIRED) find_package(OpenSSL REQUIRED) include_directories(${OPENSSL_INCLUDE_DIR}) -# Link against minifi, yaml-cpp, civetweb-cpp, uuid, openssl, jsoncpp and leveldb -target_link_libraries(minifiexe minifi yaml-cpp c-library civetweb-cpp ${JSON_CPP_LIB} ${UUID_LIBRARIES} ${LEVELDB_LIBRARIES} ${OPENSSL_LIBRARIES}) -message("**** HTTP Curl is from libminifi ${HTTP-CURL}") +# Link against minifi, yaml-cpp, civetweb-cpp, uuid, openssl, jsoncpp and rocksdb +target_link_libraries(minifiexe minifi yaml-cpp c-library civetweb-cpp ${JSON_CPP_LIB} ${UUID_LIBRARIES} ${OPENSSL_LIBRARIES}) if (APPLE) if (HTTP-CURL) target_link_libraries (minifiexe -Wl,-all_load ${HTTP-CURL}) endif() + if (ROCKSDB-REPOS) + target_link_libraries (minifiexe -Wl,-all_load ${ROCKSDB-REPOS}) + endif() + else () if (HTTP-CURL) target_link_libraries (minifiexe -Wl,--whole-archive ${HTTP-CURL} -Wl,--no-whole-archive) - endif() + endif() + if (ROCKSDB-REPOS) + target_link_libraries (minifiexe -Wl,--whole-archive ${ROCKSDB-REPOS} -Wl,--no-whole-archive) + endif() endif () set_property(TARGET minifiexe PROPERTY INTERPROCEDURAL_OPTIMIZATION True) -#SET (MYLIB -Wl,-all_load minifi-accumulo) -#TARGET_LINK_LIBRARIES(minifiexe ${MYLIB} ) + set_target_properties(minifiexe PROPERTIES OUTPUT_NAME minifi) @@ -68,4 +84,8 @@ set_target_properties(minifiexe install(TARGETS minifiexe RUNTIME DESTINATION bin - COMPONENT bin) \ No newline at end of file + COMPONENT bin) + + +add_custom_command(TARGET minifiexe POST_BUILD + COMMAND cat ${CMAKE_BINARY_DIR}/all.log) http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/main/MiNiFiMain.cpp ---------------------------------------------------------------------- diff --git a/main/MiNiFiMain.cpp b/main/MiNiFiMain.cpp index 3afa06e..4f29636 100644 --- a/main/MiNiFiMain.cpp +++ b/main/MiNiFiMain.cpp @@ -86,6 +86,9 @@ int main(int argc, char **argv) { uint16_t stop_wait_time = STOP_WAIT_TIME_MS; + // initialize static functions that were defined apriori + core::FlowConfiguration::initialize_static_functions(); + std::string graceful_shutdown_seconds = ""; std::string prov_repo_class = "provenancerepository"; std::string flow_repo_class = "flowfilerepository"; http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/.gitignore ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/.gitignore b/thirdparty/leveldb-1.18/.gitignore deleted file mode 100755 index 8d3a4c4..0000000 --- a/thirdparty/leveldb-1.18/.gitignore +++ /dev/null @@ -1,33 +0,0 @@ -build_config.mk - -db_bench -leveldbutil -*_test - -*.slo -*.lo -*.o - -# Compiled Dynamic libraries -*.so -*.so.* -*.dylib* - -# Compiled Static libraries -*.lai -*.la -*.a - - -/project/ - -# CMake -/CMakeFiles/ -*.dir/ -cmake_install.cmake -/CMakeCache.txt - -# Visual Studio -*.sln -*.vcxproj -*.vcxproj.filters \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/AUTHORS ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/AUTHORS b/thirdparty/leveldb-1.18/AUTHORS deleted file mode 100755 index 2439d7a..0000000 --- a/thirdparty/leveldb-1.18/AUTHORS +++ /dev/null @@ -1,12 +0,0 @@ -# Names should be added to this file like so: -# Name or Organization <email address> - -Google Inc. - -# Initial version authors: -Jeffrey Dean <[email protected]> -Sanjay Ghemawat <[email protected]> - -# Partial list of contributors: -Kevin Regan <[email protected]> -Johan Bilien <[email protected]> http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/CMakeLists.txt b/thirdparty/leveldb-1.18/CMakeLists.txt deleted file mode 100755 index f053739..0000000 --- a/thirdparty/leveldb-1.18/CMakeLists.txt +++ /dev/null @@ -1,186 +0,0 @@ -cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR) - -project(leveldb CXX) -set(CMAKE_DEBUG_POSTFIX "d") - -set(Boost_USE_STATIC_LIBS ON) -set(Boost_USE_MULTITHREAD ON) -set(Boost_USE_STATIC_RUNTIME OFF) - -find_package(Boost COMPONENTS - date_time - filesystem - system - REQUIRED) - -set(SNAPPY_LIBRARY "") - -if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - add_definitions(-DOS_LINUX) -elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - add_definitions(-DOS_FREEBSD) -elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - add_definitions(-DOS_MACOSX) -endif() - -string(REGEX MATCH "clang" CLANG ${CMAKE_CXX_COMPILER}) - -if(CMAKE_COMPILER_IS_GNUCXX OR CLANG) - find_library(Pthread_LIBRARY pthread) - find_library(Realtime_LIBRARY rt) - # find library can be problematic with stdc++ which is why we hardwire the link - set(Stdcpp_LIBRARY stdc++) -else(CMAKE_COMPILER_IS_GNUCXX OR CLANG) - set(Pthread_LIBRARY "") - set(Realtime_LIBRARY "") - set(Stdcpp_LIBRARY "") -endif(CMAKE_COMPILER_IS_GNUCXX OR CLANG) - -include_directories(${Boost_INCLUDE_DIRS} - ${CMAKE_CURRENT_SOURCE_DIR} - include) - -if(MSVC) - add_compile_options( - /D_CRT_SECURE_NO_WARNINGS - /wd4389 # signed/unsigned mismatch - /wd4800 # constructor never returns, potential memory leak because of a singleton pattern - /wd4722 # unreachable code because of singleton pattern - /wd4702 # bool cast performance warning - ) -else() - add_compile_options( - -Wno-sign-compare - -std=c++11 - ) -endif() - -add_definitions( - -DLEVELDB_ATOMIC_PRESENT -) - -set(LEVEL_DB_FILES - include/leveldb/c.h - include/leveldb/cache.h - include/leveldb/comparator.h - include/leveldb/db.h - include/leveldb/dumpfile.h - include/leveldb/env.h - include/leveldb/iterator.h - include/leveldb/filter_policy.h - include/leveldb/iterator.h - include/leveldb/options.h - include/leveldb/slice.h - include/leveldb/status.h - include/leveldb/table.h - include/leveldb/table_builder.h - include/leveldb/write_batch.h - db/builder.cc - db/builder.h - db/db_impl.cc - db/db_impl.h - db/db_iter.cc - db/db_iter.h - db/dbformat.cc - db/dbformat.h - db/dumpfile.cc - db/filename.cc - db/filename.h - db/log_format.h - db/log_reader.cc - db/log_reader.h - db/log_writer.cc - db/log_writer.h - db/skiplist.h - db/snapshot.h - db/memtable.cc - db/memtable.h - db/repair.cc - db/table_cache.cc - db/table_cache.h - db/version_edit.cc - db/version_edit.h - db/version_set.cc - db/version_set.h - db/write_batch.cc - table/block.cc - table/block.h - table/block_builder.cc - table/block_builder.h - table/filter_block.cc - table/filter_block.h - table/format.cc - table/format.h - table/iterator.cc - table/iterator_wrapper.h - table/merger.cc - table/merger.h - table/table.cc - table/table_builder.cc - table/two_level_iterator.cc - table/two_level_iterator.h - util/arena.cc - util/arena.h - util/bloom.cc - util/cache.cc - util/coding.cc - util/coding.h - util/comparator.cc - util/crc32c.cc - util/crc32c.h - util/env.cc - util/filter_policy.cc - util/hash.cc - util/hash.h - util/histogram.cc - util/histogram.h - util/logging.cc - util/logging.h - util/mutexlock.h - util/options.cc - util/random.h - util/status.cc - port/port.h) - -if(WIN32) - list(APPEND LEVEL_DB_FILES - port/port_win.h - port/port_win.cc - util/win_logger.h - util/win_logger.cc - util/env_boost.cc) -else() - list(APPEND LEVEL_DB_FILES - port/port_posix.h - port/port_posix.cc - util/posix_logger.h - util/env_posix.cc) -endif() - -add_library(leveldb ${LEVEL_DB_FILES}) - -target_include_directories(leveldb - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} -) - -target_link_libraries(leveldb - PRIVATE - ${Boost_LIBRARIES} - ${Pthread_LIBRARY} -) - -add_executable(leveldbutil - db/leveldb_main.cc) - -target_link_libraries(leveldbutil - leveldb) - -set_target_properties(leveldbutil PROPERTIES - DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) - -# we distribute the leveldbutil as it might be useful -install(TARGETS leveldbutil - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/LICENSE ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/LICENSE b/thirdparty/leveldb-1.18/LICENSE deleted file mode 100755 index 8e80208..0000000 --- a/thirdparty/leveldb-1.18/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011 The LevelDB Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/NEWS ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/NEWS b/thirdparty/leveldb-1.18/NEWS deleted file mode 100755 index 3fd9924..0000000 --- a/thirdparty/leveldb-1.18/NEWS +++ /dev/null @@ -1,17 +0,0 @@ -Release 1.2 2011-05-16 ----------------------- - -Fixes for larger databases (tested up to one billion 100-byte entries, -i.e., ~100GB). - -(1) Place hard limit on number of level-0 files. This fixes errors -of the form "too many open files". - -(2) Fixed memtable management. Before the fix, a heavy write burst -could cause unbounded memory usage. - -A fix for a logging bug where the reader would incorrectly complain -about corruption. - -Allow public access to WriteBatch contents so that users can easily -wrap a DB. http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/README ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/README b/thirdparty/leveldb-1.18/README deleted file mode 100755 index 3618ade..0000000 --- a/thirdparty/leveldb-1.18/README +++ /dev/null @@ -1,51 +0,0 @@ -leveldb: A key-value store -Authors: Sanjay Ghemawat ([email protected]) and Jeff Dean ([email protected]) - -The code under this directory implements a system for maintaining a -persistent key/value store. - -See doc/index.html for more explanation. -See doc/impl.html for a brief overview of the implementation. - -The public interface is in include/*.h. Callers should not include or -rely on the details of any other header files in this package. Those -internal APIs may be changed without warning. - -Guide to header files: - -include/db.h - Main interface to the DB: Start here - -include/options.h - Control over the behavior of an entire database, and also - control over the behavior of individual reads and writes. - -include/comparator.h - Abstraction for user-specified comparison function. If you want - just bytewise comparison of keys, you can use the default comparator, - but clients can write their own comparator implementations if they - want custom ordering (e.g. to handle different character - encodings, etc.) - -include/iterator.h - Interface for iterating over data. You can get an iterator - from a DB object. - -include/write_batch.h - Interface for atomically applying multiple updates to a database. - -include/slice.h - A simple module for maintaining a pointer and a length into some - other byte array. - -include/status.h - Status is returned from many of the public interfaces and is used - to report success and various kinds of errors. - -include/env.h - Abstraction of the OS environment. A posix implementation of - this interface is in util/env_posix.cc - -include/table.h -include/table_builder.h - Lower-level modules that most clients probably won't use directly http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/README.md ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/README.md b/thirdparty/leveldb-1.18/README.md deleted file mode 100755 index 760cb10..0000000 --- a/thirdparty/leveldb-1.18/README.md +++ /dev/null @@ -1,20 +0,0 @@ -LevelDB qdb branch -================== - -Current version: 1.18 - -quasardb [LevelDB](http://code.google.com/p/leveldb/) branch with full Windows support. This is not an official LevelDB branch, but the branch we use in our product, [quasardb](https://www.quasardb.net/). - -* Full Windows support: everything builds, all tests pass; -* [CMake](http://www.cmake.org/) based build -* Explicit (thread unsafe) de-allocation routines for "clean exits". Helps a lot when running your application into a leak detector; -* The Windows build requires [Boost](http://www.boost.org/); -* Our code is C++11ish and may require a recent compiler; -* Lots of warnings fixed; -* Is not 100% compliant with Google coding style. - -Tested on [FreeBSD](http://www.freebsd.org/), Linux and Windows (32-bit & 64-bit). - -Might contains trace of nuts. - -Comments? Questions? Suggestions? Pull! http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/TODO ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/TODO b/thirdparty/leveldb-1.18/TODO deleted file mode 100755 index e603c07..0000000 --- a/thirdparty/leveldb-1.18/TODO +++ /dev/null @@ -1,14 +0,0 @@ -ss -- Stats - -db -- Maybe implement DB::BulkDeleteForRange(start_key, end_key) - that would blow away files whose ranges are entirely contained - within [start_key..end_key]? For Chrome, deletion of obsolete - object stores, etc. can be done in the background anyway, so - probably not that important. -- There have been requests for MultiGet. - -After a range is completely deleted, what gets rid of the -corresponding files if we do no future changes to that range. Make -the conditions for triggering compactions fire in more situations? http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/WINDOWS ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/WINDOWS b/thirdparty/leveldb-1.18/WINDOWS deleted file mode 100755 index 9435809..0000000 --- a/thirdparty/leveldb-1.18/WINDOWS +++ /dev/null @@ -1,42 +0,0 @@ -INSTRUCTIONS FOR BUILDING LEVELDB ON WINDOWS / MSVC++ -(Tested with Microsoft Visual C++ 2010 Express) - -1. Install Boost - You'll need the Boost libraries to compile LevelDB on Windows: - http://www.boost.org/users/download/ - You'll need at least the following Boost packages: - - date_time - - filesystem - - thread - - interprocess - -2. To create your LevelDB project, choose: - New -> "Project From Existing Code" - and point Visual Studio to the leveldb root directory. - -3. To just build the benchmarking tools, choose: - Project Type: "Console application project" - -4. In the configuration settings, make sure you include - Preprocessor definitions: LEVELDB_PLATFORM_WINDOWS;OS_WIN - You can also add these later in: - Project -> Properties -> - Configuration Properties -> C/C++ -> Preprocessor Definitions - - Include the root directory of your LevelDB sources in header search paths. - You can also add this later in: - Project -> Properties -> - Configuration Properties -> C/C++ -> Additional Include Directories - -5. Add boost/lib directory to Linker paths: - Project -> Properties -> Linker -> General -> Additional Library Dependencies - -6. Manually exclude the following files from the build - (Solution Explorer -> right-click on file -> Exclude from Project) - - port/port_android.cc - - port/port_posix.cc - - util/env_chromium.cc - - util/env_posix.cc - -7. Manually exclude all the *_test.cc and *_bench.cc files you don't want - to build. There should only be one .cc file with a main() in your project. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/build_detect_platform ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/build_detect_platform b/thirdparty/leveldb-1.18/build_detect_platform deleted file mode 100755 index bb76c4f..0000000 --- a/thirdparty/leveldb-1.18/build_detect_platform +++ /dev/null @@ -1,228 +0,0 @@ -#!/bin/sh -# -# Detects OS we're compiling on and outputs a file specified by the first -# argument, which in turn gets read while processing Makefile. -# -# The output will set the following variables: -# CC C Compiler path -# CXX C++ Compiler path -# PLATFORM_LDFLAGS Linker flags -# PLATFORM_LIBS Libraries flags -# PLATFORM_SHARED_EXT Extension for shared libraries -# PLATFORM_SHARED_LDFLAGS Flags for building shared library -# This flag is embedded just before the name -# of the shared library without intervening spaces -# PLATFORM_SHARED_CFLAGS Flags for compiling objects for shared library -# PLATFORM_CCFLAGS C compiler flags -# PLATFORM_CXXFLAGS C++ compiler flags. Will contain: -# PLATFORM_SHARED_VERSIONED Set to 'true' if platform supports versioned -# shared libraries, empty otherwise. -# -# The PLATFORM_CCFLAGS and PLATFORM_CXXFLAGS might include the following: -# -# -DLEVELDB_ATOMIC_PRESENT if <atomic> is present -# -DLEVELDB_PLATFORM_POSIX for Posix-based platforms -# -DSNAPPY if the Snappy library is present -# - -OUTPUT=$1 -PREFIX=$2 -if test -z "$OUTPUT" || test -z "$PREFIX"; then - echo "usage: $0 <output-filename> <directory_prefix>" >&2 - exit 1 -fi - -# Delete existing output, if it exists -rm -f $OUTPUT -touch $OUTPUT - -if test -z "$CC"; then - CC=cc -fi - -if test -z "$CXX"; then - CXX=g++ -fi - -if test -z "$TMPDIR"; then - TMPDIR=/tmp -fi - -# Detect OS -if test -z "$TARGET_OS"; then - TARGET_OS=`uname -s` -fi - -COMMON_FLAGS= -CROSS_COMPILE= -PLATFORM_CCFLAGS= -PLATFORM_CXXFLAGS= -PLATFORM_LDFLAGS= -PLATFORM_LIBS= -PLATFORM_SHARED_EXT="so" -PLATFORM_SHARED_LDFLAGS="-shared -Wl,-soname -Wl," -PLATFORM_SHARED_CFLAGS="-fPIC" -PLATFORM_SHARED_VERSIONED=true - -MEMCMP_FLAG= -if [ "$CXX" = "g++" ]; then - # Use libc's memcmp instead of GCC's memcmp. This results in ~40% - # performance improvement on readrandom under gcc 4.4.3 on Linux/x86. - MEMCMP_FLAG="-fno-builtin-memcmp" -fi - -case "$TARGET_OS" in - CYGWIN_*) - PLATFORM=OS_LINUX - COMMON_FLAGS="$MEMCMP_FLAG -lpthread -DOS_LINUX -DCYGWIN" - PLATFORM_LDFLAGS="-lpthread" - PORT_FILE=port/port_posix.cc - ;; - Darwin) - PLATFORM=OS_MACOSX - COMMON_FLAGS="$MEMCMP_FLAG -DOS_MACOSX" - PLATFORM_SHARED_EXT=dylib - [ -z "$INSTALL_PATH" ] && INSTALL_PATH=`pwd` - PLATFORM_SHARED_LDFLAGS="-dynamiclib -install_name $INSTALL_PATH/" - PORT_FILE=port/port_posix.cc - ;; - Linux) - PLATFORM=OS_LINUX - COMMON_FLAGS="$MEMCMP_FLAG -pthread -DOS_LINUX" - PLATFORM_LDFLAGS="-pthread" - PORT_FILE=port/port_posix.cc - ;; - SunOS) - PLATFORM=OS_SOLARIS - COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_SOLARIS" - PLATFORM_LIBS="-lpthread -lrt" - PORT_FILE=port/port_posix.cc - ;; - FreeBSD) - PLATFORM=OS_FREEBSD - COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_FREEBSD" - PLATFORM_LIBS="-lpthread" - PORT_FILE=port/port_posix.cc - ;; - NetBSD) - PLATFORM=OS_NETBSD - COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_NETBSD" - PLATFORM_LIBS="-lpthread -lgcc_s" - PORT_FILE=port/port_posix.cc - ;; - OpenBSD) - PLATFORM=OS_OPENBSD - COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_OPENBSD" - PLATFORM_LDFLAGS="-pthread" - PORT_FILE=port/port_posix.cc - ;; - DragonFly) - PLATFORM=OS_DRAGONFLYBSD - COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_DRAGONFLYBSD" - PLATFORM_LIBS="-lpthread" - PORT_FILE=port/port_posix.cc - ;; - OS_ANDROID_CROSSCOMPILE) - PLATFORM=OS_ANDROID - COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_ANDROID -DLEVELDB_PLATFORM_POSIX" - PLATFORM_LDFLAGS="" # All pthread features are in the Android C library - PORT_FILE=port/port_posix.cc - CROSS_COMPILE=true - ;; - HP-UX) - PLATFORM=OS_HPUX - COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_HPUX" - PLATFORM_LDFLAGS="-pthread" - PORT_FILE=port/port_posix.cc - # man ld: +h internal_name - PLATFORM_SHARED_LDFLAGS="-shared -Wl,+h -Wl," - ;; - IOS) - PLATFORM=IOS - COMMON_FLAGS="$MEMCMP_FLAG -DOS_MACOSX" - [ -z "$INSTALL_PATH" ] && INSTALL_PATH=`pwd` - PORT_FILE=port/port_posix.cc - PLATFORM_SHARED_EXT= - PLATFORM_SHARED_LDFLAGS= - PLATFORM_SHARED_CFLAGS= - PLATFORM_SHARED_VERSIONED= - ;; - *) - echo "Unknown platform!" >&2 - exit 1 -esac - -# We want to make a list of all cc files within util, db, table, and helpers -# except for the test and benchmark files. By default, find will output a list -# of all files matching either rule, so we need to append -print to make the -# prune take effect. -DIRS="$PREFIX/db $PREFIX/util $PREFIX/table" - -set -f # temporarily disable globbing so that our patterns aren't expanded -PRUNE_TEST="-name *test*.cc -prune" -PRUNE_BENCH="-name *_bench.cc -prune" -PRUNE_TOOL="-name leveldb_main.cc -prune" -PORTABLE_FILES=`find $DIRS $PRUNE_TEST -o $PRUNE_BENCH -o $PRUNE_TOOL -o -name '*.cc' -print | sort | sed "s,^$PREFIX/,," | tr "\n" " "` - -set +f # re-enable globbing - -# The sources consist of the portable files, plus the platform-specific port -# file. -echo "SOURCES=$PORTABLE_FILES $PORT_FILE" >> $OUTPUT -echo "MEMENV_SOURCES=helpers/memenv/memenv.cc" >> $OUTPUT - -if [ "$CROSS_COMPILE" = "true" ]; then - # Cross-compiling; do not try any compilation tests. - true -else - CXXOUTPUT="${TMPDIR}/leveldb_build_detect_platform-cxx.$$" - - # If -std=c++0x works, use <atomic> as fallback for when memory barriers - # are not available. - $CXX $CXXFLAGS -std=c++0x -x c++ - -o $CXXOUTPUT 2>/dev/null <<EOF - #include <atomic> - int main() {} -EOF - if [ "$?" = 0 ]; then - COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT" - PLATFORM_CXXFLAGS="-std=c++0x" - else - COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX" - fi - - # Test whether Snappy library is installed - # http://code.google.com/p/snappy/ - $CXX $CXXFLAGS -x c++ - -o $CXXOUTPUT 2>/dev/null <<EOF - #include <snappy.h> - int main() {} -EOF - if [ "$?" = 0 ]; then - COMMON_FLAGS="$COMMON_FLAGS -DSNAPPY" - PLATFORM_LIBS="$PLATFORM_LIBS -lsnappy" - fi - - # Test whether tcmalloc is available - $CXX $CXXFLAGS -x c++ - -o $CXXOUTPUT -ltcmalloc 2>/dev/null <<EOF - int main() {} -EOF - if [ "$?" = 0 ]; then - PLATFORM_LIBS="$PLATFORM_LIBS -ltcmalloc" - fi - - rm -f $CXXOUTPUT 2>/dev/null -fi - -PLATFORM_CCFLAGS="$PLATFORM_CCFLAGS $COMMON_FLAGS" -PLATFORM_CXXFLAGS="$PLATFORM_CXXFLAGS $COMMON_FLAGS" - -echo "CC=$CC" >> $OUTPUT -echo "CXX=$CXX" >> $OUTPUT -echo "PLATFORM=$PLATFORM" >> $OUTPUT -echo "PLATFORM_LDFLAGS=$PLATFORM_LDFLAGS" >> $OUTPUT -echo "PLATFORM_LIBS=$PLATFORM_LIBS" >> $OUTPUT -echo "PLATFORM_CCFLAGS=$PLATFORM_CCFLAGS" >> $OUTPUT -echo "PLATFORM_CXXFLAGS=$PLATFORM_CXXFLAGS" >> $OUTPUT -echo "PLATFORM_SHARED_CFLAGS=$PLATFORM_SHARED_CFLAGS" >> $OUTPUT -echo "PLATFORM_SHARED_EXT=$PLATFORM_SHARED_EXT" >> $OUTPUT -echo "PLATFORM_SHARED_LDFLAGS=$PLATFORM_SHARED_LDFLAGS" >> $OUTPUT -echo "PLATFORM_SHARED_VERSIONED=$PLATFORM_SHARED_VERSIONED" >> $OUTPUT http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/build_detect_platform.cmake ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/build_detect_platform.cmake b/thirdparty/leveldb-1.18/build_detect_platform.cmake deleted file mode 100755 index 6a69be5..0000000 --- a/thirdparty/leveldb-1.18/build_detect_platform.cmake +++ /dev/null @@ -1,7 +0,0 @@ -if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - add_definitions(-DOS_LINUX) -elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - add_definitions(-DOS_FREEBSD) -elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - add_definitions(-DOS_MACOSX) -endif() http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/db/autocompact_test.cc ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/db/autocompact_test.cc b/thirdparty/leveldb-1.18/db/autocompact_test.cc deleted file mode 100755 index 026873f..0000000 --- a/thirdparty/leveldb-1.18/db/autocompact_test.cc +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2013 The LevelDB Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. See the AUTHORS file for names of contributors. - -#include "leveldb/db.h" -#include "db/db_impl.h" -#include "leveldb/cache.h" -#include "util/testharness.h" -#include "util/testutil.h" - -namespace leveldb { - -class AutoCompactTest { - public: - std::string dbname_; - Cache* tiny_cache_; - Options options_; - DB* db_; - - AutoCompactTest() { - dbname_ = test::TmpDir() + "/autocompact_test"; - tiny_cache_ = NewLRUCache(100); - options_.block_cache = tiny_cache_; - DestroyDB(dbname_, options_); - options_.create_if_missing = true; - options_.compression = kNoCompression; - ASSERT_OK(DB::Open(options_, dbname_, &db_)); - } - - ~AutoCompactTest() { - delete db_; - DestroyDB(dbname_, Options()); - delete tiny_cache_; - } - - std::string Key(int i) { - char buf[100]; - snprintf(buf, sizeof(buf), "key%06d", i); - return std::string(buf); - } - - uint64_t Size(const Slice& start, const Slice& limit) { - Range r(start, limit); - uint64_t size; - db_->GetApproximateSizes(&r, 1, &size); - return size; - } - - void DoReads(int n); -}; - -static const int kValueSize = 200 * 1024; -static const int kTotalSize = 100 * 1024 * 1024; -static const int kCount = kTotalSize / kValueSize; - -// Read through the first n keys repeatedly and check that they get -// compacted (verified by checking the size of the key space). -void AutoCompactTest::DoReads(int n) { - std::string value(kValueSize, 'x'); - DBImpl* dbi = reinterpret_cast<DBImpl*>(db_); - - // Fill database - for (int i = 0; i < kCount; i++) { - ASSERT_OK(db_->Put(WriteOptions(), Key(i), value)); - } - ASSERT_OK(dbi->TEST_CompactMemTable()); - - // Delete everything - for (int i = 0; i < kCount; i++) { - ASSERT_OK(db_->Delete(WriteOptions(), Key(i))); - } - ASSERT_OK(dbi->TEST_CompactMemTable()); - - // Get initial measurement of the space we will be reading. - const int64_t initial_size = Size(Key(0), Key(n)); - const int64_t initial_other_size = Size(Key(n), Key(kCount)); - - // Read until size drops significantly. - std::string limit_key = Key(n); - for (int read = 0; true; read++) { - ASSERT_LT(read, 100) << "Taking too long to compact"; - Iterator* iter = db_->NewIterator(ReadOptions()); - for (iter->SeekToFirst(); - iter->Valid() && iter->key().ToString() < limit_key; - iter->Next()) { - // Drop data - } - delete iter; - // Wait a little bit to allow any triggered compactions to complete. - Env::Default()->SleepForMicroseconds(1000000); - uint64_t size = Size(Key(0), Key(n)); - fprintf(stderr, "iter %3d => %7.3f MB [other %7.3f MB]\n", - read+1, size/1048576.0, Size(Key(n), Key(kCount))/1048576.0); - if (size <= static_cast<uint64_t>(initial_size/4)) { // 10 is too much, put it to 4 - break; - } - } - - // Verify that the size of the key space not touched by the reads - // is pretty much unchanged. - const int64_t final_other_size = Size(Key(n), Key(kCount)); - ASSERT_LE(final_other_size, initial_other_size + 1048576); - ASSERT_GE(final_other_size, initial_other_size/5 - 1048576); -} - -TEST(AutoCompactTest, ReadAll) { - DoReads(kCount); -} - -TEST(AutoCompactTest, ReadHalf) { - DoReads(kCount/2); -} - -} // namespace leveldb - -int main(int argc, char** argv) { - return leveldb::test::RunAllTests(); -} http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/db/builder.cc ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/db/builder.cc b/thirdparty/leveldb-1.18/db/builder.cc deleted file mode 100755 index f419882..0000000 --- a/thirdparty/leveldb-1.18/db/builder.cc +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2011 The LevelDB Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. See the AUTHORS file for names of contributors. - -#include "db/builder.h" - -#include "db/filename.h" -#include "db/dbformat.h" -#include "db/table_cache.h" -#include "db/version_edit.h" -#include "leveldb/db.h" -#include "leveldb/env.h" -#include "leveldb/iterator.h" - -namespace leveldb { - -Status BuildTable(const std::string& dbname, - Env* env, - const Options& options, - TableCache* table_cache, - Iterator* iter, - FileMetaData* meta) { - Status s; - meta->file_size = 0; - iter->SeekToFirst(); - - std::string fname = TableFileName(dbname, meta->number); - if (iter->Valid()) { - WritableFile* file; - s = env->NewWritableFile(fname, &file); - if (!s.ok()) { - return s; - } - - TableBuilder* builder = new TableBuilder(options, file); - meta->smallest.DecodeFrom(iter->key()); - for (; iter->Valid(); iter->Next()) { - Slice key = iter->key(); - meta->largest.DecodeFrom(key); - builder->Add(key, iter->value()); - } - - // Finish and check for builder errors - if (s.ok()) { - s = builder->Finish(); - if (s.ok()) { - meta->file_size = builder->FileSize(); - assert(meta->file_size > 0); - } - } else { - builder->Abandon(); - } - delete builder; - - // Finish and check for file errors - if (s.ok()) { - s = file->Sync(); - } - if (s.ok()) { - s = file->Close(); - } - delete file; - file = NULL; - - if (s.ok()) { - // Verify that the table is usable - Iterator* it = table_cache->NewIterator(ReadOptions(), - meta->number, - meta->file_size); - s = it->status(); - delete it; - } - } - - // Check for input iterator errors - if (!iter->status().ok()) { - s = iter->status(); - } - - if (s.ok() && meta->file_size > 0) { - // Keep it - } else { - env->DeleteFile(fname); - } - return s; -} - -} // namespace leveldb http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/db/builder.h ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/db/builder.h b/thirdparty/leveldb-1.18/db/builder.h deleted file mode 100755 index 62431fc..0000000 --- a/thirdparty/leveldb-1.18/db/builder.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2011 The LevelDB Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. See the AUTHORS file for names of contributors. - -#ifndef STORAGE_LEVELDB_DB_BUILDER_H_ -#define STORAGE_LEVELDB_DB_BUILDER_H_ - -#include "leveldb/status.h" - -namespace leveldb { - -struct Options; -struct FileMetaData; - -class Env; -class Iterator; -class TableCache; -class VersionEdit; - -// Build a Table file from the contents of *iter. The generated file -// will be named according to meta->number. On success, the rest of -// *meta will be filled with metadata about the generated table. -// If no data is present in *iter, meta->file_size will be set to -// zero, and no Table file will be produced. -extern Status BuildTable(const std::string& dbname, - Env* env, - const Options& options, - TableCache* table_cache, - Iterator* iter, - FileMetaData* meta); - -} // namespace leveldb - -#endif // STORAGE_LEVELDB_DB_BUILDER_H_ http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/db/c.cc ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/db/c.cc b/thirdparty/leveldb-1.18/db/c.cc deleted file mode 100755 index 08ff0ad..0000000 --- a/thirdparty/leveldb-1.18/db/c.cc +++ /dev/null @@ -1,595 +0,0 @@ -// Copyright (c) 2011 The LevelDB Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. See the AUTHORS file for names of contributors. - -#include "leveldb/c.h" - -#include <stdlib.h> -#include <unistd.h> -#include "leveldb/cache.h" -#include "leveldb/comparator.h" -#include "leveldb/db.h" -#include "leveldb/env.h" -#include "leveldb/filter_policy.h" -#include "leveldb/iterator.h" -#include "leveldb/options.h" -#include "leveldb/status.h" -#include "leveldb/write_batch.h" - -using leveldb::Cache; -using leveldb::Comparator; -using leveldb::CompressionType; -using leveldb::DB; -using leveldb::Env; -using leveldb::FileLock; -using leveldb::FilterPolicy; -using leveldb::Iterator; -using leveldb::kMajorVersion; -using leveldb::kMinorVersion; -using leveldb::Logger; -using leveldb::NewBloomFilterPolicy; -using leveldb::NewLRUCache; -using leveldb::Options; -using leveldb::RandomAccessFile; -using leveldb::Range; -using leveldb::ReadOptions; -using leveldb::SequentialFile; -using leveldb::Slice; -using leveldb::Snapshot; -using leveldb::Status; -using leveldb::WritableFile; -using leveldb::WriteBatch; -using leveldb::WriteOptions; - -extern "C" { - -struct leveldb_t { DB* rep; }; -struct leveldb_iterator_t { Iterator* rep; }; -struct leveldb_writebatch_t { WriteBatch rep; }; -struct leveldb_snapshot_t { const Snapshot* rep; }; -struct leveldb_readoptions_t { ReadOptions rep; }; -struct leveldb_writeoptions_t { WriteOptions rep; }; -struct leveldb_options_t { Options rep; }; -struct leveldb_cache_t { Cache* rep; }; -struct leveldb_seqfile_t { SequentialFile* rep; }; -struct leveldb_randomfile_t { RandomAccessFile* rep; }; -struct leveldb_writablefile_t { WritableFile* rep; }; -struct leveldb_logger_t { Logger* rep; }; -struct leveldb_filelock_t { FileLock* rep; }; - -struct leveldb_comparator_t : public Comparator { - void* state_; - void (*destructor_)(void*); - int (*compare_)( - void*, - const char* a, size_t alen, - const char* b, size_t blen); - const char* (*name_)(void*); - - virtual ~leveldb_comparator_t() { - (*destructor_)(state_); - } - - virtual int Compare(const Slice& a, const Slice& b) const { - return (*compare_)(state_, a.data(), a.size(), b.data(), b.size()); - } - - virtual const char* Name() const { - return (*name_)(state_); - } - - // No-ops since the C binding does not support key shortening methods. - virtual void FindShortestSeparator(std::string*, const Slice&) const { } - virtual void FindShortSuccessor(std::string* key) const { } -}; - -struct leveldb_filterpolicy_t : public FilterPolicy { - void* state_; - void (*destructor_)(void*); - const char* (*name_)(void*); - char* (*create_)( - void*, - const char* const* key_array, const size_t* key_length_array, - int num_keys, - size_t* filter_length); - unsigned char (*key_match_)( - void*, - const char* key, size_t length, - const char* filter, size_t filter_length); - - virtual ~leveldb_filterpolicy_t() { - (*destructor_)(state_); - } - - virtual const char* Name() const { - return (*name_)(state_); - } - - virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const { - std::vector<const char*> key_pointers(n); - std::vector<size_t> key_sizes(n); - for (int i = 0; i < n; i++) { - key_pointers[i] = keys[i].data(); - key_sizes[i] = keys[i].size(); - } - size_t len; - char* filter = (*create_)(state_, &key_pointers[0], &key_sizes[0], n, &len); - dst->append(filter, len); - free(filter); - } - - virtual bool KeyMayMatch(const Slice& key, const Slice& filter) const { - return (*key_match_)(state_, key.data(), key.size(), - filter.data(), filter.size()); - } -}; - -struct leveldb_env_t { - Env* rep; - bool is_default; -}; - -static bool SaveError(char** errptr, const Status& s) { - assert(errptr != NULL); - if (s.ok()) { - return false; - } else if (*errptr == NULL) { - *errptr = strdup(s.ToString().c_str()); - } else { - // TODO(sanjay): Merge with existing error? - free(*errptr); - *errptr = strdup(s.ToString().c_str()); - } - return true; -} - -static char* CopyString(const std::string& str) { - char* result = reinterpret_cast<char*>(malloc(sizeof(char) * str.size())); - memcpy(result, str.data(), sizeof(char) * str.size()); - return result; -} - -leveldb_t* leveldb_open( - const leveldb_options_t* options, - const char* name, - char** errptr) { - DB* db; - if (SaveError(errptr, DB::Open(options->rep, std::string(name), &db))) { - return NULL; - } - leveldb_t* result = new leveldb_t; - result->rep = db; - return result; -} - -void leveldb_close(leveldb_t* db) { - delete db->rep; - delete db; -} - -void leveldb_put( - leveldb_t* db, - const leveldb_writeoptions_t* options, - const char* key, size_t keylen, - const char* val, size_t vallen, - char** errptr) { - SaveError(errptr, - db->rep->Put(options->rep, Slice(key, keylen), Slice(val, vallen))); -} - -void leveldb_delete( - leveldb_t* db, - const leveldb_writeoptions_t* options, - const char* key, size_t keylen, - char** errptr) { - SaveError(errptr, db->rep->Delete(options->rep, Slice(key, keylen))); -} - - -void leveldb_write( - leveldb_t* db, - const leveldb_writeoptions_t* options, - leveldb_writebatch_t* batch, - char** errptr) { - SaveError(errptr, db->rep->Write(options->rep, &batch->rep)); -} - -char* leveldb_get( - leveldb_t* db, - const leveldb_readoptions_t* options, - const char* key, size_t keylen, - size_t* vallen, - char** errptr) { - char* result = NULL; - std::string tmp; - Status s = db->rep->Get(options->rep, Slice(key, keylen), &tmp); - if (s.ok()) { - *vallen = tmp.size(); - result = CopyString(tmp); - } else { - *vallen = 0; - if (!s.IsNotFound()) { - SaveError(errptr, s); - } - } - return result; -} - -leveldb_iterator_t* leveldb_create_iterator( - leveldb_t* db, - const leveldb_readoptions_t* options) { - leveldb_iterator_t* result = new leveldb_iterator_t; - result->rep = db->rep->NewIterator(options->rep); - return result; -} - -const leveldb_snapshot_t* leveldb_create_snapshot( - leveldb_t* db) { - leveldb_snapshot_t* result = new leveldb_snapshot_t; - result->rep = db->rep->GetSnapshot(); - return result; -} - -void leveldb_release_snapshot( - leveldb_t* db, - const leveldb_snapshot_t* snapshot) { - db->rep->ReleaseSnapshot(snapshot->rep); - delete snapshot; -} - -char* leveldb_property_value( - leveldb_t* db, - const char* propname) { - std::string tmp; - if (db->rep->GetProperty(Slice(propname), &tmp)) { - // We use strdup() since we expect human readable output. - return strdup(tmp.c_str()); - } else { - return NULL; - } -} - -void leveldb_approximate_sizes( - leveldb_t* db, - int num_ranges, - const char* const* range_start_key, const size_t* range_start_key_len, - const char* const* range_limit_key, const size_t* range_limit_key_len, - uint64_t* sizes) { - Range* ranges = new Range[num_ranges]; - for (int i = 0; i < num_ranges; i++) { - ranges[i].start = Slice(range_start_key[i], range_start_key_len[i]); - ranges[i].limit = Slice(range_limit_key[i], range_limit_key_len[i]); - } - db->rep->GetApproximateSizes(ranges, num_ranges, sizes); - delete[] ranges; -} - -void leveldb_compact_range( - leveldb_t* db, - const char* start_key, size_t start_key_len, - const char* limit_key, size_t limit_key_len) { - Slice a, b; - db->rep->CompactRange( - // Pass NULL Slice if corresponding "const char*" is NULL - (start_key ? (a = Slice(start_key, start_key_len), &a) : NULL), - (limit_key ? (b = Slice(limit_key, limit_key_len), &b) : NULL)); -} - -void leveldb_destroy_db( - const leveldb_options_t* options, - const char* name, - char** errptr) { - SaveError(errptr, DestroyDB(name, options->rep)); -} - -void leveldb_repair_db( - const leveldb_options_t* options, - const char* name, - char** errptr) { - SaveError(errptr, RepairDB(name, options->rep)); -} - -void leveldb_iter_destroy(leveldb_iterator_t* iter) { - delete iter->rep; - delete iter; -} - -unsigned char leveldb_iter_valid(const leveldb_iterator_t* iter) { - return iter->rep->Valid(); -} - -void leveldb_iter_seek_to_first(leveldb_iterator_t* iter) { - iter->rep->SeekToFirst(); -} - -void leveldb_iter_seek_to_last(leveldb_iterator_t* iter) { - iter->rep->SeekToLast(); -} - -void leveldb_iter_seek(leveldb_iterator_t* iter, const char* k, size_t klen) { - iter->rep->Seek(Slice(k, klen)); -} - -void leveldb_iter_next(leveldb_iterator_t* iter) { - iter->rep->Next(); -} - -void leveldb_iter_prev(leveldb_iterator_t* iter) { - iter->rep->Prev(); -} - -const char* leveldb_iter_key(const leveldb_iterator_t* iter, size_t* klen) { - Slice s = iter->rep->key(); - *klen = s.size(); - return s.data(); -} - -const char* leveldb_iter_value(const leveldb_iterator_t* iter, size_t* vlen) { - Slice s = iter->rep->value(); - *vlen = s.size(); - return s.data(); -} - -void leveldb_iter_get_error(const leveldb_iterator_t* iter, char** errptr) { - SaveError(errptr, iter->rep->status()); -} - -leveldb_writebatch_t* leveldb_writebatch_create() { - return new leveldb_writebatch_t; -} - -void leveldb_writebatch_destroy(leveldb_writebatch_t* b) { - delete b; -} - -void leveldb_writebatch_clear(leveldb_writebatch_t* b) { - b->rep.Clear(); -} - -void leveldb_writebatch_put( - leveldb_writebatch_t* b, - const char* key, size_t klen, - const char* val, size_t vlen) { - b->rep.Put(Slice(key, klen), Slice(val, vlen)); -} - -void leveldb_writebatch_delete( - leveldb_writebatch_t* b, - const char* key, size_t klen) { - b->rep.Delete(Slice(key, klen)); -} - -void leveldb_writebatch_iterate( - leveldb_writebatch_t* b, - void* state, - void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen), - void (*deleted)(void*, const char* k, size_t klen)) { - class H : public WriteBatch::Handler { - public: - void* state_; - void (*put_)(void*, const char* k, size_t klen, const char* v, size_t vlen); - void (*deleted_)(void*, const char* k, size_t klen); - virtual void Put(const Slice& key, const Slice& value) { - (*put_)(state_, key.data(), key.size(), value.data(), value.size()); - } - virtual void Delete(const Slice& key) { - (*deleted_)(state_, key.data(), key.size()); - } - }; - H handler; - handler.state_ = state; - handler.put_ = put; - handler.deleted_ = deleted; - b->rep.Iterate(&handler); -} - -leveldb_options_t* leveldb_options_create() { - return new leveldb_options_t; -} - -void leveldb_options_destroy(leveldb_options_t* options) { - delete options; -} - -void leveldb_options_set_comparator( - leveldb_options_t* opt, - leveldb_comparator_t* cmp) { - opt->rep.comparator = cmp; -} - -void leveldb_options_set_filter_policy( - leveldb_options_t* opt, - leveldb_filterpolicy_t* policy) { - opt->rep.filter_policy = policy; -} - -void leveldb_options_set_create_if_missing( - leveldb_options_t* opt, unsigned char v) { - opt->rep.create_if_missing = v; -} - -void leveldb_options_set_error_if_exists( - leveldb_options_t* opt, unsigned char v) { - opt->rep.error_if_exists = v; -} - -void leveldb_options_set_paranoid_checks( - leveldb_options_t* opt, unsigned char v) { - opt->rep.paranoid_checks = v; -} - -void leveldb_options_set_env(leveldb_options_t* opt, leveldb_env_t* env) { - opt->rep.env = (env ? env->rep : NULL); -} - -void leveldb_options_set_info_log(leveldb_options_t* opt, leveldb_logger_t* l) { - opt->rep.info_log = (l ? l->rep : NULL); -} - -void leveldb_options_set_write_buffer_size(leveldb_options_t* opt, size_t s) { - opt->rep.write_buffer_size = s; -} - -void leveldb_options_set_max_open_files(leveldb_options_t* opt, int n) { - opt->rep.max_open_files = n; -} - -void leveldb_options_set_cache(leveldb_options_t* opt, leveldb_cache_t* c) { - opt->rep.block_cache = c->rep; -} - -void leveldb_options_set_block_size(leveldb_options_t* opt, size_t s) { - opt->rep.block_size = s; -} - -void leveldb_options_set_block_restart_interval(leveldb_options_t* opt, int n) { - opt->rep.block_restart_interval = n; -} - -void leveldb_options_set_compression(leveldb_options_t* opt, int t) { - opt->rep.compression = static_cast<CompressionType>(t); -} - -leveldb_comparator_t* leveldb_comparator_create( - void* state, - void (*destructor)(void*), - int (*compare)( - void*, - const char* a, size_t alen, - const char* b, size_t blen), - const char* (*name)(void*)) { - leveldb_comparator_t* result = new leveldb_comparator_t; - result->state_ = state; - result->destructor_ = destructor; - result->compare_ = compare; - result->name_ = name; - return result; -} - -void leveldb_comparator_destroy(leveldb_comparator_t* cmp) { - delete cmp; -} - -leveldb_filterpolicy_t* leveldb_filterpolicy_create( - void* state, - void (*destructor)(void*), - char* (*create_filter)( - void*, - const char* const* key_array, const size_t* key_length_array, - int num_keys, - size_t* filter_length), - unsigned char (*key_may_match)( - void*, - const char* key, size_t length, - const char* filter, size_t filter_length), - const char* (*name)(void*)) { - leveldb_filterpolicy_t* result = new leveldb_filterpolicy_t; - result->state_ = state; - result->destructor_ = destructor; - result->create_ = create_filter; - result->key_match_ = key_may_match; - result->name_ = name; - return result; -} - -void leveldb_filterpolicy_destroy(leveldb_filterpolicy_t* filter) { - delete filter; -} - -leveldb_filterpolicy_t* leveldb_filterpolicy_create_bloom(int bits_per_key) { - // Make a leveldb_filterpolicy_t, but override all of its methods so - // they delegate to a NewBloomFilterPolicy() instead of user - // supplied C functions. - struct Wrapper : public leveldb_filterpolicy_t { - const FilterPolicy* rep_; - ~Wrapper() { delete rep_; } - const char* Name() const { return rep_->Name(); } - void CreateFilter(const Slice* keys, int n, std::string* dst) const { - return rep_->CreateFilter(keys, n, dst); - } - bool KeyMayMatch(const Slice& key, const Slice& filter) const { - return rep_->KeyMayMatch(key, filter); - } - static void DoNothing(void*) { } - }; - Wrapper* wrapper = new Wrapper; - wrapper->rep_ = NewBloomFilterPolicy(bits_per_key); - wrapper->state_ = NULL; - wrapper->destructor_ = &Wrapper::DoNothing; - return wrapper; -} - -leveldb_readoptions_t* leveldb_readoptions_create() { - return new leveldb_readoptions_t; -} - -void leveldb_readoptions_destroy(leveldb_readoptions_t* opt) { - delete opt; -} - -void leveldb_readoptions_set_verify_checksums( - leveldb_readoptions_t* opt, - unsigned char v) { - opt->rep.verify_checksums = v; -} - -void leveldb_readoptions_set_fill_cache( - leveldb_readoptions_t* opt, unsigned char v) { - opt->rep.fill_cache = v; -} - -void leveldb_readoptions_set_snapshot( - leveldb_readoptions_t* opt, - const leveldb_snapshot_t* snap) { - opt->rep.snapshot = (snap ? snap->rep : NULL); -} - -leveldb_writeoptions_t* leveldb_writeoptions_create() { - return new leveldb_writeoptions_t; -} - -void leveldb_writeoptions_destroy(leveldb_writeoptions_t* opt) { - delete opt; -} - -void leveldb_writeoptions_set_sync( - leveldb_writeoptions_t* opt, unsigned char v) { - opt->rep.sync = v; -} - -leveldb_cache_t* leveldb_cache_create_lru(size_t capacity) { - leveldb_cache_t* c = new leveldb_cache_t; - c->rep = NewLRUCache(capacity); - return c; -} - -void leveldb_cache_destroy(leveldb_cache_t* cache) { - delete cache->rep; - delete cache; -} - -leveldb_env_t* leveldb_create_default_env() { - leveldb_env_t* result = new leveldb_env_t; - result->rep = Env::Default(); - result->is_default = true; - return result; -} - -void leveldb_env_destroy(leveldb_env_t* env) { - if (!env->is_default) delete env->rep; - delete env; -} - -void leveldb_free(void* ptr) { - free(ptr); -} - -int leveldb_major_version() { - return kMajorVersion; -} - -int leveldb_minor_version() { - return kMinorVersion; -} - -} // end extern "C" http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/48867732/thirdparty/leveldb-1.18/db/c_test.c ---------------------------------------------------------------------- diff --git a/thirdparty/leveldb-1.18/db/c_test.c b/thirdparty/leveldb-1.18/db/c_test.c deleted file mode 100755 index 7cd5ee0..0000000 --- a/thirdparty/leveldb-1.18/db/c_test.c +++ /dev/null @@ -1,390 +0,0 @@ -/* Copyright (c) 2011 The LevelDB Authors. All rights reserved. - Use of this source code is governed by a BSD-style license that can be - found in the LICENSE file. See the AUTHORS file for names of contributors. */ - -#include "leveldb/c.h" - -#include <stddef.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <unistd.h> - -const char* phase = ""; -static char dbname[200]; - -static void StartPhase(const char* name) { - fprintf(stderr, "=== Test %s\n", name); - phase = name; -} - -static const char* GetTempDir(void) { - const char* ret = getenv("TEST_TMPDIR"); - if (ret == NULL || ret[0] == '\0') - ret = "/tmp"; - return ret; -} - -#define CheckNoError(err) \ - if ((err) != NULL) { \ - fprintf(stderr, "%s:%d: %s: %s\n", __FILE__, __LINE__, phase, (err)); \ - abort(); \ - } - -#define CheckCondition(cond) \ - if (!(cond)) { \ - fprintf(stderr, "%s:%d: %s: %s\n", __FILE__, __LINE__, phase, #cond); \ - abort(); \ - } - -static void CheckEqual(const char* expected, const char* v, size_t n) { - if (expected == NULL && v == NULL) { - // ok - } else if (expected != NULL && v != NULL && n == strlen(expected) && - memcmp(expected, v, n) == 0) { - // ok - return; - } else { - fprintf(stderr, "%s: expected '%s', got '%s'\n", - phase, - (expected ? expected : "(null)"), - (v ? v : "(null")); - abort(); - } -} - -static void Free(char** ptr) { - if (*ptr) { - free(*ptr); - *ptr = NULL; - } -} - -static void CheckGet( - leveldb_t* db, - const leveldb_readoptions_t* options, - const char* key, - const char* expected) { - char* err = NULL; - size_t val_len; - char* val; - val = leveldb_get(db, options, key, strlen(key), &val_len, &err); - CheckNoError(err); - CheckEqual(expected, val, val_len); - Free(&val); -} - -static void CheckIter(leveldb_iterator_t* iter, - const char* key, const char* val) { - size_t len; - const char* str; - str = leveldb_iter_key(iter, &len); - CheckEqual(key, str, len); - str = leveldb_iter_value(iter, &len); - CheckEqual(val, str, len); -} - -// Callback from leveldb_writebatch_iterate() -static void CheckPut(void* ptr, - const char* k, size_t klen, - const char* v, size_t vlen) { - int* state = (int*) ptr; - CheckCondition(*state < 2); - switch (*state) { - case 0: - CheckEqual("bar", k, klen); - CheckEqual("b", v, vlen); - break; - case 1: - CheckEqual("box", k, klen); - CheckEqual("c", v, vlen); - break; - } - (*state)++; -} - -// Callback from leveldb_writebatch_iterate() -static void CheckDel(void* ptr, const char* k, size_t klen) { - int* state = (int*) ptr; - CheckCondition(*state == 2); - CheckEqual("bar", k, klen); - (*state)++; -} - -static void CmpDestroy(void* arg) { } - -static int CmpCompare(void* arg, const char* a, size_t alen, - const char* b, size_t blen) { - int n = (alen < blen) ? alen : blen; - int r = memcmp(a, b, n); - if (r == 0) { - if (alen < blen) r = -1; - else if (alen > blen) r = +1; - } - return r; -} - -static const char* CmpName(void* arg) { - return "foo"; -} - -// Custom filter policy -static unsigned char fake_filter_result = 1; -static void FilterDestroy(void* arg) { } -static const char* FilterName(void* arg) { - return "TestFilter"; -} -static char* FilterCreate( - void* arg, - const char* const* key_array, const size_t* key_length_array, - int num_keys, - size_t* filter_length) { - *filter_length = 4; - char* result = malloc(4); - memcpy(result, "fake", 4); - return result; -} -unsigned char FilterKeyMatch( - void* arg, - const char* key, size_t length, - const char* filter, size_t filter_length) { - CheckCondition(filter_length == 4); - CheckCondition(memcmp(filter, "fake", 4) == 0); - return fake_filter_result; -} - -int main(int argc, char** argv) { - leveldb_t* db; - leveldb_comparator_t* cmp; - leveldb_cache_t* cache; - leveldb_env_t* env; - leveldb_options_t* options; - leveldb_readoptions_t* roptions; - leveldb_writeoptions_t* woptions; - char* err = NULL; - int run = -1; - - CheckCondition(leveldb_major_version() >= 1); - CheckCondition(leveldb_minor_version() >= 1); - - snprintf(dbname, sizeof(dbname), - "%s/leveldb_c_test-%d", - GetTempDir(), - ((int) geteuid())); - - StartPhase("create_objects"); - cmp = leveldb_comparator_create(NULL, CmpDestroy, CmpCompare, CmpName); - env = leveldb_create_default_env(); - cache = leveldb_cache_create_lru(100000); - - options = leveldb_options_create(); - leveldb_options_set_comparator(options, cmp); - leveldb_options_set_error_if_exists(options, 1); - leveldb_options_set_cache(options, cache); - leveldb_options_set_env(options, env); - leveldb_options_set_info_log(options, NULL); - leveldb_options_set_write_buffer_size(options, 100000); - leveldb_options_set_paranoid_checks(options, 1); - leveldb_options_set_max_open_files(options, 10); - leveldb_options_set_block_size(options, 1024); - leveldb_options_set_block_restart_interval(options, 8); - leveldb_options_set_compression(options, leveldb_no_compression); - - roptions = leveldb_readoptions_create(); - leveldb_readoptions_set_verify_checksums(roptions, 1); - leveldb_readoptions_set_fill_cache(roptions, 0); - - woptions = leveldb_writeoptions_create(); - leveldb_writeoptions_set_sync(woptions, 1); - - StartPhase("destroy"); - leveldb_destroy_db(options, dbname, &err); - Free(&err); - - StartPhase("open_error"); - db = leveldb_open(options, dbname, &err); - CheckCondition(err != NULL); - Free(&err); - - StartPhase("leveldb_free"); - db = leveldb_open(options, dbname, &err); - CheckCondition(err != NULL); - leveldb_free(err); - err = NULL; - - StartPhase("open"); - leveldb_options_set_create_if_missing(options, 1); - db = leveldb_open(options, dbname, &err); - CheckNoError(err); - CheckGet(db, roptions, "foo", NULL); - - StartPhase("put"); - leveldb_put(db, woptions, "foo", 3, "hello", 5, &err); - CheckNoError(err); - CheckGet(db, roptions, "foo", "hello"); - - StartPhase("compactall"); - leveldb_compact_range(db, NULL, 0, NULL, 0); - CheckGet(db, roptions, "foo", "hello"); - - StartPhase("compactrange"); - leveldb_compact_range(db, "a", 1, "z", 1); - CheckGet(db, roptions, "foo", "hello"); - - StartPhase("writebatch"); - { - leveldb_writebatch_t* wb = leveldb_writebatch_create(); - leveldb_writebatch_put(wb, "foo", 3, "a", 1); - leveldb_writebatch_clear(wb); - leveldb_writebatch_put(wb, "bar", 3, "b", 1); - leveldb_writebatch_put(wb, "box", 3, "c", 1); - leveldb_writebatch_delete(wb, "bar", 3); - leveldb_write(db, woptions, wb, &err); - CheckNoError(err); - CheckGet(db, roptions, "foo", "hello"); - CheckGet(db, roptions, "bar", NULL); - CheckGet(db, roptions, "box", "c"); - int pos = 0; - leveldb_writebatch_iterate(wb, &pos, CheckPut, CheckDel); - CheckCondition(pos == 3); - leveldb_writebatch_destroy(wb); - } - - StartPhase("iter"); - { - leveldb_iterator_t* iter = leveldb_create_iterator(db, roptions); - CheckCondition(!leveldb_iter_valid(iter)); - leveldb_iter_seek_to_first(iter); - CheckCondition(leveldb_iter_valid(iter)); - CheckIter(iter, "box", "c"); - leveldb_iter_next(iter); - CheckIter(iter, "foo", "hello"); - leveldb_iter_prev(iter); - CheckIter(iter, "box", "c"); - leveldb_iter_prev(iter); - CheckCondition(!leveldb_iter_valid(iter)); - leveldb_iter_seek_to_last(iter); - CheckIter(iter, "foo", "hello"); - leveldb_iter_seek(iter, "b", 1); - CheckIter(iter, "box", "c"); - leveldb_iter_get_error(iter, &err); - CheckNoError(err); - leveldb_iter_destroy(iter); - } - - StartPhase("approximate_sizes"); - { - int i; - int n = 20000; - char keybuf[100]; - char valbuf[100]; - uint64_t sizes[2]; - const char* start[2] = { "a", "k00000000000000010000" }; - size_t start_len[2] = { 1, 21 }; - const char* limit[2] = { "k00000000000000010000", "z" }; - size_t limit_len[2] = { 21, 1 }; - leveldb_writeoptions_set_sync(woptions, 0); - for (i = 0; i < n; i++) { - snprintf(keybuf, sizeof(keybuf), "k%020d", i); - snprintf(valbuf, sizeof(valbuf), "v%020d", i); - leveldb_put(db, woptions, keybuf, strlen(keybuf), valbuf, strlen(valbuf), - &err); - CheckNoError(err); - } - leveldb_approximate_sizes(db, 2, start, start_len, limit, limit_len, sizes); - CheckCondition(sizes[0] > 0); - CheckCondition(sizes[1] > 0); - } - - StartPhase("property"); - { - char* prop = leveldb_property_value(db, "nosuchprop"); - CheckCondition(prop == NULL); - prop = leveldb_property_value(db, "leveldb.stats"); - CheckCondition(prop != NULL); - Free(&prop); - } - - StartPhase("snapshot"); - { - const leveldb_snapshot_t* snap; - snap = leveldb_create_snapshot(db); - leveldb_delete(db, woptions, "foo", 3, &err); - CheckNoError(err); - leveldb_readoptions_set_snapshot(roptions, snap); - CheckGet(db, roptions, "foo", "hello"); - leveldb_readoptions_set_snapshot(roptions, NULL); - CheckGet(db, roptions, "foo", NULL); - leveldb_release_snapshot(db, snap); - } - - StartPhase("repair"); - { - leveldb_close(db); - leveldb_options_set_create_if_missing(options, 0); - leveldb_options_set_error_if_exists(options, 0); - leveldb_repair_db(options, dbname, &err); - CheckNoError(err); - db = leveldb_open(options, dbname, &err); - CheckNoError(err); - CheckGet(db, roptions, "foo", NULL); - CheckGet(db, roptions, "bar", NULL); - CheckGet(db, roptions, "box", "c"); - leveldb_options_set_create_if_missing(options, 1); - leveldb_options_set_error_if_exists(options, 1); - } - - StartPhase("filter"); - for (run = 0; run < 2; run++) { - // First run uses custom filter, second run uses bloom filter - CheckNoError(err); - leveldb_filterpolicy_t* policy; - if (run == 0) { - policy = leveldb_filterpolicy_create( - NULL, FilterDestroy, FilterCreate, FilterKeyMatch, FilterName); - } else { - policy = leveldb_filterpolicy_create_bloom(10); - } - - // Create new database - leveldb_close(db); - leveldb_destroy_db(options, dbname, &err); - leveldb_options_set_filter_policy(options, policy); - db = leveldb_open(options, dbname, &err); - CheckNoError(err); - leveldb_put(db, woptions, "foo", 3, "foovalue", 8, &err); - CheckNoError(err); - leveldb_put(db, woptions, "bar", 3, "barvalue", 8, &err); - CheckNoError(err); - leveldb_compact_range(db, NULL, 0, NULL, 0); - - fake_filter_result = 1; - CheckGet(db, roptions, "foo", "foovalue"); - CheckGet(db, roptions, "bar", "barvalue"); - if (phase == 0) { - // Must not find value when custom filter returns false - fake_filter_result = 0; - CheckGet(db, roptions, "foo", NULL); - CheckGet(db, roptions, "bar", NULL); - fake_filter_result = 1; - - CheckGet(db, roptions, "foo", "foovalue"); - CheckGet(db, roptions, "bar", "barvalue"); - } - leveldb_options_set_filter_policy(options, NULL); - leveldb_filterpolicy_destroy(policy); - } - - StartPhase("cleanup"); - leveldb_close(db); - leveldb_options_destroy(options); - leveldb_readoptions_destroy(roptions); - leveldb_writeoptions_destroy(woptions); - leveldb_cache_destroy(cache); - leveldb_comparator_destroy(cmp); - leveldb_env_destroy(env); - - fprintf(stderr, "PASS\n"); - return 0; -}
