Skip to content

Commit

Permalink
Change perfect hash to grape perfect hash.
Browse files Browse the repository at this point in the history
Signed-off-by: vegetableysm <[email protected]>
  • Loading branch information
vegetableysm committed Mar 29, 2024
1 parent 76e9175 commit a2e4e39
Show file tree
Hide file tree
Showing 16 changed files with 240 additions and 746 deletions.
3 changes: 2 additions & 1 deletion modules/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ file(GLOB_RECURSE VINEYARD_MOD_SRCS "${CMAKE_CURRENT_SOURCE_DIR}"

file(GLOB_RECURSE VINEYARD_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}"
"ds/*.h"
"stream/*.h")
"stream/*.h"
"ds/grape_perfect_hash/*.h")

if(VINEYARD_MOD_SRCS)
vineyard_generate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef GRAPE_CONFIG_H_
#define GRAPE_CONFIG_H_
#ifndef MODULES_BASIC_DS_GRAPE_PERFECT_HASH_CONFIG_H_
#define MODULES_BASIC_DS_GRAPE_PERFECT_HASH_CONFIG_H_

#ifdef USE_JEMALLOC
#include <jemalloc/jemalloc.h>
Expand All @@ -24,8 +24,8 @@ limitations under the License.
#include <thrust/host_vector.h>
#endif

#include "default_allocator.h"
#include "hp_allocator.h"
#include "basic/ds/grape_perfect_hash/default_allocator.h"
#include "basic/ds/grape_perfect_hash/hp_allocator.h"

namespace google {}
namespace grape {
Expand Down Expand Up @@ -67,4 +67,4 @@ const char kSerializationVertexMapFilename[] = "vertex_map.s";
const char kSerializationFilenameFormat[] = "%s/frag_%d.s";

} // namespace grape
#endif // GRAPE_CONFIG_H_
#endif // MODULES_BASIC_DS_GRAPE_PERFECT_HASH_CONFIG_H_
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef GRAPE_UTILS_DEFAULT_ALLOCATOR_H_
#define GRAPE_UTILS_DEFAULT_ALLOCATOR_H_
#ifndef MODULES_BASIC_DS_GRAPE_PERFECT_HASH_DEFAULT_ALLOCATOR_H_
#define MODULES_BASIC_DS_GRAPE_PERFECT_HASH_DEFAULT_ALLOCATOR_H_

#include <stdlib.h>
#define ALLOC_ALIGNMENT 64
Expand Down Expand Up @@ -71,4 +71,4 @@ inline bool operator==(const DefaultAllocator<_Tp1>&,

} // namespace grape

#endif // GRAPE_UTILS_DEFAULT_ALLOCATOR_H_
#endif // MODULES_BASIC_DS_GRAPE_PERFECT_HASH_DEFAULT_ALLOCATOR_H_
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
* limitations under the License.
*/

#ifndef GRAPHSCOPE_PTHASH_UTILS_EF_SEQUENCE_VIEW_VIEW_H_
#define GRAPHSCOPE_PTHASH_UTILS_EF_SEQUENCE_VIEW_VIEW_H_
#ifndef MODULES_BASIC_DS_GRAPE_PERFECT_HASH_EF_SEQUENCE_VIEW_H_
#define MODULES_BASIC_DS_GRAPE_PERFECT_HASH_EF_SEQUENCE_VIEW_H_

#include <assert.h>
#include <stddef.h>
#include <stdint.h>

#include <type_traits>

#include "ref_vector.h"
#include "basic/ds/grape_perfect_hash/ref_vector.h"
#include "pthash/encoders/util.hpp"

namespace grape {
Expand Down Expand Up @@ -146,4 +146,4 @@ struct ef_sequence_view {

} // namespace grape

#endif // GRAPHSCOPE_PTHASH_UTILS_EF_SEQUENCE_VIEW_VIEW_H_
#endif // MODULES_BASIC_DS_GRAPE_PERFECT_HASH_EF_SEQUENCE_VIEW_H_
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* limitations under the License.
*/

#ifndef GRAPHSCOPE_PTHASH_UTILS_ENCODERS_VIEW_VIEW_H_
#define GRAPHSCOPE_PTHASH_UTILS_ENCODERS_VIEW_VIEW_H_
#ifndef MODULES_BASIC_DS_GRAPE_PERFECT_HASH_ENCODERS_VIEW_H_
#define MODULES_BASIC_DS_GRAPE_PERFECT_HASH_ENCODERS_VIEW_H_

#include "ef_sequence_view.h"
#include "basic/ds/grape_perfect_hash/ef_sequence_view.h"

namespace grape {

Expand Down Expand Up @@ -59,4 +59,4 @@ struct dual_dictionary_view {

} // namespace grape

#endif // GRAPHSCOPE_PTHASH_UTILS_ENCODERS_VIEW_VIEW_H_
#endif // MODULES_BASIC_DS_GRAPE_PERFECT_HASH_ENCODERS_VIEW_H_
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef GRAPE_GRAPH_HASHMAP_INDEXER_IMPL_H_
#define GRAPE_GRAPH_HASHMAP_INDEXER_IMPL_H_
#ifndef MODULES_BASIC_DS_GRAPE_PERFECT_HASH_HASHMAP_INDEXER_IMPL_H_
#define MODULES_BASIC_DS_GRAPE_PERFECT_HASH_HASHMAP_INDEXER_IMPL_H_

#include <memory>
#include <utility>
#include <vector>

#include "config.h"
#include "ref_vector.h"
#include "string_view_vector.h"
#include "basic/ds/grape_perfect_hash/config.h"
#include "basic/ds/grape_perfect_hash/ref_vector.h"
#include "basic/ds/grape_perfect_hash/string_view_vector.h"

namespace grape {

Expand Down Expand Up @@ -173,38 +175,6 @@ struct KeyBufferView {

} // namespace hashmap_indexer_impl

namespace sync_comm {

// template <typename T>
// struct CommImpl<hashmap_indexer_impl::KeyBuffer<T>> {
// static void send(const hashmap_indexer_impl::KeyBuffer<T>& buf,
// int dst_worker_id, int tag, MPI_Comm comm) {
// Send(buf.buffer(), dst_worker_id, tag, comm);
// }

// static void recv(hashmap_indexer_impl::KeyBuffer<T>& buf, int
// src_worker_id,
// int tag, MPI_Comm comm) {
// Recv(buf.buffer(), src_worker_id, tag, comm);
// }
// };

// template <>
// struct CommImpl<hashmap_indexer_impl::KeyBuffer<nonstd::string_view>> {
// static void send(
// const hashmap_indexer_impl::KeyBuffer<nonstd::string_view>& buf,
// int dst_worker_id, int tag, MPI_Comm comm) {
// Send(buf.buffer(), dst_worker_id, tag, comm);
// }

// static void recv(hashmap_indexer_impl::KeyBuffer<nonstd::string_view>& buf,
// int src_worker_id, int tag, MPI_Comm comm) {
// Recv(buf.buffer(), src_worker_id, tag, comm);
// }
// };

} // namespace sync_comm

} // namespace grape

#endif // GRAPE_GRAPH_HASHMAP_INDEXER_IMPL_H_
#endif // MODULES_BASIC_DS_GRAPE_PERFECT_HASH_HASHMAP_INDEXER_IMPL_H_
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef GRAPE_UTILS_HP_ALLOCATOR_H_
#define GRAPE_UTILS_HP_ALLOCATOR_H_
#ifndef MODULES_BASIC_DS_GRAPE_PERFECT_HASH_HP_ALLOCATOR_H_
#define MODULES_BASIC_DS_GRAPE_PERFECT_HASH_HP_ALLOCATOR_H_

#include <glog/logging.h>
#include <stdlib.h>
#include <sys/mman.h>

#include <glog/logging.h>
#include <limits>

#ifdef USE_HUGEPAGES

Expand Down Expand Up @@ -124,4 +125,4 @@ inline bool operator==(const HpAllocator<_Tp1>&, const HpAllocator<_Tp2>&) {

#endif

#endif // GRAPE_UTILS_HP_ALLOCATOR_H_
#endif // MODULES_BASIC_DS_GRAPE_PERFECT_HASH_HP_ALLOCATOR_H_
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* limitations under the License.
*/

#ifndef GRAPE_UTILS_REF_VECTOR_H_
#define GRAPE_UTILS_REF_VECTOR_H_
#ifndef MODULES_BASIC_DS_GRAPE_PERFECT_HASH_REF_VECTOR_H_
#define MODULES_BASIC_DS_GRAPE_PERFECT_HASH_REF_VECTOR_H_

#include <vector>

Expand Down Expand Up @@ -79,4 +79,4 @@ const char* decode_val(T& val, const char* buf) {

} // namespace grape

#endif // GRAPE_UTILS_REF_VECTOR_H_
#endif // MODULES_BASIC_DS_GRAPE_PERFECT_HASH_REF_VECTOR_H_
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@
* limitations under the License.
*/

#ifndef GRAPHSCOPE_PTHASH_UTILS_SINGLE_PHF_VIEW_H_
#define GRAPHSCOPE_PTHASH_UTILS_SINGLE_PHF_VIEW_H_
#ifndef MODULES_BASIC_DS_GRAPE_PERFECT_HASH_SINGLE_PHF_VIEW_H_
#define MODULES_BASIC_DS_GRAPE_PERFECT_HASH_SINGLE_PHF_VIEW_H_

#include <cstdlib>
#include <set>
#include <vector>
#include "encoders_view.h"
#include "ref_vector.h"

#include "basic/ds/grape_perfect_hash/encoders_view.h"
#include "basic/ds/grape_perfect_hash/ref_vector.h"
#include "basic/ds/grape_perfect_hash/types.h"
#include "pthash/pthash.hpp"
#include "pthash/single_phf.hpp"
#include "types.h"

#define nssv_CONFIG_SELECT_STRING_VIEW nssv_STRING_VIEW_NONSTD
#include "string_view/string_view.hpp"
Expand Down Expand Up @@ -163,4 +165,4 @@ struct SinglePHFView {

} // namespace grape

#endif // GRAPHSCOPE_PTHASH_UTILS_SINGLE_PHF_VIEW_H_
#endif // MODULES_BASIC_DS_GRAPE_PERFECT_HASH_SINGLE_PHF_VIEW_H_
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef GRAPE_UTILS_STRING_VIEW_VECTOR_H_
#define GRAPE_UTILS_STRING_VIEW_VECTOR_H_
#ifndef MODULES_BASIC_DS_GRAPE_PERFECT_HASH_STRING_VIEW_VECTOR_H_
#define MODULES_BASIC_DS_GRAPE_PERFECT_HASH_STRING_VIEW_VECTOR_H_

#include <stdlib.h>
#include <string.h>
#include <cassert>
#include <memory>
#include <utility>
#include <vector>

#include "ref_vector.h"
#include "basic/ds/grape_perfect_hash/ref_vector.h"
#define nssv_CONFIG_SELECT_STRING_VIEW nssv_STRING_VIEW_NONSTD
#include "string_view/string_view.hpp"

Expand Down Expand Up @@ -165,4 +166,4 @@ struct ref_vector<nonstd::string_view> {

} // namespace grape

#endif // GRAPE_UTILS_STRING_VIEW_VECTOR_H_
#endif // MODULES_BASIC_DS_GRAPE_PERFECT_HASH_STRING_VIEW_VECTOR_H_
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef GRAPE_TYPES_H_
#define GRAPE_TYPES_H_
#ifndef MODULES_BASIC_DS_GRAPE_PERFECT_HASH_TYPES_H_
#define MODULES_BASIC_DS_GRAPE_PERFECT_HASH_TYPES_H_

#include <istream>
#include <ostream>
#include <string>
#include <type_traits>
#include "pthash/utils/hasher.hpp"

Expand Down Expand Up @@ -160,4 +161,4 @@ struct murmurhasher {

} // namespace grape

#endif // GRAPE_TYPES_H_
#endif // MODULES_BASIC_DS_GRAPE_PERFECT_HASH_TYPES_H_
Loading

0 comments on commit a2e4e39

Please sign in to comment.