Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 1.3.0 from fork #37

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e49f40f
Merge pull request #1 from improbable-eng/master
tzaeschke Mar 24, 2021
5bc827b
Merge branch 'improbable-eng:master' into master
tzaeschke Jan 14, 2022
2ae1314
Merge branch 'improbable-eng:master' into master
tzaeschke Jan 26, 2022
4b540d4
Merge branch 'improbable-eng:master' into master
tzaeschke Feb 6, 2022
df29cb6
Improve build experience
tzaeschke Feb 16, 2022
4f6bfdd
Update README.md
tzaeschke Feb 16, 2022
291d960
Fix for each postlen / #2 (#3)
tzaeschke Feb 22, 2022
18cbb71
Fix/issue 4 fix key copy (#6)
tzaeschke Mar 2, 2022
ced5e27
Avoid find on remove node (#7)
tzaeschke Mar 2, 2022
45f2bf5
Fix/issue 9 entry union (#10)
tzaeschke Mar 9, 2022
5d76f97
Move postfix tfrom Node to Entry (#12)
tzaeschke Mar 9, 2022
80a5ceb
issue 11 cleanup (#13)
tzaeschke Mar 9, 2022
671f603
Update README.md
tzaeschke Mar 9, 2022
7a6b1d8
Fix/issue 14 b tree (#15)
tzaeschke Apr 1, 2022
039da73
Avoid std::uint16_t (#17)
tzaeschke Apr 1, 2022
8732b56
moveable PhTree (#20)
tzaeschke Apr 4, 2022
1078e35
Fix/19 clean up iterators (#23)
tzaeschke Apr 7, 2022
582fccf
Initial (#25)
tzaeschke Apr 8, 2022
899716d
FilterSphere issue (#28)
tzaeschke Apr 8, 2022
fb80406
Release v1.2.0 (#32)
tzaeschke Apr 14, 2022
277ad87
filters for multimaps (#30)
tzaeschke Apr 15, 2022
6eccd4f
Filters (#34)
tzaeschke Apr 18, 2022
0dc4465
Filters (#35)
tzaeschke Apr 18, 2022
25d2e1a
Add filters for box keys (#37)
tzaeschke Apr 18, 2022
5009b5e
Issue 38: remove std::optional (#41)
tzaeschke May 18, 2022
d6a58d1
Add try_emplace() (#42)
tzaeschke May 18, 2022
c2e3d8b
Cleaned up erase() (#47)
tzaeschke May 23, 2022
9d622c1
Fix slight problem with value initialization in entry.h (#49)
tzaeschke Jun 9, 2022
6b5759e
Issue 44: alternative multimap bucket (#48)
tzaeschke Jun 9, 2022
cb5dc1e
Fix/43 relocate (#45)
tzaeschke Jun 21, 2022
7992902
Cleanup unit tests (#54)
tzaeschke Jun 23, 2022
09583a6
issue 56 - support move-only/copy-only values (#57)
tzaeschke Jul 1, 2022
71c4054
Iterator cleanup (#58)
tzaeschke Jul 1, 2022
5569986
improved multimap consistency check (#59)
tzaeschke Jul 1, 2022
8ca44f0
Initial
tzaeschke Jul 24, 2022
6c7f74a
Undo erroneous commit
tzaeschke Jul 24, 2022
83db67c
Fix/60 MSVC 2019 issues (#64)
tzaeschke Aug 3, 2022
a25c7e0
Update phtree_test_issues.cc
tzaeschke Aug 3, 2022
629f5cc
Update README converter example
tzaeschke Aug 5, 2022
8adf018
Issue 51 relocate multimap v2 (#52)
tzaeschke Aug 5, 2022
0111120
separate folders for tests/benchmarks (#67)
tzaeschke Aug 5, 2022
789b60c
Fixed result counting in query_mm_d_benchmark.cc
tzaeschke Aug 16, 2022
91b99f4
Add flag to relocate() (#69)
tzaeschke Aug 16, 2022
0935cfe
cmake full build and VS 19 (#71)
tzaeschke Aug 23, 2022
5d1da3b
Initial
tzaeschke Aug 25, 2022
3c6689d
Initial
tzaeschke Aug 25, 2022
d89e32c
Fixed numerous MSVC warnings (#76)
tzaeschke Aug 28, 2022
fcbfd85
v1.3.0
tzaeschke Aug 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ignore typical cmake build folders
build
out
cmake-build-debug
8 changes: 4 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ build:ubsan --linkopt="-lubsan"
test:ubsan --run_under=//tools/runners/sanitizers/ubsan

# MSAN is disabled for now, as there are false positives and we can't suppress them easily.
#build:msan --config=base-sanitizer
#build:msan --copt="-fsanitize=memory"
#build:msan --linkopt="-fsanitize=memory"
#test:msan --run_under=//tools/runners/sanitizers/msan
build:msan --config=base-sanitizer
build:msan --copt="-fsanitize=memory"
build:msan --linkopt="-fsanitize=memory"
test:msan --run_under=//tools/runners/sanitizers/msan

build:lint --define linting_only=true
14 changes: 8 additions & 6 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Bazel build

on: [push, pull_request]
on: [push]

jobs:
build:
Expand All @@ -16,11 +16,13 @@ jobs:
uses: actions/checkout@v2

- name: Setup bazel
# install bazelisk to install the appropriate bazel version
run: |
export PATH=$PATH:$HOME/bin && mkdir -p $HOME/bin
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.5.0/bazelisk-linux-amd64 && chmod +x bazelisk-linux-amd64 && mv bazelisk-linux-amd64 $HOME/bin/bazel
wget https://github.com/bazelbuild/buildtools/releases/download/0.22.0/buildifier && chmod +x buildifier && mv buildifier $HOME/bin/
uses: bazelbuild/setup-bazelisk@v2

- name: Mount bazel cache # Optional
uses: actions/cache@v3
with:
path: "~/.cache/bazel"
key: bazel

- name: Build
shell: bash
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/cmake-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CMake Windows build

on: [push]

env:
BUILD_TYPE: Release

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- uses: ilammy/msvc-dev-cmd@v1

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}\out

- name: Configure CMake
working-directory: ${{github.workspace}}\out
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -S ${{github.workspace}} -B ${{github.workspace}}\out -DPHTREE_BUILD_EXAMPLES=ON -DPHTREE_BUILD_TESTS=ON

- name: Build
working-directory: ${{github.workspace}}\out
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config ${env:BUILD_TYPE}

- name: Test
working-directory: ${{github.workspace}}\out
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${env:BUILD_TYPE}
9 changes: 7 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CMake build

on: [push, pull_request]
on: [push]

env:
BUILD_TYPE: Release
Expand All @@ -23,7 +23,7 @@ jobs:
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPHTREE_BUILD_ALL=ON

- name: Build
working-directory: ${{github.workspace}}/build
Expand All @@ -38,3 +38,8 @@ jobs:
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# TODO Currently tests are run via bazel only.
run: ctest -C $BUILD_TYPE

- name: Example
working-directory: ${{github.workspace}}/build
shell: bash
run: examples/Example
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
!.clang-format
!.gitignore
!.github
!*.yml
bazel-*
!bazel-*.sh
compile_commands.json
perf.data*
build
out
CMakeSettings.json

/cmake-build-debug/
85 changes: 83 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,86 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
Nothing yet.
### Added
- Nothing.

### Changed
- Nothing.

### Removed
- Nothing.

### Fixed
- Nothing.

## [1.3.0] - 2022-08-28
### Added
- Added flag to relocate() allow short cutting in case of identical keys.
[#68](https://github.com/tzaeschke/phtree-cpp/issues/68)
- Added tested support for move-only and copy-only value objects.
[#56](https://github.com/tzaeschke/phtree-cpp/issues/56)
- Added custom bucket implementation (similar to std::unordered_set). This improves update performance by 5%-20%.
[#44](https://github.com/tzaeschke/phtree-cpp/issues/44)
- Added `PhTree.relocate(old_key, new_key)` and `PhTree.relocate_if(old_key, new_key, predicate)`.
This is **a lot faster** than using other methods.
[#43](https://github.com/tzaeschke/phtree-cpp/issues/43)
- Added try_emplace(key, value) and try_emplace(iter_hint, key, value)
[#40](https://github.com/tzaeschke/phtree-cpp/issues/40)
- Added FilterBoxAABB and FilterSphereAABB as examples for filtering a PH-Tree with box keys
[#33](https://github.com/tzaeschke/phtree-cpp/issues/33)
### Changed
- Moved tests and benchmarks into separate folders. [#67](https://github.com/tzaeschke/phtree-cpp/pull/67)
- Cleaned up unit tests. [#54](https://github.com/tzaeschke/phtree-cpp/pull/54)
- Simplified internals of `erase()`. [#47](https://github.com/tzaeschke/phtree-cpp/pull/47)
- Removed internal use of `std::optional()` to slightly reduce memory overhead
[#38](https://github.com/tzaeschke/phtree-cpp/issues/38)
- Removed restrictions on bazel version [#35](https://github.com/tzaeschke/phtree-cpp/issues/35)
- **API BREAKING CHANGE**: API of filters have been changed to be more correct, explicit and flexible.
[#21](https://github.com/tzaeschke/phtree-cpp/issues/21)
- Correctness: Converters and distance functions are not copied unnecessarily anymore.
- Explicit:
Filters *must* have a mandatory parameter for a converter reference. This ensures that the correct
converter is used, probably `tree.converter()`.
- Flexible:
Distance functions can be provided through a universal reference (forwarding reference).
Also, filters are now movable and copyable.

- **API BREAKING CHANGE**: Allow filtering on buckets in multimaps. Multimap filters have different functions
and function signatures than normal `PhTree` filters. [#26](https://github.com/tzaeschke/phtree-cpp/issues/26)

### Fixed
- Fixed compiler warnings when compiling with Visual Studio 2019.
[#74](https://github.com/tzaeschke/phtree-cpp/issues/74)
- Fixed cmake to work with Visual Studio 2019. Added tests and benchmarks to cmake.
(benchmarks still do not work with VS at the moment).
[#62](https://github.com/tzaeschke/phtree-cpp/issues/62)
- Fixed compilation problems and a memory leak when compiling with Visual Studio 2019.
(also added `msan` support). [#64](https://github.com/tzaeschke/phtree-cpp/pull/64)

## [1.2.0] - 2022-04-14
### Changed
- Bugfix: FilterSphere was not working correctly. [#27](https://github.com/tzaeschke/phtree-cpp/issues/27)
- Potentially **BREAKING CHANGE**: Refactored API of all methods that accept callbacks and filters to
accept universal/forwarding references.
Also changed filters and callback to not require `const` methods.
[#22](https://github.com/tzaeschke/phtree-cpp/issues/22)
- Clean up iterator implementations. [#19](https://github.com/tzaeschke/phtree-cpp/issues/19)
- Make PhTree and PhTreeMultimap movable (move-assign/copy). [#18](https://github.com/tzaeschke/phtree-cpp/issues/18)
- Potentially **BREAKING CHANGE** when using `IsNodeValid()` in provided filters:
Changed `bit_width_t` from `uin16_t` to `uint32_t`. This improves performance of 3D insert/emplace
on small datasets by up to 15%. To avoid warnings that meant that the API of `FilterAABB` and `FilterSphere`
had to be changed to accept `uint32_t` instead of `int`. This may break some implementations.
[#17](https://github.com/tzaeschke/phtree-cpp/pull/17)
- DIM>8 now uses custom b_plus_tree_map instead of std::map. This improves performance for all operations, e.g.
window queries on large datasets are up to 4x faster. Benchmarks results can be found in the issue.
[#14](https://github.com/tzaeschke/phtree-cpp/issues/14)
- postfix/infix field moved from Node to Entry. This avoids indirections and improves performance of most by ~10%.
operations by 5-15%. [#11](https://github.com/tzaeschke/phtree-cpp/issues/11)
- Entries now use 'union' to store children. [#9](https://github.com/tzaeschke/phtree-cpp/issues/9)
- Avoid unnecessary find() when removing a node. [#5](https://github.com/tzaeschke/phtree-cpp/issues/5)
- Avoid unnecessary key copy when inserting a node. [#4](https://github.com/tzaeschke/phtree-cpp/issues/4)
- for_each(callback, filter) was traversing too many nodes. [#2](https://github.com/tzaeschke/phtree-cpp/issues/2)
- Build improvements for bazel/cmake

## [1.1.1] - 2022-01-30
### Changed
Expand Down Expand Up @@ -70,7 +149,9 @@ Nothing yet.
- Nothing.


[Unreleased]: https://github.com/improbable-eng/phtree-cpp/compare/v1.1.1...HEAD
[Unreleased]: https://github.com/improbable-eng/phtree-cpp/compare/v1.3.0...HEAD
[1.3.0]: https://github.com/improbable-eng/phtree-cpp/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/improbable-eng/phtree-cpp/compare/v1.1.0...v1.2.0
[1.1.1]: https://github.com/improbable-eng/phtree-cpp/compare/v1.1.0...v1.1.1
[1.1.0]: https://github.com/improbable-eng/phtree-cpp/compare/v1.0.0...v1.1.0
[1.0.1]: https://github.com/improbable-eng/phtree-cpp/compare/v1.0.0...v1.0.1
Expand Down
122 changes: 113 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,123 @@
cmake_minimum_required(VERSION 3.14)

# set the project name
project(PH_Tree_Main VERSION 1.1.1
project(phtree VERSION 1.3.0
DESCRIPTION "PH-Tree C++"
LANGUAGES CXX)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

cmake_policy(SET CMP0077 NEW)

# ---------------------------------------------------------------------------------------
# Set default build to release
# ---------------------------------------------------------------------------------------
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
endif ()

# ---------------------------------------------------------------------------------------
# Build options
# ---------------------------------------------------------------------------------------
# example options
option(PHTREE_BUILD_ALL "Build examples, tests and benchmarks" OFF)

# example options
option(PHTREE_BUILD_EXAMPLES "Build examples" OFF)
#option(PHTREE_BUILD_EXAMPLE_HO "Build header only example" OFF)

# testing options
option(PHTREE_BUILD_TESTS "Build tests" OFF)
#option(PHTREE_BUILD_TESTS_HO "Build tests using the header only version" OFF)

# bench options
option(PHTREE_BUILD_BENCHMARKS "Build benchmarks (Requires https://github.com/google/benchmark.git to be installed)" OFF)

# ---------------------------------------------------------------------------------------
# Compiler config
# ---------------------------------------------------------------------------------------
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
message("CCACHE is found")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
else (CCACHE_FOUND)
message("CCACHE is NOT found")
endif (CCACHE_FOUND)

# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Werror")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif ()

if (MSVC)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17 /Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
set(CMAKE_CXX_FLAGS_RELEASE "/O2")

if (PHTREE_BUILD_TESTS OR PHTREE_BUILD_ALL)
add_compile_options(/bigobj)
endif ()

# For google benchmark
if (PHTREE_BUILD_BENCHMARKS) # OR PHTREE_BUILD_ALL)
# This still doesn't work. This also breaks gtest
# See for example
# https://stackoverflow.com/questions/55376111/how-to-build-and-link-google-benchmark-using-cmake-in-windows
# https://github.com/google/benchmark/issues/1348
# https://github.com/google/benchmark/issues/639
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
# set(BUILD_SHARED_LIBS TRUE) #=TRUE
# set(BENCHMARK_DOWNLOAD_DEPENDENCIES on)
# set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
endif ()
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Werror")
if (PHTREE_BUILD_BENCHMARKS)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -mavx -pthread")
else ()
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -mavx")
endif ()
endif ()

# ---------------------------------------------------------------------------------------
# Build binaries
# ---------------------------------------------------------------------------------------
add_subdirectory(phtree)
add_subdirectory(examples)

if (PHTREE_BUILD_EXAMPLES OR PHTREE_BUILD_ALL)
message(STATUS "Generating examples")
add_subdirectory(examples)
endif ()

if (!MSVC AND (PHTREE_BUILD_BENCHMARKS OR PHTREE_BUILD_ALL))
message(STATUS "Generating benchmarks")
add_subdirectory(benchmark)
endif ()

if (PHTREE_BUILD_TESTS OR PHTREE_BUILD_ALL)
message(STATUS "Generating tests")
if (FALSE)
add_compile_definitions(GTEST_HAS_ABSL=0)
add_compile_definitions(GTEST_OS_WINDOWS_MOBILE=0)
if (MSVC)
add_compile_definitions(GTEST_OS_WINDOWS_MINGW=0)
endif ()
add_compile_definitions(GTEST_OS_LINUX_ANDROID=0)
if (LINUX)
add_compile_definitions(GTEST_OS_LINUX=1)
else ()
add_compile_definitions(GTEST_OS_LINUX=0)
endif ()
add_compile_definitions(
GTEST_OS_WINDOWS_MOBILE=0
GTEST_OS_WINDOWS_PHONE=0
GTEST_OS_WINDOWS_RT=0
GTEST_OS_ESP8266=0
GTEST_OS_XTENSA=0)
endif ()

enable_testing()
include(GoogleTest)
add_subdirectory(test)
endif ()
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
identification within third-party archives.

Copyright 2020 Improbable Worlds Limited
Copyright 2022 Tilmann Zäschke

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Loading