Exemple #1
0
static void aggregate_from(void* handle, int32_t* min, int32_t* max)
{
    unsigned char read_buffer[log_buffer_size];
    storage_len_t len;

    error_t res = logr_read(handle, read_buffer, sizeof(read_buffer), &len);
    assert (res == SUCCESS);
    assert((len % sizeof(int32_t)) == 0);

    {   int i;
        for (i=0; i< len / sizeof(int32_t); i++) {
            int32_t tmp;
            memcpy(&tmp, read_buffer + i * sizeof(int32_t), sizeof(int32_t));
            if (tmp < *min) *min = tmp;
            if (tmp > *max) *max = tmp;
        }
    }
}
Exemple #2
0
CTEST(log, read) {
	uint64_t lsn = 112;
	struct options *opts = options_new();
	struct logr *lgr = logr_open(opts, lsn);

	struct msg k;
	struct msg v;
	msgtype_t type;
	uint32_t tid;

	int i = 0;
	while (logr_read(lgr, &k, &v, &type, &tid) == NESS_OK) {
		i++;
	}

	ASSERT_EQUAL(R, i);

	logr_close(lgr);
	options_free(opts);
}