Ejemplo n.º 1
0
static int
tnt_log_process_xlog(struct tnt_log *l, char *buf, uint32_t size,
		     union tnt_log_value *value)
{
	(void)size;
	/* copying row data */
	memcpy(&l->current.row, buf, sizeof(l->current.row));

	/* preparing pseudo iproto header */
	struct tnt_header hdr_iproto;
	hdr_iproto.type = l->current.row.op;
	hdr_iproto.len = l->current.hdr.len - sizeof(l->current.row);
	hdr_iproto.reqid = 0;

	/* deserializing operation */
	tnt_request_init(&value->r);
	size_t off = 0;
	int rc = tnt_request(&value->r,
			     buf + sizeof(l->current.row),
			     l->current.hdr.len - sizeof(l->current.row),
			     &off,
			     &hdr_iproto);

	/* in case of not completed request or parsing error */
	if (rc != 0)
		return tnt_log_seterr(l, TNT_LOG_ECORRUPT);
	return 0;
}
Ejemplo n.º 2
0
static int tnt_iter_request_next(struct tnt_iter *i) {
	struct tnt_iter_request *ir = TNT_IREQUEST(i);
	tnt_request_free(&ir->r);
	tnt_request_init(&ir->r);
	int rc = ir->s->read_request(ir->s, &ir->r);
	if (rc == -1) {
		i->status = TNT_ITER_FAIL;
		return 0;
	}
	return (rc == 1 /* finish */ ) ? 0 : 1;
}
Ejemplo n.º 3
0
/*
 * tnt_iter_request()
 *
 * initialize tuple request iterator;
 * create and initialize request iterator;
 *
 * i - tuple request iterator pointer, maybe NULL
 * s - stream pointer
 * 
 * if stream iterator pointer is NULL, then new stream
 * iterator will be created. 
 *
 * returns stream iterator pointer, or NULL on error.
*/
struct tnt_iter *tnt_iter_request(struct tnt_iter *i, struct tnt_stream *s) {
	i = tnt_iter_init(i);
	if (i == NULL)
		return NULL;
	i->type = TNT_ITER_REQUEST;
	i->next = tnt_iter_request_next;
	i->rewind = NULL;
	i->free = tnt_iter_request_free;
	struct tnt_iter_request *ir = TNT_IREQUEST(i);
	ir->s = s;
	tnt_request_init(&ir->r);
	return i;
}