diff --git a/.gitignore b/.gitignore index 5b80f2dcb..18f338d1f 100644 --- a/.gitignore +++ b/.gitignore @@ -34,71 +34,36 @@ TAGS *.fas *.fasl -# Cap'n Proto generated files -*.capnp.c++ -*.capnp.h - -# LCP generated C++ & Cap'n Proto files +# LCP generated C++ files *.lcp.cpp -# TODO delete later -src/storage/distributed/concurrent_id_mapper_rpc_messages.capnp -src/storage/distributed/concurrent_id_mapper_rpc_messages.hpp -##### - - -src/database/distributed/counters_rpc_messages.capnp src/database/distributed/counters_rpc_messages.hpp -src/database/distributed/serialization.capnp src/database/distributed/serialization.hpp -src/database/single_node_ha/serialization.capnp src/database/single_node_ha/serialization.hpp -src/distributed/bfs_rpc_messages.capnp src/distributed/bfs_rpc_messages.hpp -src/distributed/coordination_rpc_messages.capnp src/distributed/coordination_rpc_messages.hpp -src/distributed/data_rpc_messages.capnp src/distributed/data_rpc_messages.hpp -src/distributed/durability_rpc_messages.capnp src/distributed/durability_rpc_messages.hpp -src/distributed/dynamic_worker_rpc_messages.capnp src/distributed/dynamic_worker_rpc_messages.hpp -src/distributed/index_rpc_messages.capnp src/distributed/index_rpc_messages.hpp -src/distributed/plan_rpc_messages.capnp src/distributed/plan_rpc_messages.hpp -src/distributed/pull_produce_rpc_messages.capnp src/distributed/pull_produce_rpc_messages.hpp -src/distributed/storage_gc_rpc_messages.capnp src/distributed/storage_gc_rpc_messages.hpp -src/distributed/token_sharing_rpc_messages.capnp src/distributed/token_sharing_rpc_messages.hpp -src/distributed/updates_rpc_messages.capnp src/distributed/updates_rpc_messages.hpp src/query/frontend/ast/ast.hpp -src/query/distributed/frontend/ast/ast_serialization.capnp src/query/distributed/frontend/ast/ast_serialization.hpp -src/durability/distributed/state_delta.capnp src/durability/distributed/state_delta.hpp src/durability/single_node/state_delta.hpp src/durability/single_node_ha/state_delta.hpp src/query/frontend/semantic/symbol.hpp -src/query/distributed/frontend/semantic/symbol_serialization.capnp src/query/distributed/frontend/semantic/symbol_serialization.hpp -src/query/distributed/plan/ops.capnp src/query/distributed/plan/ops.hpp src/query/plan/operator.hpp -src/raft/log_entry.capnp src/raft/log_entry.hpp -src/raft/raft_rpc_messages.capnp src/raft/raft_rpc_messages.hpp -src/raft/snapshot_metadata.capnp src/raft/snapshot_metadata.hpp src/raft/storage_info_rpc_messages.hpp -src/raft/storage_info_rpc_messages.capnp -src/stats/stats_rpc_messages.capnp src/stats/stats_rpc_messages.hpp -src/storage/distributed/rpc/concurrent_id_mapper_rpc_messages.capnp src/storage/distributed/rpc/concurrent_id_mapper_rpc_messages.hpp -src/transactions/distributed/engine_rpc_messages.capnp src/transactions/distributed/engine_rpc_messages.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 34913e46d..078aa3941 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,7 +154,6 @@ include_directories(SYSTEM ${ANTLR4_INCLUDE_DIR}) include_directories(SYSTEM ${BZIP2_INCLUDE_DIR}) include_directories(SYSTEM ${ZLIB_INCLUDE_DIR}) include_directories(SYSTEM ${ROCKSDB_INCLUDE_DIR}) -include_directories(SYSTEM ${CAPNP_INCLUDE_DIR}) include_directories(SYSTEM ${LIBRDKAFKA_INCLUDE_DIR}) # ----------------------------------------------------------------------------- diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 777ddd4f2..b285b6a51 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -85,27 +85,3 @@ function(get_target_cxx_flags target result) endif() set(${result} ${flags} PARENT_SCOPE) endfunction() - -# Define `add_capnp` function for registering a capnp file for generation. -# -# The `define_add_capnp` expects 3 arguments: -# * name -- name for the function, you usually want `add_capnp` -# * main_src_files -- variable to be updated with generated cpp files -# * generated_capnp_files -- variable to be updated with generated hpp and cpp files -# -# The `add_capnp` function expects a single argument, path to capnp file. -# Each added file is standalone and we avoid recompiling everything. -macro(define_add_capnp name main_src_files generated_capnp_files) - function(${name} capnp_src_file) - set(cpp_file ${CMAKE_CURRENT_SOURCE_DIR}/${capnp_src_file}.c++) - set(h_file ${CMAKE_CURRENT_SOURCE_DIR}/${capnp_src_file}.h) - add_custom_command(OUTPUT ${cpp_file} ${h_file} - COMMAND ${CAPNP_EXE} compile -o${CAPNP_CXX_EXE} ${capnp_src_file} -I ${CMAKE_SOURCE_DIR}/src - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${capnp_src_file} capnproto-proj - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - # Update *global* generated_capnp_files - set(${generated_capnp_files} ${${generated_capnp_files}} ${cpp_file} ${h_file} PARENT_SCOPE) - # Update *global* main_src_files - set(${main_src_files} ${${main_src_files}} ${cpp_file} PARENT_SCOPE) - endfunction(${name}) -endmacro(define_add_capnp) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 239026cf1..06b862ffa 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -213,30 +213,6 @@ import_external_library(rocksdb STATIC DISABLE_WARNING_AS_ERROR=1 INSTALL_COMMAND true) -# Setup Cap'n Proto -ExternalProject_Add(capnproto-proj - PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/capnproto - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/capnproto - BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/capnproto - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/capnproto/configure - --prefix=${CMAKE_CURRENT_SOURCE_DIR}/capnproto/local - --enable-shared=no --silent - CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} - BUILD_COMMAND make -j${NPROC} check) -set(CAPNP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/capnproto/local/include - CACHE FILEPATH "Path to capnproto include directory" FORCE) -set(CAPNP_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/capnproto/local/lib/libcapnp.a - CACHE FILEPATH "Path to capnproto library" FORCE) -set(KJ_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/capnproto/local/lib/libkj.a - CACHE FILEPATH "Path to kj library (used by capnproto)" FORCE) -import_library(capnp STATIC ${CAPNP_LIBRARY} capnproto-proj) -import_library(kj STATIC ${KJ_LIBRARY} capnproto-proj) -set(CAPNP_EXE ${CMAKE_CURRENT_SOURCE_DIR}/capnproto/local/bin/capnp - CACHE FILEPATH "Path to capnproto executable" FORCE) -set(CAPNP_CXX_EXE ${CMAKE_CURRENT_SOURCE_DIR}/capnproto/local/bin/capnpc-c++ - CACHE FILEPATH "Path to capnproto c++ plugin executable" FORCE) -mark_as_advanced(CAPNP_INCLUDE_DIR CAPNP_LIBRARY KJ_LIBRARY CAPNP_EXE CAPNP_CXX_EXE) - # Setup librdkafka. import_external_library(librdkafka STATIC ${CMAKE_CURRENT_SOURCE_DIR}/librdkafka/lib/librdkafka.a diff --git a/libs/setup.sh b/libs/setup.sh index 091ab15ae..dfe5a37d1 100755 --- a/libs/setup.sh +++ b/libs/setup.sh @@ -130,13 +130,6 @@ clone git://deps.memgraph.io/rocksdb.git rocksdb $rocksdb_tag # fix compilation flags to work with clang 8 sed -i 's/-Wshadow/-Wno-defaulted-function-deleted/' rocksdb/Makefile -# Cap'n Proto serialization (and RPC) lib -wget -nv http://deps.memgraph.io/capnproto-c++-0.6.1.tar.gz -O capnproto.tar.gz -tar -xzf capnproto.tar.gz -rm -rf capnproto -mv capnproto-c++-0.6.1 capnproto -rm capnproto.tar.gz - # kafka kafka_tag="c319b4e987d0bc4fe4f01cf91419d90b62061655" # Mar 8, 2018 # git clone https://github.com/edenhill/librdkafka.git diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cef839da0..172a2a6fd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,7 +10,6 @@ add_subdirectory(telemetry) add_subdirectory(communication) add_subdirectory(stats) add_subdirectory(auth) -add_subdirectory(rpc) add_subdirectory(slk) # ---------------------------------------------------------------------------- @@ -176,83 +175,51 @@ set(mg_distributed_sources # ----------------------------------------------------------------------------- -define_add_capnp(add_capnp_distributed mg_distributed_sources generated_capnp_files) - define_add_lcp(add_lcp_distributed mg_distributed_sources generated_lcp_distributed_files) add_lcp_distributed(durability/distributed/state_delta.lcp) -add_lcp_distributed(database/distributed/counters_rpc_messages.lcp CAPNP_SCHEMA @0x95a2c3ea3871e945) -add_capnp_distributed(database/distributed/counters_rpc_messages.capnp) -add_lcp_distributed(database/distributed/serialization.lcp CAPNP_SCHEMA @0xdea01657b3563887 +add_lcp_distributed(database/distributed/counters_rpc_messages.lcp SLK_SERIALIZE) +add_lcp_distributed(database/distributed/serialization.lcp SLK_SERIALIZE DEPENDS durability/distributed/state_delta.lcp) -add_capnp_distributed(database/distributed/serialization.capnp) -add_lcp_distributed(distributed/bfs_rpc_messages.lcp CAPNP_SCHEMA @0x8e508640b09b6d2a) -add_capnp_distributed(distributed/bfs_rpc_messages.capnp) -add_lcp_distributed(distributed/coordination_rpc_messages.lcp CAPNP_SCHEMA @0x93df0c4703cf98fb) -add_capnp_distributed(distributed/coordination_rpc_messages.capnp) -add_lcp_distributed(distributed/data_rpc_messages.lcp CAPNP_SCHEMA @0xc1c8a341ba37aaf5) -add_capnp_distributed(distributed/data_rpc_messages.capnp) -add_lcp_distributed(distributed/durability_rpc_messages.lcp CAPNP_SCHEMA @0xf5e53bc271e2163d) -add_capnp_distributed(distributed/durability_rpc_messages.capnp) -add_lcp_distributed(distributed/index_rpc_messages.lcp CAPNP_SCHEMA @0xa8aab46862945bd6) -add_capnp_distributed(distributed/index_rpc_messages.capnp) -add_lcp_distributed(distributed/plan_rpc_messages.lcp CAPNP_SCHEMA @0xfcbc48dc9f106d28) -add_capnp_distributed(distributed/plan_rpc_messages.capnp) -add_lcp_distributed(distributed/pull_produce_rpc_messages.lcp CAPNP_SCHEMA @0xa78a9254a73685bd +add_lcp_distributed(distributed/bfs_rpc_messages.lcp SLK_SERIALIZE) +add_lcp_distributed(distributed/coordination_rpc_messages.lcp SLK_SERIALIZE) +add_lcp_distributed(distributed/data_rpc_messages.lcp SLK_SERIALIZE) +add_lcp_distributed(distributed/durability_rpc_messages.lcp SLK_SERIALIZE) +add_lcp_distributed(distributed/index_rpc_messages.lcp SLK_SERIALIZE) +add_lcp_distributed(distributed/plan_rpc_messages.lcp SLK_SERIALIZE) +add_lcp_distributed(distributed/pull_produce_rpc_messages.lcp SLK_SERIALIZE DEPENDS transactions/distributed/serialization.lcp) -add_capnp_distributed(distributed/pull_produce_rpc_messages.capnp) -add_lcp_distributed(distributed/storage_gc_rpc_messages.lcp CAPNP_SCHEMA @0xd705663dfe36cf81) -add_capnp_distributed(distributed/storage_gc_rpc_messages.capnp) -add_lcp_distributed(distributed/token_sharing_rpc_messages.lcp CAPNP_SCHEMA @0x8f295db54ec4caec) -add_capnp_distributed(distributed/token_sharing_rpc_messages.capnp) -add_lcp_distributed(distributed/updates_rpc_messages.lcp CAPNP_SCHEMA @0x82d5f38d73c7b53a) -add_capnp_distributed(distributed/updates_rpc_messages.capnp) -add_lcp_distributed(distributed/dynamic_worker_rpc_messages.lcp CAPNP_SCHEMA @0x8c53f6c9a0c71b05) -add_capnp_distributed(distributed/dynamic_worker_rpc_messages.capnp) +add_lcp_distributed(distributed/storage_gc_rpc_messages.lcp SLK_SERIALIZE) +add_lcp_distributed(distributed/token_sharing_rpc_messages.lcp SLK_SERIALIZE) +add_lcp_distributed(distributed/updates_rpc_messages.lcp SLK_SERIALIZE) +add_lcp_distributed(distributed/dynamic_worker_rpc_messages.lcp SLK_SERIALIZE) -# distributed_ops.lcp is leading the capnp code generation, so we don't need -# to generate any capnp for operator.lcp add_lcp_distributed(query/frontend/ast/ast.lcp) -add_lcp_distributed(query/distributed/frontend/ast/ast_serialization.lcp CAPNP_SCHEMA @0xb107d3d6b4b1600b +add_lcp_distributed(query/distributed/frontend/ast/ast_serialization.lcp SLK_SERIALIZE DEPENDS query/frontend/ast/ast.lcp) -add_capnp_distributed(query/distributed/frontend/ast/ast_serialization.capnp) add_lcp_distributed(query/frontend/semantic/symbol.lcp) -add_lcp_distributed(query/distributed/frontend/semantic/symbol_serialization.lcp CAPNP_SCHEMA @0x93c1dcee84e93b76 +add_lcp_distributed(query/distributed/frontend/semantic/symbol_serialization.lcp SLK_SERIALIZE DEPENDS query/frontend/semantic/symbol.lcp) add_lcp_distributed(query/plan/operator.lcp) -add_lcp_distributed(query/distributed/plan/ops.lcp CAPNP_SCHEMA @0xe5cae8d045d30c42 +add_lcp_distributed(query/distributed/plan/ops.lcp SLK_SERIALIZE DEPENDS query/plan/operator.lcp) -add_capnp_distributed(query/distributed/plan/ops.capnp) -add_lcp_distributed(storage/distributed/rpc/concurrent_id_mapper_rpc_messages.lcp CAPNP_SCHEMA @0xa6068dae93d225dd) -add_capnp_distributed(storage/distributed/rpc/concurrent_id_mapper_rpc_messages.capnp) -add_lcp_distributed(transactions/distributed/engine_rpc_messages.lcp CAPNP_SCHEMA @0xde02b7c49180cad5 +add_lcp_distributed(storage/distributed/rpc/concurrent_id_mapper_rpc_messages.lcp SLK_SERIALIZE) +add_lcp_distributed(transactions/distributed/engine_rpc_messages.lcp SLK_SERIALIZE DEPENDS transactions/distributed/serialization.lcp) -add_capnp_distributed(transactions/distributed/engine_rpc_messages.capnp) add_custom_target(generate_lcp_distributed DEPENDS ${generated_lcp_distributed_files}) -# Registering capnp must come after registering lcp files. - -add_capnp_distributed(communication/rpc/messages.capnp) -add_capnp_distributed(durability/distributed/serialization.capnp) -add_capnp_distributed(query/distributed/frontend/semantic/symbol_serialization.capnp) -add_capnp_distributed(query/distributed/serialization.capnp) -add_capnp_distributed(storage/distributed/rpc/serialization.capnp) - -add_custom_target(generate_capnp DEPENDS generate_lcp_distributed ${generated_capnp_files}) - set(MG_DISTRIBUTED_LIBS stdc++fs Threads::Threads fmt cppitertools - antlr_opencypher_parser_lib dl glog gflags capnp kj - mg-utils mg-io mg-io-serialization mg-integrations-kafka mg-requests - mg-communication mg-comm-rpc mg-auth mg-rpc) + antlr_opencypher_parser_lib dl glog gflags + mg-utils mg-io mg-integrations-kafka mg-requests + mg-communication mg-comm-rpc mg-auth) # STATIC library used by memgraph executables add_library(mg-distributed STATIC ${mg_distributed_sources}) target_link_libraries(mg-distributed ${MG_DISTRIBUTED_LIBS}) add_dependencies(mg-distributed generate_opencypher_parser) add_dependencies(mg-distributed generate_lcp_distributed) -add_dependencies(mg-distributed generate_capnp) target_compile_definitions(mg-distributed PUBLIC MG_DISTRIBUTED) # ---------------------------------------------------------------------------- @@ -300,44 +267,30 @@ set(mg_single_node_ha_sources storage/common/locking/record_lock.cpp storage/single_node_ha/edge_accessor.cpp storage/single_node_ha/record_accessor.cpp - storage/single_node_ha/rpc/serialization.cpp storage/single_node_ha/vertex_accessor.cpp transactions/single_node_ha/engine.cpp memgraph_init.cpp ) -define_add_capnp(add_capnp_single_node_ha mg_single_node_ha_sources generated_capnp_single_node_ha_files) - define_add_lcp(add_lcp_single_node_ha mg_single_node_ha_sources generated_lcp_single_node_ha_files) add_lcp_single_node_ha(durability/single_node_ha/state_delta.lcp) -add_lcp_single_node_ha(database/single_node_ha/serialization.lcp CAPNP_SCHEMA @0xd0f4a502575fb6f7 +add_lcp_single_node_ha(database/single_node_ha/serialization.lcp SLK_SERIALIZE DEPENDS durability/single_node_ha/state_delta.lcp) -add_capnp_single_node_ha(database/single_node_ha/serialization.capnp) add_lcp_single_node_ha(query/frontend/ast/ast.lcp) add_lcp_single_node_ha(query/frontend/semantic/symbol.lcp) add_lcp_single_node_ha(query/plan/operator.lcp) -add_lcp_single_node_ha(raft/raft_rpc_messages.lcp CAPNP_SCHEMA @0xa6c29b4287233b66) -add_capnp_single_node_ha(raft/raft_rpc_messages.capnp) -add_lcp_single_node_ha(raft/log_entry.lcp CAPNP_SCHEMA @0x96c07fe13850c22a) -add_capnp_single_node_ha(raft/log_entry.capnp) -add_lcp_single_node_ha(raft/snapshot_metadata.lcp CAPNP_SCHEMA @0xaa08e34991680f6c) -add_capnp_single_node_ha(raft/snapshot_metadata.capnp) -add_lcp_single_node_ha(raft/storage_info_rpc_messages.lcp CAPNP_SCHEMA @0xceee3960cd8eaa7e) -add_capnp_single_node_ha(raft/storage_info_rpc_messages.capnp) +add_lcp_single_node_ha(raft/raft_rpc_messages.lcp SLK_SERIALIZE) +add_lcp_single_node_ha(raft/log_entry.lcp SLK_SERIALIZE) +add_lcp_single_node_ha(raft/snapshot_metadata.lcp SLK_SERIALIZE) +add_lcp_single_node_ha(raft/storage_info_rpc_messages.lcp SLK_SERIALIZE) add_custom_target(generate_lcp_single_node_ha DEPENDS ${generated_lcp_single_node_ha_files}) -# Registering capnp must come after registering lcp files. - -add_capnp_single_node_ha(storage/single_node_ha/rpc/serialization.capnp) - -add_custom_target(generate_capnp_single_node_ha DEPENDS generate_lcp_single_node_ha ${generated_capnp_single_node_ha_files}) - set(MG_SINGLE_NODE_HA_LIBS stdc++fs Threads::Threads fmt cppitertools - antlr_opencypher_parser_lib dl glog gflags capnp kj + antlr_opencypher_parser_lib dl glog gflags mg-utils mg-io mg-integrations-kafka mg-requests mg-communication mg-comm-rpc - mg-auth mg-rpc) + mg-auth) if (USE_LTALLOC) list(APPEND MG_SINGLE_NODE_HA_LIBS ltalloc) @@ -353,7 +306,6 @@ add_library(mg-single-node-ha STATIC ${mg_single_node_ha_sources}) target_link_libraries(mg-single-node-ha ${MG_SINGLE_NODE_HA_LIBS}) add_dependencies(mg-single-node-ha generate_opencypher_parser) add_dependencies(mg-single-node-ha generate_lcp_single_node_ha) -add_dependencies(mg-single-node-ha generate_capnp_single_node_ha) target_compile_definitions(mg-single-node-ha PUBLIC MG_SINGLE_NODE_HA) # ---------------------------------------------------------------------------- diff --git a/src/communication/CMakeLists.txt b/src/communication/CMakeLists.txt index 94aaec60c..f06a8d320 100644 --- a/src/communication/CMakeLists.txt +++ b/src/communication/CMakeLists.txt @@ -16,15 +16,6 @@ set(communication_rpc_src_files rpc/protocol.cpp rpc/server.cpp) -define_add_capnp(add_capnp communication_rpc_src_files communication_rpc_capnp_files) - -add_capnp(rpc/messages.capnp) - -add_custom_target(generate_communication_rpc_capnp DEPENDS ${communication_rpc_capnp_files}) - add_library(mg-comm-rpc STATIC ${communication_rpc_src_files}) -target_link_libraries(mg-comm-rpc Threads::Threads mg-communication mg-utils mg-io mg-rpc fmt glog gflags) -target_link_libraries(mg-comm-rpc capnp kj) +target_link_libraries(mg-comm-rpc Threads::Threads mg-communication mg-utils mg-io fmt glog gflags) target_link_libraries(mg-comm-rpc mg-slk) - -add_dependencies(mg-comm-rpc generate_communication_rpc_capnp) diff --git a/src/communication/rpc/client.hpp b/src/communication/rpc/client.hpp index a735a0f09..9bfd29ab7 100644 --- a/src/communication/rpc/client.hpp +++ b/src/communication/rpc/client.hpp @@ -4,8 +4,6 @@ #include #include -#include -#include #include #include "communication/client.hpp" diff --git a/src/communication/rpc/messages.capnp b/src/communication/rpc/messages.capnp deleted file mode 100644 index 507d52148..000000000 --- a/src/communication/rpc/messages.capnp +++ /dev/null @@ -1,9 +0,0 @@ -@0xd3832c9a1a3d8ec7; - -using Cxx = import "/capnp/c++.capnp"; -$Cxx.namespace("communication::rpc::capnp"); - -struct Message { - typeId @0 :UInt64; - data @1 :AnyPointer; -} diff --git a/src/database/distributed/counters_rpc_messages.lcp b/src/database/distributed/counters_rpc_messages.lcp index 3493a89ff..9db5f9f2e 100644 --- a/src/database/distributed/counters_rpc_messages.lcp +++ b/src/database/distributed/counters_rpc_messages.lcp @@ -4,14 +4,11 @@ #include #include "communication/rpc/messages.hpp" -#include "database/distributed/counters_rpc_messages.capnp.h" #include "slk/serialization.hpp" cpp<# (lcp:namespace database) -(lcp:capnp-namespace "database") - (lcp:define-rpc counters-get (:request ((name "std::string"))) (:response ((value :int64_t)))) diff --git a/src/database/distributed/serialization.lcp b/src/database/distributed/serialization.lcp index a47efe5b5..36c22c400 100644 --- a/src/database/distributed/serialization.lcp +++ b/src/database/distributed/serialization.lcp @@ -1,7 +1,6 @@ #>cpp #pragma once -#include "database/distributed/serialization.capnp.h" #include "durability/distributed/state_delta.hpp" #include "storage/distributed/rpc/serialization.hpp" cpp<# diff --git a/src/database/single_node_ha/serialization.lcp b/src/database/single_node_ha/serialization.lcp index 51f1b07e0..970b2585f 100644 --- a/src/database/single_node_ha/serialization.lcp +++ b/src/database/single_node_ha/serialization.lcp @@ -1,9 +1,8 @@ #>cpp #pragma once -#include "database/single_node_ha/serialization.capnp.h" #include "durability/single_node_ha/state_delta.hpp" -#include "storage/single_node_ha/rpc/serialization.hpp" +#include "storage/common/types/slk.hpp" cpp<# ;; Generate serialization of state-delta diff --git a/src/distributed/bfs_rpc_messages.lcp b/src/distributed/bfs_rpc_messages.lcp index 4fc321e3e..cf6d7ecc0 100644 --- a/src/distributed/bfs_rpc_messages.lcp +++ b/src/distributed/bfs_rpc_messages.lcp @@ -4,92 +4,34 @@ #include #include "communication/rpc/messages.hpp" -#include "distributed/bfs_rpc_messages.capnp.h" #include "distributed/bfs_subcursor.hpp" #include "query/frontend/semantic/symbol_table.hpp" #include "query/distributed/plan/ops.hpp" #include "query/distributed/serialization.hpp" #include "storage/distributed/rpc/serialization.hpp" #include "transactions/type.hpp" -#include "rpc/serialization.hpp" cpp<# (lcp:namespace distributed) -(lcp:capnp-namespace "distributed") - -(lcp:capnp-import 'ast "/query/distributed/frontend/ast/ast_serialization.capnp") -(lcp:capnp-import 'dist-ops "/query/distributed/plan/ops.capnp") -(lcp:capnp-import 'query "/query/distributed/serialization.capnp") -(lcp:capnp-import 'storage "/storage/distributed/rpc/serialization.capnp") -(lcp:capnp-import 'utils "/rpc/serialization.capnp") - -(lcp:capnp-type-conversion "storage::EdgeAddress" "Storage.Address") -(lcp:capnp-type-conversion "storage::VertexAddress" "Storage.Address") -(lcp:capnp-type-conversion "storage::EdgeType" "Storage.EdgeType") - (lcp:define-rpc create-bfs-subcursor (:request - ((tx-id "tx::TransactionId" :capnp-type "UInt64") - (direction "query::EdgeAtom::Direction" - :capnp-type "Ast.EdgeAtom.Direction" :capnp-init nil - :capnp-save (lcp:capnp-save-enum "::query::capnp::EdgeAtom::Direction" - "query::EdgeAtom::Direction" - '(in out both)) - :capnp-load (lcp:capnp-load-enum "::query::capnp::EdgeAtom::Direction" - "query::EdgeAtom::Direction" - '(in out both))) - (edge-types "std::vector" - :capnp-save (lcp:capnp-save-vector "::storage::capnp::EdgeType" - "storage::EdgeType") - :capnp-load (lcp:capnp-load-vector "::storage::capnp::EdgeType" - "storage::EdgeType")) + ((tx-id "tx::TransactionId") + (direction "query::EdgeAtom::Direction") + (edge-types "std::vector") (filter-lambda "query::plan::ExpansionLambda" :slk-load (lambda (member) #>cpp slk::Load(&self->${member}, reader, ast_storage); - cpp<#) - :capnp-type "DistOps.ExpansionLambda" - :capnp-load (lambda (reader member capnp-name) - #>cpp - Load(&${member}, ${reader}, ast_storage); - cpp<#)) - (symbol-table "query::SymbolTable" :capnp-type "Query.SymbolTable") + cpp<#)) + (symbol-table "query::SymbolTable") (timestamp :int64_t) - (parameters "query::Parameters" - :capnp-type "Utils.Map(Utils.BoxInt64, Storage.PropertyValue)")) - (:serialize (:slk :load-args '((ast-storage "query::AstStorage *"))) - (:capnp :load-args '((ast-storage "query::AstStorage *"))))) + (parameters "query::Parameters")) + (:serialize (:slk :load-args '((ast-storage "query::AstStorage *"))))) (:response ((member :int64_t)))) (lcp:define-rpc register-subcursors - (:request ((subcursor-ids "std::unordered_map" - :capnp-type "Utils.Map(Utils.BoxInt16, Utils.BoxInt64)" - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - utils::SaveMap( - ${member}, &${builder}, - [](auto *builder, const auto &entry) { - auto key_builder = builder->initKey(); - key_builder.setValue(entry.first); - auto value_builder = builder->initValue(); - value_builder.setValue(entry.second); - }); - cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore capnp-name)) - #>cpp - utils::LoadMap( - &${member}, ${reader}, - [](const auto &reader) { - int16_t key = reader.getKey().getValue(); - int64_t value = reader.getValue().getValue(); - return std::make_pair(key, value); - }); - cpp<#)))) + (:request ((subcursor-ids "std::unordered_map"))) (:response ())) (lcp:define-rpc reset-subcursor @@ -123,27 +65,10 @@ cpp<# if (has_value) { self->${member} = slk::LoadVertexAccessor(reader, dba, data_manager); } - cpp<#) - :capnp-type "Utils.Optional(Storage.VertexAccessor)" - :capnp-save (lcp:capnp-save-optional - "storage::capnp::VertexAccessor" - "VertexAccessor" - "[worker_id](auto *builder, const auto &vertex) { - storage::SaveVertexAccessor(vertex, builder, storage::SendVersions::BOTH, worker_id); - }") - :capnp-load (lcp:capnp-load-optional - "storage::capnp::VertexAccessor" - "VertexAccessor" - "[dba, data_manager](const auto &reader) { - return storage::LoadVertexAccessor(reader, dba, data_manager); - }"))) + cpp<#))) (:serialize (:slk :save-args '((worker-id :int16_t)) :load-args '((dba "database::GraphDbAccessor *") - (data-manager "distributed::DataManager *"))) - (:capnp - :save-args '((worker-id :int16_t)) - :load-args '((dba "database::GraphDbAccessor *") - (data-manager "distributed::DataManager *")))))) + (data-manager "distributed::DataManager *")))))) (lcp:define-rpc set-source (:request @@ -161,16 +86,10 @@ cpp<# (lcp:define-rpc reconstruct-path (:request ((subcursor-id :int64_t) - (vertex "std::optional" - :capnp-save (lcp:capnp-save-optional "storage::capnp::Address" "storage::VertexAddress") - :capnp-load (lcp:capnp-load-optional "storage::capnp::Address" "storage::VertexAddress")) - (edge "std::optional" - :capnp-save (lcp:capnp-save-optional "storage::capnp::Address" "storage::EdgeAddress") - :capnp-load (lcp:capnp-load-optional "storage::capnp::Address" "storage::EdgeAddress"))) + (vertex "std::optional") + (edge "std::optional")) (:public #>cpp - using Capnp = capnp::ReconstructPathReq; - ReconstructPathReq() {} ReconstructPathReq(int64_t subcursor_id, storage::VertexAddress vertex) @@ -201,35 +120,14 @@ cpp<# for (size_t i = 0; i < size; ++i) { self->${member}.push_back(slk::LoadEdgeAccessor(reader, dba, data_manager)); } - cpp<#) - :capnp-type "List(Storage.EdgeAccessor)" - :capnp-save (lcp:capnp-save-vector "storage::capnp::EdgeAccessor" - "EdgeAccessor" - "[worker_id](auto *builder, const auto &edge) { - storage::SaveEdgeAccessor(edge, builder, storage::SendVersions::BOTH, worker_id); - }") - :capnp-load (lcp:capnp-load-vector "storage::capnp::EdgeAccessor" - "EdgeAccessor" - "[dba, data_manager](const auto &reader) { - return storage::LoadEdgeAccessor(reader, dba, data_manager); - }")) - (next-vertex "std::optional" - :capnp-save (lcp:capnp-save-optional "storage::capnp::Address" "storage::VertexAddress") - :capnp-load (lcp:capnp-load-optional "storage::capnp::Address" "storage::VertexAddress")) - (next-edge "std::optional" - :capnp-save (lcp:capnp-save-optional "storage::capnp::Address" "storage::EdgeAddress") - :capnp-load (lcp:capnp-load-optional "storage::capnp::Address" "storage::EdgeAddress"))) + cpp<#)) + (next-vertex "std::optional") + (next-edge "std::optional")) (:serialize (:slk :save-args '((worker-id :int16_t)) :load-args '((dba "database::GraphDbAccessor *") - (data-manager "distributed::DataManager *"))) - (:capnp - :save-args '((worker-id :int16_t)) - :load-args '((dba "database::GraphDbAccessor *") - (data-manager "distributed::DataManager *")))) + (data-manager "distributed::DataManager *")))) (:public #>cpp - using Capnp = capnp::ReconstructPathRes; - ReconstructPathRes() {} ReconstructPathRes( @@ -264,29 +162,10 @@ cpp<# for (size_t i = 0; i < size; ++i) { slk::Load(&self->${member}[i], reader, subcursor->db_accessor(), data_manager); } - cpp<#) - :capnp-type "List(Query.TypedValue)" - :capnp-save (lcp:capnp-save-vector - "query::capnp::TypedValue" - "query::TypedValue" - "[&self](auto *builder, const auto &value) { - query::SaveCapnpTypedValue(value, builder, - storage::SendVersions::ONLY_OLD, self.worker_id); - }") - :capnp-load (lcp:capnp-load-vector - "query::capnp::TypedValue" - "query::TypedValue" - "[dba, data_manager](const auto &reader) { - query::TypedValue value; - query::LoadCapnpTypedValue(reader, &value, dba, data_manager); - return value; - }")) + cpp<#)) (worker-id :int16_t :dont-save t)) (:serialize (:slk :load-args '((subcursor_storage "distributed::BfsSubcursorStorage *") - (data-manager "distributed::DataManager *"))) - (:capnp - :load-args '((dba "database::GraphDbAccessor *") - (data-manager "distributed::DataManager *"))))) + (data-manager "distributed::DataManager *"))))) (:response ())) (lcp:pop-namespace) ;; distributed diff --git a/src/distributed/coordination_rpc_messages.lcp b/src/distributed/coordination_rpc_messages.lcp index 845ad3eb6..44294440f 100644 --- a/src/distributed/coordination_rpc_messages.lcp +++ b/src/distributed/coordination_rpc_messages.lcp @@ -5,7 +5,6 @@ #include #include "communication/rpc/messages.hpp" -#include "distributed/coordination_rpc_messages.capnp.h" #include "durability/distributed/recovery.hpp" #include "durability/distributed/serialization.hpp" #include "io/network/endpoint.hpp" @@ -14,12 +13,6 @@ cpp<# (lcp:namespace distributed) -(lcp:capnp-namespace "distributed") - -(lcp:capnp-import 'dur "/durability/distributed/serialization.capnp") -(lcp:capnp-import 'io "/io/network/endpoint.capnp") -(lcp:capnp-import 'utils "/rpc/serialization.capnp") - (lcp:define-rpc register-worker (:request ((desired-worker-id :int16_t) @@ -28,61 +21,13 @@ cpp<# (:response ((registration-successful :bool) (durability-error :bool) - (snapshot-to-recover "std::optional>" - :capnp-type "Utils.Optional(Utils.Pair(Utils.BoxUInt64, Utils.BoxUInt64))" - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - utils::SaveOptional, std::pair>( - ${member}, &${builder}, - [](auto builder, const auto &v) { - auto first_builder = builder->initFirst(); - auto second_builder = builder->initSecond(); - first_builder.setValue(v.first); - second_builder.setValue(v.second); - }); - cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore capnp-name)) - #>cpp - ${member} = utils::LoadOptional, std::pair>( - ${reader}, [](auto reader){ - return std::make_pair(reader.getFirst().getValue(), reader.getSecond().getValue()); - }); - cpp<#)) - (workers "std::unordered_map" - :capnp-type "Utils.Map(Utils.BoxInt16, Io.Endpoint)" - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - utils::SaveMap( - ${member}, &${builder}, [](auto *builder, const auto &entry) { - auto key_builder = builder->initKey(); - key_builder.setValue(entry.first); - auto value_builder = builder->initValue(); - Save(entry.second, &value_builder); - }); - cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore capnp-name)) - #>cpp - utils::LoadMap(&${member}, ${reader}, - [](const auto &reader) { - io::network::Endpoint value; - Load(&value, reader.getValue()); - return std::make_pair( - reader.getKey().getValue(), value); - }); - cpp<#))))) + (snapshot-to-recover "std::optional>") + (workers "std::unordered_map")))) (lcp:define-rpc cluster-discovery (:request ((worker-id :int16_t) - (endpoint "io::network::Endpoint" :capnp-type "Io.Endpoint"))) + (endpoint "io::network::Endpoint"))) (:response ())) (lcp:define-rpc stop-worker @@ -92,8 +37,7 @@ cpp<# (lcp:define-rpc notify-worker-recovered (:request ((worker-id :int16_t) - (recovery-info "std::optional" - :capnp-type "Utils.Optional(Dur.RecoveryInfo)"))) + (recovery-info "std::optional"))) (:response ())) (lcp:define-rpc heartbeat diff --git a/src/distributed/data_rpc_messages.lcp b/src/distributed/data_rpc_messages.lcp index c218afcd9..b9e97e64f 100644 --- a/src/distributed/data_rpc_messages.lcp +++ b/src/distributed/data_rpc_messages.lcp @@ -5,7 +5,6 @@ #include #include "communication/rpc/messages.hpp" -#include "distributed/data_rpc_messages.capnp.h" #include "storage/distributed/edge.hpp" #include "storage/distributed/gid.hpp" #include "storage/distributed/rpc/serialization.hpp" @@ -15,33 +14,17 @@ cpp<# (lcp:namespace distributed) -(lcp:capnp-namespace "distributed") - -(lcp:capnp-import 'utils "/rpc/serialization.capnp") -(lcp:capnp-import 'storage "/storage/distributed/rpc/serialization.capnp") - (lcp:define-struct tx-gid-pair () - ((tx-id "tx::TransactionId" :capnp-type "UInt64") - (gid "gid::Gid" :capnp-type "UInt64") + ((tx-id "tx::TransactionId") + (gid "gid::Gid") (from-worker-id :int64_t)) - (:serialize (:slk) (:capnp))) + (:serialize (:slk))) (lcp:define-rpc vertex (:request ((member "TxGidPair"))) (:response ((cypher-id :int64_t) (vertex-old-input "const Vertex *" - :capnp-type "Storage.Vertex" - :capnp-init nil - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - if (${member}) { - auto my_builder = ${builder}->initVertexOldInput(); - storage::SaveVertex(*${member}, &my_builder, self.worker_id); - } - cpp<#) :slk-save (lambda (member) #>cpp @@ -51,15 +34,6 @@ cpp<# slk::Save(*self.${member}, builder, self.worker_id); } cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore member capnp-name)) - #>cpp - if (${reader}.hasVertexOldInput()) { - auto my_reader = ${reader}.getVertexOldInput(); - self->vertex_old_output = storage::LoadVertex(my_reader); - } - cpp<#) :slk-load (lambda (member) (declare (ignore member)) @@ -72,17 +46,6 @@ cpp<# } cpp<#)) (vertex-new-input "const Vertex *" - :capnp-type "Storage.Vertex" - :capnp-init nil - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - if (${member}) { - auto my_builder = ${builder}->initVertexNewInput(); - storage::SaveVertex(*${member}, &my_builder, self.worker_id); - } - cpp<#) :slk-save (lambda (member) #>cpp @@ -92,15 +55,6 @@ cpp<# slk::Save(*self.${member}, builder, self.worker_id); } cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore member capnp-name)) - #>cpp - if (${reader}.hasVertexNewInput()) { - auto my_reader = ${reader}.getVertexNewInput(); - self->vertex_new_output = storage::LoadVertex(my_reader); - } - cpp<#) :slk-load (lambda (member) (declare (ignore member)) @@ -121,17 +75,6 @@ cpp<# (:response ((cypher-id :int64_t) (edge-old-input "const Edge *" - :capnp-type "Storage.Edge" - :capnp-init nil - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - if (${member}) { - auto my_builder = ${builder}->initEdgeOldInput(); - storage::SaveEdge(*${member}, &my_builder, self.worker_id); - } - cpp<#) :slk-save (lambda (member) #>cpp @@ -141,15 +84,6 @@ cpp<# slk::Save(*self.${member}, builder, self.worker_id); } cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore member capnp-name)) - #>cpp - if (${reader}.hasEdgeOldInput()) { - auto my_reader = ${reader}.getEdgeOldInput(); - self->edge_old_output = storage::LoadEdge(my_reader); - } - cpp<#) :slk-load (lambda (member) #>cpp @@ -160,17 +94,6 @@ cpp<# } cpp<#)) (edge-new-input "const Edge *" - :capnp-type "Storage.Edge" - :capnp-init nil - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - if (${member}) { - auto my_builder = ${builder}->initEdgeNewInput(); - storage::SaveEdge(*${member}, &my_builder, self.worker_id); - } - cpp<#) :slk-save (lambda (member) #>cpp @@ -180,15 +103,6 @@ cpp<# slk::Save(*self.${member}, builder, self.worker_id); } cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore member capnp-name)) - #>cpp - if (${reader}.hasEdgeNewInput()) { - auto my_reader = ${reader}.getEdgeNewInput(); - self->edge_new_output = storage::LoadEdge(my_reader); - } - cpp<#) :slk-load (lambda (member) #>cpp @@ -203,7 +117,7 @@ cpp<# (edge-new-output "std::unique_ptr" :initarg nil :dont-save t)))) (lcp:define-rpc vertex-count - (:request ((member "tx::TransactionId" :capnp-type "UInt64"))) + (:request ((member "tx::TransactionId"))) (:response ((member :int64_t)))) (lcp:pop-namespace) ;; distributed diff --git a/src/distributed/durability_rpc_messages.lcp b/src/distributed/durability_rpc_messages.lcp index 954d5d48d..fe1a05399 100644 --- a/src/distributed/durability_rpc_messages.lcp +++ b/src/distributed/durability_rpc_messages.lcp @@ -2,7 +2,6 @@ #pragma once #include "communication/rpc/messages.hpp" -#include "distributed/durability_rpc_messages.capnp.h" #include "durability/distributed/recovery.hpp" #include "durability/distributed/serialization.hpp" #include "transactions/transaction.hpp" @@ -10,16 +9,12 @@ cpp<# (lcp:namespace distributed) -(lcp:capnp-import 'dur "/durability/distributed/serialization.capnp") - -(lcp:capnp-namespace "distributed") - (lcp:define-rpc make-snapshot - (:request ((member "tx::TransactionId" :capnp-type "UInt64"))) + (:request ((member "tx::TransactionId"))) (:response ((member :bool)))) (lcp:define-rpc recover-wal-and-indexes - (:request ((member "durability::RecoveryData" :capnp-type "Dur.RecoveryData"))) + (:request ((member "durability::RecoveryData"))) (:response ())) (lcp:pop-namespace) ;; distributed diff --git a/src/distributed/dynamic_worker_rpc_messages.lcp b/src/distributed/dynamic_worker_rpc_messages.lcp index 00094955f..e24960ed5 100644 --- a/src/distributed/dynamic_worker_rpc_messages.lcp +++ b/src/distributed/dynamic_worker_rpc_messages.lcp @@ -5,41 +5,14 @@ #include #include "communication/rpc/messages.hpp" -#include "distributed/dynamic_worker_rpc_messages.capnp.h" #include "slk/serialization.hpp" cpp<# (lcp:namespace distributed) -(lcp:capnp-namespace "distributed") - -(lcp:capnp-import 'utils "/rpc/serialization.capnp") - (lcp:define-rpc dynamic-worker (:request ()) (:response - ((recover-indices "std::vector>" - :capnp-type "List(Utils.Pair(Text, Text))" - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - utils::SaveVector, - std::pair>( - ${member}, &${builder}, [](auto *builder, const auto value) { - builder->setFirst(value.first); - builder->setSecond(value.second); - }); - cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore capnp-name)) - #>cpp - utils::LoadVector, - std::pair>( - &${member}, ${reader}, [](const auto &reader) { - return std::make_pair(reader.getFirst(), reader.getSecond()); - }); - cpp<#))))) + ((recover-indices "std::vector>")))) (lcp:pop-namespace) ;; distributed diff --git a/src/distributed/index_rpc_messages.lcp b/src/distributed/index_rpc_messages.lcp index 7f03abd7e..ae8deb5db 100644 --- a/src/distributed/index_rpc_messages.lcp +++ b/src/distributed/index_rpc_messages.lcp @@ -5,7 +5,6 @@ #include #include "communication/rpc/messages.hpp" -#include "distributed/index_rpc_messages.capnp.h" #include "storage/common/types/types.hpp" #include "storage/distributed/rpc/serialization.hpp" #include "transactions/transaction.hpp" @@ -13,21 +12,17 @@ cpp<# (lcp:namespace distributed) -(lcp:capnp-namespace "distributed") - -(lcp:capnp-import 'storage "/storage/distributed/rpc/serialization.capnp") - (lcp:define-rpc populate-index (:request - ((label "storage::Label" :capnp-type "Storage.Label") - (property "storage::Property" :capnp-type "Storage.Property") - (tx-id "tx::TransactionId" :capnp-type "UInt64"))) + ((label "storage::Label") + (property "storage::Property") + (tx-id "tx::TransactionId"))) (:response ())) (lcp:define-rpc create-index (:request - ((label "storage::Label" :capnp-type "Storage.Label") - (property "storage::Property" :capnp-type "Storage.Property"))) + ((label "storage::Label") + (property "storage::Property"))) (:response ())) (lcp:pop-namespace) ;; distributed diff --git a/src/distributed/plan_rpc_messages.lcp b/src/distributed/plan_rpc_messages.lcp index d38698ced..49745b85c 100644 --- a/src/distributed/plan_rpc_messages.lcp +++ b/src/distributed/plan_rpc_messages.lcp @@ -5,31 +5,10 @@ #include "query/frontend/ast/ast.hpp" #include "query/frontend/semantic/symbol_table.hpp" #include "query/distributed/plan/ops.hpp" - -#include "distributed/plan_rpc_messages.capnp.h" cpp<# (lcp:namespace distributed) -(lcp:capnp-namespace "distributed") - -(lcp:capnp-import 'utils "/rpc/serialization.capnp") -(lcp:capnp-import 'plan "/query/distributed/plan/ops.capnp") -(lcp:capnp-import 'query "/query/distributed/serialization.capnp") - -(defun load-plan (reader member capnp-name) - (declare (ignore capnp-name)) - #>cpp - query::plan::LogicalOperator::LoadHelper helper; - ${member} = utils::LoadSharedPtr( - ${reader}, [&helper](const auto &reader) { - std::unique_ptr op; - query::plan::Load(&op, reader, &helper); - return op.release(); - }, &helper.loaded_ops); - self->storage = std::move(helper.ast_storage); - cpp<#) - (defun slk-save-plan (member) #>cpp query::plan::LogicalOperator::SaveHelper helper; @@ -50,26 +29,13 @@ cpp<# self->storage = std::move(helper.ast_storage); cpp<#) -(defun save-plan (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - query::plan::LogicalOperator::SaveHelper helper; - utils::SaveSharedPtr( - ${member}, &${builder}, - [&helper](auto *builder, const auto &val) { - Save(val, builder, &helper); - }, &helper.saved_ops); - cpp<#) - (lcp:define-rpc dispatch-plan (:request ((plan-id :int64_t) (plan "std::shared_ptr" - :capnp-type "Utils.SharedPtr(Plan.LogicalOperator)" :slk-save #'slk-save-plan - :slk-load #'slk-load-plan - :capnp-save #'save-plan :capnp-load #'load-plan) - (symbol-table "query::SymbolTable" :capnp-type "Query.SymbolTable") + :slk-load #'slk-load-plan) + (symbol-table "query::SymbolTable") (storage "query::AstStorage" :initarg nil :dont-save t))) (:response ())) diff --git a/src/distributed/pull_produce_rpc_messages.lcp b/src/distributed/pull_produce_rpc_messages.lcp index 26a6c9a70..78e9d23a0 100644 --- a/src/distributed/pull_produce_rpc_messages.lcp +++ b/src/distributed/pull_produce_rpc_messages.lcp @@ -6,14 +6,12 @@ #include #include "communication/rpc/messages.hpp" -#include "distributed/pull_produce_rpc_messages.capnp.h" #include "query/context.hpp" #include "query/frontend/semantic/symbol.hpp" #include "query/parameters.hpp" #include "query/distributed/serialization.hpp" #include "storage/distributed/address_types.hpp" #include "transactions/type.hpp" -#include "rpc/serialization.hpp" cpp<# (lcp:in-impl @@ -27,16 +25,6 @@ cpp<# (lcp:namespace distributed) -(lcp:capnp-namespace "distributed") - -(lcp:capnp-import 'storage "/storage/distributed/rpc/serialization.capnp") -(lcp:capnp-import 'query "/query/distributed/serialization.capnp") -(lcp:capnp-import 'sem "/query/distributed/frontend/semantic/symbol_serialization.capnp") -(lcp:capnp-import 'utils "/rpc/serialization.capnp") - -(lcp:capnp-type-conversion "tx::CommandId" "UInt32") -(lcp:capnp-type-conversion "tx::TransactionId" "UInt64") - #>cpp // Forward declare for LoadGraphElement. class DataManager; @@ -100,38 +88,7 @@ the relevant parts of the response, ready for use.")) ((pull-state "PullState") (frames "std::vector>" :slk-save #'slk-save-frames - :slk-load #'slk-load-frames - :capnp-type "List(List(Query.TypedValue))" - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - for (size_t frame_i = 0; frame_i < ${member}.size(); ++frame_i) { - const auto &frame = ${member}[frame_i]; - auto frame_builder = ${builder}.init(frame_i, frame.size()); - for (size_t val_i = 0; val_i < frame.size(); ++val_i) { - const auto &value = frame[val_i]; - auto value_builder = frame_builder[val_i]; - query::SaveCapnpTypedValue(value, &value_builder, self.send_versions, self.worker_id); - } - } - cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore capnp-name)) - #>cpp - ${member}.reserve(${reader}.size()); - for (const auto &frame_reader : ${reader}) { - std::vector current_frame; - current_frame.reserve(frame_reader.size()); - for (const auto &value_reader : frame_reader) { - query::TypedValue value; - query::LoadCapnpTypedValue(value_reader, &value, dba, data_manager); - current_frame.emplace_back(value); - } - ${member}.emplace_back(current_frame); - } - cpp<#)) + :slk-load #'slk-load-frames) (worker-id :int16_t :dont-save t :documentation "Id of the worker on which the response is created, used for @@ -206,37 +163,23 @@ to the appropriate value. Not used on side that generates the response.") PullResData &operator=(PullResData &&) = default; cpp<#) (:serialize (:slk :load-args '((dba "database::GraphDbAccessor *") - (data-manager "distributed::DataManager *"))) - (:capnp :load-args '((dba "database::GraphDbAccessor *") - (data-manager "distributed::DataManager *"))))) + (data-manager "distributed::DataManager *"))))) (lcp:define-rpc pull (:request ((tx-id "tx::TransactionId") (tx-snapshot "tx::Snapshot" :slk-save #'slk-save-snapshot - :slk-load #'slk-load-snapshot - :capnp-type "List(UInt64)" - :capnp-init nil - :capnp-save #'save-snapshot - :capnp-load #'load-snapshot) + :slk-load #'slk-load-snapshot) (plan-id :int64_t) (command-id "tx::CommandId") (timestamp :int64_t) - (parameters "query::Parameters" - :capnp-type "Utils.Map(Utils.BoxInt64, Storage.PropertyValue)") - (symbols "std::vector" :capnp-type "List(Sem.Symbol)") + (parameters "query::Parameters") + (symbols "std::vector") (accumulate :bool) (batch-size :int64_t) ;; Indicates which of (old, new) records of a graph element should be sent. - (send-versions "storage::SendVersions" - :capnp-type "Storage.SendVersions" :capnp-init nil - :capnp-save (lcp:capnp-save-enum "storage::capnp::SendVersions" - "storage::SendVersions" - '(both only-old only-new)) - :capnp-load (lcp:capnp-load-enum "storage::capnp::SendVersions" - "storage::SendVersions" - '(both only-old only-new))))) + (send-versions "storage::SendVersions"))) (:response ((data "PullResData" :initarg :move :slk-load (lambda (m) @@ -244,9 +187,7 @@ to the appropriate value. Not used on side that generates the response.") slk::Load(&self->${m}, reader, dba, data_manager); cpp<#))) (:serialize (:slk :load-args '((dba "database::GraphDbAccessor *") - (data-manager "distributed::DataManager *"))) - (:capnp :load-args '((dba "database::GraphDbAccessor *") - (data-manager "distributed::DataManager *")))))) + (data-manager "distributed::DataManager *")))))) ;; TODO make a separate RPC for the continuation of an existing pull, as an ;; optimization not to have to send the full PullReqData pack every time. diff --git a/src/distributed/storage_gc_rpc_messages.lcp b/src/distributed/storage_gc_rpc_messages.lcp index 877f7a97e..f977a5d3a 100644 --- a/src/distributed/storage_gc_rpc_messages.lcp +++ b/src/distributed/storage_gc_rpc_messages.lcp @@ -2,7 +2,6 @@ #pragma once #include "communication/rpc/messages.hpp" -#include "distributed/storage_gc_rpc_messages.capnp.h" #include "io/network/endpoint.hpp" #include "slk/serialization.hpp" #include "transactions/transaction.hpp" @@ -10,11 +9,9 @@ cpp<# (lcp:namespace distributed) -(lcp:capnp-namespace "distributed") - (lcp:define-rpc ran-local-gc (:request - ((local-oldest-active "tx::TransactionId" :capnp-type "UInt64") + ((local-oldest-active "tx::TransactionId") (worker-id :int16_t))) (:response ())) diff --git a/src/distributed/token_sharing_rpc_messages.lcp b/src/distributed/token_sharing_rpc_messages.lcp index 3e88cab2e..e9e02e491 100644 --- a/src/distributed/token_sharing_rpc_messages.lcp +++ b/src/distributed/token_sharing_rpc_messages.lcp @@ -5,14 +5,11 @@ #include #include "communication/rpc/messages.hpp" -#include "distributed/token_sharing_rpc_messages.capnp.h" #include "slk/serialization.hpp" cpp<# (lcp:namespace distributed) -(lcp:capnp-namespace "distributed") - (lcp:define-rpc token-transfer (:request ()) (:response ())) diff --git a/src/distributed/updates_rpc_messages.lcp b/src/distributed/updates_rpc_messages.lcp index fb79959e7..b5a02a175 100644 --- a/src/distributed/updates_rpc_messages.lcp +++ b/src/distributed/updates_rpc_messages.lcp @@ -5,31 +5,15 @@ #include "communication/rpc/messages.hpp" #include "database/distributed/serialization.hpp" -#include "distributed/updates_rpc_messages.capnp.h" #include "durability/distributed/state_delta.hpp" #include "storage/distributed/address_types.hpp" #include "storage/distributed/gid.hpp" #include "storage/distributed/rpc/serialization.hpp" #include "transactions/type.hpp" -#include "rpc/serialization.hpp" cpp<# (lcp:namespace distributed) -(lcp:capnp-namespace "distributed") - -(lcp:capnp-import 'db "/database/distributed/serialization.capnp") -(lcp:capnp-import 'storage "/storage/distributed/rpc/serialization.capnp") -(lcp:capnp-import 'utils "/rpc/serialization.capnp") - -(lcp:capnp-type-conversion "tx::TransactionId" "UInt64") -(lcp:capnp-type-conversion "gid::Gid" "UInt64") -(lcp:capnp-type-conversion "storage::Label" "Storage.Label") -(lcp:capnp-type-conversion "storage::EdgeType" "Storage.EdgeType") -(lcp:capnp-type-conversion "storage::Property" "Storage.Property") -(lcp:capnp-type-conversion "storage::EdgeAddress" "Storage.Address") -(lcp:capnp-type-conversion "storage::VertexAddress" "Storage.Address") - (lcp:define-enum update-result (done serialization-error @@ -40,7 +24,7 @@ cpp<# (:serialize)) (lcp:define-rpc update - (:request ((member "database::StateDelta" :capnp-type "Db.StateDelta") + (:request ((member "database::StateDelta") (worker-id :int64_t))) (:response ((member "UpdateResult")))) @@ -52,63 +36,14 @@ cpp<# ((result "UpdateResult") (cypher-id :int64_t :documentation "Only valid if creation was successful.") (gid "gid::Gid" :documentation "Only valid if creation was successful.")) - (:serialize (:slk) (:capnp))) + (:serialize (:slk))) (lcp:define-struct create-vertex-req-data () ((tx-id "tx::TransactionId") - (labels "std::vector" - :capnp-save (lcp:capnp-save-vector "storage::capnp::Label" "storage::Label") - :capnp-load (lcp:capnp-load-vector "storage::capnp::Label" "storage::Label")) - (properties "std::unordered_map" - :capnp-type "Utils.Map(Storage.Property, Storage.PropertyValue)" - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - utils::SaveMap( - ${member}, &${builder}, - [](auto *builder, const auto &entry) { - auto key_builder = builder->initKey(); - Save(entry.first, &key_builder); - auto value_builder = builder->initValue(); - storage::SaveCapnpPropertyValue(entry.second, &value_builder); - }); - cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore capnp-name)) - #>cpp - utils::LoadMap( - &${member}, ${reader}, - [](const auto &reader) { - storage::Property prop; - storage::Load(&prop, reader.getKey()); - PropertyValue value; - storage::LoadCapnpPropertyValue(reader.getValue(), &value); - return std::make_pair(prop, value); - }); - cpp<#)) - (cypher-id "std::optional" - :capnp-type "Utils.Optional(Utils.BoxInt64)" - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - utils::SaveOptional( - ${member}, &${builder}, [](auto *builder, const auto &value) { - builder->setValue(value); - }); - cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore capnp-name)) - #>cpp - ${member} = utils::LoadOptional( - ${reader}, [](const auto &reader) { - return reader.getValue(); - }); - cpp<#))) - (:serialize (:slk) (:capnp))) + (labels "std::vector") + (properties "std::unordered_map") + (cypher-id "std::optional")) + (:serialize (:slk))) (lcp:define-rpc create-vertex (:request ((member "CreateVertexReqData"))) @@ -120,27 +55,8 @@ cpp<# (to "storage::VertexAddress") (edge-type "storage::EdgeType") (tx-id "tx::TransactionId") - (cypher-id "std::optional" - :capnp-type "Utils.Optional(Utils.BoxInt64)" - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - utils::SaveOptional( - ${member}, &${builder}, [](auto *builder, const auto &value) { - builder->setValue(value); - }); - cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore capnp-name)) - #>cpp - ${member} = utils::LoadOptional( - ${reader}, [](const auto &reader) { - return reader.getValue(); - }); - cpp<#))) - (:serialize (:slk) (:capnp))) + (cypher-id "std::optional")) + (:serialize (:slk))) (lcp:define-rpc create-edge (:request ((member "CreateEdgeReqData"))) @@ -153,7 +69,7 @@ cpp<# (to "gid::Gid") (edge-type "storage::EdgeType") (tx-id "tx::TransactionId")) - (:serialize (:slk) (:capnp))) + (:serialize (:slk))) (lcp:define-rpc add-in-edge (:request ((member "AddInEdgeReqData"))) @@ -164,7 +80,7 @@ cpp<# (gid "gid::Gid") (tx-id "tx::TransactionId") (check-empty :bool)) - (:serialize (:slk) (:capnp))) + (:serialize (:slk))) (lcp:define-rpc remove-vertex (:request ((member "RemoveVertexReqData"))) @@ -176,7 +92,7 @@ cpp<# (edge-id "gid::Gid") (vertex-from-id "gid::Gid") (vertex-to-address "storage::VertexAddress")) - (:serialize (:slk) (:capnp))) + (:serialize (:slk))) (lcp:define-rpc remove-edge (:request ((member "RemoveEdgeData"))) @@ -187,7 +103,7 @@ cpp<# (tx-id "tx::TransactionId") (vertex "gid::Gid") (edge-address "storage::EdgeAddress")) - (:serialize (:slk) (:capnp))) + (:serialize (:slk))) (lcp:define-rpc remove-in-edge (:request ((member "RemoveInEdgeData"))) diff --git a/src/durability/distributed/serialization.capnp b/src/durability/distributed/serialization.capnp deleted file mode 100644 index c8a6392dc..000000000 --- a/src/durability/distributed/serialization.capnp +++ /dev/null @@ -1,19 +0,0 @@ -@0xb3d70bc0576218f3; - -using Cxx = import "/capnp/c++.capnp"; -using Utils = import "/rpc/serialization.capnp"; - -$Cxx.namespace("durability::capnp"); - -struct RecoveryInfo { - durabilityVersion @0 :UInt64; - snapshotTxId @1 :UInt64; - walRecovered @2 :List(UInt64); -} - -struct RecoveryData { - snapshooterTxId @0 :UInt64; - walTxToRecover @1 :List(UInt64); - snapshooterTxSnapshot @2 :List(UInt64); - indexes @3 :List(Utils.Pair(Text, Text)); -} diff --git a/src/durability/distributed/serialization.hpp b/src/durability/distributed/serialization.hpp index 0365b82ca..0772a8549 100644 --- a/src/durability/distributed/serialization.hpp +++ b/src/durability/distributed/serialization.hpp @@ -1,75 +1,8 @@ #pragma once #include "durability/distributed/recovery.hpp" -#include "durability/distributed/serialization.capnp.h" -#include "rpc/serialization.hpp" #include "slk/serialization.hpp" -namespace durability { - -inline void Save(const RecoveryInfo &info, - capnp::RecoveryInfo::Builder *builder) { - builder->setDurabilityVersion(info.durability_version); - builder->setSnapshotTxId(info.snapshot_tx_id); - auto list_builder = builder->initWalRecovered(info.wal_recovered.size()); - utils::SaveVector(info.wal_recovered, &list_builder); -} - -inline void Load(RecoveryInfo *info, - const capnp::RecoveryInfo::Reader &reader) { - info->durability_version = reader.getDurabilityVersion(); - info->snapshot_tx_id = reader.getSnapshotTxId(); - auto list_reader = reader.getWalRecovered(); - utils::LoadVector(&info->wal_recovered, list_reader); -} - -inline void Save(const RecoveryData &data, - capnp::RecoveryData::Builder *builder) { - builder->setSnapshooterTxId(data.snapshooter_tx_id); - { - auto list_builder = - builder->initWalTxToRecover(data.wal_tx_to_recover.size()); - utils::SaveVector(data.wal_tx_to_recover, &list_builder); - } - { - auto list_builder = - builder->initSnapshooterTxSnapshot(data.snapshooter_tx_snapshot.size()); - utils::SaveVector(data.snapshooter_tx_snapshot, &list_builder); - } - { - auto list_builder = builder->initIndexes(data.indexes.size()); - utils::SaveVector, - std::pair>( - data.indexes, &list_builder, [](auto *builder, const auto value) { - builder->setFirst(value.first); - builder->setSecond(value.second); - }); - } -} - -inline void Load(RecoveryData *data, - const capnp::RecoveryData::Reader &reader) { - data->snapshooter_tx_id = reader.getSnapshooterTxId(); - { - auto list_reader = reader.getWalTxToRecover(); - utils::LoadVector(&data->wal_tx_to_recover, list_reader); - } - { - auto list_reader = reader.getSnapshooterTxSnapshot(); - utils::LoadVector(&data->snapshooter_tx_snapshot, list_reader); - } - { - auto list_reader = reader.getIndexes(); - utils::LoadVector, - std::pair>( - &data->indexes, list_reader, [](const auto &reader) { - return std::make_pair(reader.getFirst(), reader.getSecond()); - }); - } -} - -} // namespace durability - namespace slk { inline void Save(const durability::RecoveryInfo &info, slk::Builder *builder) { diff --git a/src/durability/distributed/state_delta.lcp b/src/durability/distributed/state_delta.lcp index c679646b2..b7ab41518 100644 --- a/src/durability/distributed/state_delta.lcp +++ b/src/durability/distributed/state_delta.lcp @@ -18,18 +18,6 @@ cpp<# class GraphDbAccessor; cpp<# -(lcp:capnp-namespace "database") - -(lcp:capnp-import 'storage "/storage/distributed/rpc/serialization.capnp") - -(lcp:capnp-type-conversion "tx::TransactionId" "UInt64") -(lcp:capnp-type-conversion "gid::Gid" "UInt64") -(lcp:capnp-type-conversion "storage::Label" "Storage.Label") -(lcp:capnp-type-conversion "storage::EdgeType" "Storage.EdgeType") -(lcp:capnp-type-conversion "storage::Property" "Storage.Property") -(lcp:capnp-type-conversion "storage::EdgeAddress" "Storage.Address") -(lcp:capnp-type-conversion "storage::VertexAddress" "Storage.Address") - (lcp:define-struct state-delta () ( ;; Members valid for every delta. @@ -50,20 +38,7 @@ cpp<# (edge-type-name "std::string") (property "storage::Property") (property-name "std::string") - (value "PropertyValue" :initval "PropertyValue::Null" - :capnp-type "Storage.PropertyValue" - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - storage::SaveCapnpPropertyValue(${member}, &${builder}); - cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore capnp-name)) - #>cpp - storage::LoadCapnpPropertyValue(${reader}, &${member}); - cpp<#)) + (value "PropertyValue" :initval "PropertyValue::Null") (label "storage::Label") (label-name "std::string") (check-empty :bool)) @@ -171,6 +146,6 @@ omitted in the comment.") /// Applies CRUD delta to database accessor. Fails on other types of deltas void Apply(GraphDbAccessor &dba) const; cpp<#) - (:serialize (:slk) (:capnp))) + (:serialize (:slk))) (lcp:pop-namespace) ;; database diff --git a/src/durability/single_node_ha/state_delta.lcp b/src/durability/single_node_ha/state_delta.lcp index 4e1495462..64817dec8 100644 --- a/src/durability/single_node_ha/state_delta.lcp +++ b/src/durability/single_node_ha/state_delta.lcp @@ -21,16 +21,6 @@ cpp<# class GraphDbAccessor; cpp<# -(lcp:capnp-namespace "database") - -(lcp:capnp-import 'storage "/storage/single_node_ha/rpc/serialization.capnp") - -(lcp:capnp-type-conversion "tx::TransactionId" "UInt64") -(lcp:capnp-type-conversion "gid::Gid" "UInt64") -(lcp:capnp-type-conversion "storage::Label" "Storage.Label") -(lcp:capnp-type-conversion "storage::EdgeType" "Storage.EdgeType") -(lcp:capnp-type-conversion "storage::Property" "Storage.Property") - (lcp:define-struct state-delta () ( ;; Members valid for every delta. @@ -45,20 +35,7 @@ cpp<# (edge-type-name "std::string") (property "storage::Property") (property-name "std::string") - (value "PropertyValue" :initval "PropertyValue::Null" - :capnp-type "Storage.PropertyValue" - :capnp-save - (lambda (builder member capnp-name) - (declare (ignore capnp-name)) - #>cpp - storage::SaveCapnpPropertyValue(${member}, &${builder}); - cpp<#) - :capnp-load - (lambda (reader member capnp-name) - (declare (ignore capnp-name)) - #>cpp - storage::LoadCapnpPropertyValue(${reader}, &${member}); - cpp<#)) + (value "PropertyValue" :initval "PropertyValue::Null") (label "storage::Label") (label-name "std::string") (check-empty :bool) @@ -156,6 +133,6 @@ omitted in the comment.") /// Applies CRUD delta to database accessor. Fails on other types of deltas void Apply(GraphDbAccessor &dba) const; cpp<#) - (:serialize (:slk) (:capnp))) + (:serialize (:slk))) (lcp:pop-namespace) ;; database diff --git a/src/io/CMakeLists.txt b/src/io/CMakeLists.txt index 060692737..0aa3c631d 100644 --- a/src/io/CMakeLists.txt +++ b/src/io/CMakeLists.txt @@ -6,13 +6,3 @@ set(io_src_files add_library(mg-io STATIC ${io_src_files}) target_link_libraries(mg-io stdc++fs Threads::Threads fmt glog mg-utils) - -set(io_serialization_src_files) - -define_add_capnp(add_capnp io_serialization_src_files io_capnp_files) -add_capnp(network/endpoint.capnp) -add_custom_target(generate_io_capnp DEPENDS ${io_capnp_files}) - -add_library(mg-io-serialization STATIC ${io_serialization_src_files}) -target_link_libraries(mg-io-serialization mg-io capnp kj) -add_dependencies(mg-io-serialization generate_io_capnp) diff --git a/src/io/network/endpoint.capnp b/src/io/network/endpoint.capnp deleted file mode 100644 index bc58b2869..000000000 --- a/src/io/network/endpoint.capnp +++ /dev/null @@ -1,10 +0,0 @@ -@0x93c2449a1e02365a; - -using Cxx = import "/capnp/c++.capnp"; -$Cxx.namespace("io::network::capnp"); - -struct Endpoint { - address @0 :Text; - port @1 :UInt16; - family @2 :UInt8; -} diff --git a/src/io/network/serialization.hpp b/src/io/network/serialization.hpp index 222c9bfcc..7d466ba6c 100644 --- a/src/io/network/serialization.hpp +++ b/src/io/network/serialization.hpp @@ -1,25 +1,8 @@ #pragma once -#include "io/network/endpoint.capnp.h" #include "io/network/endpoint.hpp" #include "slk/serialization.hpp" -namespace io::network { - -inline void Save(const Endpoint &endpoint, capnp::Endpoint::Builder *builder) { - builder->setAddress(endpoint.address()); - builder->setPort(endpoint.port()); - builder->setFamily(endpoint.family()); -} - -inline void Load(Endpoint *endpoint, const capnp::Endpoint::Reader &reader) { - endpoint->address_ = reader.getAddress(); - endpoint->port_ = reader.getPort(); - endpoint->family_ = reader.getFamily(); -} - -} // namespace io::network - namespace slk { inline void Save(const io::network::Endpoint &endpoint, slk::Builder *builder) { diff --git a/src/lisp/CMakeLists.txt b/src/lisp/CMakeLists.txt index 4eb37a953..d54678b1c 100644 --- a/src/lisp/CMakeLists.txt +++ b/src/lisp/CMakeLists.txt @@ -23,24 +23,16 @@ add_custom_target(lcp # The `define_add_lcp` expects 3 arguments: # * name -- name for the function, you usually want `add_lcp` # * main_src_files -- variable to be updated with generated cpp files -# * generated_lcp_files -- variable to be updated with generated hpp, cpp and capnp files +# * generated_lcp_files -- variable to be updated with generated hpp and cpp files # # The `add_lcp` function expects at least a single argument, path to lcp file. # Each added file is standalone and we avoid recompiling everything. # # By default, each `.lcp` file will produce a `.hpp` and `.cpp` file. To tell # CMake that no `.cpp` file will be generated, pass a NO_CPP option. -# -# You may pass a CAPNP_SCHEMA keyword argument to generate the Cap'n Proto -# serialization code from .lcp file. You still need to add the generated capnp -# file through `add_capnp` function. To generate the use `capnp id` -# invocation, and specify it here. This preserves correct id information across -# multiple schema generations. If this wasn't the case, wrong typeId -# information will break serialization between different compilations. macro(define_add_lcp name main_src_files generated_lcp_files) function(${name} lcp_file) - set(options NO_CPP) - set(one_value_kwargs CAPNP_SCHEMA) + set(options NO_CPP SLK_SERIALIZE) set(multi_value_kwargs DEPENDS) # NOTE: ${${}ARGN} syntax escapes evaluating macro's ARGN variable; see: # https://stackoverflow.com/questions/50365544/how-to-access-enclosing-functions-arguments-from-within-a-macro @@ -52,11 +44,8 @@ macro(define_add_lcp name main_src_files generated_lcp_files) # Update *global* main_src_files set(${main_src_files} ${${main_src_files}} ${cpp_file} PARENT_SCOPE) endif() - if (KW_CAPNP_SCHEMA) - string(REGEX REPLACE "\.lcp$" ".capnp" capnp_file - "${CMAKE_CURRENT_SOURCE_DIR}/${lcp_file}") - set(capnp_id ${KW_CAPNP_SCHEMA}) - set(capnp_depend capnproto-proj) + if (KW_SLK_SERIALIZE) + set(slk_serialize "SLK_SERIALIZE") endif() # Repeat the `lcp_src_files` because this is a macro and the variable is # not visible when invoked in another file. @@ -71,12 +60,12 @@ macro(define_add_lcp name main_src_files generated_lcp_files) ${CMAKE_SOURCE_DIR}/src/lisp/lcp.lisp ${CMAKE_SOURCE_DIR}/src/lisp/lcp-test.lisp ${CMAKE_SOURCE_DIR}/tools/lcp) - add_custom_command(OUTPUT ${h_file} ${cpp_file} ${capnp_file} - COMMAND ${CMAKE_SOURCE_DIR}/tools/lcp ${lcp_file} ${capnp_id} + add_custom_command(OUTPUT ${h_file} ${cpp_file} + COMMAND ${CMAKE_SOURCE_DIR}/tools/lcp ${lcp_file} ${slk_serialize} VERBATIM - DEPENDS ${lcp_src_files} lcp ${lcp_file} ${capnp_depend} ${KW_DEPENDS} + DEPENDS ${lcp_src_files} lcp ${lcp_file} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # Update *global* generated_lcp_files - set(${generated_lcp_files} ${${generated_lcp_files}} ${h_file} ${cpp_file} ${capnp_file} PARENT_SCOPE) + set(${generated_lcp_files} ${${generated_lcp_files}} ${h_file} ${cpp_file} PARENT_SCOPE) endfunction(${name}) endmacro(define_add_lcp) diff --git a/src/lisp/lcp.lisp b/src/lisp/lcp.lisp index bce2eee7d..d1a2913ec 100644 --- a/src/lisp/lcp.lisp +++ b/src/lisp/lcp.lisp @@ -1324,10 +1324,7 @@ enums which aren't defined in LCP." (declare (type list request response)) (assert (eq :request (car request))) (assert (eq :response (car response))) - (flet ((decl-type-info (class-name) - #>cpp - using Capnp = capnp::${class-name}; - cpp<#) + (flet ((decl-type-info (class-name)) (def-constructor (class-name members) (let ((full-constructor (let ((init-members (remove-if (lambda (slot-def) @@ -1496,7 +1493,7 @@ code generation." (write-line (cpp-enum-to-capnp-function-definition cpp-type) cpp-out) (write-line (cpp-enum-from-capnp-function-definition cpp-type) cpp-out)))))) -(defun process-file (lcp-file &key capnp-id) +(defun process-file (lcp-file &key capnp-id slk-serialize) "Process a LCP-FILE and write the output to .hpp file in the same directory. If CAPNP-ID is passed, generates the Cap'n Proto schema to .capnp file in the same directory, while the loading code is generated in LCP-FILE.cpp source @@ -1509,7 +1506,7 @@ file." ;; have our own accompanying .cpp files (cpp-file (concatenate 'string lcp-file ".cpp")) (capnp-file (concatenate 'string filename ".capnp")) - (serializep capnp-id) + (serializep slk-serialize) ;; Reset globals (*capnp-namespace* nil) (*capnp-imports* nil) diff --git a/src/query/distributed/frontend/ast/ast_serialization.lcp b/src/query/distributed/frontend/ast/ast_serialization.lcp index ebabb9981..87804dcb1 100644 --- a/src/query/distributed/frontend/ast/ast_serialization.lcp +++ b/src/query/distributed/frontend/ast/ast_serialization.lcp @@ -4,7 +4,6 @@ #include #include "query/frontend/ast/ast.hpp" -#include "query/distributed/frontend/ast/ast_serialization.capnp.h" #include "query/distributed/serialization.hpp" #include "storage/distributed/rpc/serialization.hpp" cpp<# @@ -17,8 +16,6 @@ cpp<# /// Primary function for saving Ast nodes via SLK. void SaveAstPointer(const Tree *ast, slk::Builder *builder); -Tree *Load(AstStorage *ast, const capnp::Tree::Reader &tree); - Tree *Load(AstStorage *ast, slk::Reader *reader); /// Primary function for loading Ast nodes via SLK. @@ -54,13 +51,6 @@ cpp<# ast->storage_.emplace_back(std::move(root)); return ast->storage_.back().get(); } - - Tree *Load(AstStorage *ast, const capnp::Tree::Reader &tree) { - std::unique_ptr root; - ::query::Load(&root, tree, ast); - ast->storage_.emplace_back(std::move(root)); - return ast->storage_.back().get(); - } cpp<#) (lcp:pop-namespace) ;; namespace query diff --git a/src/query/distributed/frontend/semantic/symbol_serialization.lcp b/src/query/distributed/frontend/semantic/symbol_serialization.lcp index 29d9177a6..553947ac6 100644 --- a/src/query/distributed/frontend/semantic/symbol_serialization.lcp +++ b/src/query/distributed/frontend/semantic/symbol_serialization.lcp @@ -2,7 +2,6 @@ #pragma once #include "query/frontend/semantic/symbol.hpp" -#include "query/distributed/frontend/semantic/symbol_serialization.capnp.h" cpp<# ;; Generate serialization code diff --git a/src/query/distributed/plan/ops.lcp b/src/query/distributed/plan/ops.lcp index df7fa867b..43614f77d 100644 --- a/src/query/distributed/plan/ops.lcp +++ b/src/query/distributed/plan/ops.lcp @@ -4,7 +4,6 @@ #pragma once #include "query/distributed/frontend/ast/ast_serialization.hpp" -#include "query/distributed/plan/ops.capnp.h" #include "query/plan/operator.hpp" #include "query/distributed/serialization.hpp" #include "storage/distributed/rpc/serialization.hpp" @@ -52,13 +51,9 @@ cpp<# (lcp:define-class pull-remote (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (plan-id :int64_t :initval 0 :scope :public) - (symbols "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol"))) + (symbols "std::vector" :scope :public)) (:documentation "An operator in distributed Memgraph that yields both local and remote (from other workers) frames. Obtaining remote frames is done through RPC calls to @@ -84,7 +79,7 @@ time on data transfer. It gives no guarantees on result order.") input_ = input; } cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (defun slk-load-pull-remote (member) @@ -98,29 +93,13 @@ time on data transfer. It gives no guarantees on result order.") self->${member} = std::static_pointer_cast(op); cpp<#) -(defun load-pull-remote (reader member-name capnp-name) - (declare (ignore capnp-name)) - #>cpp - ${member-name} = std::static_pointer_cast( - utils::LoadSharedPtr(${reader}, - [helper](const auto &reader) { - std::unique_ptr op; - Load(&op, reader, helper); - return op.release(); - }, &helper->loaded_ops)); - cpp<#) - (lcp:define-class synchronize (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (pull-remote "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer :slk-load #'slk-load-pull-remote - :capnp-save #'save-operator-pointer - :capnp-load #'load-pull-remote :clone (lambda (source dest) #>cpp if (${source}) { @@ -174,27 +153,19 @@ Logic of the synchronize operator is: input_ = input; } cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class pull-remote-order-by (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (plan-id :int64_t :initval 0 :scope :public) - (symbols "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol")) + (symbols "std::vector" :scope :public) (order-by "std::vector" :scope :public :slk-save #'slk-save-ast-vector - :slk-load (slk-load-ast-vector "Expression") - :capnp-type "List(Ast.Tree)" - :capnp-save (save-ast-vector "Expression *") - :capnp-load (load-ast-vector "Expression *")) - (compare "TypedValueVectorCompare" :scope :public - :capnp-type "Query.TypedValueVectorCompare")) + :slk-load (slk-load-ast-vector "Expression")) + (compare "TypedValueVectorCompare" :scope :public)) (:documentation "Operator that merges distributed OrderBy operators. Instead of using a regular OrderBy on master (which would collect all remote @@ -220,25 +191,16 @@ by having only one result from each worker.") input_ = input; } cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class distributed-expand (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (input-symbol "Symbol" :scope :public) (common "ExpandCommon" :scope :public) (graph-view "GraphView" :scope :public - :capnp-init nil - :capnp-save (lcp:capnp-save-enum "::query::capnp::GraphView" - "GraphView" - '(old new)) - :capnp-load (lcp:capnp-load-enum "::query::capnp::GraphView" - "GraphView" - '(old new)) :documentation "State from which the input node should get expanded.")) (:documentation "Distributed version of Expand operator") @@ -264,42 +226,29 @@ by having only one result from each worker.") input_ = input; } cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class distributed-expand-bfs (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (input-symbol "Symbol" :scope :public) (common "ExpandCommon" :scope :public) (lower-bound "Expression *" :scope :public :documentation "Optional lower bound, default is 1" :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (upper-bound "Expression *" :scope :public :documentation "Optional upper bound, default is infinity" :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (filter-lambda "ExpansionLambda" :scope :public :documentation "Filter that must be satisfied for expansion to succeed." :slk-load (lambda (member) #>cpp slk::Load(&self->${member}, reader, &helper->ast_storage); - cpp<#) - :capnp-type "ExpansionLambda" - :capnp-load (lambda (reader member capnp-name) - #>cpp - Load(&${member}, ${reader}, &helper->ast_storage); - cpp<#))) + cpp<#))) (:documentation "BFS expansion operator suited for distributed execution.") (:public #>cpp @@ -327,15 +276,13 @@ by having only one result from each worker.") input_ = input; } cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class distributed-create-node (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (node-info "NodeCreationInfo" :scope :public :slk-save (lambda (m) #>cpp @@ -364,7 +311,7 @@ by having only one result from each worker.") input_ = input; } cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class distributed-create-expand (logical-operator) @@ -388,9 +335,7 @@ by having only one result from each worker.") cpp<#)) (input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (input-symbol "Symbol" :scope :public) (existing-node :bool :scope :public)) (:documentation "Distributed version of CreateExpand") @@ -412,7 +357,7 @@ by having only one result from each worker.") input_ = input; } cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:pop-namespace) ;; plan diff --git a/src/query/distributed/plan/planner.cpp b/src/query/distributed/plan/planner.cpp index 5fd7e4f6f..56f805a3c 100644 --- a/src/query/distributed/plan/planner.cpp +++ b/src/query/distributed/plan/planner.cpp @@ -2,10 +2,6 @@ #include -// TODO: Remove these includes for hacked cloning of logical operators via -// serialization when proper cloning is added. -#include - #include "query/distributed/plan/ops.hpp" #include "query/distributed/plan/pretty_print.hpp" #include "query/plan/operator.hpp" diff --git a/src/query/distributed/serialization.capnp b/src/query/distributed/serialization.capnp deleted file mode 100644 index 32956ab10..000000000 --- a/src/query/distributed/serialization.capnp +++ /dev/null @@ -1,47 +0,0 @@ -@0xf47e119e21912f20; - -using Ast = import "/query/distributed/frontend/ast/ast_serialization.capnp"; -using Cxx = import "/capnp/c++.capnp"; -using Sem = import "/query/distributed/frontend/semantic/symbol_serialization.capnp"; -using Storage = import "/storage/distributed/rpc/serialization.capnp"; -using Utils = import "/rpc/serialization.capnp"; - -$Cxx.namespace("query::capnp"); - -enum GraphView { - old @0; - new @1; -} - -struct TypedValueVectorCompare { - ordering @0 :List(Ast.Ordering); -} - -struct TypedValue { - union { - nullType @0 :Void; - bool @1 :Bool; - integer @2 :Int64; - double @3 :Float64; - string @4 :Text; - list @5 :List(TypedValue); - map @6 :List(Entry); - vertex @7 :Storage.VertexAccessor; - edge @8 :Storage.EdgeAccessor; - path @9 :Path; - } - - struct Entry { - key @0 :Text; - value @1 :TypedValue; - } - - struct Path { - vertices @0 :List(Storage.VertexAccessor); - edges @1 :List(Storage.EdgeAccessor); - } -} - -struct SymbolTable { - table @0 :Utils.Map(Utils.BoxInt32, Sem.Symbol); -} diff --git a/src/query/distributed/serialization.cpp b/src/query/distributed/serialization.cpp index 551723139..55433c90a 100644 --- a/src/query/distributed/serialization.cpp +++ b/src/query/distributed/serialization.cpp @@ -2,194 +2,6 @@ #include "distributed/data_manager.hpp" #include "query/distributed/frontend/ast/ast_serialization.hpp" -#include "rpc/serialization.hpp" - -namespace query { - -void SaveCapnpTypedValue(const TypedValue &value, - capnp::TypedValue::Builder *builder, - storage::SendVersions versions, int worker_id) { - switch (value.type()) { - case TypedValue::Type::Null: - builder->setNullType(); - return; - case TypedValue::Type::Bool: - builder->setBool(value.Value()); - return; - case TypedValue::Type::Int: - builder->setInteger(value.Value()); - return; - case TypedValue::Type::Double: - builder->setDouble(value.Value()); - return; - case TypedValue::Type::String: - builder->setString(value.Value()); - return; - case TypedValue::Type::List: { - const auto &values = value.Value>(); - auto list_builder = builder->initList(values.size()); - for (size_t i = 0; i < values.size(); ++i) { - auto value_builder = list_builder[i]; - SaveCapnpTypedValue(values[i], &value_builder, versions, worker_id); - } - return; - } - case TypedValue::Type::Map: { - const auto &map = value.Value>(); - auto map_builder = builder->initMap(map.size()); - size_t i = 0; - for (const auto &kv : map) { - auto kv_builder = map_builder[i]; - kv_builder.setKey(kv.first); - auto value_builder = kv_builder.initValue(); - SaveCapnpTypedValue(kv.second, &value_builder, versions, worker_id); - ++i; - } - return; - } - case TypedValue::Type::Vertex: { - auto vertex_builder = builder->initVertex(); - storage::SaveVertexAccessor(value.ValueVertex(), &vertex_builder, - versions, worker_id); - return; - } - case TypedValue::Type::Edge: { - auto edge_builder = builder->initEdge(); - storage::SaveEdgeAccessor(value.ValueEdge(), &edge_builder, versions, - worker_id); - return; - } - case TypedValue::Type::Path: { - auto path_builder = builder->initPath(); - const auto &path = value.ValuePath(); - auto vertices_builder = path_builder.initVertices(path.vertices().size()); - for (size_t i = 0; i < path.vertices().size(); ++i) { - auto vertex_builder = vertices_builder[i]; - storage::SaveVertexAccessor(path.vertices()[i], &vertex_builder, - versions, worker_id); - } - auto edges_builder = path_builder.initEdges(path.edges().size()); - for (size_t i = 0; i < path.edges().size(); ++i) { - auto edge_builder = edges_builder[i]; - storage::SaveEdgeAccessor(path.edges()[i], &edge_builder, versions, - worker_id); - } - return; - } - } -} - -void LoadCapnpTypedValue(const capnp::TypedValue::Reader &reader, - TypedValue *value, database::GraphDbAccessor *dba, - distributed::DataManager *data_manager) { - switch (reader.which()) { - case capnp::TypedValue::NULL_TYPE: - *value = TypedValue::Null; - return; - case capnp::TypedValue::BOOL: - *value = reader.getBool(); - return; - case capnp::TypedValue::INTEGER: - *value = reader.getInteger(); - return; - case capnp::TypedValue::DOUBLE: - *value = reader.getDouble(); - return; - case capnp::TypedValue::STRING: - *value = reader.getString().cStr(); - return; - case capnp::TypedValue::LIST: { - std::vector list; - list.reserve(reader.getList().size()); - for (const auto &value_reader : reader.getList()) { - list.emplace_back(); - LoadCapnpTypedValue(value_reader, &list.back(), dba, data_manager); - } - *value = list; - return; - } - case capnp::TypedValue::MAP: { - std::map map; - for (const auto &kv_reader : reader.getMap()) { - auto key = kv_reader.getKey().cStr(); - LoadCapnpTypedValue(kv_reader.getValue(), &map[key], dba, data_manager); - } - *value = map; - return; - } - case capnp::TypedValue::VERTEX: - *value = - storage::LoadVertexAccessor(reader.getVertex(), dba, data_manager); - return; - case capnp::TypedValue::EDGE: - *value = storage::LoadEdgeAccessor(reader.getEdge(), dba, data_manager); - return; - case capnp::TypedValue::PATH: { - auto vertices_reader = reader.getPath().getVertices(); - auto edges_reader = reader.getPath().getEdges(); - query::Path path( - storage::LoadVertexAccessor(vertices_reader[0], dba, data_manager)); - for (size_t i = 0; i < edges_reader.size(); ++i) { - path.Expand( - storage::LoadEdgeAccessor(edges_reader[i], dba, data_manager)); - path.Expand(storage::LoadVertexAccessor(vertices_reader[i + 1], dba, - data_manager)); - } - *value = path; - return; - } - } -} - -void Save(const Parameters ¶meters, - utils::capnp::Map::Builder *builder) { - auto params_builder = builder->initEntries(parameters.size()); - size_t i = 0; - for (auto &entry : parameters) { - auto builder = params_builder[i]; - auto key_builder = builder.initKey(); - key_builder.setValue(entry.first); - auto value_builder = builder.initValue(); - storage::SaveCapnpPropertyValue(entry.second, &value_builder); - ++i; - } -} - -void Load( - Parameters *parameters, - const utils::capnp::Map::Reader &reader) { - for (const auto &entry_reader : reader.getEntries()) { - PropertyValue value; - storage::LoadCapnpPropertyValue(entry_reader.getValue(), &value); - parameters->Add(entry_reader.getKey().getValue(), value); - } -} - -void Save(const TypedValueVectorCompare &comparator, - capnp::TypedValueVectorCompare::Builder *builder) { - auto ordering_builder = builder->initOrdering(comparator.ordering().size()); - for (size_t i = 0; i < comparator.ordering().size(); ++i) { - ordering_builder.set(i, comparator.ordering()[i] == Ordering::ASC - ? capnp::Ordering::ASC - : capnp::Ordering::DESC); - } -} - -void Load(TypedValueVectorCompare *comparator, - const capnp::TypedValueVectorCompare::Reader &reader) { - std::vector ordering; - ordering.reserve(reader.getOrdering().size()); - for (auto ordering_reader : reader.getOrdering()) { - ordering.push_back(ordering_reader == capnp::Ordering::ASC - ? Ordering::ASC - : Ordering::DESC); - } - comparator->ordering_ = ordering; -} - -} // namespace query namespace slk { diff --git a/src/query/distributed/serialization.hpp b/src/query/distributed/serialization.hpp index afe8d4fba..c42912143 100644 --- a/src/query/distributed/serialization.hpp +++ b/src/query/distributed/serialization.hpp @@ -4,69 +4,13 @@ #include "query/context.hpp" #include "query/distributed/frontend/semantic/symbol_serialization.hpp" #include "query/frontend/semantic/symbol_table.hpp" -#include "query/distributed/serialization.capnp.h" #include "query/typed_value.hpp" -#include "rpc/serialization.hpp" #include "storage/distributed/rpc/serialization.hpp" namespace distributed { class DataManager; } -namespace query { - -void SaveCapnpTypedValue(const query::TypedValue &value, - capnp::TypedValue::Builder *builder, - storage::SendVersions versions, int worker_id); - -void LoadCapnpTypedValue(const capnp::TypedValue::Reader &reader, - query::TypedValue *value, - database::GraphDbAccessor *dba, - distributed::DataManager *data_manager); - -void Save(const TypedValueVectorCompare &comparator, - capnp::TypedValueVectorCompare::Builder *builder); - -void Load(TypedValueVectorCompare *comparator, - const capnp::TypedValueVectorCompare::Reader &reader); - -inline void Save(const SymbolTable &symbol_table, - capnp::SymbolTable::Builder *builder) { - auto table_builder = builder->initTable(); - utils::SaveMap>( - symbol_table.table(), &table_builder, - [](auto *builder, const auto &entry) { - auto key_builder = builder->initKey(); - key_builder.setValue(entry.first); - auto value_builder = builder->initValue(); - Save(entry.second, &value_builder); - }); -} - -inline void Load(SymbolTable *symbol_table, - const capnp::SymbolTable::Reader &reader) { - utils::LoadMap>( - &symbol_table->table_, reader.getTable(), [](const auto &reader) { - std::pair entry; - entry.first = reader.getKey().getValue(); - Load(&entry.second, reader.getValue()); - return entry; - }); -} - -void Save(const Parameters ¶meters, - utils::capnp::Map::Builder *builder); - -void Load( - Parameters *parameters, - const utils::capnp::Map::Reader &reader); - -} // namespace query - namespace slk { inline void Save(const query::SymbolTable &symbol_table, diff --git a/src/query/frontend/ast/ast.lcp b/src/query/frontend/ast/ast.lcp index e4fdf4abb..49cf13ac5 100644 --- a/src/query/frontend/ast/ast.lcp +++ b/src/query/frontend/ast/ast.lcp @@ -19,14 +19,6 @@ class GraphDbAccessor; cpp<# (lcp:namespace query) -(lcp:capnp-namespace "query") - -(lcp:capnp-import 'storage "/storage/distributed/rpc/serialization.capnp") -(lcp:capnp-import 'symbol "/query/distributed/frontend/semantic/symbol_serialization.capnp") -(lcp:capnp-import 'utils "/rpc/serialization.capnp") - -(lcp:capnp-type-conversion "PropertyValue" "Storage.PropertyValue") -(lcp:capnp-type-conversion "Symbol" "Symbol.Symbol") (defun slk-save-ast-pointer (member) #>cpp @@ -39,25 +31,6 @@ cpp<# self->${member} = query::LoadAstPointer(storage, reader); cpp<#)) -(defun save-ast-pointer (builder member capnp-name) - #>cpp - if (${member}) { - auto ${capnp-name}_builder = ${builder}->init${capnp-name}(); - Save(*${member}, &${capnp-name}_builder); - } - cpp<#) - -(defun load-ast-pointer (type) - (lambda (reader member capnp-name) - #>cpp - if (${reader}.has${capnp-name}()) { - ${member} = static_cast<${type}>( - Load(storage, ${reader}.get${capnp-name}())); - } else { - ${member} = nullptr; - } - cpp<#)) - (defun slk-save-ast-vector (member) #>cpp size_t size = self.${member}.size(); @@ -80,21 +53,6 @@ cpp<# } cpp<#)) -(defun save-ast-vector (type) - (lcp:capnp-save-vector "capnp::Tree" type - "[](auto *builder, const auto &val) { - Save(*val, builder); - }")) - -(defun load-ast-vector (type) - (lcp:capnp-load-vector "capnp::Tree" type - (format - nil - "[storage](const auto &reader) { - return static_cast<~A>(Load(storage, reader)); - }" - type))) - (defun slk-save-property-map (member) #>cpp size_t size = self.${member}.size(); @@ -119,29 +77,6 @@ cpp<# } cpp<#) -(defun save-property-map (builder member capnp-name) - #>cpp - auto entries_builder = ${builder}.initEntries(${member}.size()); - size_t i = 0; - for (const auto &entry : ${member}) { - auto key_builder = entries_builder[i].initKey(); - Save(entry.first, &key_builder); - auto value_builder = entries_builder[i].initValue(); - Save(*entry.second, &value_builder); - ++i; - } - cpp<#) - -(defun load-property-map (reader member capnp-name) - #>cpp - for (const auto &entry : ${reader}.getEntries()) { - PropertyIx prop; - Load(&prop, entry.getKey(), storage); - ${member}.emplace(prop, static_cast( - Load(storage, entry.getValue()))); - } - cpp<#) - (defun clone-property-map (source dest) #>cpp for (const auto &entry : ${source}) { @@ -150,13 +85,6 @@ cpp<# } cpp<#) -(defun capnp-load-name-ix (name-type) - (lambda (reader member capnp-name) - (declare (ignore capnp-name)) - #>cpp - ${member} = storage->Get${name-type}Ix(self->name).ix; - cpp<#)) - (defun slk-load-name-ix (name-type) (lambda (member) #>cpp @@ -188,31 +116,22 @@ cpp<# ((name "std::string") (ix :int64_t :dont-save t - :slk-load (slk-load-name-ix "Label") - :capnp-init nil - :capnp-load (capnp-load-name-ix "Label"))) - (:serialize (:slk :load-args '((storage "query::AstStorage *"))) - (:capnp :load-args '((storage "AstStorage *"))))) + :slk-load (slk-load-name-ix "Label"))) + (:serialize (:slk :load-args '((storage "query::AstStorage *"))))) (lcp:define-struct property-ix () ((name "std::string") (ix :int64_t :dont-save t - :slk-load (slk-load-name-ix "Property") - :capnp-init nil - :capnp-load (capnp-load-name-ix "Property"))) - (:serialize (:slk :load-args '((storage "query::AstStorage *"))) - (:capnp :load-args '((storage "AstStorage *"))))) + :slk-load (slk-load-name-ix "Property"))) + (:serialize (:slk :load-args '((storage "query::AstStorage *"))))) (lcp:define-struct edge-type-ix () ((name "std::string") (ix :int64_t :dont-save t - :slk-load (slk-load-name-ix "EdgeType") - :capnp-init nil - :capnp-load (capnp-load-name-ix "EdgeType"))) - (:serialize (:slk :load-args '((storage "query::AstStorage *"))) - (:capnp :load-args '((storage "AstStorage *"))))) + :slk-load (slk-load-name-ix "EdgeType"))) + (:serialize (:slk :load-args '((storage "query::AstStorage *"))))) #>cpp inline bool operator==(const LabelIx &a, const LabelIx &b) { @@ -333,8 +252,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk :load-args '((storage "query::AstStorage *"))) - (:capnp :load-args '((storage "AstStorage *")))) + (:serialize (:slk :load-args '((storage "query::AstStorage *")))) (:clone :return-type (lambda (typename) (format nil "~A*" typename)) :args '((storage "AstStorage *")) @@ -363,18 +281,14 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk :ignore-other-base-classes t) - (:capnp :ignore-other-base-classes t)) + (:serialize (:slk :ignore-other-base-classes t)) (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) (lcp:define-class where (tree "::utils::Visitable") ((expression "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *"))) + :slk-load (slk-load-ast-pointer "Expression"))) (:public #>cpp using ::utils::Visitable::Accept; @@ -396,24 +310,17 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk :ignore-other-base-classes t) - (:capnp :ignore-other-base-classes t)) + (:serialize (:slk :ignore-other-base-classes t)) (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) (lcp:define-class binary-operator (expression) ((expression1 "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (expression2 "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *"))) + :slk-load (slk-load-ast-pointer "Expression"))) (:abstractp t) (:public #>cpp @@ -428,16 +335,13 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class unary-operator (expression) ((expression "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *"))) + :slk-load (slk-load-ast-pointer "Expression"))) (:abstractp t) (:public #>cpp @@ -451,7 +355,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (macrolet ((define-binary-operators () @@ -485,7 +389,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)))))) (define-binary-operators)) @@ -517,7 +421,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)))))) (define-unary-operators)) @@ -581,28 +485,19 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class list-slicing-operator (expression) ((list "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (lower-bound "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (upper-bound "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *"))) + :slk-load (slk-load-ast-pointer "Expression"))) (:public #>cpp ListSlicingOperator() = default; @@ -632,29 +527,20 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class if-operator (expression) ((condition "Expression *" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *") :documentation "None of the expressions should be nullptr. If there is no else_expression, you should make it null PrimitiveLiteral.") (then-expression "Expression *" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (else-expression "Expression *" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *"))) + :slk-load (slk-load-ast-pointer "Expression"))) (:public #>cpp IfOperator() = default; @@ -681,7 +567,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class base-literal (expression) @@ -695,19 +581,11 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class primitive-literal (base-literal) - ((value "PropertyValue" :scope :public - :capnp-save (lambda (builder member capnp-name) - #>cpp - storage::SaveCapnpPropertyValue(${member}, &${builder}); - cpp<#) - :capnp-load (lambda (reader member capnp-name) - #>cpp - storage::LoadCapnpPropertyValue(${reader}, &${member}); - cpp<#)) + ((value "PropertyValue" :scope :public) (token-position :int32_t :scope :public :initval -1 :documentation "This field contains token position of literal used to create PrimitiveLiteral object. If PrimitiveLiteral object is not created from query, leave its value at -1.")) (:public @@ -730,17 +608,14 @@ cpp<# PrimitiveLiteral(T value, int token_position) : value_(value), token_position_(token_position) {} cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class list-literal (base-literal) ((elements "std::vector" :scope :public :slk-save #'slk-save-ast-vector - :slk-load (slk-load-ast-vector "Expression") - :capnp-type "List(Tree)" - :capnp-save (save-ast-vector "Expression *") - :capnp-load (load-ast-vector "Expression *"))) + :slk-load (slk-load-ast-vector "Expression"))) (:public #>cpp ListLiteral() = default; @@ -764,16 +639,13 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class map-literal (base-literal) ((elements "std::unordered_map" :slk-save #'slk-save-property-map :slk-load #'slk-load-property-map - :capnp-type "Utils.Map(PropertyIx, Tree)" - :capnp-save #'save-property-map - :capnp-load #'load-property-map :clone #'clone-property-map :scope :public)) (:public @@ -800,7 +672,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class identifier (expression) @@ -831,16 +703,13 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class property-lookup (expression) ((expression "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (property "PropertyIx" :scope :public :slk-load (lambda (member) #>cpp @@ -872,16 +741,13 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class labels-test (expression) ((expression "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (labels "std::vector" :scope :public :slk-load (lambda (member) #>cpp @@ -892,13 +758,6 @@ cpp<# slk::Load(&self->${member}[i], reader, storage); } cpp<#) - :capnp-load (lcp:capnp-load-vector - "capnp::LabelIx" "LabelIx" - "[storage](const auto &reader) { - LabelIx ix; - Load(&ix, reader, storage); - return ix; - }") :clone (clone-name-ix-vector "Label"))) (:public #>cpp @@ -922,17 +781,14 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class function (expression) ((arguments "std::vector" :scope :public :slk-save #'slk-save-ast-vector - :slk-load (slk-load-ast-vector "Expression") - :capnp-type "List(Tree)" - :capnp-save (save-ast-vector "Expression *") - :capnp-load (load-ast-vector "Expression *")) + :slk-load (slk-load-ast-vector "Expression")) (function-name "std::string" :scope :public) (function "std::function" :scope :public @@ -941,12 +797,7 @@ cpp<# :slk-load (lambda (member) #>cpp self->${member} = query::NameToFunction(self->function_name_); - cpp<#) - :capnp-init nil - :capnp-load (lambda (reader member capnp-name) - #>cpp - ${member} = NameToFunction(self->get()->function_name_); - cpp<#))) + cpp<#))) (:public #>cpp Function() = default; @@ -976,44 +827,29 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class reduce (expression) ((accumulator "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Identifier") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Identifier *") :documentation "Identifier for the accumulating variable") (initializer "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *") :documentation "Expression which produces the initial accumulator value.") (identifier "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Identifier") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Identifier *") :documentation "Identifier for the list element.") (list "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *") :documentation "Expression which produces a list to be reduced.") (expression "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *") :documentation "Expression which does the reduction, i.e. produces the new accumulator value.")) (:public #>cpp @@ -1044,7 +880,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class coalesce (expression) @@ -1052,9 +888,6 @@ cpp<# :scope :public :slk-save #'slk-save-ast-vector :slk-load (slk-load-ast-vector "Expression") - :capnp-type "List(Tree)" - :capnp-save (save-ast-vector "Expression *") - :capnp-load (load-ast-vector "Expression *") :documentation "A list of expressions to evaluate. None of the expressions should be nullptr.")) (:public #>cpp @@ -1079,30 +912,21 @@ cpp<# friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class extract (expression) ((identifier "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Identifier") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Identifier *") :documentation "Identifier for the list element.") (list "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *") :documentation "Expression which produces a list which will be extracted.") (expression "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *") :documentation "Expression which produces the new value for list element.")) (:public #>cpp @@ -1127,28 +951,19 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class all (expression) ((identifier "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Identifier") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Identifier *")) + :slk-load (slk-load-ast-pointer "Identifier")) (list-expression "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (where "Where *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Where") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Where *"))) + :slk-load (slk-load-ast-pointer "Where"))) (:public #>cpp All() = default; @@ -1174,7 +989,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) ;; TODO: This is pretty much copy pasted from All. Consider merging Reduce, @@ -1183,22 +998,13 @@ cpp<# (lcp:define-class single (expression) ((identifier "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Identifier") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Identifier *")) + :slk-load (slk-load-ast-pointer "Identifier")) (list-expression "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (where "Where *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Where") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Where *"))) + :slk-load (slk-load-ast-pointer "Where"))) (:public #>cpp Single() = default; @@ -1224,7 +1030,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class parameter-lookup (expression) @@ -1247,22 +1053,16 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class regex-match (expression) ((string-expr "Expression *" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (regex "Expression *" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *"))) + :slk-load (slk-load-ast-pointer "Expression"))) (:public #>cpp RegexMatch() = default; @@ -1282,7 +1082,7 @@ cpp<# RegexMatch(Expression *string_expr, Expression *regex) : string_expr_(string_expr), regex_(regex) {} cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class named-expression (tree "::utils::Visitable" @@ -1291,10 +1091,7 @@ cpp<# ((name "std::string" :scope :public) (expression "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (token-position :int32_t :initval -1 :scope :public :documentation "This field contains token position of first token in named expression used to create name_. If NamedExpression object is not created from query or it is aliased leave this value at -1.") (symbol-pos :int32_t :initval -1 :scope :public @@ -1334,8 +1131,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk :ignore-other-base-classes t) - (:capnp :ignore-other-base-classes t)) + (:serialize (:slk :ignore-other-base-classes t)) (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) @@ -1346,10 +1142,7 @@ cpp<# (lcp:define-class pattern-atom (tree "::utils::Visitable") ((identifier "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Identifier") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Identifier *"))) + :slk-load (slk-load-ast-pointer "Identifier"))) (:abstractp t) (:public #>cpp @@ -1365,8 +1158,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk :ignore-other-base-classes t) - (:capnp :ignore-other-base-classes t)) + (:serialize (:slk :ignore-other-base-classes t)) (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) @@ -1381,20 +1173,10 @@ cpp<# slk::Load(&self->${member}[i], reader, storage); } cpp<#) - :capnp-load (lcp:capnp-load-vector - "capnp::LabelIx" "LabelIx" - "[storage](const auto &reader) { - LabelIx ix; - Load(&ix, reader, storage); - return ix; - }") :clone (clone-name-ix-vector "Label")) (properties "std::unordered_map" :slk-save #'slk-save-property-map :slk-load #'slk-load-property-map - :capnp-type "Utils.Map(PropertyIx, Tree)" - :capnp-save #'save-property-map - :capnp-load #'load-property-map :clone #'clone-property-map :scope :public)) (:public @@ -1419,7 +1201,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class edge-atom (pattern-atom) @@ -1435,35 +1217,19 @@ cpp<# slk::Load(&self->${member}[i], reader, storage); } cpp<#) - :capnp-load (lcp:capnp-load-vector - "capnp::EdgeTypeIx" "EdgeTypeIx" - "[storage](const auto &reader) { - EdgeTypeIx ix; - Load(&ix, reader, storage); - return ix; - }") :clone (clone-name-ix-vector "EdgeType")) (properties "std::unordered_map" :scope :public :slk-save #'slk-save-property-map :slk-load #'slk-load-property-map - :capnp-type "Utils.Map(PropertyIx, Tree)" - :capnp-save #'save-property-map - :capnp-load #'load-property-map :clone #'clone-property-map) (lower-bound "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *") :documentation "Evaluates to lower bound in variable length expands.") (upper-bound "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *") :documentation "Evaluated to upper bound in variable length expands.") (filter-lambda "Lambda" :scope :public :documentation "Filter lambda for variable length expands. Can have an empty expression, but identifiers must be valid, because an optimization pass may inline other expressions into this lambda." @@ -1480,9 +1246,6 @@ cpp<# (total-weight "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Identifier") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Identifier *") :documentation "Variable where the total weight for weighted shortest path will be stored.")) (:public (lcp:define-enum type @@ -1495,27 +1258,17 @@ cpp<# ((inner-edge "Identifier *" :initval "nullptr" :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Identifier") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Identifier *") :documentation "Argument identifier for the edge currently being traversed.") (inner-node "Identifier *" :initval "nullptr" :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Identifier") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Identifier *") :documentation "Argument identifier for the destination node of the edge.") (expression "Expression *" :initval "nullptr" :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *") :documentation "Evaluates the result of the lambda.")) (:documentation "Lambda for use in filtering or weight calculation during variable expand.") - (:serialize (:slk :load-args '((storage "query::AstStorage *"))) - (:capnp :load-args '((storage "AstStorage *")))) + (:serialize (:slk :load-args '((storage "query::AstStorage *")))) (:clone :args '((storage "AstStorage *")))) #>cpp bool Accept(HierarchicalTreeVisitor &visitor) override { @@ -1568,23 +1321,17 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class pattern (tree "::utils::Visitable") ((identifier "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Identifier") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Identifier *")) + :slk-load (slk-load-ast-pointer "Identifier")) (atoms "std::vector" :scope :public :slk-save #'slk-save-ast-vector - :slk-load (slk-load-ast-vector "PatternAtom") - :capnp-type "List(Tree)" - :capnp-save (save-ast-vector "PatternAtom *") - :capnp-load (load-ast-vector "PatternAtom *"))) + :slk-load (slk-load-ast-vector "PatternAtom"))) (:public #>cpp using ::utils::Visitable::Accept; @@ -1607,8 +1354,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk :ignore-other-base-classes t) - (:capnp :ignore-other-base-classes t)) + (:serialize (:slk :ignore-other-base-classes t)) (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) @@ -1625,8 +1371,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk :ignore-other-base-classes t) - (:capnp :ignore-other-base-classes t)) + (:serialize (:slk :ignore-other-base-classes t)) (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) @@ -1634,10 +1379,7 @@ cpp<# ((clauses "std::vector" :scope :public :slk-save #'slk-save-ast-vector - :slk-load (slk-load-ast-vector "Clause") - :capnp-type "List(Tree)" - :capnp-save (save-ast-vector "Clause *") - :capnp-load (load-ast-vector "Clause *"))) + :slk-load (slk-load-ast-vector "Clause"))) (:public #>cpp using ::utils::Visitable::Accept; @@ -1657,18 +1399,14 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk :ignore-other-base-classes t) - (:capnp :ignore-other-base-classes t)) + (:serialize (:slk :ignore-other-base-classes t)) (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) (lcp:define-class cypher-union (tree "::utils::Visitable") ((single-query "SingleQuery *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "SingleQuery") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "SingleQuery *")) + :slk-load (slk-load-ast-pointer "SingleQuery")) (distinct :bool :initval "false" :scope :public) (union-symbols "std::vector" :scope :public :documentation "Holds symbols that are created during symbol generation phase. These symbols are used when UNION/UNION ALL combines single query results.")) @@ -1698,8 +1436,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk :ignore-other-base-classes t) - (:capnp :ignore-other-base-classes t)) + (:serialize (:slk :ignore-other-base-classes t)) (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) @@ -1716,8 +1453,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk :ignore-other-base-classes t) - (:capnp :ignore-other-base-classes t)) + (:serialize (:slk :ignore-other-base-classes t)) (:clone :ignore-other-base-classes t) (:type-info :ignore-other-base-classes t)) @@ -1725,17 +1461,11 @@ cpp<# ((single-query "SingleQuery *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "SingleQuery") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "SingleQuery *") :documentation "First and potentially only query.") (cypher-unions "std::vector" :scope :public :slk-save #'slk-save-ast-vector :slk-load (slk-load-ast-vector "CypherUnion") - :capnp-type "List(Tree)" - :capnp-save (save-ast-vector "CypherUnion *") - :capnp-load (load-ast-vector "CypherUnion *") :documentation "Contains remaining queries that should form and union with `single_query_`.")) (:public #>cpp @@ -1747,16 +1477,13 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class explain-query (query) ((cypher-query "CypherQuery *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "CypherQuery") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "CypherQuery *") :documentation "The CypherQuery to explain.")) (:public #>cpp @@ -1768,7 +1495,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class profile-query (query) @@ -1777,10 +1504,6 @@ cpp<# :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "CypherQuery") - :capnp-type "Tree" - :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "CypherQuery *") :documentation "The CypherQuery to profile.")) (:public #>cpp @@ -1792,7 +1515,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class index-query (query) @@ -1816,13 +1539,6 @@ cpp<# slk::Load(&self->${member}[i], reader, storage); } cpp<#) - :capnp-load (lcp:capnp-load-vector - "capnp::PropertyIx" "PropertyIx" - "[storage](const auto &reader) { - PropertyIx ix; - Load(&ix, reader, storage); - return ix; - }") :clone (clone-name-ix-vector "Property"))) (:public (lcp:define-enum action @@ -1843,17 +1559,14 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class create (clause) ((patterns "std::vector" :scope :public :slk-save #'slk-save-ast-vector - :slk-load (slk-load-ast-vector "Pattern") - :capnp-type "List(Tree)" - :capnp-save (save-ast-vector "Pattern *") - :capnp-load (load-ast-vector "Pattern *"))) + :slk-load (slk-load-ast-vector "Pattern"))) (:public #>cpp Create() = default; @@ -1875,23 +1588,17 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class match (clause) ((patterns "std::vector" :scope :public :slk-save #'slk-save-ast-vector - :slk-load (slk-load-ast-vector "Pattern") - :capnp-type "List(Tree)" - :capnp-save (save-ast-vector "Pattern *") - :capnp-load (load-ast-vector "Pattern *")) + :slk-load (slk-load-ast-vector "Pattern")) (where "Where *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Where") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Where *")) + :slk-load (slk-load-ast-pointer "Where")) (optional :bool :initval "false" :scope :public)) (:public #>cpp @@ -1923,7 +1630,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-enum ordering @@ -1935,12 +1642,8 @@ cpp<# ((ordering "Ordering" :scope :public) (expression "Expression *" :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *"))) - (:serialize (:slk :load-args '((storage "query::AstStorage *"))) - (:capnp :load-args '((storage "AstStorage *")))) + :slk-load (slk-load-ast-pointer "Expression"))) + (:serialize (:slk :load-args '((storage "query::AstStorage *")))) (:clone :args '((storage "AstStorage *")))) (lcp:define-struct return-body () @@ -1951,9 +1654,6 @@ cpp<# (named-expressions "std::vector" :slk-save #'slk-save-ast-vector :slk-load (slk-load-ast-vector "NamedExpression") - :capnp-type "List(Tree)" - :capnp-save (save-ast-vector "NamedExpression *") - :capnp-load (load-ast-vector "NamedExpression *") :documentation "Expressions which are used to produce results.") (order-by "std::vector" :slk-load (lambda (member) @@ -1967,32 +1667,17 @@ cpp<# slk::Load(&self->${member}[i], reader, storage); } cpp<#) - :capnp-load (lcp:capnp-load-vector - "capnp::SortItem" - "SortItem" - "[storage](const auto &reader) { - SortItem val; - Load(&val, reader, storage); - return val; - }") :documentation "Expressions used for ordering the results.") (skip "Expression *" :initval "nullptr" :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *") :documentation "Optional expression on how many results to skip.") (limit "Expression *" :initval "nullptr" :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *") :documentation "Optional expression on how many results to produce.")) (:documentation "Contents common to @c Return and @c With clauses.") - (:serialize (:slk :load-args '((storage "query::AstStorage *"))) - (:capnp :load-args '((storage "AstStorage *")))) + (:serialize (:slk :load-args '((storage "query::AstStorage *")))) (:clone :args '((storage "AstStorage *")))) (lcp:define-class return (clause) @@ -2036,7 +1721,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class with (clause) @@ -2047,10 +1732,7 @@ cpp<# cpp<#)) (where "Where *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Where") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Where *"))) + :slk-load (slk-load-ast-pointer "Where"))) (:public #>cpp With() = default; @@ -2087,16 +1769,13 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class delete (clause) ((expressions "std::vector" :slk-save #'slk-save-ast-vector :slk-load (slk-load-ast-vector "Expression") - :capnp-type "List(Tree)" - :capnp-save (save-ast-vector "Expression *") - :capnp-load (load-ast-vector "Expression *") :scope :public) (detach :bool :initval "false" :scope :public)) (:public @@ -2121,22 +1800,16 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class set-property (clause) ((property-lookup "PropertyLookup *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "PropertyLookup") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "PropertyLookup *")) + :slk-load (slk-load-ast-pointer "PropertyLookup")) (expression "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *"))) + :slk-load (slk-load-ast-pointer "Expression"))) (:public #>cpp SetProperty() = default; @@ -2157,22 +1830,16 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class set-properties (clause) ((identifier "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Identifier") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Identifier *")) + :slk-load (slk-load-ast-pointer "Identifier")) (expression "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (update :bool :initval "false" :scope :public)) (:public #>cpp @@ -2195,16 +1862,13 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class set-labels (clause) ((identifier "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Identifier") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Identifier *")) + :slk-load (slk-load-ast-pointer "Identifier")) (labels "std::vector" :scope :public :slk-load (lambda (member) #>cpp @@ -2215,13 +1879,6 @@ cpp<# slk::Load(&self->${member}[i], reader, storage); } cpp<#) - :capnp-load (lcp:capnp-load-vector - "capnp::LabelIx" "LabelIx" - "[storage](const auto &reader) { - LabelIx ix; - Load(&ix, reader, storage); - return ix; - }") :clone (clone-name-ix-vector "Label"))) (:public #>cpp @@ -2243,16 +1900,13 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class remove-property (clause) ((property-lookup "PropertyLookup *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "PropertyLookup") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "PropertyLookup *"))) + :slk-load (slk-load-ast-pointer "PropertyLookup"))) (:public #>cpp RemoveProperty() = default; @@ -2273,16 +1927,13 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class remove-labels (clause) ((identifier "Identifier *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Identifier") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Identifier *")) + :slk-load (slk-load-ast-pointer "Identifier")) (labels "std::vector" :scope :public :slk-load (lambda (member) #>cpp @@ -2293,13 +1944,6 @@ cpp<# slk::Load(&self->${member}[i], reader, storage); } cpp<#) - :capnp-load (lcp:capnp-load-vector - "capnp::LabelIx" "LabelIx" - "[storage](const auto &reader) { - LabelIx ix; - Load(&ix, reader, storage); - return ix; - }") :clone (clone-name-ix-vector "Label"))) (:public #>cpp @@ -2321,30 +1965,21 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class merge (clause) ((pattern "Pattern *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Pattern") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Pattern *")) + :slk-load (slk-load-ast-pointer "Pattern")) (on-match "std::vector" :scope :public :slk-save #'slk-save-ast-vector - :slk-load (slk-load-ast-vector "Clause") - :capnp-type "List(Tree)" - :capnp-save (save-ast-vector "Clause *") - :capnp-load (load-ast-vector "Clause *")) + :slk-load (slk-load-ast-vector "Clause")) (on-create "std::vector" :scope :public :slk-save #'slk-save-ast-vector - :slk-load (slk-load-ast-vector "Clause") - :capnp-type "List(Tree)" - :capnp-save (save-ast-vector "Clause *") - :capnp-load (load-ast-vector "Clause *"))) + :slk-load (slk-load-ast-vector "Clause"))) (:public #>cpp Merge() = default; @@ -2382,16 +2017,13 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class unwind (clause) ((named-expression "NamedExpression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "NamedExpression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "NamedExpression *"))) + :slk-load (slk-load-ast-pointer "NamedExpression"))) (:public #>cpp Unwind() = default; @@ -2414,7 +2046,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class auth-query (query) @@ -2424,10 +2056,7 @@ cpp<# (user-or-role "std::string" :scope :public) (password "Expression *" :initval "nullptr" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (privileges "std::vector" :scope :public)) (:public (lcp:define-enum action @@ -2460,7 +2089,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) ;; TODO: Generate this via LCP @@ -2480,40 +2109,22 @@ cpp<# (stream-name "std::string" :scope :public) (stream-uri "Expression *" :scope :public :initval "nullptr" :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (stream-topic "Expression *" :scope :public :initval "nullptr" :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (transform-uri "Expression *" :scope :public :initval "nullptr" :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (batch-interval-in-ms "Expression *" :scope :public :initval "nullptr" :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (batch-size "Expression *" :scope :public :initval "nullptr" :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (limit-batches "Expression *" :scope :public :initval "nullptr" :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (load-ast-pointer "Expression *"))) + :slk-load (slk-load-ast-pointer "Expression"))) (:public (lcp:define-enum action (create-stream drop-stream show-streams start-stream stop-stream @@ -2544,7 +2155,7 @@ cpp<# #>cpp friend class AstStorage; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class info-query (query) @@ -2557,7 +2168,7 @@ cpp<# #>cpp DEFVISITABLE(QueryVisitor); cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-struct constraint () @@ -2581,19 +2192,11 @@ cpp<# slk::Load(&self->${member}[i], reader, storage); } cpp<#) - :capnp-load (lcp:capnp-load-vector - "capnp::PropertyIx" "PropertyIx" - "[storage](const auto &reader) { - PropertyIx ix; - Load(&ix, reader, storage); - return ix; - }") :clone (clone-name-ix-vector "Property"))) (:public (lcp:define-enum type (exists unique node-key) - (:serialize (:lcp) (:capnp)))) - (:serialize (:slk :load-args '((storage "query::AstStorage *"))) - (:capnp :load-args '((storage "AstStorage *")))) + (:serialize (:lcp)))) + (:serialize (:slk :load-args '((storage "query::AstStorage *")))) (:clone :args '((storage "AstStorage *")))) (lcp:define-class constraint-query (query) @@ -2611,7 +2214,7 @@ cpp<# #>cpp DEFVISITABLE(QueryVisitor); cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:pop-namespace) ;; namespace query diff --git a/src/query/frontend/semantic/symbol.lcp b/src/query/frontend/semantic/symbol.lcp index c28c47e5b..366376609 100644 --- a/src/query/frontend/semantic/symbol.lcp +++ b/src/query/frontend/semantic/symbol.lcp @@ -8,8 +8,6 @@ cpp<# (lcp:namespace query) -(lcp:capnp-namespace "query") - (lcp:define-class symbol () ((name "std::string" :scope :public) (position :int64_t :scope :public) @@ -53,7 +51,7 @@ cpp<# bool user_declared() const { return user_declared_; } int token_position() const { return token_position_; } cpp<#) - (:serialize (:slk) (:capnp))) + (:serialize (:slk))) (lcp:pop-namespace) ;; query diff --git a/src/query/plan/operator.lcp b/src/query/plan/operator.lcp index e966a5e8e..2bfdbab44 100644 --- a/src/query/plan/operator.lcp +++ b/src/query/plan/operator.lcp @@ -122,20 +122,6 @@ class HierarchicalLogicalOperatorVisitor }; cpp<# -(lcp:capnp-namespace "query::plan") - -(lcp:capnp-import 'utils "/rpc/serialization.capnp") -(lcp:capnp-import 'storage "/storage/distributed/rpc/serialization.capnp") -(lcp:capnp-import 'ast "/query/distributed/frontend/ast/ast_serialization.capnp") -(lcp:capnp-import 'semantic "/query/distributed/frontend/semantic/symbol_serialization.capnp") -(lcp:capnp-import 'query "/query/distributed/serialization.capnp") - -(lcp:capnp-type-conversion "Symbol" "Semantic.Symbol") -(lcp:capnp-type-conversion "storage::Label" "Storage.Label") -(lcp:capnp-type-conversion "storage::Property" "Storage.Property") -(lcp:capnp-type-conversion "storage::EdgeType" "Storage.EdgeType") -(lcp:capnp-type-conversion "GraphView" "Query.GraphView") - (lcp:define-class logical-operator ("::utils::Visitable") () (:abstractp t) @@ -230,10 +216,7 @@ can serve as inputs to others and thus a sequence of operations is formed.") (:serialize (:slk :base t :save-args '((helper "query::plan::LogicalOperator::SaveHelper *")) - :load-args '((helper "query::plan::LogicalOperator::SlkLoadHelper *"))) - (:capnp :base t - :save-args '((helper "LogicalOperator::SaveHelper *")) - :load-args '((helper "LogicalOperator::LoadHelper *")))) + :load-args '((helper "query::plan::LogicalOperator::SlkLoadHelper *")))) (:type-info :base t) (:clone :args '((storage "AstStorage *")) :base t)) @@ -250,25 +233,6 @@ can serve as inputs to others and thus a sequence of operations is formed.") &helper->ast_storage, reader); cpp<#)) -(defun save-ast-pointer (builder member capnp-name) - #>cpp - if (${member}) { - auto ${capnp-name}_builder = ${builder}->init${capnp-name}(); - Save(*${member}, &${capnp-name}_builder); - } - cpp<#) - -(defun load-ast-pointer (ast-type) - (lambda (reader member capnp-name) - #>cpp - if (${reader}.has${capnp-name}()) { - ${member} = static_cast<${ast-type}>(Load(&helper->ast_storage, - ${reader}.get${capnp-name}())); - } else { - ${member} = nullptr; - } - cpp<#)) - (defun slk-save-ast-vector (member) #>cpp size_t size = self.${member}.size(); @@ -292,21 +256,6 @@ can serve as inputs to others and thus a sequence of operations is formed.") } cpp<#)) -(defun save-ast-vector (ast-type) - (lcp:capnp-save-vector "::query::capnp::Tree" ast-type - "[](auto *builder, const auto &val) { - Save(*val, builder); - }")) - -(defun load-ast-vector (ast-type) - (lcp:capnp-load-vector "::query::capnp::Tree" ast-type - (format - nil - "[helper](const auto &reader) { - return static_cast<~A>(Load(&helper->ast_storage, reader)); - }" - ast-type))) - (defun slk-save-operator-pointer (member) #>cpp slk::Save(self.${member}, builder, @@ -325,26 +274,6 @@ can serve as inputs to others and thus a sequence of operations is formed.") }); cpp<#) -(defun save-operator-pointer (builder member-name capnp-name) - (declare (ignore capnp-name)) - #>cpp - utils::SaveSharedPtr(${member-name}, &${builder}, - [helper](auto *builder, const auto &val) { - Save(val, builder, helper); - }, &helper->saved_ops); - cpp<#) - -(defun load-operator-pointer (reader member-name capnp-name) - (declare (ignore capnp-name)) - #>cpp - ${member-name} = utils::LoadSharedPtr(${reader}, - [helper](const auto &reader) { - std::unique_ptr op; - Load(&op, reader, helper); - return op.release(); - }, &helper->loaded_ops); - cpp<#) - (lcp:define-class once (logical-operator) () (:documentation @@ -376,7 +305,7 @@ and false on every following Pull.") bool did_pull_{false}; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (defun slk-save-properties (member) @@ -403,49 +332,20 @@ and false on every following Pull.") } cpp<#) -(defun capnp-save-properties (builder member capnp-name) - #>cpp - for (size_t i = 0; i < ${member}.size(); ++i) { - auto prop_builder = ${builder}[i].initFirst(); - storage::Save(${member}[i].first, &prop_builder); - auto expr_builder = ${builder}[i].initSecond(); - Save(*${member}[i].second, &expr_builder); - } - cpp<#) - -(defun capnp-load-properties (reader member capnp-name) - #>cpp - for (const auto &pair_reader : ${reader}) { - auto prop_reader = pair_reader.getFirst(); - storage::Property prop; - storage::Load(&prop, prop_reader); - auto *expr = static_cast(Load( - &helper->ast_storage, pair_reader.getSecond())); - ${member}.emplace_back(prop, expr); - } - cpp<#) - (lcp:define-struct node-creation-info () ((symbol "Symbol") (labels "std::vector") (properties "std::vector>" :slk-save #'slk-save-properties - :slk-load #'slk-load-properties - :capnp-type "List(Utils.Pair(Storage.Property, Ast.Tree))" - :capnp-save #'capnp-save-properties - :capnp-load #'capnp-load-properties)) + :slk-load #'slk-load-properties)) (:serialize (:slk :save-args '((helper "query::plan::LogicalOperator::SaveHelper *")) - :load-args '((helper "query::plan::LogicalOperator::SlkLoadHelper *"))) - (:capnp :save-args '((helper "LogicalOperator::SaveHelper *")) - :load-args '((helper "LogicalOperator::LoadHelper *")))) + :load-args '((helper "query::plan::LogicalOperator::SlkLoadHelper *")))) (:clone :args '((storage "AstStorage *")))) (lcp:define-class create-node (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (node-info "NodeCreationInfo" :scope :public :slk-save (lambda (m) #>cpp @@ -502,30 +402,18 @@ a preceeding `MATCH`), or multiple nodes (`MATCH ... CREATE` or const std::unique_ptr input_cursor_; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-struct edge-creation-info () ((symbol "Symbol") (properties "std::vector>" :slk-save #'slk-save-properties - :slk-load #'slk-load-properties - :capnp-type "List(Utils.Pair(Storage.Property, Ast.Tree))" - :capnp-save #'capnp-save-properties - :capnp-load #'capnp-load-properties) + :slk-load #'slk-load-properties) (edge-type "storage::EdgeType") - (direction "EdgeAtom::Direction" :initval "EdgeAtom::Direction::BOTH" - :capnp-type "Ast.EdgeAtom.Direction" :capnp-init nil - :capnp-save (lcp:capnp-save-enum "::query::capnp::EdgeAtom::Direction" - "EdgeAtom::Direction" - '(in out both)) - :capnp-load (lcp:capnp-load-enum "::query::capnp::EdgeAtom::Direction" - "EdgeAtom::Direction" - '(in out both)))) + (direction "EdgeAtom::Direction" :initval "EdgeAtom::Direction::BOTH")) (:serialize (:slk :save-args '((helper "query::plan::LogicalOperator::SaveHelper *")) - :load-args '((helper "query::plan::LogicalOperator::SlkLoadHelper *"))) - (:capnp :save-args '((helper "LogicalOperator::SaveHelper *")) - :load-args '((helper "LogicalOperator::LoadHelper *")))) + :load-args '((helper "query::plan::LogicalOperator::SlkLoadHelper *")))) (:clone :args '((storage "AstStorage *")))) (lcp:define-class create-expand (logical-operator) @@ -551,9 +439,7 @@ a preceeding `MATCH`), or multiple nodes (`MATCH ... CREATE` or ;; can be found in the frame (input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (input-symbol "Symbol" :scope :public) (existing-node :bool :scope :public :documentation "if the given node atom refers to an existing node (either matched or created)")) @@ -632,22 +518,15 @@ chained in cases when longer paths need creating. ExpressionEvaluator &evaluator); }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class scan-all (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (output-symbol "Symbol" :scope :public) (graph-view "GraphView" :scope :public - :capnp-init nil - :capnp-save (lcp:capnp-save-enum "::query::capnp::GraphView" "GraphView" - '(old new)) - :capnp-load (lcp:capnp-load-enum "::query::capnp::GraphView" "GraphView" - '(old new)) :documentation "Controls which graph state is used to produce vertices. @@ -687,7 +566,7 @@ with a constructor argument. input_ = input; } cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class scan-all-by-label (scan-all) @@ -709,7 +588,7 @@ given label. std::unique_ptr MakeCursor( database::GraphDbAccessor *, utils::MemoryResource *) const override; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (defun slk-save-optional-bound (member) @@ -758,36 +637,6 @@ given label. self->${member}.emplace(utils::Bound(value, bound_type)); cpp<#) -(defun save-optional-bound (builder member capnp-name) - (let ((save-bound - "[](auto *builder, const auto &bound) { - builder->setType(bound.type() == utils::BoundType::INCLUSIVE ? - ::utils::capnp::Bound<::query::capnp::Tree>::Type::INCLUSIVE : - ::utils::capnp::Bound<::query::capnp::Tree>::Type::EXCLUSIVE); - auto value_builder = builder->initValue(); - Save(*bound.value(), &value_builder); - }")) - (funcall (lcp:capnp-save-optional "::utils::capnp::Bound<::query::capnp::Tree>" - "utils::Bound" - save-bound) - builder member capnp-name))) - -(defun load-optional-bound (reader member capnp-name) - (let ((load-bound - "[helper](const auto &reader) { - auto type = reader.getType() == - ::utils::capnp::Bound<::query::capnp::Tree>::Type::INCLUSIVE - ? utils::BoundType::INCLUSIVE - : utils::BoundType::EXCLUSIVE; - auto *value = static_cast( - Load(&helper->ast_storage, reader.getValue())); - return utils::Bound(value, type); - }")) - (funcall (lcp:capnp-load-optional "::utils::capnp::Bound<::query::capnp::Tree>" - "utils::Bound" - load-bound) - reader member capnp-name))) - (defun clone-optional-bound (source dest) #>cpp if (${source}) { @@ -806,16 +655,10 @@ given label. (lower-bound "std::optional" :scope :public :slk-save #'slk-save-optional-bound :slk-load #'slk-load-optional-bound - :capnp-save #'save-optional-bound - :capnp-load #'load-optional-bound - :capnp-type "Utils.Optional(Utils.Bound(Ast.Tree))" :clone #'clone-optional-bound) (upper-bound "std::optional" :scope :public :slk-save #'slk-save-optional-bound :slk-load #'slk-load-optional-bound - :capnp-save #'save-optional-bound - :capnp-load #'load-optional-bound - :capnp-type "Utils.Optional(Utils.Bound(Ast.Tree))" :clone #'clone-optional-bound)) (:documentation "Behaves like @c ScanAll, but produces only vertices with given label and @@ -855,7 +698,7 @@ property value which is inside a range (inclusive or exlusive). std::unique_ptr MakeCursor( database::GraphDbAccessor *, utils::MemoryResource *) const override; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class scan-all-by-label-property-value (scan-all) @@ -864,9 +707,7 @@ property value which is inside a range (inclusive or exlusive). (property-name "std::string" :scope :public) (expression "Expression *" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer :capnp-load (load-ast-pointer "Expression *"))) + :slk-load (slk-load-ast-pointer "Expression"))) (:documentation "Behaves like @c ScanAll, but produces only vertices with given label and property value. @@ -898,7 +739,7 @@ property value. std::unique_ptr MakeCursor( database::GraphDbAccessor *, utils::MemoryResource *) const override; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-struct expand-common () @@ -912,42 +753,22 @@ This is where the new node will be stored.") This is where a TypedValue containing a list of expanded edges will be stored.") (direction "EdgeAtom::Direction" :documentation "EdgeAtom::Direction determining the direction of edge -expansion. The direction is relative to the starting vertex for each expansion." - :capnp-type "Ast.EdgeAtom.Direction" :capnp-init nil - :capnp-save (lcp:capnp-save-enum "::query::capnp::EdgeAtom::Direction" - "EdgeAtom::Direction" - '(in out both)) - :capnp-load (lcp:capnp-load-enum "::query::capnp::EdgeAtom::Direction" - "EdgeAtom::Direction" - '(in out both))) +expansion. The direction is relative to the starting vertex for each expansion.") (edge-types "std::vector" :documentation "storage::EdgeType specifying which edges we want to expand. If empty, all edges are valid. If not empty, only edges with one of -the given types are valid." - :capnp-save (lcp:capnp-save-vector "::storage::capnp::EdgeType" - "storage::EdgeType") - :capnp-load (lcp:capnp-load-vector "::storage::capnp::EdgeType" - "storage::EdgeType")) +the given types are valid.") (existing-node :bool :documentation "If the given node atom refer to a symbol that has already been expanded and should be just validated in the frame.")) - (:serialize (:slk) (:capnp))) + (:serialize (:slk))) (lcp:define-class expand (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (input-symbol "Symbol" :scope :public) (common "ExpandCommon" :scope :public) (graph-view "GraphView" :scope :public - :capnp-init nil - :capnp-save (lcp:capnp-save-enum "::query::capnp::GraphView" - "GraphView" - '(old new)) - :capnp-load (lcp:capnp-load-enum "::query::capnp::GraphView" - "GraphView" - '(old new)) :documentation "State from which the input node should get expanded.")) (:documentation @@ -1021,7 +842,7 @@ pulled.") bool InitEdges(Frame &, ExecutionContext &); }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-struct expansion-lambda () @@ -1033,60 +854,33 @@ pulled.") #>cpp self->${member} = query::LoadAstPointer( ast_storage, reader); - cpp<#) - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer - :capnp-load (lambda (reader member capnp-name) - #>cpp - if (${reader}.has${capnp-name}()) { - ${member} = static_cast(Load(ast_storage, - ${reader}.get${capnp-name}())); - } else { - ${member} = nullptr; - } - cpp<#))) - (:serialize (:slk :load-args '((ast-storage "query::AstStorage *"))) - (:capnp :load-args '((ast-storage "AstStorage *")))) + cpp<#))) + (:serialize (:slk :load-args '((ast-storage "query::AstStorage *")))) (:clone :args '((storage "AstStorage *")))) (lcp:define-class expand-variable (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (input-symbol "Symbol" :scope :public) (common "ExpandCommon" :scope :public) - (type "EdgeAtom::Type" :scope :public :capnp-type "Ast.EdgeAtom.Type" - :capnp-init nil - :capnp-save (lcp:capnp-save-enum "::query::capnp::EdgeAtom::Type" "EdgeAtom::Type" - '(single depth-first breadth-first weighted-shortest-path)) - :capnp-load (lcp:capnp-load-enum "::query::capnp::EdgeAtom::Type" "EdgeAtom::Type" - '(single depth-first breadth-first weighted-shortest-path))) + (type "EdgeAtom::Type" :scope :public) (is-reverse :bool :scope :public :documentation "True if the path should be written as expanding from node_symbol to input_symbol.") (lower-bound "Expression *" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer :capnp-load (load-ast-pointer "Expression *") :documentation "Optional lower bound of the variable length expansion, defaults are (1, inf)") (upper-bound "Expression *" :scope :public :slk-save #'slk-save-ast-pointer :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer :capnp-load (load-ast-pointer "Expression *") :documentation "Optional upper bound of the variable length expansion, defaults are (1, inf)") (filter-lambda "ExpansionLambda" :scope :public :slk-load (lambda (member) #>cpp slk::Load(&self->${member}, reader, &helper->ast_storage); - cpp<#) - :capnp-load (lambda (reader member capnp-name) - #>cpp - Load(&${member}, ${reader}, &helper->ast_storage); - cpp<#)) + cpp<#)) (weight-lambda "std::optional" :scope :public :slk-load (lambda (member) #>cpp @@ -1099,20 +893,8 @@ pulled.") query::plan::ExpansionLambda lambda; slk::Load(&lambda, reader, &helper->ast_storage); self->${member}.emplace(lambda); - cpp<#) - :capnp-save (lcp:capnp-save-optional - "capnp::ExpansionLambda" - "ExpansionLambda") - :capnp-load (lcp:capnp-load-optional - "capnp::ExpansionLambda" "ExpansionLambda" - "[helper](const auto &reader) { - ExpansionLambda val; - Load(&val, reader, &helper->ast_storage); - return val; - }")) - (total-weight "std::optional" :scope :public - :capnp-save (lcp:capnp-save-optional "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-optional "::query::capnp::Symbol" "Symbol"))) + cpp<#)) + (total-weight "std::optional" :scope :public)) (:documentation "Variable-length expansion operator. For a node existing in the frame it expands a variable number of edges and places them @@ -1189,19 +971,15 @@ pulled.") friend class ExpandVariableCursor; friend class ExpandWeightedShortestPathCursor; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class construct-named-path (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (path-symbol "Symbol" :scope :public) - (path-elements "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol"))) + (path-elements "std::vector" :scope :public)) (:documentation "Constructs a named path from its elements and places it on the frame.") (:public @@ -1224,20 +1002,16 @@ pulled.") input_ = input; } cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class filter (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (expression "Expression *" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer :capnp-load (load-ast-pointer "Expression *"))) + :slk-load (slk-load-ast-pointer "Expression"))) (:documentation "Filter whose Pull returns true only when the given expression evaluates into true. @@ -1276,21 +1050,16 @@ a boolean value.") const std::unique_ptr input_cursor_; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class produce (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (named-expressions "std::vector" :scope :public :slk-save #'slk-save-ast-vector - :slk-load (slk-load-ast-vector "NamedExpression") - :capnp-type "List(Ast.Tree)" - :capnp-save (save-ast-vector "NamedExpression *") - :capnp-load (load-ast-vector "NamedExpression *"))) + :slk-load (slk-load-ast-vector "NamedExpression"))) (:documentation "A logical operator that places an arbitrary number of named expressions on the frame (the logical operator @@ -1334,21 +1103,16 @@ RETURN clause) the Produce's pull succeeds exactly once.") const std::unique_ptr input_cursor_; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class delete (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (expressions "std::vector" :scope :public :slk-save #'slk-save-ast-vector - :slk-load (slk-load-ast-vector "Expression") - :capnp-type "List(Ast.Tree)" - :capnp-save (save-ast-vector "Expression *") - :capnp-load (load-ast-vector "Expression *")) + :slk-load (slk-load-ast-vector "Expression")) (detach :bool :scope :public :documentation "Whether the vertex should be detached before deletion. If not detached, and has connections, an error is raised when deleting edges.")) @@ -1389,26 +1153,20 @@ Has a flag for using DETACH DELETE when deleting vertices.") const std::unique_ptr input_cursor_; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class set-property (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (property "storage::Property" :scope :public) (lhs "PropertyLookup *" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "PropertyLookup") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer :capnp-load (load-ast-pointer "PropertyLookup *")) + :slk-load (slk-load-ast-pointer "PropertyLookup")) (rhs "Expression *" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer :capnp-load (load-ast-pointer "Expression *"))) + :slk-load (slk-load-ast-pointer "Expression"))) (:documentation "Logical operator for setting a single property on a single vertex or edge. @@ -1447,21 +1205,17 @@ can be stored (a TypedValue that can be converted to PropertyValue).") const std::unique_ptr input_cursor_; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class set-properties (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (input-symbol "Symbol" :scope :public) (rhs "Expression *" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (op "Op" :scope :public)) (:documentation "Logical operator for setting the whole property set on a vertex or an edge. @@ -1521,19 +1275,15 @@ that the old properties are discarded and replaced with new ones.") void Set(TRecordAccessor &record, const TypedValue &rhs) const; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class set-labels (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (input-symbol "Symbol" :scope :public) - (labels "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::storage::capnp::Label" "storage::Label") - :capnp-load (lcp:capnp-load-vector "::storage::capnp::Label" "storage::Label"))) + (labels "std::vector" :scope :public)) (:documentation "Logical operator for setting an arbitrary number of labels on a Vertex. @@ -1570,21 +1320,17 @@ It does NOT remove labels that are already set on that Vertex.") const std::unique_ptr input_cursor_; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class remove-property (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (property "storage::Property" :scope :public) (lhs "PropertyLookup *" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "PropertyLookup") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer :capnp-load (load-ast-pointer "PropertyLookup *"))) + :slk-load (slk-load-ast-pointer "PropertyLookup"))) (:documentation "Logical operator for removing a property from an edge or a vertex.") (:public @@ -1619,19 +1365,15 @@ It does NOT remove labels that are already set on that Vertex.") const std::unique_ptr input_cursor_; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class remove-labels (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (input-symbol "Symbol" :scope :public) - (labels "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::storage::capnp::Label" "storage::Label") - :capnp-load (lcp:capnp-load-vector "::storage::capnp::Label" "storage::Label"))) + (labels "std::vector" :scope :public)) (:documentation "Logical operator for removing an arbitrary number of labels on a Vertex. @@ -1668,19 +1410,15 @@ If a label does not exist on a Vertex, nothing happens.") const std::unique_ptr input_cursor_; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class edge-uniqueness-filter (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (expand-symbol "Symbol" :scope :public) - (previous-symbols "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol"))) + (previous-symbols "std::vector" :scope :public)) (:documentation "Filter whose Pull returns true only when the given expand_symbol frame value (the latest expansion) is not equal to any of the previous_symbols frame @@ -1729,18 +1467,14 @@ edge lists).") const std::unique_ptr input_cursor_; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class accumulate (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) - (symbols "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol")) + :slk-load #'slk-load-operator-pointer) + (symbols "std::vector" :scope :public) (advance-command :bool :scope :public)) (:documentation "Pulls everything from the input before passing it through. @@ -1805,7 +1539,7 @@ has been cached will be reconstructed before Pull returns. bool pulled_all_input_{false}; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) #>cpp @@ -1822,9 +1556,7 @@ cpp<# (lcp:define-class aggregate (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (aggregations "std::vector" :scope :public :slk-save (lambda (member) #>cpp @@ -1844,22 +1576,11 @@ cpp<# ++i) { slk::Load(&self->${member}[i], reader, helper); } - cpp<#) - :capnp-save (lcp:capnp-save-vector - "capnp::Aggregate::Element" "Aggregate::Element" - "[helper](auto *builder, const auto &val) { Save(val, builder, helper); }") - :capnp-load (lcp:capnp-load-vector - "capnp::Aggregate::Element" "Aggregate::Element" - "[helper](const auto &reader) { Aggregate::Element val; Load(&val, reader, helper); return val; }")) + cpp<#)) (group-by "std::vector" :scope :public :slk-save #'slk-save-ast-vector - :slk-load (slk-load-ast-vector "Expression") - :capnp-type "List(Ast.Tree)" - :capnp-save (save-ast-vector "Expression *") - :capnp-load (load-ast-vector "Expression *")) - (remember "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol"))) + :slk-load (slk-load-ast-vector "Expression")) + (remember "std::vector" :scope :public)) (:documentation "Performs an arbitrary number of aggregations of data from the given input grouped by the given criteria. @@ -1878,30 +1599,18 @@ elements are in an undefined state after aggregation.") (lcp:define-struct element () ((value "Expression *" :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (key "Expression *" :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer :capnp-load (load-ast-pointer "Expression *")) - (op "Aggregation::Op" - :capnp-type "Ast.Aggregation.Op" - :capnp-init nil :capnp-save (lcp:capnp-save-enum "::query::capnp::Aggregation::Op" "Aggregation::Op" - '(count min max sum avg collect-list collect-map)) - :capnp-load (lcp:capnp-load-enum "::query::capnp::Aggregation::Op" "Aggregation::Op" - '(count min max sum avg collect-list collect-map))) + :slk-load (slk-load-ast-pointer "Expression")) + (op "Aggregation::Op") (output-sym "Symbol")) (:documentation "An aggregation element, contains: (input data expression, key expression - only used in COLLECT_MAP, type of aggregation, output symbol).") (:serialize (:slk :save-args '((helper "query::plan::LogicalOperator::SaveHelper *")) - :load-args '((helper "query::plan::LogicalOperator::SlkLoadHelper *"))) - (:capnp - :save-args '((helper "LogicalOperator::SaveHelper *")) - :load-args '((helper "LogicalOperator::LoadHelper *")))) + :load-args '((helper "query::plan::LogicalOperator::SlkLoadHelper *")))) (:clone :args '((storage "AstStorage *")))) #>cpp Aggregate() = default; @@ -2003,20 +1712,16 @@ elements are in an undefined state after aggregation.") void EnsureOkForAvgSum(const TypedValue &value) const; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class skip (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (expression "Expression *" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer :capnp-load (load-ast-pointer "Expression *"))) + :slk-load (slk-load-ast-pointer "Expression"))) (:documentation "Skips a number of Pulls from the input op. @@ -2065,20 +1770,16 @@ operator's implementation does not expect this.") int skipped_{0}; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class limit (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (expression "Expression *" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer :capnp-load (load-ast-pointer "Expression *"))) + :slk-load (slk-load-ast-pointer "Expression"))) (:documentation "Limits the number of Pulls from the input op. @@ -2130,26 +1831,18 @@ input should be performed).") int pulled_{0}; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class order-by (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) - (compare "TypedValueVectorCompare" :scope :public - :capnp-type "Query.TypedValueVectorCompare") + :slk-load #'slk-load-operator-pointer) + (compare "TypedValueVectorCompare" :scope :public) (order-by "std::vector" :scope :public :slk-save #'slk-save-ast-vector - :slk-load (slk-load-ast-vector "Expression") - :capnp-type "List(Ast.Tree)" - :capnp-save (save-ast-vector "Expression *") - :capnp-load (load-ast-vector "Expression *")) - (output-symbols "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol"))) + :slk-load (slk-load-ast-vector "Expression")) + (output-symbols "std::vector" :scope :public)) (:documentation "Logical operator for ordering (sorting) results. @@ -2204,25 +1897,19 @@ are valid for usage after the OrderBy operator.") decltype(cache_.begin()) cache_it_ = cache_.begin(); }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class merge (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (merge-match "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (merge-create "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer)) + :slk-load #'slk-load-operator-pointer)) (:documentation "Merge operator. For every sucessful Pull from the input operator a Pull from the merge_match is attempted. All @@ -2279,23 +1966,17 @@ documentation.") bool pull_input_{true}; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class optional (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (optional "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) - (optional-symbols "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol"))) + :slk-load #'slk-load-operator-pointer) + (optional-symbols "std::vector" :scope :public)) (:documentation "Optional operator. Used for optional match. For every successful Pull from the input branch a Pull from the optional @@ -2343,20 +2024,16 @@ and returns true, once.") bool pull_input_{true}; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class unwind (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (input-expression "Expression *" :scope :public :slk-save #'slk-save-ast-pointer - :slk-load (slk-load-ast-pointer "Expression") - :capnp-type "Ast.Tree" :capnp-init nil - :capnp-save #'save-ast-pointer :capnp-load (load-ast-pointer "Expression *")) + :slk-load (slk-load-ast-pointer "Expression")) (output-symbol "Symbol" :scope :public)) (:documentation "Takes a list TypedValue as it's input and yields each @@ -2402,18 +2079,14 @@ Input is optional (unwind can be the first clause in a query).") std::vector::iterator input_value_it_ = input_value_.end(); }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class distinct (logical-operator) ((input "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) - (value-symbols "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol"))) + :slk-load #'slk-load-operator-pointer) + (value-symbols "std::vector" :scope :public)) (:documentation "Ensures that only distinct rows are yielded. This implementation accepts a vector of Symbols @@ -2439,29 +2112,19 @@ This implementation maintains input ordering.") input_ = input; } cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class union (logical-operator) ((left-op "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) + :slk-load #'slk-load-operator-pointer) (right-op "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) - (union-symbols "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol")) - (left-symbols "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol")) - (right-symbols "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol"))) + :slk-load #'slk-load-operator-pointer) + (union-symbols "std::vector" :scope :public) + (left-symbols "std::vector" :scope :public) + (right-symbols "std::vector" :scope :public)) (:documentation "A logical operator that applies UNION operator on inputs and places the result on the frame. @@ -2502,7 +2165,7 @@ of symbols used by each of the inputs.") const std::unique_ptr left_cursor_, right_cursor_; }; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) ;; TODO: We should probably output this operator in regular planner, not just @@ -2510,20 +2173,12 @@ of symbols used by each of the inputs.") (lcp:define-class cartesian (logical-operator) ((left-op "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) - (left-symbols "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol")) + :slk-load #'slk-load-operator-pointer) + (left-symbols "std::vector" :scope :public) (right-op "std::shared_ptr" :scope :public :slk-save #'slk-save-operator-pointer - :slk-load #'slk-load-operator-pointer - :capnp-save #'save-operator-pointer - :capnp-load #'load-operator-pointer) - (right-symbols "std::vector" :scope :public - :capnp-save (lcp:capnp-save-vector "::query::capnp::Symbol" "Symbol") - :capnp-load (lcp:capnp-load-vector "::query::capnp::Symbol" "Symbol"))) + :slk-load #'slk-load-operator-pointer) + (right-symbols "std::vector" :scope :public)) (:documentation "Operator for producing a Cartesian product from 2 input branches") (:public @@ -2548,7 +2203,7 @@ of symbols used by each of the inputs.") std::shared_ptr input() const override; void set_input(std::shared_ptr) override; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:define-class output-table (logical-operator) @@ -2583,7 +2238,7 @@ of symbols used by each of the inputs.") std::shared_ptr input() const override; void set_input(std::shared_ptr input) override; cpp<#) - (:serialize (:slk) (:capnp)) + (:serialize (:slk)) (:clone)) (lcp:pop-namespace) ;; plan diff --git a/src/raft/log_entry.lcp b/src/raft/log_entry.lcp index 0aaabac02..ba1504e47 100644 --- a/src/raft/log_entry.lcp +++ b/src/raft/log_entry.lcp @@ -3,22 +3,17 @@ #include "database/single_node_ha/serialization.hpp" #include "durability/single_node_ha/state_delta.hpp" -#include "raft/log_entry.capnp.h" cpp<# (lcp:namespace raft) -(lcp:capnp-namespace "raft") - -(lcp:capnp-import 'database "/database/single_node_ha/serialization.capnp") - (lcp:define-struct log-entry () ((term :uint64_t) - (deltas "std::vector" :capnp-type "List(Database.StateDelta)")) + (deltas "std::vector")) (:public #>cpp LogEntry() = default; LogEntry(uint64_t _term, std::vector _deltas): term(_term), deltas(_deltas) {} cpp<#) - (:serialize (:slk) (:capnp))) + (:serialize (:slk))) (lcp:pop-namespace) ;; raft diff --git a/src/raft/raft_rpc_messages.lcp b/src/raft/raft_rpc_messages.lcp index bc0fd52b8..8dd3fcc3d 100644 --- a/src/raft/raft_rpc_messages.lcp +++ b/src/raft/raft_rpc_messages.lcp @@ -6,17 +6,11 @@ #include "communication/rpc/messages.hpp" #include "raft/log_entry.hpp" -#include "raft/raft_rpc_messages.capnp.h" #include "raft/snapshot_metadata.hpp" cpp<# (lcp:namespace raft) -(lcp:capnp-namespace "raft") - -(lcp:capnp-import 'log "/raft/log_entry.capnp") -(lcp:capnp-import 'snap "/raft/snapshot_metadata.capnp") - (lcp:define-rpc request-vote (:request ((candidate-id :uint16_t) @@ -34,7 +28,7 @@ cpp<# (term :uint64_t) (prev-log-index :uint64_t) (prev-log-term :uint64_t) - (entries "std::vector" :capnp-type "List(Log.LogEntry)"))) + (entries "std::vector"))) (:response ((success :bool) (term :uint64_t)))) @@ -51,7 +45,7 @@ cpp<# (:request ((leader-id :uint16_t) (term :uint64_t) - (snapshot-metadata "raft::SnapshotMetadata" :capnp-type "Snap.SnapshotMetadata") + (snapshot-metadata "raft::SnapshotMetadata") (data "std::string"))) (:response ((term :uint64_t)))) diff --git a/src/raft/raft_server.cpp b/src/raft/raft_server.cpp index 47ae27b28..5d66b7b3e 100644 --- a/src/raft/raft_server.cpp +++ b/src/raft/raft_server.cpp @@ -15,7 +15,6 @@ #include "durability/single_node_ha/recovery.hpp" #include "durability/single_node_ha/snapshooter.hpp" #include "raft/exceptions.hpp" -#include "rpc/serialization.hpp" #include "slk/streams.hpp" #include "utils/cast.hpp" #include "utils/exceptions.hpp" diff --git a/src/raft/snapshot_metadata.lcp b/src/raft/snapshot_metadata.lcp index 26daad523..a2c3e4aa4 100644 --- a/src/raft/snapshot_metadata.lcp +++ b/src/raft/snapshot_metadata.lcp @@ -2,14 +2,11 @@ #pragma once #include -#include "raft/snapshot_metadata.capnp.h" #include "utils/typeinfo.hpp" cpp<# (lcp:namespace raft) -(lcp:capnp-namespace "raft") - (lcp:define-struct snapshot-metadata () ((last-included-term :uint64_t) (last-included-index :uint64_t) @@ -22,6 +19,6 @@ cpp<# last_included_index(_last_included_index), snapshot_filename(_snapshot_filename) {} cpp<#) - (:serialize (:slk) (:capnp))) + (:serialize (:slk))) (lcp:pop-namespace) ;; raft diff --git a/src/raft/storage_info_rpc_messages.lcp b/src/raft/storage_info_rpc_messages.lcp index 96cd8a8ce..d2f0ef7dc 100644 --- a/src/raft/storage_info_rpc_messages.lcp +++ b/src/raft/storage_info_rpc_messages.lcp @@ -5,39 +5,15 @@ #include #include "communication/rpc/messages.hpp" -#include "raft/storage_info_rpc_messages.capnp.h" -#include "rpc/serialization.hpp" #include "slk/serialization.hpp" cpp<# (lcp:namespace raft) -(lcp:capnp-namespace "raft") - -(lcp:capnp-import 'utils "/rpc/serialization.capnp") - (lcp:define-rpc storage-info (:request ()) (:response ((server-id :uint16_t) - (storage-info "std::vector>" - :capnp-type "List(Utils.Pair(Text, Text))" - :capnp-save - (lcp:capnp-save-vector - "utils::capnp::Pair<::capnp::Text, ::capnp::Text>" - "std::pair" - "[](auto *builder, const auto &pair) { - builder->setFirst(pair.first); - builder->setSecond(pair.second); - }") - :capnp-load - (lcp:capnp-load-vector - "utils::capnp::Pair<::capnp::Text, ::capnp::Text>" - "std::pair" - "[](const auto &reader) { - std::string first = reader.getFirst(); - std::string second = reader.getSecond(); - return std::make_pair(first, second); - }"))))) + (storage-info "std::vector>")))) (lcp:pop-namespace) ;; raft diff --git a/src/rpc/CMakeLists.txt b/src/rpc/CMakeLists.txt deleted file mode 100644 index d7213ddf2..000000000 --- a/src/rpc/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -define_add_capnp(add_capnp rpc_src_files rpc_capnp_files) - -add_capnp(serialization.capnp) - -add_custom_target(generate_rpc_capnp DEPENDS ${rpc_capnp_files}) - -add_library(mg-rpc STATIC ${rpc_src_files}) -target_link_libraries(mg-rpc glog gflags capnp kj) -add_dependencies(mg-rpc generate_rpc_capnp) diff --git a/src/rpc/serialization.capnp b/src/rpc/serialization.capnp deleted file mode 100644 index a25111477..000000000 --- a/src/rpc/serialization.capnp +++ /dev/null @@ -1,97 +0,0 @@ -@0xe7647d63b36c2c65; - -using Cxx = import "/capnp/c++.capnp"; - -$Cxx.namespace("utils::capnp"); - -# Primitive type wrappers - -struct BoxInt16 { - value @0 :Int16; -} - -struct BoxInt32 { - value @0 :Int32; -} - -struct BoxInt64 { - value @0 :Int64; -} - -struct BoxUInt16 { - value @0 :UInt16; -} - -struct BoxUInt32 { - value @0 :UInt32; -} - -struct BoxUInt64 { - value @0 :UInt64; -} - -struct BoxFloat32 { - value @0 :Float32; -} - -struct BoxFloat64 { - value @0 :Float64; -} - -struct BoxBool { - value @0 :Bool; -} - -# C++ STL types - -struct Optional(T) { - union { - nullopt @0 :Void; - value @1 :T; - } -} - -struct UniquePtr(T) { - union { - nullptr @0 :Void; - value @1 :T; - } -} - -struct SharedPtr(T) { - union { - nullptr @0 :Void; - entry @1 :Entry; - } - - struct Entry { - id @0 :UInt64; - value @1 :T; - } -} - -struct Map(K, V) { - entries @0 :List(Entry); - - struct Entry { - key @0 :K; - value @1 :V; - } -} - -struct Pair(First, Second) { - first @0 :First; - second @1 :Second; -} - -# Our types - -struct Bound(T) { - type @0 :Type; - value @1 :T; - - enum Type { - inclusive @0; - exclusive @1; - } -} diff --git a/src/rpc/serialization.hpp b/src/rpc/serialization.hpp deleted file mode 100644 index 83b37477d..000000000 --- a/src/rpc/serialization.hpp +++ /dev/null @@ -1,194 +0,0 @@ -#pragma once - -#include -#include -#include - -#include - -#include "rpc/serialization.capnp.h" -#include "utils/algorithm.hpp" - -namespace utils { - -template -inline void SaveVector(const std::vector &data, - typename ::capnp::List::Builder *list_builder) { - for (size_t i = 0; i < data.size(); ++i) { - list_builder->set(i, data[i]); - } -} - -inline void SaveVector(const std::vector &data, - ::capnp::List<::capnp::Text>::Builder *list_builder) { - for (size_t i = 0; i < data.size(); ++i) { - list_builder->set(i, data[i]); - } -} - -template -inline void LoadVector(std::vector *data, - const typename ::capnp::List::Reader &list_reader) { - for (const auto e : list_reader) { - data->emplace_back(e); - } -} - -inline void LoadVector( - std::vector *data, - const typename ::capnp::List<::capnp::Text>::Reader &list_reader) { - for (const auto e : list_reader) { - data->emplace_back(e); - } -} - -template -inline void SaveVector( - const std::vector &data, - typename ::capnp::List::Builder *list_builder, - const std::function &save) { - for (size_t i = 0; i < data.size(); ++i) { - auto elem_builder = (*list_builder)[i]; - save(&elem_builder, data[i]); - } -} - -template -inline void LoadVector( - std::vector *data, - const typename ::capnp::List::Reader &list_reader, - const std::function &load) { - for (const auto reader : list_reader) { - data->emplace_back(load(reader)); - } -} - -template -void SaveMap(const TMap &map, - typename capnp::Map::Builder *map_builder, - std::function::Entry::Builder *, - const typename TMap::value_type &)> - save) { - auto entries_builder = map_builder->initEntries(map.size()); - size_t i = 0; - for (const auto &entry : map) { - auto entry_builder = entries_builder[i]; - save(&entry_builder, entry); - ++i; - } -} - -template -void LoadMap( - TMap *map, - const typename capnp::Map::Reader &map_reader, - std::function::Entry::Reader &)> - load) { - for (const auto &entry_reader : map_reader.getEntries()) { - map->insert(load(entry_reader)); - } -} - -template -inline void SaveOptional( - const std::optional &data, - typename capnp::Optional::Builder *builder, - const std::function &save) { - if (data) { - auto value_builder = builder->initValue(); - save(&value_builder, data.value()); - } else { - builder->setNullopt(); - } -} - -template -inline std::optional LoadOptional( - const typename capnp::Optional::Reader &reader, - const std::function &load) { - switch (reader.which()) { - case capnp::Optional::NULLOPT: - return std::nullopt; - case capnp::Optional::VALUE: - auto value_reader = reader.getValue(); - return std::optional{load(value_reader)}; - } -} - -template -inline void SaveUniquePtr( - const std::unique_ptr &data, - typename capnp::UniquePtr::Builder *builder, - const std::function &save) { - if (data) { - auto value_builder = builder->initValue(); - save(&value_builder, *data); - } else { - builder->setNullptr(); - } -} - -template -inline std::unique_ptr LoadUniquePtr( - const typename capnp::UniquePtr::Reader &reader, - const std::function &load) { - switch (reader.which()) { - case capnp::UniquePtr::NULLPTR: - return nullptr; - case capnp::UniquePtr::VALUE: - auto value_reader = reader.getValue(); - return std::unique_ptr(load(value_reader)); - } -} - -template -inline void SaveSharedPtr( - const std::shared_ptr &data, - typename capnp::SharedPtr::Builder *builder, - const std::function &save, - std::vector *saved_pointers) { - if (!data) { - builder->setNullptr(); - return; - } - auto entry_builder = builder->initEntry(); - auto pointer_id = reinterpret_cast(data.get()); - CHECK(pointer_id <= std::numeric_limits::max()); - entry_builder.setId(pointer_id); - if (utils::Contains(*saved_pointers, data.get())) { - return; - } - auto value_builder = entry_builder.initValue(); - save(&value_builder, *data); - saved_pointers->emplace_back(data.get()); -} - -template -std::shared_ptr LoadSharedPtr( - const typename capnp::SharedPtr::Reader &reader, - const std::function &load, - std::vector>> *loaded_pointers) { - std::shared_ptr ret; - switch (reader.which()) { - case capnp::SharedPtr::NULLPTR: - ret = nullptr; - break; - case capnp::SharedPtr::ENTRY: - auto entry_reader = reader.getEntry(); - uint64_t pointer_id = entry_reader.getId(); - auto found = - std::find_if(loaded_pointers->begin(), loaded_pointers->end(), - [pointer_id](const auto &e) -> bool { - return e.first == pointer_id; - }); - if (found != loaded_pointers->end()) return found->second; - auto value_reader = entry_reader.getValue(); - ret = std::shared_ptr(load(value_reader)); - loaded_pointers->emplace_back(std::make_pair(pointer_id, ret)); - } - return ret; -} - -} // namespace utils diff --git a/src/stats/CMakeLists.txt b/src/stats/CMakeLists.txt index f3808f78f..64fa053fe 100644 --- a/src/stats/CMakeLists.txt +++ b/src/stats/CMakeLists.txt @@ -2,17 +2,12 @@ set(stats_src_files metrics.cpp stats.cpp) -define_add_capnp(add_capnp stats_src_files stats_capnp_files) define_add_lcp(add_lcp stats_src_files stats_lcp_files) -add_lcp(stats_rpc_messages.lcp CAPNP_SCHEMA @0xc19a87c81b9b4512) -add_capnp(stats_rpc_messages.capnp) +add_lcp(stats_rpc_messages.lcp SLK_SERIALIZE) add_custom_target(generate_stats_lcp DEPENDS ${stats_lcp_files}) -add_custom_target(generate_stats_capnp DEPENDS generate_stats_lcp ${stats_capnp_files}) add_library(mg-stats STATIC ${stats_src_files}) target_link_libraries(mg-stats Threads::Threads mg-utils mg-io mg-comm-rpc fmt glog gflags) -target_link_libraries(mg-stats capnp kj) add_dependencies(mg-stats generate_stats_lcp) -add_dependencies(mg-stats generate_stats_capnp) diff --git a/src/stats/stats_rpc_messages.lcp b/src/stats/stats_rpc_messages.lcp index 759aae035..0ab4aaa7c 100644 --- a/src/stats/stats_rpc_messages.lcp +++ b/src/stats/stats_rpc_messages.lcp @@ -3,39 +3,15 @@ #include "communication/rpc/messages.hpp" #include "slk/serialization.hpp" -#include "stats/stats_rpc_messages.capnp.h" -#include "rpc/serialization.hpp" #include "utils/timestamp.hpp" cpp<# (lcp:namespace stats) -(lcp:capnp-namespace "stats") - -(lcp:capnp-import 'utils "/rpc/serialization.capnp") - (lcp:define-rpc stats (:request ((metric-path "std::string") - (tags "std::vector>" - :capnp-type "List(Utils.Pair(Text, Text))" - :capnp-save - (lcp:capnp-save-vector - "utils::capnp::Pair<::capnp::Text, ::capnp::Text>" - "std::pair" - "[](auto *builder, const auto &pair) { - builder->setFirst(pair.first); - builder->setSecond(pair.second); - }") - :capnp-load - (lcp:capnp-load-vector - "utils::capnp::Pair<::capnp::Text, ::capnp::Text>" - "std::pair" - "[](const auto &reader) { - std::string first = reader.getFirst(); - std::string second = reader.getSecond(); - return std::make_pair(first, second); - }")) + (tags "std::vector>") (value :double) (timestamp :uint64_t :initarg nil :initval "static_cast(utils::Timestamp::Now().SecSinceTheEpoch())"))) diff --git a/src/storage/distributed/rpc/concurrent_id_mapper_rpc_messages.lcp b/src/storage/distributed/rpc/concurrent_id_mapper_rpc_messages.lcp index ee447936a..c004fb31f 100644 --- a/src/storage/distributed/rpc/concurrent_id_mapper_rpc_messages.lcp +++ b/src/storage/distributed/rpc/concurrent_id_mapper_rpc_messages.lcp @@ -5,7 +5,6 @@ #include "communication/rpc/messages.hpp" #include "storage/common/types/types.hpp" -#include "storage/distributed/rpc/concurrent_id_mapper_rpc_messages.capnp.h" #include "storage/distributed/rpc/serialization.hpp" #include "transactions/commit_log.hpp" #include "transactions/snapshot.hpp" @@ -14,32 +13,28 @@ cpp<# (lcp:namespace storage) -(lcp:capnp-namespace "storage") - -(lcp:capnp-import 's "/storage/distributed/rpc/serialization.capnp") - (lcp:define-rpc label-id (:request ((member "std::string"))) - (:response ((member "Label" :capnp-type "S.Label")))) + (:response ((member "Label")))) (lcp:define-rpc id-label - (:request ((member "Label" :capnp-type "S.Label"))) + (:request ((member "Label"))) (:response ((member "std::string")))) (lcp:define-rpc edge-type-id (:request ((member "std::string"))) - (:response ((member "EdgeType" :capnp-type "S.EdgeType")))) + (:response ((member "EdgeType")))) (lcp:define-rpc id-edge-type - (:request ((member "EdgeType" :capnp-type "S.EdgeType"))) + (:request ((member "EdgeType"))) (:response ((member "std::string")))) (lcp:define-rpc property-id (:request ((member "std::string"))) - (:response ((member "Property" :capnp-type "S.Property")))) + (:response ((member "Property")))) (lcp:define-rpc id-property - (:request ((member "Property" :capnp-type "S.Property"))) + (:request ((member "Property"))) (:response ((member "std::string")))) (lcp:pop-namespace) diff --git a/src/storage/distributed/rpc/serialization.capnp b/src/storage/distributed/rpc/serialization.capnp deleted file mode 100644 index 7f81a5162..000000000 --- a/src/storage/distributed/rpc/serialization.capnp +++ /dev/null @@ -1,87 +0,0 @@ -@0x8678c6a8817808d9; - -using Cxx = import "/capnp/c++.capnp"; -$Cxx.namespace("storage::capnp"); - -struct Label { - storage @0 :UInt16; -} - -struct EdgeType { - storage @0 :UInt16; -} - -struct Property { - storage @0 :UInt16; -} - -struct Address { - storage @0 :UInt64; -} - -struct PropertyValue { - union { - nullType @0 :Void; - bool @1 :Bool; - integer @2 :Int64; - double @3 :Float64; - string @4 :Text; - list @5 :List(PropertyValue); - map @6 :List(MapEntry); - } - - struct MapEntry { - key @0 :Text; - value @1 :PropertyValue; - } -} - -struct PropertyValueStore { - properties @0 :List(Entry); - - struct Entry { - id @0 :Property; - value @1 :PropertyValue; - } -} - -struct Edge { - from @0 :Address; - to @1 :Address; - typeId @2 :UInt16; - properties @3 :PropertyValueStore; -} - -struct Vertex { - outEdges @0 :List(EdgeEntry); - inEdges @1 :List(EdgeEntry); - labelIds @2 :List(UInt16); - properties @3 :PropertyValueStore; - - struct EdgeEntry { - vertexAddress @0 :Address; - edgeAddress @1 :Address; - edgeTypeId @2 :UInt16; - } -} - -enum SendVersions { - both @0; - onlyOld @1; - onlyNew @2; -} - -struct VertexAccessor { - cypherId @0 :Int64; - address @1 :UInt64; - old @2 :Vertex; - new @3 :Vertex; -} - -struct EdgeAccessor { - cypherId @0 :Int64; - address @1 :UInt64; - old @2 :Edge; - new @3 :Edge; -} - diff --git a/src/storage/distributed/rpc/serialization.cpp b/src/storage/distributed/rpc/serialization.cpp index 8e3be03f0..2e9d6b81a 100644 --- a/src/storage/distributed/rpc/serialization.cpp +++ b/src/storage/distributed/rpc/serialization.cpp @@ -3,318 +3,6 @@ #include "database/distributed/graph_db_accessor.hpp" #include "distributed/data_manager.hpp" -namespace storage { - -void Save(const Label &label, capnp::Label::Builder *builder) { - builder->setStorage(label.id_); -} - -void Load(Label *label, const capnp::Label::Reader &reader) { - label->id_ = reader.getStorage(); -} - -void Save(const EdgeType &edge_type, capnp::EdgeType::Builder *builder) { - builder->setStorage(edge_type.id_); -} - -void Load(EdgeType *edge_type, const capnp::EdgeType::Reader &reader) { - edge_type->id_ = reader.getStorage(); -} - -void Save(const Property &property, capnp::Property::Builder *builder) { - builder->setStorage(property.id_); -} - -void Load(Property *property, const capnp::Property::Reader &reader) { - property->id_ = reader.getStorage(); -} - -void SaveCapnpPropertyValue(const PropertyValue &value, - capnp::PropertyValue::Builder *builder) { - switch (value.type()) { - case PropertyValue::Type::Null: - builder->setNullType(); - return; - case PropertyValue::Type::Bool: - builder->setBool(value.Value()); - return; - case PropertyValue::Type::Int: - builder->setInteger(value.Value()); - return; - case PropertyValue::Type::Double: - builder->setDouble(value.Value()); - return; - case PropertyValue::Type::String: - builder->setString(value.Value()); - return; - case PropertyValue::Type::List: { - const auto &values = value.Value>(); - auto list_builder = builder->initList(values.size()); - for (size_t i = 0; i < values.size(); ++i) { - auto value_builder = list_builder[i]; - SaveCapnpPropertyValue(values[i], &value_builder); - } - return; - } - case PropertyValue::Type::Map: { - const auto &map = value.Value>(); - auto map_builder = builder->initMap(map.size()); - size_t i = 0; - for (const auto &kv : map) { - auto kv_builder = map_builder[i]; - kv_builder.setKey(kv.first); - auto value_builder = kv_builder.initValue(); - SaveCapnpPropertyValue(kv.second, &value_builder); - ++i; - } - return; - } - } -} - -void LoadCapnpPropertyValue(const capnp::PropertyValue::Reader &reader, - PropertyValue *value) { - switch (reader.which()) { - case capnp::PropertyValue::NULL_TYPE: - *value = PropertyValue::Null; - return; - case capnp::PropertyValue::BOOL: - *value = reader.getBool(); - return; - case capnp::PropertyValue::INTEGER: - *value = reader.getInteger(); - return; - case capnp::PropertyValue::DOUBLE: - *value = reader.getDouble(); - return; - case capnp::PropertyValue::STRING: - *value = reader.getString().cStr(); - return; - case capnp::PropertyValue::LIST: { - std::vector list; - list.reserve(reader.getList().size()); - for (const auto &value_reader : reader.getList()) { - list.emplace_back(); - LoadCapnpPropertyValue(value_reader, &list.back()); - } - *value = list; - return; - } - case capnp::PropertyValue::MAP: { - std::map map; - for (const auto &kv_reader : reader.getMap()) { - auto key = kv_reader.getKey(); - LoadCapnpPropertyValue(kv_reader.getValue(), &map[key]); - } - *value = map; - return; - } - } -} - -void SaveProperties(const PropertyValueStore &properties, - capnp::PropertyValueStore::Builder *builder) { - size_t i = 0; - auto props_builder = builder->initProperties(properties.size()); - for (const auto &kv : properties) { - auto kv_builder = props_builder[i++]; - auto id_builder = kv_builder.initId(); - Save(kv.first, &id_builder); - auto value_builder = kv_builder.initValue(); - SaveCapnpPropertyValue(kv.second, &value_builder); - } -} - -void LoadProperties(const capnp::PropertyValueStore::Reader &reader, - PropertyValueStore *properties) { - properties->clear(); - auto props_reader = reader.getProperties(); - for (const auto &kv_reader : props_reader) { - storage::Property id; - storage::Load(&id, kv_reader.getId()); - PropertyValue value; - LoadCapnpPropertyValue(kv_reader.getValue(), &value); - properties->set(id, value); - } -} - -template -void SaveAddress(TAddress address, capnp::Address::Builder *builder, - int16_t worker_id) { - TAddress global_address = - address.is_local() ? TAddress(address.local()->gid_, worker_id) : address; - builder->setStorage(global_address.raw()); -} - -EdgeAddress LoadEdgeAddress(const capnp::Address::Reader &reader) { - return EdgeAddress(reader.getStorage()); -} - -VertexAddress LoadVertexAddress(const capnp::Address::Reader &reader) { - return VertexAddress(reader.getStorage()); -} - -void SaveVertex(const Vertex &vertex, capnp::Vertex::Builder *builder, - int16_t worker_id) { - auto save_edges = [worker_id](const auto &edges, auto *edges_builder) { - int64_t i = 0; - for (const auto &edge : edges) { - auto edge_builder = (*edges_builder)[i]; - auto vertex_addr_builder = edge_builder.initVertexAddress(); - SaveAddress(edge.vertex, &vertex_addr_builder, worker_id); - auto edge_addr_builder = edge_builder.initEdgeAddress(); - SaveAddress(edge.edge, &edge_addr_builder, worker_id); - edge_builder.setEdgeTypeId(edge.edge_type.Id()); - ++i; - } - }; - auto out_builder = builder->initOutEdges(vertex.out_.size()); - save_edges(vertex.out_, &out_builder); - auto in_builder = builder->initInEdges(vertex.in_.size()); - save_edges(vertex.in_, &in_builder); - auto labels_builder = builder->initLabelIds(vertex.labels_.size()); - for (size_t i = 0; i < vertex.labels_.size(); ++i) { - labels_builder.set(i, vertex.labels_[i].Id()); - } - auto properties_builder = builder->initProperties(); - storage::SaveProperties(vertex.properties_, &properties_builder); -} - -void SaveEdge(const Edge &edge, capnp::Edge::Builder *builder, - int16_t worker_id) { - auto from_builder = builder->initFrom(); - SaveAddress(edge.from_, &from_builder, worker_id); - auto to_builder = builder->initTo(); - SaveAddress(edge.to_, &to_builder, worker_id); - builder->setTypeId(edge.edge_type_.Id()); - auto properties_builder = builder->initProperties(); - storage::SaveProperties(edge.properties_, &properties_builder); -} - -/// Alias for `SaveEdge` allowing for param type resolution. -void SaveElement(const Edge &record, capnp::Edge::Builder *builder, - int16_t worker_id) { - return SaveEdge(record, builder, worker_id); -} - -/// Alias for `SaveVertex` allowing for param type resolution. -void SaveElement(const Vertex &record, capnp::Vertex::Builder *builder, - int16_t worker_id) { - return SaveVertex(record, builder, worker_id); -} - -std::unique_ptr LoadVertex(const capnp::Vertex::Reader &reader) { - auto vertex = std::make_unique(); - auto load_edges = [](const auto &edges_reader) { - Edges edges; - for (const auto &edge_reader : edges_reader) { - auto vertex_address = LoadVertexAddress(edge_reader.getVertexAddress()); - auto edge_address = LoadEdgeAddress(edge_reader.getEdgeAddress()); - storage::EdgeType edge_type(edge_reader.getEdgeTypeId()); - edges.emplace(vertex_address, edge_address, edge_type); - } - return edges; - }; - vertex->out_ = load_edges(reader.getOutEdges()); - vertex->in_ = load_edges(reader.getInEdges()); - for (const auto &label_id : reader.getLabelIds()) { - vertex->labels_.emplace_back(label_id); - } - storage::LoadProperties(reader.getProperties(), &vertex->properties_); - return vertex; -} - -std::unique_ptr LoadEdge(const capnp::Edge::Reader &reader) { - auto from = LoadVertexAddress(reader.getFrom()); - auto to = LoadVertexAddress(reader.getTo()); - auto edge = - std::make_unique(from, to, storage::EdgeType{reader.getTypeId()}); - storage::LoadProperties(reader.getProperties(), &edge->properties_); - return edge; -} - -template -void SaveRecordAccessor(const RecordAccessor &accessor, - typename TCapnpRecord::Builder *builder, - SendVersions versions, int worker_id) { - builder->setCypherId(accessor.CypherId()); - builder->setAddress(accessor.GlobalAddress().raw()); - - bool reconstructed = false; - auto guard = storage::GetDataLock(accessor); - if (!accessor.GetOld() && !accessor.GetNew()) { - reconstructed = true; - bool result = accessor.Reconstruct(); - CHECK(result) << "Attempting to serialize an element not visible to " - "current transaction."; - } - auto old_rec = accessor.GetOld(); - if (old_rec && versions != SendVersions::ONLY_NEW) { - auto old_builder = builder->initOld(); - storage::SaveElement(*old_rec, &old_builder, worker_id); - } - if (versions != SendVersions::ONLY_OLD) { - if (!reconstructed && !accessor.GetNew()) { - bool result = accessor.Reconstruct(); - CHECK(result) << "Attempting to serialize an element not visible to " - "current transaction."; - } - auto *new_rec = accessor.GetNew(); - if (new_rec) { - auto new_builder = builder->initNew(); - storage::SaveElement(*new_rec, &new_builder, worker_id); - } - } -} - -void SaveVertexAccessor(const VertexAccessor &vertex_accessor, - capnp::VertexAccessor::Builder *builder, - SendVersions versions, int worker_id) { - SaveRecordAccessor(vertex_accessor, builder, - versions, worker_id); -} - -void SaveEdgeAccessor(const EdgeAccessor &edge_accessor, - capnp::EdgeAccessor::Builder *builder, - SendVersions versions, int worker_id) { - SaveRecordAccessor(edge_accessor, builder, - versions, worker_id); -} - -VertexAccessor LoadVertexAccessor(const capnp::VertexAccessor::Reader &reader, - database::GraphDbAccessor *dba, - distributed::DataManager *data_manager) { - int64_t cypher_id = reader.getCypherId(); - storage::VertexAddress global_address(reader.getAddress()); - auto old_record = - reader.hasOld() ? storage::LoadVertex(reader.getOld()) : nullptr; - auto new_record = - reader.hasNew() ? storage::LoadVertex(reader.getNew()) : nullptr; - data_manager->Emplace( - dba->transaction_id(), global_address.gid(), - distributed::CachedRecordData(cypher_id, std::move(old_record), - std::move(new_record))); - return VertexAccessor(global_address, *dba); -} - -EdgeAccessor LoadEdgeAccessor(const capnp::EdgeAccessor::Reader &reader, - database::GraphDbAccessor *dba, - distributed::DataManager *data_manager) { - int64_t cypher_id = reader.getCypherId(); - storage::EdgeAddress global_address(reader.getAddress()); - auto old_record = - reader.hasOld() ? storage::LoadEdge(reader.getOld()) : nullptr; - auto new_record = - reader.hasNew() ? storage::LoadEdge(reader.getNew()) : nullptr; - data_manager->Emplace( - dba->transaction_id(), global_address.gid(), - distributed::CachedRecordData(cypher_id, std::move(old_record), - std::move(new_record))); - return EdgeAccessor(global_address, *dba); -} - -} // namespace storage - namespace slk { void Save(const storage::SendVersions &versions, slk::Builder *builder) { diff --git a/src/storage/distributed/rpc/serialization.hpp b/src/storage/distributed/rpc/serialization.hpp index 09a9cc589..0f6717fa3 100644 --- a/src/storage/distributed/rpc/serialization.hpp +++ b/src/storage/distributed/rpc/serialization.hpp @@ -6,7 +6,6 @@ #include "storage/common/types/slk.hpp" #include "storage/distributed/edge.hpp" #include "storage/distributed/edge_accessor.hpp" -#include "storage/distributed/rpc/serialization.capnp.h" #include "storage/distributed/vertex.hpp" #include "storage/distributed/vertex_accessor.hpp" @@ -20,76 +19,8 @@ class DataManager; namespace storage { -template -void Save(const Address &address, capnp::Address::Builder *builder) { - builder->setStorage(address.raw()); -} - -template -void Load(Address *address, const capnp::Address::Reader &reader) { - address->storage_ = reader.getStorage(); -} - -void Save(const Label &label, capnp::Label::Builder *builder); - -void Load(Label *label, const capnp::Label::Reader &reader); - -void Save(const EdgeType &edge_type, capnp::EdgeType::Builder *builder); - -void Load(EdgeType *edge_type, const capnp::EdgeType::Reader &reader); - -void Save(const Property &property, capnp::Property::Builder *builder); - -void Load(Property *property, const capnp::Property::Reader &reader); - -void SaveCapnpPropertyValue(const PropertyValue &value, - capnp::PropertyValue::Builder *builder); - -void LoadCapnpPropertyValue(const capnp::PropertyValue::Reader &reader, - PropertyValue *value); - -void SaveProperties(const PropertyValueStore &properties, - capnp::PropertyValueStore::Builder *builder); - -void LoadProperties(const capnp::PropertyValueStore::Reader &reader, - PropertyValueStore *properties); - -void SaveVertex(const Vertex &vertex, capnp::Vertex::Builder *builder, - int16_t worker_id); - -void SaveEdge(const Edge &edge, capnp::Edge::Builder *builder, - int16_t worker_id); - -/// Alias for `SaveEdge` allowing for param type resolution. -void SaveElement(const Edge &record, capnp::Edge::Builder *builder, - int16_t worker_id); - -/// Alias for `SaveVertex` allowing for param type resolution. -void SaveElement(const Vertex &record, capnp::Vertex::Builder *builder, - int16_t worker_id); - -std::unique_ptr LoadVertex(const capnp::Vertex::Reader &reader); - -std::unique_ptr LoadEdge(const capnp::Edge::Reader &reader); - enum class SendVersions { BOTH, ONLY_OLD, ONLY_NEW }; -void SaveVertexAccessor(const VertexAccessor &vertex_accessor, - capnp::VertexAccessor::Builder *builder, - SendVersions versions, int worker_id); - -VertexAccessor LoadVertexAccessor(const capnp::VertexAccessor::Reader &reader, - database::GraphDbAccessor *dba, - distributed::DataManager *data_manager); - -void SaveEdgeAccessor(const EdgeAccessor &edge_accessor, - capnp::EdgeAccessor::Builder *builder, - SendVersions versions, int worker_id); - -EdgeAccessor LoadEdgeAccessor(const capnp::EdgeAccessor::Reader &reader, - database::GraphDbAccessor *dba, - distributed::DataManager *data_manager); - } // namespace storage namespace slk { diff --git a/src/storage/single_node_ha/rpc/serialization.capnp b/src/storage/single_node_ha/rpc/serialization.capnp deleted file mode 100644 index db97daa72..000000000 --- a/src/storage/single_node_ha/rpc/serialization.capnp +++ /dev/null @@ -1,33 +0,0 @@ -@0x8424471a44ccd2df; - -using Cxx = import "/capnp/c++.capnp"; -$Cxx.namespace("storage::capnp"); - -struct Label { - storage @0 :UInt16; -} - -struct EdgeType { - storage @0 :UInt16; -} - -struct Property { - storage @0 :UInt16; -} - -struct PropertyValue { - union { - nullType @0 :Void; - bool @1 :Bool; - integer @2 :Int64; - double @3 :Float64; - string @4 :Text; - list @5 :List(PropertyValue); - map @6 :List(MapEntry); - } - - struct MapEntry { - key @0 :Text; - value @1 :PropertyValue; - } -} diff --git a/src/storage/single_node_ha/rpc/serialization.cpp b/src/storage/single_node_ha/rpc/serialization.cpp deleted file mode 100644 index 6550144d3..000000000 --- a/src/storage/single_node_ha/rpc/serialization.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "storage/single_node_ha/rpc/serialization.hpp" - -namespace storage { - -void Save(const Label &label, capnp::Label::Builder *builder) { - builder->setStorage(label.id_); -} - -void Load(Label *label, const capnp::Label::Reader &reader) { - label->id_ = reader.getStorage(); -} - -void Save(const EdgeType &edge_type, capnp::EdgeType::Builder *builder) { - builder->setStorage(edge_type.id_); -} - -void Load(EdgeType *edge_type, const capnp::EdgeType::Reader &reader) { - edge_type->id_ = reader.getStorage(); -} - -void Save(const Property &property, capnp::Property::Builder *builder) { - builder->setStorage(property.id_); -} - -void Load(Property *property, const capnp::Property::Reader &reader) { - property->id_ = reader.getStorage(); -} - -void SaveCapnpPropertyValue(const PropertyValue &value, - capnp::PropertyValue::Builder *builder) { - switch (value.type()) { - case PropertyValue::Type::Null: - builder->setNullType(); - return; - case PropertyValue::Type::Bool: - builder->setBool(value.Value()); - return; - case PropertyValue::Type::Int: - builder->setInteger(value.Value()); - return; - case PropertyValue::Type::Double: - builder->setDouble(value.Value()); - return; - case PropertyValue::Type::String: - builder->setString(value.Value()); - return; - case PropertyValue::Type::List: { - const auto &values = value.Value>(); - auto list_builder = builder->initList(values.size()); - for (size_t i = 0; i < values.size(); ++i) { - auto value_builder = list_builder[i]; - SaveCapnpPropertyValue(values[i], &value_builder); - } - return; - } - case PropertyValue::Type::Map: { - const auto &map = value.Value>(); - auto map_builder = builder->initMap(map.size()); - size_t i = 0; - for (const auto &kv : map) { - auto kv_builder = map_builder[i]; - kv_builder.setKey(kv.first); - auto value_builder = kv_builder.initValue(); - SaveCapnpPropertyValue(kv.second, &value_builder); - ++i; - } - return; - } - } -} - -void LoadCapnpPropertyValue(const capnp::PropertyValue::Reader &reader, - PropertyValue *value) { - switch (reader.which()) { - case capnp::PropertyValue::NULL_TYPE: - *value = PropertyValue::Null; - return; - case capnp::PropertyValue::BOOL: - *value = reader.getBool(); - return; - case capnp::PropertyValue::INTEGER: - *value = reader.getInteger(); - return; - case capnp::PropertyValue::DOUBLE: - *value = reader.getDouble(); - return; - case capnp::PropertyValue::STRING: - *value = reader.getString().cStr(); - return; - case capnp::PropertyValue::LIST: { - std::vector list; - list.reserve(reader.getList().size()); - for (const auto &value_reader : reader.getList()) { - list.emplace_back(); - LoadCapnpPropertyValue(value_reader, &list.back()); - } - *value = list; - return; - } - case capnp::PropertyValue::MAP: { - std::map map; - for (const auto &kv_reader : reader.getMap()) { - auto key = kv_reader.getKey(); - LoadCapnpPropertyValue(kv_reader.getValue(), &map[key]); - } - *value = map; - return; - } - } -} - -} // namespace storage diff --git a/src/storage/single_node_ha/rpc/serialization.hpp b/src/storage/single_node_ha/rpc/serialization.hpp deleted file mode 100644 index e88473624..000000000 --- a/src/storage/single_node_ha/rpc/serialization.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "slk/serialization.hpp" -#include "storage/common/types/property_value.hpp" -#include "storage/common/types/slk.hpp" -#include "storage/common/types/types.hpp" -#include "storage/single_node_ha/rpc/serialization.capnp.h" - -namespace storage { - -void Save(const Label &label, capnp::Label::Builder *builder); - -void Load(Label *label, const capnp::Label::Reader &reader); - -void Save(const EdgeType &edge_type, capnp::EdgeType::Builder *builder); - -void Load(EdgeType *edge_type, const capnp::EdgeType::Reader &reader); - -void Save(const Property &property, capnp::Property::Builder *builder); - -void Load(Property *property, const capnp::Property::Reader &reader); - -void SaveCapnpPropertyValue(const PropertyValue &value, - capnp::PropertyValue::Builder *builder); - -void LoadCapnpPropertyValue(const capnp::PropertyValue::Reader &reader, - PropertyValue *value); - -} // namespace storage diff --git a/src/transactions/distributed/engine_rpc_messages.lcp b/src/transactions/distributed/engine_rpc_messages.lcp index 12208096c..87de2879f 100644 --- a/src/transactions/distributed/engine_rpc_messages.lcp +++ b/src/transactions/distributed/engine_rpc_messages.lcp @@ -4,7 +4,6 @@ #include "communication/rpc/messages.hpp" #include "slk/serialization.hpp" #include "transactions/commit_log.hpp" -#include "transactions/distributed/engine_rpc_messages.capnp.h" #include "transactions/snapshot.hpp" #include "transactions/type.hpp" cpp<# @@ -13,21 +12,12 @@ cpp<# (lcp:namespace tx) -(lcp:capnp-namespace "tx") - -(lcp:capnp-type-conversion "TransactionId" "UInt64") -(lcp:capnp-type-conversion "CommandId" "UInt32") - (lcp:define-struct tx-and-snapshot () ((tx-id "TransactionId") (snapshot "Snapshot" :slk-save #'slk-save-snapshot - :slk-load #'slk-load-snapshot - :capnp-type "List(UInt64)" - :capnp-init nil - :capnp-save #'save-snapshot - :capnp-load #'load-snapshot)) - (:serialize (:slk) (:capnp))) + :slk-load #'slk-load-snapshot)) + (:serialize (:slk))) (lcp:define-rpc begin (:request ()) @@ -49,11 +39,7 @@ cpp<# (:request ((member "TransactionId"))) (:response ((member "Snapshot" :slk-save #'slk-save-snapshot - :slk-load #'slk-load-snapshot - :capnp-type "List(UInt64)" - :capnp-init nil - :capnp-save #'save-snapshot - :capnp-load #'load-snapshot)))) + :slk-load #'slk-load-snapshot)))) (lcp:define-rpc command (:request ((member "TransactionId"))) @@ -63,31 +49,19 @@ cpp<# (:request ()) (:response ((member "Snapshot" :slk-save #'slk-save-snapshot - :slk-load #'slk-load-snapshot - :capnp-type "List(UInt64)" - :capnp-init nil - :capnp-save #'save-snapshot - :capnp-load #'load-snapshot)))) + :slk-load #'slk-load-snapshot)))) (lcp:define-rpc clog-info (:request ((member "TransactionId"))) (:response ((member "CommitLog::Info" :slk-save #'slk-save-commitlog-info - :slk-load #'slk-load-commitlog-info - :capnp-type "UInt8" - :capnp-init nil - :capnp-save #'save-commitlog-info - :capnp-load #'load-commitlog-info)))) + :slk-load #'slk-load-commitlog-info)))) (lcp:define-rpc active-transactions (:request ()) (:response ((member "Snapshot" :slk-save #'slk-save-snapshot - :slk-load #'slk-load-snapshot - :capnp-type "List(UInt64)" - :capnp-init nil - :capnp-save #'save-snapshot - :capnp-load #'load-snapshot)))) + :slk-load #'slk-load-snapshot)))) (lcp:define-rpc ensure-next-id-greater (:request ((member "TransactionId"))) diff --git a/src/transactions/distributed/serialization.lcp b/src/transactions/distributed/serialization.lcp index bc4c57868..625f5e863 100644 --- a/src/transactions/distributed/serialization.lcp +++ b/src/transactions/distributed/serialization.lcp @@ -12,16 +12,6 @@ self->${member} = tx::CommitLog::Info(info_flags); cpp<#) -(defun save-commitlog-info (builder member capnp-name) - #>cpp - ${builder}->set${capnp-name}(${member}); - cpp<#) - -(defun load-commitlog-info (reader member capnp-name) - #>cpp - ${member} = CommitLog::Info(${reader}.get${capnp-name}()); - cpp<#) - (defun slk-save-snapshot (member) #>cpp slk::Save(self.${member}.transaction_ids(), builder); @@ -33,16 +23,3 @@ slk::Load(&transaction_ids, reader); self->${member} = tx::Snapshot(std::move(transaction_ids)); cpp<#) - -(defun save-snapshot (builder member capnp-name) - #>cpp - auto list_builder = builder->init${capnp-name}(${member}.transaction_ids().size()); - utils::SaveVector(${member}.transaction_ids(), &list_builder); - cpp<#) - -(defun load-snapshot (reader member capnp-name) - #>cpp - std::vector transaction_ids; - utils::LoadVector(&transaction_ids, ${reader}.get${capnp-name}()); - ${member} = tx::Snapshot(std::move(transaction_ids)); - cpp<#) diff --git a/tests/benchmark/rpc.cpp b/tests/benchmark/rpc.cpp index 8380de767..d2d8cd9a9 100644 --- a/tests/benchmark/rpc.cpp +++ b/tests/benchmark/rpc.cpp @@ -3,8 +3,6 @@ #include -#include "capnp/serialize.h" - #include "communication/rpc/client.hpp" #include "communication/rpc/client_pool.hpp" #include "communication/rpc/messages.hpp" diff --git a/tests/benchmark/serialization.cpp b/tests/benchmark/serialization.cpp index 2bf57e825..a9675e9ed 100644 --- a/tests/benchmark/serialization.cpp +++ b/tests/benchmark/serialization.cpp @@ -3,9 +3,6 @@ #include -#include -#include - #include "query/distributed/frontend/semantic/symbol_serialization.hpp" #include "query/frontend/semantic/symbol.hpp" #include "slk/serialization.hpp" @@ -30,72 +27,6 @@ class SymbolVectorFixture : public benchmark::Fixture { void TearDown(const benchmark::State &) override { symbols_.clear(); } }; -void SymbolVectorToCapnpMessage(const std::vector &symbols, - capnp::MessageBuilder &message) { - auto symbols_builder = - message.initRoot>(symbols.size()); - for (int i = 0; i < symbols.size(); ++i) { - const auto &sym = symbols[i]; - query::capnp::Symbol::Builder sym_builder = symbols_builder[i]; - sym_builder.setName(sym.name()); - sym_builder.setPosition(sym.position()); - sym_builder.setType(query::capnp::Symbol::Type::ANY); - sym_builder.setUserDeclared(sym.user_declared()); - sym_builder.setTokenPosition(sym.token_position()); - } -} - -std::stringstream SerializeCapnpSymbolVector( - const std::vector &symbols) { - std::stringstream stream(std::ios_base::in | std::ios_base::out | - std::ios_base::binary); - { - capnp::MallocMessageBuilder message; - SymbolVectorToCapnpMessage(symbols, message); - kj::std::StdOutputStream std_stream(stream); - kj::BufferedOutputStreamWrapper buffered_stream(std_stream); - writeMessage(buffered_stream, message); - } - return stream; -} - -BENCHMARK_DEFINE_F(SymbolVectorFixture, CapnpSerial)(benchmark::State &state) { - while (state.KeepRunning()) { - SerializeCapnpSymbolVector(symbols_); - } - state.SetItemsProcessed(state.iterations()); -} - -BENCHMARK_DEFINE_F(SymbolVectorFixture, CapnpDeserial) -(benchmark::State &state) { - while (state.KeepRunning()) { - state.PauseTiming(); - auto stream = SerializeCapnpSymbolVector(symbols_); - state.ResumeTiming(); - kj::std::StdInputStream std_stream(stream); - capnp::InputStreamMessageReader message(std_stream); - auto symbols_reader = message.getRoot>(); - std::vector symbols; - symbols.reserve(symbols_reader.size()); - for (const auto &sym : symbols_reader) { - symbols.emplace_back(sym.getName().cStr(), sym.getPosition(), - sym.getUserDeclared(), query::Symbol::Type::ANY, - sym.getTokenPosition()); - } - } - state.SetItemsProcessed(state.iterations()); -} - -BENCHMARK_REGISTER_F(SymbolVectorFixture, CapnpSerial) - ->RangeMultiplier(4) - ->Range(4, 1 << 12) - ->Unit(benchmark::kNanosecond); - -BENCHMARK_REGISTER_F(SymbolVectorFixture, CapnpDeserial) - ->RangeMultiplier(4) - ->Range(4, 1 << 12) - ->Unit(benchmark::kNanosecond); - void SymbolVectorToSlk(const std::vector &symbols, slk::Builder *builder) { slk::Save(symbols.size(), builder); diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 6e147a29d..27ad4f069 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -226,9 +226,6 @@ target_link_libraries(${test_prefix}queue mg-single-node kvstore_dummy_lib) add_unit_test(record_edge_vertex_accessor.cpp) target_link_libraries(${test_prefix}record_edge_vertex_accessor mg-single-node kvstore_dummy_lib) -add_unit_test(serialization.cpp) -target_link_libraries(${test_prefix}serialization mg-rpc) - add_unit_test(skip_list.cpp) target_link_libraries(${test_prefix}skip_list mg-utils) diff --git a/tests/unit/ast_serialization.cpp b/tests/unit/ast_serialization.cpp index 69b83137d..5a8a0b578 100644 --- a/tests/unit/ast_serialization.cpp +++ b/tests/unit/ast_serialization.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include @@ -74,43 +73,6 @@ class Base { } }; -class CapnpAstGenerator : public Base { - public: - Query *ParseQuery(const std::string &query_string) override { - ::frontend::opencypher::Parser parser(query_string); - AstStorage tmp_storage; - CypherMainVisitor visitor(context_, &tmp_storage); - visitor.visit(parser.tree()); - - ::capnp::MallocMessageBuilder message; - { - query::capnp::Tree::Builder builder = - message.initRoot(); - Save(*visitor.query(), &builder); - } - - { - const query::capnp::Tree::Reader reader = - message.getRoot(); - return dynamic_cast(Load(&storage_, reader)); - } - } - - PropertyIx Prop(const std::string &prop_name) override { - return storage_.GetPropertyIx(prop_name); - } - - LabelIx Label(const std::string &name) override { - return storage_.GetLabelIx(name); - } - - EdgeTypeIx EdgeType(const std::string &name) override { - return storage_.GetEdgeTypeIx(name); - } - - AstStorage storage_; -}; - class SlkAstGenerator : public Base { public: Query *ParseQuery(const std::string &query_string) override { @@ -148,7 +110,6 @@ class CypherMainVisitorTest : public ::testing::TestWithParam> {}; std::shared_ptr gAstGeneratorTypes[] = { - std::make_shared(), std::make_shared(), }; @@ -163,7 +124,7 @@ INSTANTIATE_TEST_CASE_P(AstGeneratorTypes, CypherMainVisitorTest, // future reference in case someone gets the idea to change to *appropriate* // Typed Tests mechanism and ruin the compilation times. // -// typedef ::testing::Types +// typedef ::testing::Types // AstGeneratorTypes; // // TYPED_TEST_CASE(CypherMainVisitorTest, AstGeneratorTypes); diff --git a/tests/unit/distributed_query_plan.cpp b/tests/unit/distributed_query_plan.cpp index 838db64d3..a26fcc43f 100644 --- a/tests/unit/distributed_query_plan.cpp +++ b/tests/unit/distributed_query_plan.cpp @@ -574,47 +574,6 @@ class ExpectPullRemoteOrderBy : public OpChecker { std::vector symbols_; }; -void SavePlan(const LogicalOperator &plan, ::capnp::MessageBuilder *message) { - auto builder = message->initRoot(); - LogicalOperator::SaveHelper helper; - Save(plan, &builder, &helper); -} - -auto LoadPlan(const ::query::plan::capnp::LogicalOperator::Reader &reader) { - std::unique_ptr plan; - LogicalOperator::LoadHelper helper; - Load(&plan, reader, &helper); - return std::make_pair(std::move(plan), std::move(helper.ast_storage)); -} - -class CapnpPlanner { - public: - template - CapnpPlanner(std::vector single_query_parts, - PlanningContext context) { - ::capnp::MallocMessageBuilder message; - { - query::Parameters parameters; - PostProcessor post_processor(parameters); - auto original_plan = MakeLogicalPlanForSingleQuery( - single_query_parts, &context); - original_plan = - post_processor.Rewrite(std::move(original_plan), &context); - SavePlan(*original_plan, &message); - } - { - auto reader = message.getRoot(); - std::tie(plan_, ast_storage_) = LoadPlan(reader); - } - } - - auto &plan() { return *plan_; } - - private: - AstStorage ast_storage_; - std::unique_ptr plan_; -}; - struct ExpectedDistributedPlan { std::list> master_checkers; std::vector>> worker_checkers; @@ -729,7 +688,7 @@ class Planner { template class TestPlanner : public ::testing::Test {}; -using PlannerTypes = ::testing::Types; +using PlannerTypes = ::testing::Types; TYPED_TEST_CASE(TestPlanner, PlannerTypes); @@ -2183,109 +2142,3 @@ TYPED_TEST(TestPlanner, DistributedOptionalScanExpandExisting) { CheckDistributedPlan(storage, planner.plan(), symbol_table, properties_by_ix, expected); } - -TEST(CapnpSerial, Union) { - std::vector left_symbols{ - Symbol("symbol", 1, true, Symbol::Type::EDGE)}; - std::vector right_symbols{ - Symbol("symbol", 3, true, Symbol::Type::ANY)}; - auto union_symbols = right_symbols; - auto union_op = std::make_unique(nullptr, nullptr, union_symbols, - left_symbols, right_symbols); - std::unique_ptr loaded_plan; - ::capnp::MallocMessageBuilder message; - SavePlan(*union_op, &message); - AstStorage new_storage; - std::tie(loaded_plan, new_storage) = - LoadPlan(message.getRoot()); - ASSERT_TRUE(loaded_plan); - auto *loaded_op = dynamic_cast(loaded_plan.get()); - ASSERT_TRUE(loaded_op); - EXPECT_FALSE(loaded_op->left_op_); - EXPECT_FALSE(loaded_op->right_op_); - EXPECT_EQ(loaded_op->left_symbols_, left_symbols); - EXPECT_EQ(loaded_op->right_symbols_, right_symbols); - EXPECT_EQ(loaded_op->union_symbols_, union_symbols); -} - -TEST(CapnpSerial, Cartesian) { - std::vector left_symbols{ - Symbol("left_symbol", 1, true, Symbol::Type::EDGE)}; - std::vector right_symbols{ - Symbol("right_symbol", 3, true, Symbol::Type::ANY)}; - auto cartesian = std::make_unique(nullptr, left_symbols, nullptr, - right_symbols); - std::unique_ptr loaded_plan; - ::capnp::MallocMessageBuilder message; - SavePlan(*cartesian, &message); - AstStorage new_storage; - std::tie(loaded_plan, new_storage) = - LoadPlan(message.getRoot()); - ASSERT_TRUE(loaded_plan); - auto *loaded_op = dynamic_cast(loaded_plan.get()); - ASSERT_TRUE(loaded_op); - EXPECT_FALSE(loaded_op->left_op_); - EXPECT_FALSE(loaded_op->right_op_); - EXPECT_EQ(loaded_op->left_symbols_, left_symbols); - EXPECT_EQ(loaded_op->right_symbols_, right_symbols); -} - -TEST(CapnpSerial, Synchronize) { - auto synchronize = std::make_unique(nullptr, nullptr, true); - std::unique_ptr loaded_plan; - ::capnp::MallocMessageBuilder message; - SavePlan(*synchronize, &message); - AstStorage new_storage; - std::tie(loaded_plan, new_storage) = - LoadPlan(message.getRoot()); - ASSERT_TRUE(loaded_plan); - auto *loaded_op = dynamic_cast(loaded_plan.get()); - ASSERT_TRUE(loaded_op); - EXPECT_FALSE(loaded_op->input()); - EXPECT_FALSE(loaded_op->pull_remote_); - EXPECT_TRUE(loaded_op->advance_command_); -} - -TEST(CapnpSerial, PullRemote) { - std::vector symbols{Symbol("symbol", 1, true, Symbol::Type::EDGE)}; - auto pull_remote = std::make_unique(nullptr, 42, symbols); - std::unique_ptr loaded_plan; - ::capnp::MallocMessageBuilder message; - SavePlan(*pull_remote, &message); - AstStorage new_storage; - std::tie(loaded_plan, new_storage) = - LoadPlan(message.getRoot()); - ASSERT_TRUE(loaded_plan); - auto *loaded_op = dynamic_cast(loaded_plan.get()); - ASSERT_TRUE(loaded_op); - EXPECT_FALSE(loaded_op->input()); - EXPECT_EQ(loaded_op->plan_id_, 42); - EXPECT_EQ(loaded_op->symbols_, symbols); -} - -TEST(CapnpSerial, PullRemoteOrderBy) { - auto once = std::make_shared(); - AstStorage storage; - std::vector symbols{ - Symbol("my_symbol", 2, true, Symbol::Type::VERTEX, 3)}; - std::vector order_by{ - {query::Ordering::ASC, IDENT("my_symbol")}}; - auto pull_remote_order_by = - std::make_unique(once, 42, order_by, symbols); - std::unique_ptr loaded_plan; - ::capnp::MallocMessageBuilder message; - SavePlan(*pull_remote_order_by, &message); - AstStorage new_storage; - std::tie(loaded_plan, new_storage) = - LoadPlan(message.getRoot()); - ASSERT_TRUE(loaded_plan); - auto *loaded_op = dynamic_cast(loaded_plan.get()); - ASSERT_TRUE(loaded_op); - ASSERT_TRUE(std::dynamic_pointer_cast(loaded_op->input())); - EXPECT_EQ(loaded_op->plan_id_, 42); - EXPECT_EQ(loaded_op->symbols_, symbols); - ASSERT_EQ(loaded_op->order_by_.size(), 1); - EXPECT_TRUE(dynamic_cast(loaded_op->order_by_[0])); - ASSERT_EQ(loaded_op->compare_.ordering().size(), 1); - EXPECT_EQ(loaded_op->compare_.ordering()[0], query::Ordering::ASC); -} diff --git a/tests/unit/rpc.cpp b/tests/unit/rpc.cpp index 7ada41543..fe4e09db4 100644 --- a/tests/unit/rpc.cpp +++ b/tests/unit/rpc.cpp @@ -1,6 +1,5 @@ #include -#include "capnp/serialize.h" #include "gmock/gmock.h" #include "gtest/gtest.h" diff --git a/tests/unit/serialization.cpp b/tests/unit/serialization.cpp deleted file mode 100644 index 1bceada24..000000000 --- a/tests/unit/serialization.cpp +++ /dev/null @@ -1,334 +0,0 @@ -#include -#include - -#include "gtest/gtest.h" - -#include "capnp/message.h" -#include "rpc/serialization.hpp" - -using std::optional; -using std::string_literals::operator""s; - -void CheckOptionalInt(const std::optional &x1) { - ::capnp::MallocMessageBuilder message; - std::optional y1; - { - auto builder = - message.initRoot>(); - auto save = [](utils::capnp::BoxInt32::Builder *builder, int value) { - builder->setValue(value); - }; - utils::SaveOptional(x1, &builder, save); - } - - { - auto reader = - message.getRoot>(); - auto load = [](const utils::capnp::BoxInt32::Reader &reader) -> int { - return reader.getValue(); - }; - y1 = utils::LoadOptional(reader, load); - } - - EXPECT_EQ(x1, y1); -} - -TEST(Serialization, CapnpOptional) { - std::optional x1 = {}; - std::optional x2 = 42; - - CheckOptionalInt(x1); - CheckOptionalInt(x2); -} - -TEST(Serialization, CapnpOptionalNonCopyable) { - std::optional> data = std::make_unique(5); - ::capnp::MallocMessageBuilder message; - { - auto builder = message.initRoot>>(); - auto save = [](auto *ptr_builder, const auto &data) { - auto save_int = [](auto *int_builder, int value) { - int_builder->setValue(value); - }; - utils::SaveUniquePtr(data, ptr_builder, - save_int); - }; - utils::SaveOptional, - std::unique_ptr>(data, &builder, save); - } - std::optional> element; - { - auto reader = message.getRoot>>(); - auto load = [](const auto &ptr_reader) { - auto load_int = [](const auto &int_reader) { - return new int(int_reader.getValue()); - }; - return utils::LoadUniquePtr(ptr_reader, - load_int); - }; - element = - utils::LoadOptional, - std::unique_ptr>(reader, load); - } - EXPECT_EQ(*element.value(), 5); -} - -void CheckUniquePtrInt(const std::unique_ptr &x1) { - ::capnp::MallocMessageBuilder message; - std::unique_ptr y1; - { - auto builder = - message.initRoot>(); - auto save = [](utils::capnp::BoxInt32::Builder *builder, int value) { - builder->setValue(value); - }; - utils::SaveUniquePtr(x1, &builder, save); - } - { - auto reader = - message.getRoot>(); - auto load = [](const auto &int_reader) { - return new int(int_reader.getValue()); - }; - y1 = utils::LoadUniquePtr(reader, load); - } - if (!x1) - EXPECT_EQ(y1, nullptr); - else - EXPECT_EQ(*x1, *y1); -} - -TEST(Serialization, CapnpUniquePtr) { - auto x1 = std::make_unique(42); - std::unique_ptr x2; - - CheckUniquePtrInt(x1); - CheckUniquePtrInt(x2); -} - -TEST(Serialization, CapnpUniquePtrNonCopyable) { - std::unique_ptr> data = - std::make_unique>(std::make_unique(5)); - ::capnp::MallocMessageBuilder message; - { - auto builder = message.initRoot>>(); - auto save = [](auto *ptr_builder, const auto &data) { - auto save_int = [](auto *int_builder, int value) { - int_builder->setValue(value); - }; - utils::SaveUniquePtr(data, ptr_builder, - save_int); - }; - utils::SaveUniquePtr, - std::unique_ptr>(data, &builder, save); - } - std::unique_ptr> element; - { - auto reader = message.getRoot>>(); - auto load = [](const auto &ptr_reader) { - auto load_int = [](const auto &int_reader) { - return new int(int_reader.getValue()); - }; - return new std::unique_ptr( - utils::LoadUniquePtr(ptr_reader, - load_int)); - }; - element = - utils::LoadUniquePtr, - std::unique_ptr>(reader, load); - } - EXPECT_EQ(**element, 5); -} - -TEST(Serialization, CapnpSharedPtr) { - std::vector saved_pointers; - auto p1 = std::make_shared(5); - std::shared_ptr p2; - std::vector> pointers{p1, p1, p2}; - ::capnp::MallocMessageBuilder message; - { - auto builders = message.initRoot< - ::capnp::List>>( - pointers.size()); - auto save = [](utils::capnp::BoxInt32::Builder *builder, int value) { - builder->setValue(value); - }; - for (size_t i = 0; i < pointers.size(); ++i) { - auto ptr_builder = builders[i]; - utils::SaveSharedPtr( - pointers[i], &ptr_builder, save, &saved_pointers); - } - } - EXPECT_EQ(saved_pointers.size(), 1); - std::vector>> loaded_pointers; - std::vector> elements; - { - auto reader = message.getRoot< - ::capnp::List>>(); - auto load = [](const auto &int_reader) { - return new int(int_reader.getValue()); - }; - for (const auto ptr_reader : reader) { - elements.emplace_back(utils::LoadSharedPtr( - ptr_reader, load, &loaded_pointers)); - } - } - EXPECT_EQ(loaded_pointers.size(), 1); - EXPECT_EQ(elements.size(), 3); - EXPECT_EQ(*elements[0], 5); - EXPECT_EQ(*elements[0], *elements[1]); - EXPECT_EQ(elements[2].get(), nullptr); -} - -TEST(Serialization, CapnpSharedPtrNonCopyable) { - std::shared_ptr> data = - std::make_shared>(std::make_unique(5)); - std::vector *> saved_pointers; - ::capnp::MallocMessageBuilder message; - { - auto builder = message.initRoot>>(); - auto save = [](auto *ptr_builder, const auto &data) { - auto save_int = [](auto *int_builder, int value) { - int_builder->setValue(value); - }; - utils::SaveUniquePtr(data, ptr_builder, - save_int); - }; - utils::SaveSharedPtr, - std::unique_ptr>(data, &builder, save, - &saved_pointers); - } - std::shared_ptr> element; - std::vector>>> - loaded_pointers; - { - auto reader = message.getRoot>>(); - auto load = [](const auto &ptr_reader) { - auto load_int = [](const auto &int_reader) { - return new int(int_reader.getValue()); - }; - return new std::unique_ptr( - utils::LoadUniquePtr(ptr_reader, - load_int)); - }; - element = - utils::LoadSharedPtr, - std::unique_ptr>(reader, load, - &loaded_pointers); - } - EXPECT_EQ(**element, 5); -} - -TEST(Serialization, CapnpVectorPrimitive) { - std::vector data{1, 2, 3}; - ::capnp::MallocMessageBuilder message; - { - auto list_builder = message.initRoot<::capnp::List>(data.size()); - utils::SaveVector(data, &list_builder); - } - std::vector elements; - { - auto reader = message.getRoot<::capnp::List>(); - utils::LoadVector(&elements, reader); - } - EXPECT_EQ(elements.size(), 3); - EXPECT_EQ(elements[0], 1); - EXPECT_EQ(elements[1], 2); - EXPECT_EQ(elements[2], 3); -} - -TEST(Serialization, CapnpVector) { - std::vector data{1, 2, 3}; - ::capnp::MallocMessageBuilder message; - { - auto list_builder = - message.initRoot<::capnp::List>(data.size()); - auto save = [](utils::capnp::BoxInt32::Builder *builder, int value) { - builder->setValue(value); - }; - utils::SaveVector(data, &list_builder, save); - } - std::vector elements; - { - auto reader = message.getRoot<::capnp::List>(); - auto load = [](const utils::capnp::BoxInt32::Reader &reader) -> int { - return reader.getValue(); - }; - utils::LoadVector(&elements, reader, load); - } - EXPECT_EQ(elements.size(), 3); - EXPECT_EQ(elements[0], 1); - EXPECT_EQ(elements[1], 2); - EXPECT_EQ(elements[2], 3); -} - -TEST(Serialization, CapnpVectorNonCopyable) { - std::vector> data; - data.emplace_back(std::make_unique(5)); - data.emplace_back(std::make_unique(10)); - ::capnp::MallocMessageBuilder message; - { - auto list_builder = message.initRoot< - ::capnp::List>>( - data.size()); - auto save = [](auto *ptr_builder, const auto &data) { - auto save_int = [](auto *int_builder, int value) { - int_builder->setValue(value); - }; - utils::SaveUniquePtr(data, ptr_builder, - save_int); - }; - utils::SaveVector, - std::unique_ptr>(data, &list_builder, save); - } - std::vector> elements; - { - auto reader = message.getRoot< - ::capnp::List>>(); - auto load = [](const auto &ptr_reader) { - auto load_int = [](const auto &int_reader) { - return new int(int_reader.getValue()); - }; - return utils::LoadUniquePtr(ptr_reader, - load_int); - }; - utils::LoadVector, - std::unique_ptr>(&elements, reader, load); - } - EXPECT_EQ(elements.size(), 2); - EXPECT_EQ(*elements[0], 5); - EXPECT_EQ(*elements[1], 10); -} - -TEST(Serialization, CapnpMap) { - std::map map{{"my_key", "my_value"}, - {"other_key", "other_value"}}; - ::capnp::MallocMessageBuilder message; - { - auto map_builder = - message.initRoot>(); - utils::SaveMap( - map, &map_builder, [](auto *entry_builder, const auto &entry) { - entry_builder->setKey(entry.first); - entry_builder->setValue(entry.second); - }); - } - std::map new_map; - { - auto map_reader = - message.getRoot>(); - utils::LoadMap( - &new_map, map_reader, [](const auto &entry_reader) { - std::string key = entry_reader.getKey(); - std::string value = entry_reader.getValue(); - return std::make_pair(key, value); - }); - } - EXPECT_EQ(new_map, map); -} diff --git a/tools/lcp b/tools/lcp index 2dec5f258..b74f9e0ed 100755 --- a/tools/lcp +++ b/tools/lcp @@ -1,9 +1,9 @@ #!/bin/bash -e if [[ $# -ne 1 && $# -ne 2 ]]; then - echo "Usage: $0 LCP_FILE [CAPNP_ID]" + echo "Usage: $0 LCP_FILE" echo "Convert a LCP_FILE to C++ header file and output to stdout." - echo "If CAPNP_ID is provided, then the Cap'n Proto schema is generated." + echo "If SLK_SERIALIZE is provided, then SLK serialization is generated." exit 1 fi @@ -20,16 +20,16 @@ if [[ -v QUICKLISP_HOME ]]; then quicklisp_install_dir="${QUICKLISP_HOME}" fi -capnp="" -if [[ $# -eq 2 ]]; then - capnp=":capnp-id \"$2\"" +slk_serialize="" +if [[ "$2" == "SLK_SERIALIZE" ]]; then + slk_serialize=":slk-serialize t" fi echo \ " (load \"${quicklisp_install_dir}/setup.lisp\") (ql:quickload :lcp :silent t) -(lcp:process-file \"$lcp_file\" $capnp) +(lcp:process-file \"$lcp_file\" $slk_serialize) " | sbcl --script filename=`basename $lcp_file .lcp`