mirror of https://github.com/yandex/odyssey.git
shapito: implement so_bewrite_data_row()
This commit is contained in:
parent
348351f7ae
commit
b7285d13ed
|
@ -129,6 +129,10 @@ so_bewrite_no_data()
|
||||||
/* RowDescription */
|
/* RowDescription */
|
||||||
so_bewrite_row_description()
|
so_bewrite_row_description()
|
||||||
so_bewrite_row_description_add()
|
so_bewrite_row_description_add()
|
||||||
|
|
||||||
|
/* DataRow */
|
||||||
|
so_bewrite_data_row()
|
||||||
|
so_bewrite_data_row_add()
|
||||||
```
|
```
|
||||||
|
|
||||||
**Read messages from Frontend**
|
**Read messages from Frontend**
|
||||||
|
|
|
@ -198,6 +198,46 @@ so_bewrite_row_description_add(so_stream_t *buf, int start,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
so_bewrite_data_row(so_stream_t *buf)
|
||||||
|
{
|
||||||
|
int rc = so_stream_ensure(buf, sizeof(so_header_t) + sizeof(uint16_t));
|
||||||
|
if (so_unlikely(rc == -1))
|
||||||
|
return -1;
|
||||||
|
int position = so_stream_used(buf);
|
||||||
|
so_stream_write8(buf, 'D');
|
||||||
|
so_stream_write32(buf, sizeof(uint32_t) + sizeof(uint16_t));
|
||||||
|
so_stream_write16(buf, 0);
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
so_bewrite_data_row_add(so_stream_t *buf, int start, char *data, int32_t len)
|
||||||
|
{
|
||||||
|
int is_null = len == -1;
|
||||||
|
int size = sizeof(uint32_t) + (is_null) ? 0 : len;
|
||||||
|
int rc = so_stream_ensure(buf, size);
|
||||||
|
if (so_unlikely(rc == -1))
|
||||||
|
return -1;
|
||||||
|
so_stream_write32(buf, len);
|
||||||
|
if (! is_null)
|
||||||
|
so_stream_write(buf, (uint8_t*)data, len);
|
||||||
|
|
||||||
|
so_header_t *header;
|
||||||
|
header = (so_header_t*)(buf->s + start);
|
||||||
|
uint32_t pos_size = sizeof(uint32_t) + sizeof(uint16_t);
|
||||||
|
uint8_t *pos = (uint8_t*)&header->len;
|
||||||
|
uint32_t total_size;
|
||||||
|
uint16_t count;
|
||||||
|
so_stream_read32(&total_size, &pos, &pos_size);
|
||||||
|
so_stream_read16(&count, &pos, &pos_size);
|
||||||
|
total_size += size;
|
||||||
|
count++;
|
||||||
|
so_stream_write32to((uint8_t*)&header->len, total_size);
|
||||||
|
so_stream_write16to((uint8_t*)&header->len + sizeof(uint32_t), count);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
so_bewrite_complete(so_stream_t *buf, char *message, int len)
|
so_bewrite_complete(so_stream_t *buf, char *message, int len)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue