Changeset: 8d84ca18bc45 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8d84ca18bc45 Added Files: common/stream/mhapi.c common/stream/mhapi.h Modified Files: bootstrap clients/mapilib/Makefile.ag clients/mapilib/mapi.c common/stream/Makefile.ag common/stream/stream.c sql/backends/monet5/Makefile.ag sql/backends/monet5/sql_result.c Branch: protocol Log Message:
protbuf working diffs (truncated from 590 to 300 lines): diff --git a/bootstrap b/bootstrap --- a/bootstrap +++ b/bootstrap @@ -61,4 +61,4 @@ if [ -f buildtools/conf/install-sh -a ! fi -protoc-c common/stream/mhapi.proto --c_out . +# protoc-c common/stream/mhapi.proto --c_out . diff --git a/clients/mapilib/Makefile.ag b/clients/mapilib/Makefile.ag --- a/clients/mapilib/Makefile.ag +++ b/clients/mapilib/Makefile.ag @@ -13,7 +13,7 @@ lib_mapi = { VERSION = $(MAPI_VERSION) SOURCES = mapi.c mapi.rc LIBS = $(SOCKET_LIBS) ../../common/stream/libstream \ - ../../common/stream/libstream_protobuf \ + ../../common/stream/libprotobuf \ ../../common/options/libmoptions \ ../../common/utils/libmcrypt $(openssl_LIBS) $(pfor_LIBS) $(protobuf_LIBS) } diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -5534,7 +5534,7 @@ mapi_split_line(MapiHdl hdl) } #ifdef HAVE_LIBPROTOBUF -#include <mhapi.pb-c.h> +#include <mhapi.h> #endif int @@ -5577,11 +5577,16 @@ mapi_fetch_row(MapiHdl hdl) if (hdl->mid->colcomp == COLUMN_COMPRESSION_PROTOBUF) { - buffer buf = bs2_buffer(hdl->mid->from); + char dummy; + buffer buf; #ifndef HAVE_LIBPROTOBUF // TODO: complain #else - Mhapi__QueryResult *res = mhapi__query_result__unpack(NULL, buf.pos, (const uint8_t *) buf.buf); + bs2_resetbuf(hdl->mid->from); + mnstr_readChr(hdl->mid->from, &dummy); + buf = bs2_buffer(hdl->mid->from); + Mhapi__QueryResult *res = mhapi__query_result__unpack(NULL, buf.len + buf.pos, (const uint8_t *) buf.buf); + assert(res); assert(res->row_count <= result->row_count); assert(res->n_columns == (size_t) result->fieldcnt); @@ -5600,7 +5605,7 @@ mapi_fetch_row(MapiHdl hdl) result->tuple_count += res->row_count; result->rows_read++; if(hdl->mid->protobuf_res) { - free(hdl->mid->protobuf_res); + mhapi__query_result__free_unpacked(NULL, hdl->mid->protobuf_res); } hdl->mid->protobuf_res = (void*) res; return result->fieldcnt; diff --git a/common/stream/Makefile.ag b/common/stream/Makefile.ag --- a/common/stream/Makefile.ag +++ b/common/stream/Makefile.ag @@ -31,9 +31,9 @@ lib_stream = { $(LTLIBICONV) } -lib_stream_protobuf = { +lib_protobuf = { COND = HAVE_LIBPROTOBUF - SOURCES = mhapi.pb-c.h mhapi.pb-c.c + SOURCES = mhapi.c mhapi.h VERSION = 42 LIBS = $(protobuf_LIBS) } diff --git a/common/stream/mhapi.c b/common/stream/mhapi.c new file mode 100644 --- /dev/null +++ b/common/stream/mhapi.c @@ -0,0 +1,283 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: common/stream/mhapi.proto */ + +/* Do not generate deprecated warnings for self */ +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED +#endif + +#include "common/stream/mhapi.h" +void mhapi__query_result__column__init + (Mhapi__QueryResult__Column *message) +{ + static Mhapi__QueryResult__Column init_value = MHAPI__QUERY_RESULT__COLUMN__INIT; + *message = init_value; +} +void mhapi__query_result__column_unpacked__init + (Mhapi__QueryResult__ColumnUnpacked *message) +{ + static Mhapi__QueryResult__ColumnUnpacked init_value = MHAPI__QUERY_RESULT__COLUMN_UNPACKED__INIT; + *message = init_value; +} +void mhapi__query_result__init + (Mhapi__QueryResult *message) +{ + static Mhapi__QueryResult init_value = MHAPI__QUERY_RESULT__INIT; + *message = init_value; +} +size_t mhapi__query_result__get_packed_size + (const Mhapi__QueryResult *message) +{ + assert(message->base.descriptor == &mhapi__query_result__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t mhapi__query_result__pack + (const Mhapi__QueryResult *message, + uint8_t *out) +{ + assert(message->base.descriptor == &mhapi__query_result__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t mhapi__query_result__pack_to_buffer + (const Mhapi__QueryResult *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &mhapi__query_result__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Mhapi__QueryResult * + mhapi__query_result__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Mhapi__QueryResult *) + protobuf_c_message_unpack (&mhapi__query_result__descriptor, + allocator, len, data); +} +void mhapi__query_result__free_unpacked + (Mhapi__QueryResult *message, + ProtobufCAllocator *allocator) +{ + assert(message->base.descriptor == &mhapi__query_result__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +static const ProtobufCFieldDescriptor mhapi__query_result__column__field_descriptors[4] = +{ + { + "string_values", + 4, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_STRING, + offsetof(Mhapi__QueryResult__Column, n_string_values), + offsetof(Mhapi__QueryResult__Column, string_values), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "int64_values", + 5, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_INT64, + offsetof(Mhapi__QueryResult__Column, n_int64_values), + offsetof(Mhapi__QueryResult__Column, int64_values), + NULL, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "int32_values", + 6, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_INT32, + offsetof(Mhapi__QueryResult__Column, n_int32_values), + offsetof(Mhapi__QueryResult__Column, int32_values), + NULL, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "double_values", + 7, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_DOUBLE, + offsetof(Mhapi__QueryResult__Column, n_double_values), + offsetof(Mhapi__QueryResult__Column, double_values), + NULL, + NULL, + 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned mhapi__query_result__column__field_indices_by_name[] = { + 3, /* field[3] = double_values */ + 2, /* field[2] = int32_values */ + 1, /* field[1] = int64_values */ + 0, /* field[0] = string_values */ +}; +static const ProtobufCIntRange mhapi__query_result__column__number_ranges[1 + 1] = +{ + { 4, 0 }, + { 0, 4 } +}; +const ProtobufCMessageDescriptor mhapi__query_result__column__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "mhapi.QueryResult.Column", + "Column", + "Mhapi__QueryResult__Column", + "mhapi", + sizeof(Mhapi__QueryResult__Column), + 4, + mhapi__query_result__column__field_descriptors, + mhapi__query_result__column__field_indices_by_name, + 1, mhapi__query_result__column__number_ranges, + (ProtobufCMessageInit) mhapi__query_result__column__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor mhapi__query_result__column_unpacked__field_descriptors[4] = +{ + { + "string_values", + 4, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_STRING, + offsetof(Mhapi__QueryResult__ColumnUnpacked, n_string_values), + offsetof(Mhapi__QueryResult__ColumnUnpacked, string_values), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "int64_values", + 5, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_INT64, + offsetof(Mhapi__QueryResult__ColumnUnpacked, n_int64_values), + offsetof(Mhapi__QueryResult__ColumnUnpacked, int64_values), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "int32_values", + 6, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_INT32, + offsetof(Mhapi__QueryResult__ColumnUnpacked, n_int32_values), + offsetof(Mhapi__QueryResult__ColumnUnpacked, int32_values), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "double_values", + 7, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_DOUBLE, + offsetof(Mhapi__QueryResult__ColumnUnpacked, n_double_values), + offsetof(Mhapi__QueryResult__ColumnUnpacked, double_values), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned mhapi__query_result__column_unpacked__field_indices_by_name[] = { + 3, /* field[3] = double_values */ + 2, /* field[2] = int32_values */ + 1, /* field[1] = int64_values */ + 0, /* field[0] = string_values */ +}; +static const ProtobufCIntRange mhapi__query_result__column_unpacked__number_ranges[1 + 1] = +{ + { 4, 0 }, + { 0, 4 } +}; +const ProtobufCMessageDescriptor mhapi__query_result__column_unpacked__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "mhapi.QueryResult.ColumnUnpacked", + "ColumnUnpacked", + "Mhapi__QueryResult__ColumnUnpacked", + "mhapi", + sizeof(Mhapi__QueryResult__ColumnUnpacked), + 4, + mhapi__query_result__column_unpacked__field_descriptors, + mhapi__query_result__column_unpacked__field_indices_by_name, + 1, mhapi__query_result__column_unpacked__number_ranges, + (ProtobufCMessageInit) mhapi__query_result__column_unpacked__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor mhapi__query_result__field_descriptors[3] = _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list