Skip to content

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

Merged
liulx20 merged 13 commits into
alibaba:mainfrom
liulx20:create-edge
May 20, 2026
Merged

fix: Support Returning Edge Properties Immediately After Edge Creation#309
liulx20 merged 13 commits into
alibaba: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.

Comment thread include/neug/transaction/insert_transaction.h Outdated
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.

Comment thread include/neug/storages/csr/mutable_csr.h
Comment thread src/transaction/insert_transaction.cc
Comment thread include/neug/storages/graph/graph_interface.h Outdated
Comment thread tools/python_bind/tests/test_db_query.py
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

conn.execute("CREATE NODE TABLE person(id INT64, PRIMARY KEY(id));")
conn.execute(
"CREATE REL TABLE knows(FROM person TO person, since INT64, MANY_MANY);"
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.

should be MANT_TO_MANY

@longbinlai longbinlai added this to neug May 14, 2026
@github-project-automation github-project-automation Bot moved this to In progress in neug May 14, 2026
@longbinlai longbinlai removed this from neug May 14, 2026
Copy link
Copy Markdown
Member

@zhanglei1949 zhanglei1949 left a comment

Choose a reason for hiding this comment

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

LGTM

@liulx20 liulx20 merged commit ee9b13d into alibaba:main May 20, 2026
18 checks passed
@lnfjpt lnfjpt mentioned this pull request May 26, 2026
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

4 participants