Commit e63ccee0 authored by Giorgio Azzinnaro's avatar Giorgio Azzinnaro

test get

parent cb03611b
......@@ -20,7 +20,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
name='nested.proto',
package='test',
syntax='proto3',
serialized_pb=_b('\n\x0cnested.proto\x12\x04test\x1a profanedb/protobuf/options.proto\"2\n\x0e\x45xternalNested\x12 \n\x10\x66ield_one_double\x18\x01 \x01(\x01\x42\x06\xfa\xe9\x30\x02\x08\x01\x62\x06proto3')
serialized_pb=_b('\n\x0cnested.proto\x12\x04test\x1a profanedb/protobuf/options.proto\"1\n\x0e\x45xternalNested\x12\x1f\n\x10\x66ield_one_double\x18\x01 \x01(\x01\x42\x05\xe2@\x02\x08\x01\x62\x06proto3')
,
dependencies=[profanedb_dot_protobuf_dot_options__pb2.DESCRIPTOR,])
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
......@@ -41,7 +41,7 @@ _EXTERNALNESTED = _descriptor.Descriptor(
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\372\3510\002\010\001'))),
options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\342@\002\010\001'))),
],
extensions=[
],
......@@ -55,7 +55,7 @@ _EXTERNALNESTED = _descriptor.Descriptor(
oneofs=[
],
serialized_start=56,
serialized_end=106,
serialized_end=105,
)
DESCRIPTOR.message_types_by_name['ExternalNested'] = _EXTERNALNESTED
......@@ -69,7 +69,7 @@ _sym_db.RegisterMessage(ExternalNested)
_EXTERNALNESTED.fields_by_name['field_one_double'].has_options = True
_EXTERNALNESTED.fields_by_name['field_one_double']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\372\3510\002\010\001'))
_EXTERNALNESTED.fields_by_name['field_one_double']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\342@\002\010\001'))
try:
# THESE ELEMENTS WILL BE DEPRECATED.
# Please use the generated *_pb2_grpc.py files instead.
......
syntax = "proto3";
package profanedb.protobuf;
option go_package = "gitlab.com/profanedb/protobuf/db";
option csharp_namespace = "ProfaneDB.Protobuf";
option java_package = "com.profanedb.protobuf";
option objc_class_prefix = "PDB";
import "google/protobuf/any.proto";
service Db {
rpc Get (GetReq) returns (GetResp);
rpc Put (PutReq) returns (PutResp);
rpc Delete (DelReq) returns (DelResp);
}
message GetReq {
}
message GetResp {
}
message PutReq {
google.protobuf.Any serializable = 1;
}
message PutResp {
}
message DelReq {
}
message DelResp {
}
../../../src/profanedb/protobuf/db.proto
\ No newline at end of file
......@@ -20,7 +20,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
name='profanedb/protobuf/db.proto',
package='profanedb.protobuf',
syntax='proto3',
serialized_pb=_b('\n\x1bprofanedb/protobuf/db.proto\x12\x12profanedb.protobuf\x1a\x19google/protobuf/any.proto\"\x08\n\x06GetReq\"\t\n\x07GetResp\"4\n\x06PutReq\x12*\n\x0cserializable\x18\x01 \x01(\x0b\x32\x14.google.protobuf.Any\"\t\n\x07PutResp\"\x08\n\x06\x44\x65lReq\"\t\n\x07\x44\x65lResp2\xc7\x01\n\x02\x44\x62\x12>\n\x03Get\x12\x1a.profanedb.protobuf.GetReq\x1a\x1b.profanedb.protobuf.GetResp\x12>\n\x03Put\x12\x1a.profanedb.protobuf.PutReq\x1a\x1b.profanedb.protobuf.PutResp\x12\x41\n\x06\x44\x65lete\x12\x1a.profanedb.protobuf.DelReq\x1a\x1b.profanedb.protobuf.DelRespBU\n\x16\x63om.profanedb.protobufZ gitlab.com/profanedb/protobuf/db\xa2\x02\x03PDB\xaa\x02\x12ProfaneDB.Protobufb\x06proto3')
serialized_pb=_b('\n\x1bprofanedb/protobuf/db.proto\x12\x12profanedb.protobuf\x1a\x19google/protobuf/any.proto\"\x15\n\x06GetReq\x12\x0b\n\x03key\x18\x01 \x01(\t\"0\n\x07GetResp\x12%\n\x07message\x18\x01 \x01(\x0b\x32\x14.google.protobuf.Any\"4\n\x06PutReq\x12*\n\x0cserializable\x18\x01 \x01(\x0b\x32\x14.google.protobuf.Any\"\x16\n\x07PutResp\x12\x0b\n\x03key\x18\x01 \x01(\t\"\x15\n\x06\x44\x65lReq\x12\x0b\n\x03key\x18\x01 \x01(\t\"\t\n\x07\x44\x65lResp2\xc7\x01\n\x02\x44\x62\x12>\n\x03Get\x12\x1a.profanedb.protobuf.GetReq\x1a\x1b.profanedb.protobuf.GetResp\x12>\n\x03Put\x12\x1a.profanedb.protobuf.PutReq\x1a\x1b.profanedb.protobuf.PutResp\x12\x41\n\x06\x44\x65lete\x12\x1a.profanedb.protobuf.DelReq\x1a\x1b.profanedb.protobuf.DelRespBU\n\x16\x63om.profanedb.protobufZ gitlab.com/profanedb/protobuf/db\xa2\x02\x03PDB\xaa\x02\x12ProfaneDB.Protobufb\x06proto3')
,
dependencies=[google_dot_protobuf_dot_any__pb2.DESCRIPTOR,])
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
......@@ -35,6 +35,13 @@ _GETREQ = _descriptor.Descriptor(
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='key', full_name='profanedb.protobuf.GetReq.key', index=0,
number=1, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
......@@ -48,7 +55,7 @@ _GETREQ = _descriptor.Descriptor(
oneofs=[
],
serialized_start=78,
serialized_end=86,
serialized_end=99,
)
......@@ -59,6 +66,13 @@ _GETRESP = _descriptor.Descriptor(
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='message', full_name='profanedb.protobuf.GetResp.message', index=0,
number=1, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
......@@ -71,8 +85,8 @@ _GETRESP = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=88,
serialized_end=97,
serialized_start=101,
serialized_end=149,
)
......@@ -102,8 +116,8 @@ _PUTREQ = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=99,
serialized_end=151,
serialized_start=151,
serialized_end=203,
)
......@@ -114,6 +128,13 @@ _PUTRESP = _descriptor.Descriptor(
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='key', full_name='profanedb.protobuf.PutResp.key', index=0,
number=1, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
......@@ -126,8 +147,8 @@ _PUTRESP = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=153,
serialized_end=162,
serialized_start=205,
serialized_end=227,
)
......@@ -138,6 +159,13 @@ _DELREQ = _descriptor.Descriptor(
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='key', full_name='profanedb.protobuf.DelReq.key', index=0,
number=1, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
......@@ -150,8 +178,8 @@ _DELREQ = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=164,
serialized_end=172,
serialized_start=229,
serialized_end=250,
)
......@@ -174,10 +202,11 @@ _DELRESP = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=174,
serialized_end=183,
serialized_start=252,
serialized_end=261,
)
_GETRESP.fields_by_name['message'].message_type = google_dot_protobuf_dot_any__pb2._ANY
_PUTREQ.fields_by_name['serializable'].message_type = google_dot_protobuf_dot_any__pb2._ANY
DESCRIPTOR.message_types_by_name['GetReq'] = _GETREQ
DESCRIPTOR.message_types_by_name['GetResp'] = _GETRESP
......
syntax = "proto2";
package profanedb.protobuf;
option go_package = "gitlab.com/profanedb/protobuf/options";
option csharp_namespace = "ProfaneDB.Protobuf";
option java_package = "com.profanedb.protobuf";
option objc_class_prefix = "PDB";
import "google/protobuf/descriptor.proto";
// These options should be used during schema definition,
// applying them to some of the fields in protobuf
message FieldOptions {
optional bool key = 1;
}
extend google.protobuf.FieldOptions {
optional FieldOptions options = 99999;
}
../../../src/profanedb/protobuf/options.proto
\ No newline at end of file
......@@ -20,16 +20,16 @@ DESCRIPTOR = _descriptor.FileDescriptor(
name='profanedb/protobuf/options.proto',
package='profanedb.protobuf',
syntax='proto2',
serialized_pb=_b('\n profanedb/protobuf/options.proto\x12\x12profanedb.protobuf\x1a google/protobuf/descriptor.proto\"\x1b\n\x0c\x46ieldOptions\x12\x0b\n\x03key\x18\x01 \x01(\x08:R\n\x07options\x12\x1d.google.protobuf.FieldOptions\x18\x9f\x8d\x06 \x01(\x0b\x32 .profanedb.protobuf.FieldOptionsBZ\n\x16\x63om.profanedb.protobufZ%gitlab.com/profanedb/protobuf/options\xa2\x02\x03PDB\xaa\x02\x12ProfaneDB.Protobuf')
serialized_pb=_b('\n profanedb/protobuf/options.proto\x12\x12profanedb.protobuf\x1a google/protobuf/descriptor.proto\"\x1b\n\x0c\x46ieldOptions\x12\x0b\n\x03key\x18\x01 \x01(\x08:Q\n\x07options\x12\x1d.google.protobuf.FieldOptions\x18\x8c\x08 \x01(\x0b\x32 .profanedb.protobuf.FieldOptionsBZ\n\x16\x63om.profanedb.protobufZ%gitlab.com/profanedb/protobuf/options\xa2\x02\x03PDB\xaa\x02\x12ProfaneDB.Protobuf')
,
dependencies=[google_dot_protobuf_dot_descriptor__pb2.DESCRIPTOR,])
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
OPTIONS_FIELD_NUMBER = 99999
OPTIONS_FIELD_NUMBER = 1036
options = _descriptor.FieldDescriptor(
name='options', full_name='profanedb.protobuf.options', index=0,
number=99999, type=11, cpp_type=10, label=1,
number=1036, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=True, extension_scope=None,
......
......@@ -40,6 +40,10 @@ def run():
stub.Put(db_pb2.PutReq(
serializable = serializable
))
stub.Get(db_pb2.GetReq(
key = "test.Test.field_one_int$123"
))
if __name__ == '__main__':
run()
......@@ -21,7 +21,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
name='test.proto',
package='test',
syntax='proto3',
serialized_pb=_b('\n\ntest.proto\x12\x04test\x1a profanedb/protobuf/options.proto\x1a\x0cnested.proto\"\x9b\x02\n\x04Test\x12\x1d\n\rfield_one_int\x18\x01 \x01(\x05\x42\x06\xfa\xe9\x30\x02\x08\x01\x12\x15\n\rfield_two_str\x18\x02 \x01(\t\x12\x18\n\x10\x66ield_three_bool\x18\x03 \x01(\x08\x12\'\n\x11\x66ield_five_nested\x18\x05 \x01(\x0b\x32\x0c.test.Nested\x12\x18\n\x10\x66ield_four_bytes\x18\x04 \x01(\x0c\x12\x36\n\x18\x66ield_six_externalnested\x18\x06 \x01(\x0b\x32\x14.test.ExternalNested\x12H\n\x1c\x66ield_seven_repeated_keyable\x18\x07 \x01(\x0b\x32\".test.Nested.KeyableNestedInNested\"\xc1\x01\n\x06Nested\x12$\n\x14nested_field_one_str\x18\x01 \x01(\tB\x06\xfa\xe9\x30\x02\x08\x01\x12\x1c\n\x14nested_field_two_int\x18\x02 \x01(\x03\x12!\n\x19nested_field_three_double\x18\x03 \x01(\x01\x1aP\n\x15KeyableNestedInNested\x12\x37\n\'nested_in_nested_field_one_repeated_str\x18\x01 \x03(\tB\x06\xfa\xe9\x30\x02\x08\x01\x62\x06proto3')
serialized_pb=_b('\n\ntest.proto\x12\x04test\x1a profanedb/protobuf/options.proto\x1a\x0cnested.proto\"\x9a\x02\n\x04Test\x12\x1c\n\rfield_one_int\x18\x01 \x01(\x05\x42\x05\xe2@\x02\x08\x01\x12\x15\n\rfield_two_str\x18\x02 \x01(\t\x12\x18\n\x10\x66ield_three_bool\x18\x03 \x01(\x08\x12\'\n\x11\x66ield_five_nested\x18\x05 \x01(\x0b\x32\x0c.test.Nested\x12\x18\n\x10\x66ield_four_bytes\x18\x04 \x01(\x0c\x12\x36\n\x18\x66ield_six_externalnested\x18\x06 \x01(\x0b\x32\x14.test.ExternalNested\x12H\n\x1c\x66ield_seven_repeated_keyable\x18\x07 \x01(\x0b\x32\".test.Nested.KeyableNestedInNested\"\xbf\x01\n\x06Nested\x12#\n\x14nested_field_one_str\x18\x01 \x01(\tB\x05\xe2@\x02\x08\x01\x12\x1c\n\x14nested_field_two_int\x18\x02 \x01(\x03\x12!\n\x19nested_field_three_double\x18\x03 \x01(\x01\x1aO\n\x15KeyableNestedInNested\x12\x36\n\'nested_in_nested_field_one_repeated_str\x18\x01 \x03(\tB\x05\xe2@\x02\x08\x01\x62\x06proto3')
,
dependencies=[profanedb_dot_protobuf_dot_options__pb2.DESCRIPTOR,nested__pb2.DESCRIPTOR,])
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
......@@ -42,7 +42,7 @@ _TEST = _descriptor.Descriptor(
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\372\3510\002\010\001'))),
options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\342@\002\010\001'))),
_descriptor.FieldDescriptor(
name='field_two_str', full_name='test.Test.field_two_str', index=1,
number=2, type=9, cpp_type=9, label=1,
......@@ -98,7 +98,7 @@ _TEST = _descriptor.Descriptor(
oneofs=[
],
serialized_start=69,
serialized_end=352,
serialized_end=351,
)
......@@ -115,7 +115,7 @@ _NESTED_KEYABLENESTEDINNESTED = _descriptor.Descriptor(
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\372\3510\002\010\001'))),
options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\342@\002\010\001'))),
],
extensions=[
],
......@@ -128,8 +128,8 @@ _NESTED_KEYABLENESTEDINNESTED = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=468,
serialized_end=548,
serialized_start=466,
serialized_end=545,
)
_NESTED = _descriptor.Descriptor(
......@@ -145,7 +145,7 @@ _NESTED = _descriptor.Descriptor(
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\372\3510\002\010\001'))),
options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\342@\002\010\001'))),
_descriptor.FieldDescriptor(
name='nested_field_two_int', full_name='test.Nested.nested_field_two_int', index=1,
number=2, type=3, cpp_type=2, label=1,
......@@ -172,8 +172,8 @@ _NESTED = _descriptor.Descriptor(
extension_ranges=[],
oneofs=[
],
serialized_start=355,
serialized_end=548,
serialized_start=354,
serialized_end=545,
)
_TEST.fields_by_name['field_five_nested'].message_type = _NESTED
......@@ -207,11 +207,11 @@ _sym_db.RegisterMessage(Nested.KeyableNestedInNested)
_TEST.fields_by_name['field_one_int'].has_options = True
_TEST.fields_by_name['field_one_int']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\372\3510\002\010\001'))
_TEST.fields_by_name['field_one_int']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\342@\002\010\001'))
_NESTED_KEYABLENESTEDINNESTED.fields_by_name['nested_in_nested_field_one_repeated_str'].has_options = True
_NESTED_KEYABLENESTEDINNESTED.fields_by_name['nested_in_nested_field_one_repeated_str']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\372\3510\002\010\001'))
_NESTED_KEYABLENESTEDINNESTED.fields_by_name['nested_in_nested_field_one_repeated_str']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\342@\002\010\001'))
_NESTED.fields_by_name['nested_field_one_str'].has_options = True
_NESTED.fields_by_name['nested_field_one_str']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\372\3510\002\010\001'))
_NESTED.fields_by_name['nested_field_one_str']._options = _descriptor._ParseOptions(descriptor_pb2.FieldOptions(), _b('\342@\002\010\001'))
try:
# THESE ELEMENTS WILL BE DEPRECATED.
# Please use the generated *_pb2_grpc.py files instead.
......
......@@ -19,7 +19,7 @@
#include "db.h"
profanedb::storage::Db::Db(profanedb::storage::Config config)
profanedb::storage::Db::Db(Config config)
: config(config)
, parser(config.GetProfaneConfig())
, normalizer(parser)
......@@ -35,22 +35,32 @@ profanedb::storage::Db::~Db()
delete this->db;
}
profanedb::protobuf::GetResp profanedb::storage::Db::Get(const profanedb::protobuf::GetReq & request)
profanedb::protobuf::GetResp profanedb::storage::Db::Get(const protobuf::GetReq & request)
{
std::string type = request.key();
// Split at first dollar sign ($), here starts the actual key value
type = type.substr(0, type.find('$'));
// The last dot (.) separates the message type name from the field type name
type = type.substr(0, type.rfind('.'));
std::string * serialized = new std::string();
db->Get(rocksdb::ReadOptions(), request.key(), serialized);
return *protobuf::GetResp().New();
}
profanedb::protobuf::PutResp profanedb::storage::Db::Put(const profanedb::protobuf::PutReq & request)
profanedb::protobuf::PutResp profanedb::storage::Db::Put(const protobuf::PutReq & request)
{
auto map = normalizer.NormalizeMessage(request.serializable());
for (auto const & obj: map) {
std::cout << obj.first << ":" << std::endl << obj.second.DebugString() << std::endl;
std::cout << obj.first << std::endl;
db->Put(rocksdb::WriteOptions(), obj.first, obj.second.SerializeAsString());
}
return *profanedb::protobuf::PutResp().New();
return *protobuf::PutResp().New();
}
profanedb::protobuf::DelResp profanedb::storage::Db::Delete(const profanedb::protobuf::DelReq & request)
profanedb::protobuf::DelResp profanedb::storage::Db::Delete(const protobuf::DelReq & request)
{
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment