Skip to content

fix: Support Returning Edge Properties Immediately After Edge Creation#309

Open
liulx20 wants to merge 3 commits intoalibaba:mainfrom
liulx20:create-edge
Open

fix: Support Returning Edge Properties Immediately After Edge Creation#309
liulx20 wants to merge 3 commits intoalibaba:mainfrom
liulx20:create-edge

Conversation

@liulx20
Copy link
Copy Markdown
Collaborator

@liulx20 liulx20 commented May 6, 2026

This pull request refactors the edge insertion API throughout the codebase to return additional information when adding edges. Instead of returning only a status or offset, the relevant AddEdge and put_edge methods now return a pair containing the previous offset and a pointer to the edge data. This change provides more context to the caller and enables more advanced use cases, such as direct access to the newly inserted edge's data.

const std::vector<Property>& properties) override {
bool ok =
txn_.AddEdge(src_label, src, dst_label, dst, edge_label, properties);
return ok ? reinterpret_cast<const void*>(1) : nullptr;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the expected behavior for dealing with the returned reinterpret_cast<const void*>(1)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Placeholder, cann't attempt to read this property value during insert-transaction.

virtual bool AddEdge(label_t src_label, vid_t src, label_t dst_label,
vid_t dst, label_t edge_label,
const std::vector<Property>& properties) override = 0;
virtual const void* AddEdge(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any better choice to wrap the returned edge, rather than returning a implementation-specific void* pointer?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the edge insertion path so that AddEdge/put_edge can return a reference to the newly inserted edge’s payload, enabling Cypher CREATE ... RETURN e.<prop> to surface edge properties immediately after creation.

Changes:

  • Change AddEdge return types across storage/transaction layers to return an edge-data pointer/handle (and, internally, a {offset, ptr} pair).
  • Plumb the returned edge payload pointer into execution (CreateEdge) so returned edge columns carry property access data.
  • Add a Python binding test asserting RETURN e.since works immediately after CREATE.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tools/python_bind/tests/test_db_query.py Adds coverage for returning an edge property immediately after edge creation.
src/transaction/update_transaction.cc Updates update-transaction edge insertion to return the inserted edge payload pointer.
src/transaction/insert_transaction.cc Updates insert-transaction edge insertion API to return a pointer-like success indicator.
src/storages/graph/property_graph.cc Changes PropertyGraph::AddEdge to return {offset, data_ptr} from the underlying edge table.
src/storages/graph/graph_interface.cc Updates AP update interface AddEdge to return the inserted edge payload pointer.
src/storages/graph/edge_table.cc Propagates CSR put_generic_edge return pair and returns {oe_offset, data_ptr}.
src/execution/common/operators/insert/create_edge.cc Stores returned edge payload pointer into edge columns so edge property accessors can read it.
include/neug/transaction/update_transaction.h Updates update transaction and TP update interface AddEdge signatures to return const void*.
include/neug/transaction/insert_transaction.h Updates insert transaction and TP insert interface AddEdge signatures/docs to return const void*.
include/neug/storages/graph/property_graph.h Updates PropertyGraph::AddEdge signature to return std::pair<int32_t, const void*>.
include/neug/storages/graph/graph_interface.h Updates StorageInsertInterface/StorageUpdateInterface AddEdge return types and documentation.
include/neug/storages/graph/edge_table.h Updates EdgeTable::AddEdge signature to return {offset, data_ptr}.
include/neug/storages/csr/mutable_csr.h Updates CSR put_edge implementations to return {prev_size, data_ptr}.
include/neug/storages/csr/csr_base.h Updates CSR base virtuals to return {offset, data_ptr} pairs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

nbr.data = data;
nbr.timestamp.store(ts);
edge_num_.fetch_add(1);
const void* data_ptr = static_cast<const void*>(&nbr.data);
Comment on lines 135 to 138
InsertEdgeRedo::Serialize(arc_, src_label, src, dst_label, dst, edge_label,
properties);
return true;
return reinterpret_cast<const void*>(1);
}
Comment thread include/neug/storages/graph/graph_interface.h Outdated
Comment on lines +659 to +666
result = conn.execute(
"MATCH (a:person {id: 1}), (b:person {id: 2}) "
"CREATE (a)-[e:knows {since: 2024}]->(b) "
"RETURN e.since;"
)

records = list(result)
assert records == [[2024]], f"Expected [[2024]], got {records}"
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@liulx20 liulx20 linked an issue May 6, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Segfault when accessing edge properties after CREATE edge

3 participants