feat: PolarDB graph backend with decomposed mixin architecture#1054
feat: PolarDB graph backend with decomposed mixin architecture#1054anatolykoptev wants to merge 1 commit intoMemTensor:mainfrom
Conversation
26216e3 to
3c85b6a
Compare
3c85b6a to
6d418fa
Compare
Major graph_dbs module overhaul: 1. PolarDB backend (polardb/) — decomposed into mixin-based package: - connection.py: pool management with health checks and retries - schema.py: AGE extensions, tables, indexes - nodes.py: node CRUD + agtype parsing - edges.py: edge CRUD - filters.py: dual SQL/Cypher WHERE clause builders - search.py: keyword, fulltext, embedding search - traversal.py: neighbors, subgraph, paths - queries.py: metadata queries, counts - maintenance.py: import/export, clear, cleanup 2. Shared utilities (utils.py) — compose_node, prepare_node_metadata, convert_to_vector, detect_embedding_field, clean_properties 3. BaseGraphDB extended with additional abstract methods: get_edges, search_by_fulltext, get_neighbors_by_tag, delete_node_by_prams, get_user_names_by_memory_ids, exist_user_name, search_by_keywords_like, search_by_keywords_tfidf 4. Neo4j/Neo4j Community/Nebula backends updated to implement new abstract methods Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6d418fa to
451fa74
Compare
|
Thank you for your optimization and updates to the underlying PolarDB code in the memos open-source project. Currently, PolarDB utilizes two plugins: polardb_age and vector. While vector is open-source, polardb_age is built upon Apache AGE with significant enhancements and upgrades. For instance, it supports graph_id, which serves as a bridge for connecting edges between different nodes. As you can see from the polardb_age GitHub repository page, this plugin indeed incorporates numerous optimizations and functional extensions based on Apache AGE. It introduces new functions such as graph_i, graph_s, and graph_p, along with more efficient parallel processing and multi-graph support, among other features. You can proceed with optimization and upgrades in postgres.py. The combination of pg_vector, Apache AGE, and multi-table joins is capable of supporting some fundamental functionalities to meet requirements. |
Summary
Overhaul of the
graph_dbs/module:polardb/package (11 files, ~4300 lines). Each mixin handles a logical concern (connection, nodes, edges, search, filters, etc.)utils.py): extracted common helpers used across backendsself.execute_query()incount_nodes()didn't exist — replaced with standard cursor patternPolarDB package structure
__init__.pyPolarDBGraphDBconnection.pyschema.pynodes.pyedges.pyfilters.pysearch.pytraversal.pyqueries.pymaintenance.pyhelpers.pyImport path unchanged
Test plan
BaseGraphDBabstract methods implemented in PolarDB (verified via AST)self.for cross-calls)🤖 Generated with Claude Code