2018-07-24 21:11:18 +08:00
|
|
|
/// @file Conversion functions between Value and other memgraph types.
|
2018-07-02 21:34:33 +08:00
|
|
|
#pragma once
|
|
|
|
|
2018-07-24 21:11:18 +08:00
|
|
|
#include "communication/bolt/v1/value.hpp"
|
2018-07-02 21:34:33 +08:00
|
|
|
#include "query/typed_value.hpp"
|
2020-01-22 23:20:13 +08:00
|
|
|
#include "storage/v2/property_value.hpp"
|
2019-09-05 16:25:27 +08:00
|
|
|
#include "storage/v2/result.hpp"
|
2020-01-22 22:08:43 +08:00
|
|
|
#include "storage/v2/view.hpp"
|
2019-09-05 16:25:27 +08:00
|
|
|
|
|
|
|
namespace storage {
|
|
|
|
class EdgeAccessor;
|
|
|
|
class Storage;
|
|
|
|
class VertexAccessor;
|
|
|
|
} // namespace storage
|
|
|
|
|
Extract communication to static library
Summary:
Session specifics have been move out of the Bolt `executing` state, and
are accessed via pure virtual Session type. Our server is templated on
the session and we are setting the concrete type, so there should be no
virtual call overhead. Abstract Session is used to indicate the
interface, this could have also been templated, but the explicit
interface definition makes it clearer.
Specific session implementation for running Memgraph is now implemented
in memgraph_bolt, which instantiates the concrete session type. This may
not be 100% appropriate place, but Memgraph specific session isn't
needed anywhere else.
Bolt/communication tests now use a dummy session and depend only on
communication, which significantly improves test run times.
All these changes make the communication a library which doesn't depend
on storage nor the database. Only shared connection points, which aren't
part of the base communication library are:
* glue/conversion -- which converts between storage and bolt types, and
* communication/result_stream_faker -- templated, but used in tests and query/repl
Depends on D1453
Reviewers: mferencevic, buda, mtomic, msantl
Reviewed By: mferencevic, mtomic
Subscribers: pullbot
Differential Revision: https://phabricator.memgraph.io/D1456
2018-07-10 22:18:19 +08:00
|
|
|
namespace glue {
|
2018-07-02 21:34:33 +08:00
|
|
|
|
2019-09-05 16:25:27 +08:00
|
|
|
/// @param storage::VertexAccessor for converting to
|
|
|
|
/// communication::bolt::Vertex.
|
|
|
|
/// @param storage::Storage for getting label and property names.
|
|
|
|
/// @param storage::View for deciding which vertex attributes are visible.
|
|
|
|
///
|
|
|
|
/// @throw std::bad_alloc
|
2021-02-18 22:32:43 +08:00
|
|
|
storage::Result<communication::bolt::Vertex> ToBoltVertex(const storage::VertexAccessor &vertex,
|
|
|
|
const storage::Storage &db, storage::View view);
|
2019-09-05 16:25:27 +08:00
|
|
|
|
|
|
|
/// @param storage::EdgeAccessor for converting to communication::bolt::Edge.
|
|
|
|
/// @param storage::Storage for getting edge type and property names.
|
|
|
|
/// @param storage::View for deciding which edge attributes are visible.
|
|
|
|
///
|
|
|
|
/// @throw std::bad_alloc
|
2021-02-18 22:32:43 +08:00
|
|
|
storage::Result<communication::bolt::Edge> ToBoltEdge(const storage::EdgeAccessor &edge, const storage::Storage &db,
|
|
|
|
storage::View view);
|
2019-09-05 16:25:27 +08:00
|
|
|
|
|
|
|
/// @param query::Path for converting to communication::bolt::Path.
|
|
|
|
/// @param storage::Storage for ToBoltVertex and ToBoltEdge.
|
|
|
|
/// @param storage::View for ToBoltVertex and ToBoltEdge.
|
|
|
|
///
|
|
|
|
/// @throw std::bad_alloc
|
2021-02-18 22:32:43 +08:00
|
|
|
storage::Result<communication::bolt::Path> ToBoltPath(const query::Path &path, const storage::Storage &db,
|
|
|
|
storage::View view);
|
2019-09-05 16:25:27 +08:00
|
|
|
|
|
|
|
/// @param query::TypedValue for converting to communication::bolt::Value.
|
|
|
|
/// @param storage::Storage for ToBoltVertex and ToBoltEdge.
|
|
|
|
/// @param storage::View for ToBoltVertex and ToBoltEdge.
|
|
|
|
///
|
|
|
|
/// @throw std::bad_alloc
|
2021-02-18 22:32:43 +08:00
|
|
|
storage::Result<communication::bolt::Value> ToBoltValue(const query::TypedValue &value, const storage::Storage &db,
|
|
|
|
storage::View view);
|
2018-07-02 21:34:33 +08:00
|
|
|
|
2018-07-24 21:11:18 +08:00
|
|
|
query::TypedValue ToTypedValue(const communication::bolt::Value &value);
|
2018-07-02 21:34:33 +08:00
|
|
|
|
2020-01-22 23:20:13 +08:00
|
|
|
communication::bolt::Value ToBoltValue(const storage::PropertyValue &value);
|
2018-07-02 21:34:33 +08:00
|
|
|
|
2020-01-22 23:20:13 +08:00
|
|
|
storage::PropertyValue ToPropertyValue(const communication::bolt::Value &value);
|
2018-07-02 21:34:33 +08:00
|
|
|
|
Extract communication to static library
Summary:
Session specifics have been move out of the Bolt `executing` state, and
are accessed via pure virtual Session type. Our server is templated on
the session and we are setting the concrete type, so there should be no
virtual call overhead. Abstract Session is used to indicate the
interface, this could have also been templated, but the explicit
interface definition makes it clearer.
Specific session implementation for running Memgraph is now implemented
in memgraph_bolt, which instantiates the concrete session type. This may
not be 100% appropriate place, but Memgraph specific session isn't
needed anywhere else.
Bolt/communication tests now use a dummy session and depend only on
communication, which significantly improves test run times.
All these changes make the communication a library which doesn't depend
on storage nor the database. Only shared connection points, which aren't
part of the base communication library are:
* glue/conversion -- which converts between storage and bolt types, and
* communication/result_stream_faker -- templated, but used in tests and query/repl
Depends on D1453
Reviewers: mferencevic, buda, mtomic, msantl
Reviewed By: mferencevic, mtomic
Subscribers: pullbot
Differential Revision: https://phabricator.memgraph.io/D1456
2018-07-10 22:18:19 +08:00
|
|
|
} // namespace glue
|