read-actions.h 2.52 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"
Matthieu Dorier's avatar
Matthieu Dorier committed
10
#include "buffer-union.h"
11 12 13 14 15

typedef enum {
	READ_OPCODE_BASE = 0,
	READ_OPCODE_STAT,
	READ_OPCODE_READ,
16
	READ_OPCODE_OMAP_GET_KEYS,
17 18
	READ_OPCODE_OMAP_GET_VALS,
	READ_OPCODE_OMAP_GET_VALS_BY_KEYS,
19
	_READ_OPCODE_END_ENUM_
20 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
} 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
48
	buffer_u              buffer;
49 50 51 52
	size_t*               bytes_read;
	int*                  prval;
}* rd_action_read_t;

53 54 55 56 57 58 59 60 61 62 63
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)

64 65 66 67 68 69 70
typedef struct rd_action_OMAP_GET_VALS {
	struct rd_action_BASE base;
	const char*           start_after;
	const char*           filter_prefix;
    uint64_t              max_return;
    mobject_store_omap_iter_t* iter;
    int*                  prval;
71
	size_t                data_size;
72 73 74 75 76 77 78
	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;
79
	size_t                num_keys;
80 81
	mobject_store_omap_iter_t* iter;
	int*                  prval;
82 83
	size_t                data_size;
	char                  data[1];
84
}* rd_action_omap_get_vals_by_keys_t;
85
// data is a contiguous buffer holding all
86 87
// the null-terminated keys
#endif