read-actions.h 2.54 KB
Newer Older
1 2 3 4 5 6 7 8 9
/*
 * (C) 2017 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */
#ifndef __MOBJECT_READ_OPCODES_H
#define __MOBJECT_READ_OPCODES_H

#include "mobject-store-config.h"
10
#include "libmobject-store.h"
Matthieu Dorier's avatar
Matthieu Dorier committed
11
#include "buffer-union.h"
12 13 14 15 16

typedef enum {
	READ_OPCODE_BASE = 0,
	READ_OPCODE_STAT,
	READ_OPCODE_READ,
17
	READ_OPCODE_OMAP_GET_KEYS,
18 19
	READ_OPCODE_OMAP_GET_VALS,
	READ_OPCODE_OMAP_GET_VALS_BY_KEYS,
20
	_READ_OPCODE_END_ENUM_
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
} read_op_code_t;

#define READ_ACTION_DOWNCAST(child_obj, base_obj, child_category) \
	if(READ_OPCODE_ ## child_category != base_obj->type) {\
		MOBJECT_LOG("Downcast error: " #base_obj " is not of type READ_ACTION_" #child_category);\
	}\
struct rd_action_ ## child_category * child_obj = (struct rd_action_ ## child_category *) base_obj;

#define READ_ACTION_UPCAST(base_obj, child_obj) \
    struct rd_action_BASE* base_obj = (struct rd_action_BASE*) child_obj;

typedef struct rd_action_BASE {
	read_op_code_t          type;
	struct rd_action_BASE* prev;
	struct rd_action_BASE* next;
}* rd_action_base_t;

typedef struct rd_action_STAT {
	struct rd_action_BASE base;
	uint64_t*             psize;
	time_t*               pmtime;
	int*                  prval;
}* rd_action_stat_t;

typedef struct rd_action_READ {
	struct rd_action_BASE base;
	uint64_t              offset;
	size_t                len;
Matthieu Dorier's avatar
Matthieu Dorier committed
49
	buffer_u              buffer;
50 51 52 53
	size_t*               bytes_read;
	int*                  prval;
}* rd_action_read_t;

54 55 56 57 58 59 60 61 62 63 64
typedef struct rd_action_OMAP_GET_KEYS {
	struct rd_action_BASE base;
	const char*           start_after;
	uint64_t              max_return;
	mobject_store_omap_iter_t*    iter;
	int*                  prval;
	size_t                data_size;
	char                  data[1];
}* rd_action_omap_get_keys_t;
// data field here to hold embedded data (start_after)

65 66 67 68
typedef struct rd_action_OMAP_GET_VALS {
	struct rd_action_BASE base;
	const char*           start_after;
	const char*           filter_prefix;
69 70 71
	uint64_t              max_return;
	mobject_store_omap_iter_t* iter;
	int*                  prval;
72
	size_t                data_size;
73 74 75 76 77 78 79
	char                  data[1];
}* rd_action_omap_get_vals_t;
// data field here to hold embedded data (start_after 
// and filter_prefix strings)

typedef struct rd_action_OMAP_GET_VALS_BY_KEYS {
	struct rd_action_BASE base;
80
	size_t                num_keys;
81 82
	mobject_store_omap_iter_t* iter;
	int*                  prval;
83 84
	size_t                data_size;
	char                  data[1];
85
}* rd_action_omap_get_vals_by_keys_t;
86
// data is a contiguous buffer holding all
87 88
// the null-terminated keys
#endif