diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cf0f43df..43bdacfe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,13 +11,11 @@ jobs: runs-on: ubuntu-18.04 strategy: matrix: - name: [gcc9, gcc10, gcc11, gcc12, clang11] + compiler: [gcc9, gcc10, gcc11, gcc12, clang11] + standard: [17] include: - - name: gcc9 - - name: gcc10 - - name: gcc11 - - name: gcc12 - - name: clang11 + - compiler: gcc12 # Extra test for C++20 + standard: 20 steps: - uses: actions/checkout@v2 @@ -26,7 +24,9 @@ jobs: - name: Bulid docker image shell: bash - run: docker build -t pisa -f- . < "${{runner.workspace}}/pisa/test/docker/${{matrix.name}}/Dockerfile" + run: | + docker build --build-arg CXX_STANDARD=${{matrix.standard}} \ + -t pisa -f- . < "${{runner.workspace}}/pisa/test/docker/${{matrix.compiler}}/Dockerfile" - name: Test shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index d7d52088..86c09bd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,9 @@ cmake_policy(SET CMP0074 NEW) project(PISA CXX C) -set(CMAKE_CXX_STANDARD 17) +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) +endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/README.md b/README.md index 6f8498f6..3e1204a7 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,8 @@ resources: 3. The [documentation](https://pisa.readthedocs.io/en/latest/). 4. Drop in to our [Slack channel](https://join.slack.com/t/pisa-engine/shared_invite/zt-dbxrm1mf-RtQMZTqxxlhOJsv3GHUErw) and say hi! +## Contributing + If you want to get involved with PISA, please check out our [Contributing](https://github.com/pisa-engine/pisa/blob/master/.github/CONTRIBUTING.md) page. diff --git a/docs/source/getting_started.md b/docs/source/getting_started.md index e70d9eee..dd1d708b 100644 --- a/docs/source/getting_started.md +++ b/docs/source/getting_started.md @@ -4,8 +4,9 @@ ### Requirements -Our continuous integration pipeline compiles PISA and runs tests in the -following configurations: +To compile PISA, you will need a compiler supporting at least the C++17 +standard. Our continuous integration pipeline compiles PISA and runs +tests in the following configurations: - Linux: - GCC, versions: 9, 10, 11, 12 - Clang 11 diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index ad9017ed..5e722eb6 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -88,6 +88,7 @@ target_compile_options(fmt INTERFACE -Wno-deprecated-declarations) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spdlog) # Add range-v3 +set(RANGES_CXX_STD ${CMAKE_CXX_STANDARD}) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/range-v3) # Add RapidCheck diff --git a/include/pisa/codec/varintgb.hpp b/include/pisa/codec/varintgb.hpp index e299f11b..ff4469fe 100644 --- a/include/pisa/codec/varintgb.hpp +++ b/include/pisa/codec/varintgb.hpp @@ -7,8 +7,6 @@ #include "codec/block_codecs.hpp" -using namespace std; - namespace pisa { template diff --git a/src/sharding.cpp b/src/sharding.cpp index 50a0a747..0edc9f94 100644 --- a/src/sharding.cpp +++ b/src/sharding.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -97,8 +98,8 @@ auto mapping_from_files(std::string const& full_titles, gsl::span(shard_file)); } - auto title_files = - shard_is | ranges::views::transform([](auto& is) { return is.get(); }) | ranges::to_vector; + auto title_files = shard_is | ranges::views::transform([](auto& is) { return is.get(); }) + | ranges::to(); return mapping_from_files(&fis, gsl::make_span(title_files)); } @@ -109,8 +110,8 @@ auto create_random_mapping(int document_count, int shard_count, std::optional mapping(document_count); auto shard_size = ceil_div(document_count, shard_count); - auto documents = ranges::views::iota(0_d, Document_Id{document_count}) | ranges::to_vector - | ranges::actions::shuffle(g); + auto documents = ranges::views::iota(0_d, Document_Id{document_count}) + | ranges::to | ranges::actions::shuffle(g); ranges::for_each( ranges::views::zip( @@ -259,7 +260,7 @@ void partition_fwd_index( { auto terms = read_string_vec_map(fmt::format("{}.terms", input_basename)); auto shard_count = *std::max_element(mapping.begin(), mapping.end()) + 1; - auto shard_ids = ranges::views::iota(0_s, shard_count) | ranges::to_vector; + auto shard_ids = ranges::views::iota(0_s, shard_count) | ranges::to(); rearrange_sequences(input_basename, output_basename, mapping, shard_count); spdlog::info("Remapping shards"); pisa::for_each(pisa::execution::par_unseq, shard_ids.begin(), shard_ids.end(), [&](auto&& id) { diff --git a/test/docker/clang11/Dockerfile b/test/docker/clang11/Dockerfile index 1f20095f..b9f624f1 100644 --- a/test/docker/clang11/Dockerfile +++ b/test/docker/clang11/Dockerfile @@ -13,7 +13,12 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \ COPY . /pisa RUN mkdir /pisa/build WORKDIR /pisa/build -RUN cmake -DCMAKE_BUILD_TYPE='Debug' -DPISA_BUILD_TOOLS='OFF' -DCMAKE_TOOLCHAIN_FILE='clang.cmake' .. \ +RUN cmake \ + -DCMAKE_BUILD_TYPE='Debug' \ + -DPISA_BUILD_TOOLS='OFF' \ + -DPISA_ENABLE_BENCHMARKING='OFF' \ + -DCMAKE_TOOLCHAIN_FILE='clang.cmake' \ + .. \ && cmake --build . --config Debug -- -j 4 CMD ["ctest", "-VV", "-j", "4"] diff --git a/test/docker/cmake-3.25.2-SHA-256.txt b/test/docker/cmake-3.25.2-SHA-256.txt new file mode 100644 index 00000000..643898c7 --- /dev/null +++ b/test/docker/cmake-3.25.2-SHA-256.txt @@ -0,0 +1,17 @@ +82ef7846809a6cfe282a6196b300b081ff7878e40065c1d530352f8f7a2a0c2d cmake-3.25.2-files-v1.json +73a35cab2174a3eb8f35083d55c80871185dc3808f3dae3558cd5fbdb29a4614 cmake-3.25.2-linux-aarch64.sh +9216ecf0449ade700e66e0def11eeaebf9fa7d4428c02f49cb59f11418d3f8a5 cmake-3.25.2-linux-aarch64.tar.gz +4d98de8d605da676e71a889dd94f80c76abb377fade2f21e3510e62ece1e1ada cmake-3.25.2-linux-x86_64.sh +783da74f132fd1fea91b8236d267efa4df5b91c5eec1dea0a87f0cf233748d99 cmake-3.25.2-linux-x86_64.tar.gz +644f104ae744df582b54ae47a8188bedacadd67dd996d70caa8159a47feb8749 cmake-3.25.2-macos-universal.dmg +0b5def3f77617b2ce0ec6701f96e4123a7b14bd0b8a5674ab0556c364ff7cb52 cmake-3.25.2-macos-universal.tar.gz +1851eb7a824ec380ce5edeaa46b3ba568d6572965fb9d31b2ea6f1ef0a09ecea cmake-3.25.2-macos10.10-universal.dmg +a988e2a69c1d105987f12782ee0fa80d6be941b3e1a68b4bd6a661f0fdb56d75 cmake-3.25.2-macos10.10-universal.tar.gz +2fd16ceebd64be763b9c18025159ab5c5c4d484a8021e60f80ef720803063472 cmake-3.25.2-windows-arm64.msi +c54fb253ae184b391d5366b958c38b282d5f9b6a5854643c28e6887f5fd92590 cmake-3.25.2-windows-arm64.zip +61cb3f71b1fb8ca342b723e1b18e9c4957b8c7094b5667075b8cb0309087e5b8 cmake-3.25.2-windows-i386.msi +833abaa21bb673491def058cc38834fbd606d525ab271f37a3b8a3aed586c4a0 cmake-3.25.2-windows-i386.zip +f91867471b4ae59efd79eaea63a374193b377b5372c45d78ca5f899243560089 cmake-3.25.2-windows-x86_64.msi +0db9d3cebf894f64751141253fb9d9e310f325e2e03044f61249a359d6adf301 cmake-3.25.2-windows-x86_64.zip +c026f22cb931dd532f648f087d587f07a1843c6e66a3dfca4fb0ea21944ed33c cmake-3.25.2.tar.gz +2781c207c3c64ea8a829b8fc0229374fc874b68fb1264cff99055e5bce79bbae cmake-3.25.2.zip diff --git a/test/docker/gcc10/Dockerfile b/test/docker/gcc10/Dockerfile index bfda1de1..8f0c1d2f 100644 --- a/test/docker/gcc10/Dockerfile +++ b/test/docker/gcc10/Dockerfile @@ -3,15 +3,16 @@ FROM gcc:10 ENV DEBIAN_FRONTEND=noninteractive ENV TZ=America/New_York -RUN apt-get update -y && apt-get install -y --no-install-recommends \ - cmake=3.13.* \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - COPY . /pisa +RUN ./pisa/test/docker/install-cmake.sh + RUN mkdir /pisa/build WORKDIR /pisa/build -RUN cmake "-DCMAKE_BUILD_TYPE=Debug" "-DPISA_BUILD_TOOLS=OFF" .. \ +RUN cmake \ + "-DCMAKE_BUILD_TYPE=Debug" \ + "-DPISA_BUILD_TOOLS=OFF" \ + "-DPISA_ENABLE_BENCHMARKING=OFF" \ + .. \ && cmake --build . --config Debug -- -j 4 CMD ["ctest", "-VV", "-j", "4"] diff --git a/test/docker/gcc11/Dockerfile b/test/docker/gcc11/Dockerfile index 98a43dbb..d6a1e03d 100644 --- a/test/docker/gcc11/Dockerfile +++ b/test/docker/gcc11/Dockerfile @@ -3,15 +3,16 @@ FROM gcc:11 ENV DEBIAN_FRONTEND=noninteractive ENV TZ=America/New_York -RUN apt-get update -y && apt-get install -y --no-install-recommends \ - cmake=3.18.* \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - COPY . /pisa +RUN ./pisa/test/docker/install-cmake.sh + RUN mkdir /pisa/build WORKDIR /pisa/build -RUN cmake "-DCMAKE_BUILD_TYPE=Debug" "-DPISA_BUILD_TOOLS=OFF" .. \ +RUN cmake \ + "-DCMAKE_BUILD_TYPE=Debug" \ + "-DPISA_BUILD_TOOLS=OFF" \ + "-DPISA_ENABLE_BENCHMARKING=OFF" \ + .. \ && cmake --build . --config Debug -- -j 4 CMD ["ctest", "-VV", "-j", "4"] diff --git a/test/docker/gcc12/Dockerfile b/test/docker/gcc12/Dockerfile index 34c3e86d..41fac39f 100644 --- a/test/docker/gcc12/Dockerfile +++ b/test/docker/gcc12/Dockerfile @@ -1,17 +1,21 @@ FROM gcc:12 +ARG CXX_STANDARD=17 + ENV DEBIAN_FRONTEND=noninteractive ENV TZ=America/New_York -RUN apt-get update -y && apt-get install -y --no-install-recommends \ - cmake=3.18.* \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - COPY . /pisa +RUN ./pisa/test/docker/install-cmake.sh + RUN mkdir /pisa/build WORKDIR /pisa/build -RUN cmake "-DCMAKE_BUILD_TYPE=Debug" "-DPISA_BUILD_TOOLS=OFF" .. \ +RUN cmake \ + "-DCMAKE_BUILD_TYPE=Debug" \ + "-DPISA_BUILD_TOOLS=OFF" \ + "-DPISA_ENABLE_BENCHMARKING=OFF" \ + "-DCMAKE_CXX_STANDARD=$CXX_STANDARD" \ + .. \ && cmake --build . --config Debug -- -j 4 CMD ["ctest", "-VV", "-j", "4"] diff --git a/test/docker/gcc9/Dockerfile b/test/docker/gcc9/Dockerfile index 864738fe..49167125 100644 --- a/test/docker/gcc9/Dockerfile +++ b/test/docker/gcc9/Dockerfile @@ -3,15 +3,16 @@ FROM gcc:9 ENV DEBIAN_FRONTEND=noninteractive ENV TZ=America/New_York -RUN apt-get update -y && apt-get install -y --no-install-recommends \ - cmake=3.13.* \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - COPY . /pisa +RUN ./pisa/test/docker/install-cmake.sh + RUN mkdir /pisa/build WORKDIR /pisa/build -RUN cmake "-DCMAKE_BUILD_TYPE=Debug" "-DPISA_BUILD_TOOLS=OFF" .. \ +RUN cmake \ + "-DCMAKE_BUILD_TYPE=Debug" \ + "-DPISA_BUILD_TOOLS=OFF" \ + "-DPISA_ENABLE_BENCHMARKING=OFF" \ + .. \ && cmake --build . --config Debug -- -j 4 CMD ["ctest", "-VV", "-j", "4"] diff --git a/test/docker/install-cmake.sh b/test/docker/install-cmake.sh new file mode 100755 index 00000000..a3698406 --- /dev/null +++ b/test/docker/install-cmake.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +wget -q 'https://github.com/Kitware/CMake/releases/download/v3.25.2/cmake-3.25.2-linux-x86_64.tar.gz' +sha256sum -c '/pisa/test/docker/cmake-3.25.2-SHA-256.txt' --ignore-missing +tar -xzvf 'cmake-3.25.2-linux-x86_64.tar.gz' +cp cmake-3.25.2-linux-x86_64/bin/* '/usr/local/bin' +cp -r 'cmake-3.25.2-linux-x86_64/share/cmake-3.25' '/usr/local/share' diff --git a/test/test_bmw_queries.cpp b/test/test_bmw_queries.cpp index d695d78a..629f946c 100644 --- a/test/test_bmw_queries.cpp +++ b/test/test_bmw_queries.cpp @@ -1,6 +1,7 @@ #define CATCH_CONFIG_MAIN #include "catch2/catch.hpp" +#include #include #include "test_common.hpp" @@ -70,7 +71,7 @@ struct IndexData { }; template -std::unordered_map>> IndexData::data = {}; +std::unordered_map>> IndexData::data = {}; template auto test(Wand& wdata, std::string const& s_name) diff --git a/test/test_partition_fwd_index.cpp b/test/test_partition_fwd_index.cpp index a764d994..c81e7d21 100644 --- a/test/test_partition_fwd_index.cpp +++ b/test/test_partition_fwd_index.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -82,8 +83,8 @@ TEST_CASE("mapping_from_files", "[invert][unit]") shards.push_back(std::make_unique("D00\nD01\nD02")); shards.push_back(std::make_unique("D02\nD03\nD04")); shards.push_back(std::make_unique("D06\nD07\nD08\nD09\nD010\nD11")); - auto stream_pointers = - ranges::views::transform(shards, [](auto const& s) { return s.get(); }) | ranges::to_vector; + auto stream_pointers = ranges::views::transform(shards, [](auto const& s) { return s.get(); }) + | ranges::to(); REQUIRE( mapping_from_files(&full, gsl::span(stream_pointers)).as_vector() == std::vector{0_s, 0_s, 0_s, 1_s, 1_s, 0_s, 2_s, 2_s, 2_s, 2_s, 2_s, 2_s}); @@ -103,7 +104,7 @@ TEST_CASE("create_random_mapping", "[invert][unit]") REQUIRE( documents.as_vector() - == ranges::to_vector(ranges::views::iota(Document_Id{}, Document_Id{1000U}))); + == ranges::to(ranges::views::iota(Document_Id{}, Document_Id{1000U}))); REQUIRE( counts.as_vector() == std::vector{77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 76}); } @@ -211,7 +212,7 @@ TEST_CASE("Rearrange sequences", "[invert][integration]") expected = ranges::views::transform( sorted_mapping, [&](auto&& entry) { return expected[entry.first.as_int()]; }) - | ranges::to_vector; + | ranges::to(); auto pos = expected.begin(); for (auto shard: shard_ids) { diff --git a/test/test_ranked_queries.cpp b/test/test_ranked_queries.cpp index 9db4c6ac..58a6759b 100644 --- a/test/test_ranked_queries.cpp +++ b/test/test_ranked_queries.cpp @@ -68,7 +68,7 @@ struct IndexData { }; template -std::unordered_map>> IndexData::data = {}; +std::unordered_map>> IndexData::data = {}; template class ranked_or_taat_query_acc: public ranked_or_taat_query {