Skip to content

Commit 514809e

Browse files
authored
Merge branch 'main' into improve-cli
2 parents 73028b3 + 01b67c8 commit 514809e

34 files changed

Lines changed: 725 additions & 296 deletions

.github/workflows/neug-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ jobs:
306306
run: |
307307
cd ${GITHUB_WORKSPACE}/tools/python_bind/
308308
python3 -m pytest --cov=neug --cov-report=term --exitfirst --cov-append --cov-config=.coveragerc -sv tests/test_db_query.py
309+
python3 -m pytest --cov=neug --cov-report=term --exitfirst --cov-append --cov-config=.coveragerc -sv tests/test_call_string_literal.py
309310
python3 -m pytest --cov=neug --cov-report=term --exitfirst --cov-append --cov-config=.coveragerc -sv tests/test_dataset.py
310311
python3 -m pytest --cov=neug --cov-report=term --exitfirst --cov-append --cov-config=.coveragerc -sv tests/test_merge.py
311312

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required (VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.16)
22

33
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/NEUG_VERSION NEUG_VERSION)
44
# Strip trailing newline
@@ -279,8 +279,14 @@ macro(install_neug_target target)
279279
set(_neug_install_target ${target})
280280
endif()
281281

282-
get_target_property(_neug_public_headers ${_neug_install_target} PUBLIC_HEADER)
283-
get_target_property(_neug_target_source_dir ${_neug_install_target} SOURCE_DIR)
282+
get_target_property(_neug_target_type ${_neug_install_target} TYPE)
283+
if(_neug_target_type STREQUAL "INTERFACE_LIBRARY")
284+
set(_neug_public_headers "_neug_public_headers-NOTFOUND")
285+
set(_neug_target_source_dir "")
286+
else()
287+
get_target_property(_neug_public_headers ${_neug_install_target} PUBLIC_HEADER)
288+
get_target_property(_neug_target_source_dir ${_neug_install_target} SOURCE_DIR)
289+
endif()
284290
if(_neug_public_headers AND NOT _neug_public_headers STREQUAL "_neug_public_headers-NOTFOUND" AND NOT _neug_public_headers STREQUAL "NOTFOUND")
285291
set(_neug_public_header_abs)
286292
foreach(_hdr IN LISTS _neug_public_headers)

cmake/BuildGlogAsThirdParty.cmake

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,21 @@ function (build_glog_as_third_party)
1919
set(WITH_GFLAGS OFF CACHE BOOL "Build glog without gflags" FORCE)
2020
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build static library" FORCE)
2121
set(BUILD_TESTING OFF CACHE BOOL "Build glog tests" FORCE)
22+
23+
# Disable libunwind in glog to prevent _Unwind_* symbol conflict with
24+
# libgcc_s.so.1. When both libunwind.so.8 and libgcc_s.so.1 are loaded,
25+
# the dynamic linker may resolve _Unwind_RaiseException to libunwind's
26+
# version which cannot dispatch C++ exceptions, causing abort() instead
27+
# of reaching catch blocks. With WITH_UNWIND=OFF, glog falls back to
28+
# _Unwind_Backtrace from <unwind.h> (provided by libgcc_s) for stack
29+
# traces in LOG(FATAL) / signal handlers — same quality, no conflict.
30+
set(WITH_UNWIND OFF CACHE BOOL "Disable libunwind to avoid symbol conflict with libgcc_s" FORCE)
31+
2232
add_subdirectory(third_party/glog)
2333
include_directories(third_party/glog/src)
2434
include_directories(${CMAKE_CURRENT_BINARY_DIR}/third_party/glog/) # For generated headers
2535
set_target_properties(glog PROPERTIES DEBUG_POSTFIX "")
2636
set(GLOG_LIBRARIES glog::glog PARENT_SCOPE)
2737
set(GLOG_LIB glog::glog PARENT_SCOPE)
2838
set(GLOG_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/third_party/glog/src PARENT_SCOPE)
29-
endfunction()
39+
endfunction()

cmake/neug_symbol_visibility.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ macro(neug_apply_symbol_visibility target)
4141
set_target_properties(${target} PROPERTIES LINK_DEPENDS
4242
"${CMAKE_SOURCE_DIR}/cmake/neug_exports.ld")
4343
endif()
44-
endmacro()
44+
endmacro()

doc/source/installation/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ make install
5454
In your cmake project, find and link NeuG libraries with the following command:
5555

5656
```cmake
57-
cmake_minimum_required (VERSION 3.10)
57+
cmake_minimum_required (VERSION 3.16)
5858
project (
5959
NeuGTest
6060
VERSION 0.1

include/neug/compiler/common/in_mem_overflow_buffer.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#pragma once
2424

25+
#include <cstdint>
2526
#include <iterator>
2627
#include <memory>
2728
#include <vector>
@@ -39,15 +40,16 @@ namespace common {
3940

4041
struct NEUG_API BufferBlock {
4142
public:
42-
explicit BufferBlock(std::unique_ptr<storage::MemoryBuffer> block);
43+
explicit BufferBlock(uint64_t size);
4344
~BufferBlock();
4445

45-
uint64_t size() const;
46-
uint8_t* data() const;
46+
uint64_t size() const { return bufferSize; }
47+
uint8_t* data() const { return buffer.get(); }
4748

4849
public:
4950
uint64_t currentOffset;
50-
std::unique_ptr<storage::MemoryBuffer> block;
51+
uint64_t bufferSize;
52+
std::unique_ptr<uint8_t[]> buffer;
5153

5254
void resetCurrentOffset() { currentOffset = 0; }
5355
};

include/neug/storages/csr/csr_base.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#pragma once
1616

1717
#include <string>
18+
#include <utility>
1819
#include <vector>
1920

2021
#include "neug/storages/allocators.h"
@@ -94,8 +95,9 @@ class CsrBase {
9495
virtual void revert_delete_edge(vid_t src, vid_t nbr, int32_t offset,
9596
timestamp_t ts) = 0;
9697

97-
virtual int32_t put_generic_edge(vid_t src, vid_t dst, const Property& data,
98-
timestamp_t ts, Allocator& alloc) = 0;
98+
virtual std::pair<int32_t, const void*> put_generic_edge(
99+
vid_t src, vid_t dst, const Property& data, timestamp_t ts,
100+
Allocator& alloc) = 0;
99101

100102
virtual std::tuple<std::vector<vid_t>, std::vector<vid_t>> batch_export(
101103
std::shared_ptr<ColumnBase> prev_data_col) const = 0;
@@ -109,14 +111,18 @@ class TypedCsrBase : public CsrBase {
109111
const std::vector<EDATA_T>& data_list,
110112
timestamp_t ts = 0) = 0;
111113

112-
virtual int32_t put_edge(vid_t src, vid_t dst, const EDATA_T& data,
113-
timestamp_t ts, Allocator& alloc) {
114+
virtual std::pair<int32_t, const void*> put_edge(vid_t src, vid_t dst,
115+
const EDATA_T& data,
116+
timestamp_t ts,
117+
Allocator& alloc) {
114118
LOG(FATAL) << "not supported...";
115-
return 0;
119+
return {0, nullptr};
116120
}
117121

118-
int32_t put_generic_edge(vid_t src, vid_t dst, const Property& data,
119-
timestamp_t ts, Allocator& alloc) override {
122+
std::pair<int32_t, const void*> put_generic_edge(vid_t src, vid_t dst,
123+
const Property& data,
124+
timestamp_t ts,
125+
Allocator& alloc) override {
120126
return this->put_edge(src, dst, PropUtils<EDATA_T>::to_typed(data), ts,
121127
alloc);
122128
}

include/neug/storages/csr/mutable_csr.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ class MutableCsr : public TypedCsrBase<EDATA_T> {
110110
const std::vector<EDATA_T>& data_list,
111111
timestamp_t ts = 0) override;
112112

113-
int32_t put_edge(vid_t src, vid_t dst, const EDATA_T& data, timestamp_t ts,
114-
Allocator& alloc) override {
113+
std::pair<int32_t, const void*> put_edge(vid_t src, vid_t dst,
114+
const EDATA_T& data, timestamp_t ts,
115+
Allocator& alloc) override {
115116
if (src >= vertex_capacity()) {
116117
THROW_INVALID_ARGUMENT_EXCEPTION(
117118
"Source vertex id out of range: " + std::to_string(src) +
@@ -140,8 +141,9 @@ class MutableCsr : public TypedCsrBase<EDATA_T> {
140141
nbr.data = data;
141142
nbr.timestamp.store(ts);
142143
edge_num_.fetch_add(1);
144+
const void* data_ptr = static_cast<const void*>(&nbr.data);
143145
locks_[src].unlock();
144-
return prev_size;
146+
return {prev_size, data_ptr};
145147
}
146148

147149
std::tuple<std::vector<vid_t>, std::vector<vid_t>> batch_export(
@@ -270,8 +272,9 @@ class SingleMutableCsr : public TypedCsrBase<EDATA_T> {
270272
const std::vector<EDATA_T>& data_list,
271273
timestamp_t ts = 0) override;
272274

273-
int32_t put_edge(vid_t src, vid_t dst, const EDATA_T& data, timestamp_t ts,
274-
Allocator& alloc) override {
275+
std::pair<int32_t, const void*> put_edge(vid_t src, vid_t dst,
276+
const EDATA_T& data, timestamp_t ts,
277+
Allocator& alloc) override {
275278
if (src >= vertex_capacity()) {
276279
THROW_INVALID_ARGUMENT_EXCEPTION(
277280
"Source vertex id out of range: " + std::to_string(src) +
@@ -283,7 +286,7 @@ class SingleMutableCsr : public TypedCsrBase<EDATA_T> {
283286
CHECK_EQ(nbrs[src].timestamp, std::numeric_limits<timestamp_t>::max());
284287
nbrs[src].timestamp.store(ts);
285288
edge_num_.fetch_add(1, std::memory_order_relaxed);
286-
return 0;
289+
return {0, static_cast<const void*>(&nbrs[src].data)};
287290
}
288291

289292
std::tuple<std::vector<vid_t>, std::vector<vid_t>> batch_export(
@@ -391,9 +394,10 @@ class EmptyCsr : public TypedCsrBase<EDATA_T> {
391394
const std::vector<EDATA_T>& data_list,
392395
timestamp_t ts = 0) override {}
393396

394-
int32_t put_edge(vid_t src, vid_t dst, const EDATA_T& data, timestamp_t ts,
395-
Allocator&) override {
396-
return 0;
397+
std::pair<int32_t, const void*> put_edge(vid_t src, vid_t dst,
398+
const EDATA_T& data, timestamp_t ts,
399+
Allocator&) override {
400+
return {0, nullptr};
397401
}
398402

399403
std::tuple<std::vector<vid_t>, std::vector<vid_t>> batch_export(

include/neug/storages/graph/edge_table.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <memory>
2121
#include <set>
2222
#include <string>
23+
#include <utility>
2324
#include <vector>
2425

2526
#include "neug/storages/allocators.h"
@@ -91,9 +92,9 @@ class EdgeTable {
9192

9293
// Add a single edge to the edge table. Note this method requires an Allocator
9394
// to allocate memory for the edge data. Should be called in tp mode.
94-
int32_t AddEdge(vid_t src_lid, vid_t dst_lid,
95-
const std::vector<Property>& properties, timestamp_t ts,
96-
Allocator& alloc, bool insert_safe);
95+
std::pair<int32_t, const void*> AddEdge(
96+
vid_t src_lid, vid_t dst_lid, const std::vector<Property>& properties,
97+
timestamp_t ts, Allocator& alloc, bool insert_safe);
9798

9899
void RenameProperties(const std::vector<std::string>& old_names,
99100
const std::vector<std::string>& new_names);

include/neug/storages/graph/graph_interface.h

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
#pragma once
1616

17+
#include <optional>
1718
#include "neug/storages/graph/property_graph.h"
1819
#include "neug/storages/graph/schema.h"
1920
#include "neug/utils/property/types.h"
@@ -365,8 +366,9 @@ class StorageReadInterface : virtual public IStorageInterface {
365366
* inserter.AddVertex(person_label, Property("alice"), props, vid);
366367
*
367368
* // Add edge between vertices
369+
* const void* edge_prop = nullptr;
368370
* inserter.AddEdge(person_label, src_vid, person_label, dst_vid, knows_label,
369-
* {});
371+
* {}, edge_prop);
370372
* @endcode
371373
*
372374
* @note This interface is write-only; use StorageReadInterface for reads.
@@ -391,11 +393,12 @@ class StorageInsertInterface : virtual public IStorageInterface {
391393
* @param label Vertex label
392394
* @param id Primary key value
393395
* @param props Property values (excluding primary key)
394-
* @param vid Output: assigned internal vertex ID
395-
* @return true if vertex added successfully
396+
* @param vid Output: assigned internal vertex ID on success
397+
* @return Status::OK() on success, or an error Status if validation fails
398+
* (e.g. property count/type mismatch, capacity failure).
396399
*/
397-
virtual bool AddVertex(label_t label, const Property& id,
398-
const std::vector<Property>& props, vid_t& vid) = 0;
400+
virtual Status AddVertex(label_t label, const Property& id,
401+
const std::vector<Property>& props, vid_t& vid) = 0;
399402

400403
/**
401404
* @brief Add a single edge to the graph.
@@ -406,11 +409,16 @@ class StorageInsertInterface : virtual public IStorageInterface {
406409
* @param dst Destination vertex internal ID
407410
* @param edge_label Edge label
408411
* @param properties Edge property values
409-
* @return true if edge added successfully
412+
* @param prop Output: pointer to the inserted edge property storage. For an
413+
* insert transaction the edge property is not actually inserted
414+
* into the graph until commit, so this is set to nullptr.
415+
* @return Status::OK() on success, or an error Status if validation fails
416+
* (e.g. missing source/destination vertex, property mismatch).
410417
*/
411-
virtual bool AddEdge(label_t src_label, vid_t src, label_t dst_label,
412-
vid_t dst, label_t edge_label,
413-
const std::vector<Property>& properties) = 0;
418+
virtual Status AddEdge(label_t src_label, vid_t src, label_t dst_label,
419+
vid_t dst, label_t edge_label,
420+
const std::vector<Property>& properties,
421+
const void*& prop) = 0;
414422

415423
/**
416424
* @brief Batch insert vertices from a record supplier.
@@ -517,12 +525,13 @@ class StorageUpdateInterface : public StorageReadInterface,
517525
int32_t ie_offset, int32_t col_id,
518526
const Property& value) = 0;
519527

520-
virtual bool AddVertex(label_t label, const Property& id,
521-
const std::vector<Property>& props,
522-
vid_t& vid) override = 0;
523-
virtual bool AddEdge(label_t src_label, vid_t src, label_t dst_label,
524-
vid_t dst, label_t edge_label,
525-
const std::vector<Property>& properties) override = 0;
528+
virtual Status AddVertex(label_t label, const Property& id,
529+
const std::vector<Property>& props,
530+
vid_t& vid) override = 0;
531+
virtual Status AddEdge(label_t src_label, vid_t src, label_t dst_label,
532+
vid_t dst, label_t edge_label,
533+
const std::vector<Property>& properties,
534+
const void*& prop) override = 0;
526535

527536
/**
528537
* @brief Delete multiple vertices by their internal IDs.
@@ -599,11 +608,11 @@ class StorageAPUpdateInterface : public StorageUpdateInterface {
599608
vid_t dst, label_t edge_label, int32_t oe_offset,
600609
int32_t ie_offset, int32_t col_id,
601610
const Property& value) override;
602-
bool AddVertex(label_t label, const Property& id,
603-
const std::vector<Property>& props, vid_t& vid) override;
604-
bool AddEdge(label_t src_label, vid_t src, label_t dst_label, vid_t dst,
605-
label_t edge_label,
606-
const std::vector<Property>& properties) override;
611+
Status AddVertex(label_t label, const Property& id,
612+
const std::vector<Property>& props, vid_t& vid) override;
613+
Status AddEdge(label_t src_label, vid_t src, label_t dst_label, vid_t dst,
614+
label_t edge_label, const std::vector<Property>& properties,
615+
const void*& prop) override;
607616
void CreateCheckpoint() override;
608617
Status BatchAddVertices(
609618
label_t v_label_id,

0 commit comments

Comments
 (0)