Skip to content

Commit

Permalink
Minor.
Browse files Browse the repository at this point in the history
Signed-off-by: vegetableysm <[email protected]>
  • Loading branch information
vegetableysm committed Aug 23, 2024
1 parent a6089d0 commit 31fbe87
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
14 changes: 7 additions & 7 deletions modules/basic/ds/hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ limitations under the License.
#include "client/ds/blob.h"
#include "client/ds/i_object.h"
#include "common/util/arrow.h" // IWYU pragma: keep
#include "grape/graph/perfect_hash_indexer.h"
#include "grape/vertex_map/idxers/pthash_idxer.h"

namespace vineyard {

Expand Down Expand Up @@ -245,7 +245,7 @@ class PerfectHashmapBuilder : public PerfectHashmapBaseBuilder<K, V> {
std::unique_ptr<BlobWriter> writer;
size_t serialize_size = this->builder_.getSerializeSize();
RETURN_ON_ERROR(client.CreateBlob(serialize_size, writer));
this->builder_.finish(writer->data(), serialize_size, this->idxer_);
this->builder_.finishInplace(writer->data(), serialize_size, this->idxer_);
writer->Seal(client, buf);

return this->allocateValues(
Expand Down Expand Up @@ -278,7 +278,7 @@ class PerfectHashmapBuilder : public PerfectHashmapBaseBuilder<K, V> {
std::unique_ptr<BlobWriter> writer;
size_t serialize_size = this->builder_.getSerializeSize();
RETURN_ON_ERROR(client.CreateBlob(serialize_size, writer));
this->builder_.finish(writer->data(), serialize_size, this->idxer_);
this->builder_.finishInplace(writer->data(), serialize_size, this->idxer_);
writer->Seal(client, buf);

return this->allocateValues(
Expand Down Expand Up @@ -311,7 +311,7 @@ class PerfectHashmapBuilder : public PerfectHashmapBaseBuilder<K, V> {
std::unique_ptr<BlobWriter> writer;
size_t serialize_size = this->builder_.getSerializeSize();
RETURN_ON_ERROR(client.CreateBlob(serialize_size, writer));
this->builder_.finish(writer->data(), serialize_size, this->idxer_);
this->builder_.finishInplace(writer->data(), serialize_size, this->idxer_);
writer->Seal(client, buf);

return this->allocateValues(
Expand Down Expand Up @@ -344,7 +344,7 @@ class PerfectHashmapBuilder : public PerfectHashmapBaseBuilder<K, V> {
std::unique_ptr<BlobWriter> writer;
size_t serialize_size = this->builder_.getSerializeSize();
RETURN_ON_ERROR(client.CreateBlob(serialize_size, writer));
this->builder_.finish(writer->data(), serialize_size, this->idxer_);
this->builder_.finishInplace(writer->data(), serialize_size, this->idxer_);
writer->Seal(client, buf);

return this->allocateValues(
Expand Down Expand Up @@ -390,8 +390,8 @@ class PerfectHashmapBuilder : public PerfectHashmapBaseBuilder<K, V> {
return Status::OK();
}

PHIdxerViewBuilder<K, uint64_t> builder_;
ImmPHIdxer<K, uint64_t> idxer_;
grape::PTHashIdxerBuilder<K, uint64_t> builder_;
grape::PTHashIdxer<K, uint64_t> idxer_;
std::shared_ptr<Object> buf;

const int concurrency_ = std::thread::hardware_concurrency();
Expand Down
19 changes: 10 additions & 9 deletions modules/basic/ds/hashmap.vineyard-mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ limitations under the License.
#include "client/ds/blob.h"
#include "client/ds/i_object.h"
#include "common/util/arrow.h"
#include "grape/graph/perfect_hash_indexer.h"
#include "grape/vertex_map/idxers/pthash_idxer.h"

namespace vineyard {

Expand Down Expand Up @@ -325,8 +325,8 @@ class [[vineyard]] Hashmap : public Registered<Hashmap<K, V, H, E>>,
}
};

using grape::ImmPHIdxer;
using grape::PHIdxerViewBuilder;
using grape::PTHashIdxer;
using grape::PTHashIdxerBuilder;

namespace detail {
namespace perfect_hash {
Expand Down Expand Up @@ -385,7 +385,7 @@ struct arrow_array_iterator {

template <typename K, typename V>
Status build_values(
ImmPHIdxer<K, uint64_t>& idxer_, const K* keys, const size_t n_elements,
PTHashIdxer<K, uint64_t>& idxer_, const K* keys, const size_t n_elements,
const V* begin_value, V* values,
const size_t concurrency = std::thread::hardware_concurrency()) {
RETURN_ON_ASSERT(std::is_integral<K>::value, "K must be integral type.");
Expand All @@ -402,7 +402,7 @@ Status build_values(

template <typename K, typename V>
Status build_values(
ImmPHIdxer<K, uint64_t>& idxer_,
PTHashIdxer<K, uint64_t>& idxer_,
const std::shared_ptr<ArrowArrayType<K>>& keys, const V* begin_value,
V* values, const size_t concurrency = std::thread::hardware_concurrency()) {
parallel_for(
Expand All @@ -418,7 +418,7 @@ Status build_values(

template <typename K, typename V>
Status build_values(
ImmPHIdxer<K, uint64_t>& idxer_, const K* keys, const size_t n_elements,
PTHashIdxer<K, uint64_t>& idxer_, const K* keys, const size_t n_elements,
const V begin_value, V* values,
const size_t concurrency = std::thread::hardware_concurrency()) {
RETURN_ON_ASSERT(std::is_integral<K>::value, "K must be integral type.");
Expand All @@ -435,7 +435,7 @@ Status build_values(

template <typename K, typename V>
Status build_values(
ImmPHIdxer<K, uint64_t>& idxer_,
PTHashIdxer<K, uint64_t>& idxer_,
const std::shared_ptr<ArrowArrayType<K>>& keys, const V begin_value,
V* values, const size_t concurrency = std::thread::hardware_concurrency()) {
parallel_for(
Expand Down Expand Up @@ -487,7 +487,8 @@ class [[vineyard]] PerfectHashmap : public Registered<PerfectHashmap<K, V>> {

void PostConstruct(const ObjectMeta& meta) override {
ph_values_ptr_ = reinterpret_cast<const V*>(ph_values_->data());
idxer_.Init(ph_->data(), ph_->size());
idxer_.Init(const_cast<void*>(static_cast<const void*>(ph_->data())),
ph_->size());
}

private:
Expand All @@ -497,7 +498,7 @@ class [[vineyard]] PerfectHashmap : public Registered<PerfectHashmap<K, V>> {
[[shared]] std::shared_ptr<Blob> ph_; // state

const V* ph_values_ptr_ = nullptr;
mutable ImmPHIdxer<K, uint64_t> idxer_;
mutable PTHashIdxer<K, uint64_t> idxer_;

friend class Client;
friend class PerfectHashmapBaseBuilder<K, V>;
Expand Down
2 changes: 1 addition & 1 deletion modules/graph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ else()
)
endif()

find_package(libgrapelite 0.2.5 QUIET)
find_package(libgrapelite 0.3.4 QUIET)
if(LIBGRAPELITE_INCLUDE_DIRS)
message(STATUS "-- Found libgrape-lite: ${LIBGRAPELITE_INCLUDE_DIRS}")
target_include_directories(vineyard_graph PUBLIC ${LIBGRAPELITE_INCLUDE_DIRS})
Expand Down
2 changes: 1 addition & 1 deletion modules/graph/thirdparty/libgrape-lite
Submodule libgrape-lite updated 100 files
8 changes: 8 additions & 0 deletions thirdparty/flat_hash_map/flat_hash_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,11 @@ class sherwood_v3_table : private EntryAlloc, public Hasher, public Equal
deallocate_data(entries, num_slots_minus_one, max_lookups);
}

size_t memory_usage() const
{
return (num_slots_minus_one + max_lookups + 1) * sizeof(Entry);
}

const allocator_type & get_allocator() const
{
return static_cast<const allocator_type &>(*this);
Expand Down Expand Up @@ -980,6 +985,9 @@ class sherwood_v3_table : private EntryAlloc, public Hasher, public Equal
return std::addressof(current->value);
}

// the template automatically disables the operator when value_type is already
// const, because that would cause a lot of compiler warnings otherwise.
template<class target_type = const value_type, class = typename std::enable_if<std::is_same<target_type, const value_type>::value && !std::is_same<target_type, value_type>::value>::type>
operator templated_iterator<const value_type>() const
{
return { current };
Expand Down

0 comments on commit 31fbe87

Please sign in to comment.