Skip to content

Commit

Permalink
phia: rename API methods and re-wrap phia.h
Browse files Browse the repository at this point in the history
No semantical code changes.
  • Loading branch information
rtsisyk committed May 20, 2016
1 parent 999c07a commit 2d7d5f1
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 91 deletions.
24 changes: 12 additions & 12 deletions src/box/phia.c
Original file line number Diff line number Diff line change
Expand Up @@ -13890,7 +13890,7 @@ phia_env_get_scheduler(struct phia_env *env)
}

const char *
phia_env_get_error(struct phia_env *env)
phia_error(struct phia_env *env)
{
static char error[128];
error[0] = 0;
Expand All @@ -13899,7 +13899,7 @@ phia_env_get_error(struct phia_env *env)
}

static struct phia_document *
phia_document_new(struct phia_env*, struct phia_index *, const struct sv*);
phia_document_newv(struct phia_env*, struct phia_index *, const struct sv*);

int
phia_document_delete(struct phia_document *v)
Expand Down Expand Up @@ -14007,7 +14007,7 @@ enum {
};

int
phia_env_open(struct phia_env *e)
phia_recover(struct phia_env *e)
{
/* recover phases */
int status = sr_status(&e->status);
Expand Down Expand Up @@ -14630,7 +14630,7 @@ phia_confcursor_next(struct phia_confcursor *c, const char **key,
}

struct phia_confcursor *
phia_confcursor(struct phia_env *e)
phia_confcursor_new(struct phia_env *e)
{
struct phia_confcursor *c;
c = ss_malloc(&e->a, sizeof(struct phia_confcursor));
Expand Down Expand Up @@ -14669,7 +14669,7 @@ phia_cursor_delete(struct phia_cursor *c)
}

struct phia_document *
phia_cursor_get(struct phia_cursor *c, struct phia_document *key)
phia_cursor_next(struct phia_cursor *c, struct phia_document *key)
{
struct phia_index *db = key->db;
if (unlikely(! key->orderset))
Expand All @@ -14693,7 +14693,7 @@ phia_cursor_set_read_commited(struct phia_cursor *c, bool read_commited)
}

struct phia_cursor *
phia_cursor(struct phia_index *db)
phia_cursor_new(struct phia_index *db)
{
struct phia_env *e = db->env;
struct phia_cursor *c;
Expand Down Expand Up @@ -15005,7 +15005,7 @@ phia_index_result(struct phia_env *e, struct scread *r)
sv_init(&result, &sv_vif, r->result, NULL);
r->result = NULL;

struct phia_document *v = phia_document_new(e, r->db, &result);
struct phia_document *v = phia_document_newv(e, r->db, &result);
if (unlikely(v == NULL))
return NULL;
v->cache_only = r->arg.cache_only;
Expand Down Expand Up @@ -15073,7 +15073,7 @@ phia_index_read(struct phia_index *db, struct phia_document *o,
if (unlikely(rc == -1 || rc == 2 /* delete */))
goto error;
if (rc == 1 && !sv_is(&vup, SVUPSERT)) {
ret = phia_document_new(e, db, &vup);
ret = phia_document_newv(e, db, &vup);
if (likely(ret)) {
ret->cache_only = o->cache_only;
ret->oldest_only = o->oldest_only;
Expand Down Expand Up @@ -15419,7 +15419,7 @@ phia_document_lsn(struct phia_document *v)
}

static struct phia_document *
phia_document_new(struct phia_env *e, struct phia_index *db, const struct sv *vp)
phia_document_newv(struct phia_env *e, struct phia_index *db, const struct sv *vp)
{
struct phia_document *doc;
doc = ss_malloc(&e->a, sizeof(struct phia_document));
Expand Down Expand Up @@ -15520,7 +15520,7 @@ phia_delete(struct phia_tx *tx, struct phia_document *key)
}

struct phia_document *
phia_tx_get(struct phia_tx *t, struct phia_document *key)
phia_get(struct phia_tx *t, struct phia_document *key)
{
struct phia_index *db = key->db;
struct phia_env *e = db->env;
Expand Down Expand Up @@ -15755,10 +15755,10 @@ phia_env_new(void)
}

struct phia_document *
phia_document(struct phia_index *db)
phia_document_new(struct phia_index *db)
{
struct phia_env *env = db->env;
return phia_document_new(env, db, NULL);
return phia_document_newv(env, db, NULL);
}

struct phia_service *
Expand Down
106 changes: 63 additions & 43 deletions src/box/phia.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifdef __cplusplus
extern "C" {
#endif

#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

struct phia_env;
struct phia_service;
struct phia_tx;
Expand All @@ -48,77 +49,86 @@ struct phia_confcursor;
struct phia_confkv;
struct key_def;

/*
* Environment
*/

struct phia_env *
phia_env_new(void);

int
phia_env_open(struct phia_env *e);

int
phia_env_delete(struct phia_env *e);

const char *
phia_env_get_error(struct phia_env *e);

struct phia_tx *
phia_begin(struct phia_env *e);
phia_error(struct phia_env *e);

int
phia_replace(struct phia_tx *tx, struct phia_document *doc);

int
phia_upsert(struct phia_tx *tx, struct phia_document *doc);
struct phia_confcursor *
phia_confcursor_new(struct phia_env *env);

int
phia_delete(struct phia_tx *tx, struct phia_document *doc);
void
phia_confcursor_delete(struct phia_confcursor *confcursor);

int
phia_commit(struct phia_tx *tx);
phia_confcursor_next(struct phia_confcursor *confcursor, const char **key,
const char **value);

int
phia_rollback(struct phia_tx *tx);
phia_recover(struct phia_env *env);

int
phia_checkpoint(struct phia_env *env);

bool
phia_checkpoint_is_active(struct phia_env *env);

struct phia_document *
phia_document(struct phia_index *index);
/*
* Workers
*/

struct phia_service *
phia_service_new(struct phia_env *env);

int
phia_service_do(struct phia_service *srv);
void
phia_service_delete(struct phia_service *srv);

struct phia_cursor *
phia_cursor(struct phia_index *index);
void
phia_cursor_delete(struct phia_cursor *cursor);
void
phia_cursor_set_read_commited(struct phia_cursor *cursor, bool read_commited);
struct phia_document *
phia_cursor_get(struct phia_cursor *cursor, struct phia_document *key);
phia_service_delete(struct phia_service *srv);

/*
* Configuration
* Transaction
*/
struct phia_confcursor *
phia_confcursor(struct phia_env *env);

void
phia_confcursor_delete(struct phia_confcursor *c);
struct phia_tx *
phia_begin(struct phia_env *e);

struct phia_document *
phia_get(struct phia_tx *tx, struct phia_document *key);

int
phia_confcursor_next(struct phia_confcursor *c, const char **key,
const char **value);
phia_replace(struct phia_tx *tx, struct phia_document *doc);

int
phia_upsert(struct phia_tx *tx, struct phia_document *doc);

int
phia_delete(struct phia_tx *tx, struct phia_document *doc);

int
phia_commit(struct phia_tx *tx);

int
phia_rollback(struct phia_tx *tx);

void
phia_tx_set_lsn(struct phia_tx *tx, int64_t lsn);

void
phia_tx_set_half_commit(struct phia_tx *tx, bool half_commit);

/*
* Index
*/

struct phia_index *
phia_index_by_name(struct phia_env *env, const char *name);

Expand Down Expand Up @@ -146,14 +156,21 @@ phia_index_bsize(struct phia_index *db);
uint64_t
phia_index_size(struct phia_index *db);

/*
* Index Cursor
*/

struct phia_cursor *
phia_cursor_new(struct phia_index *index);

void
phia_tx_set_lsn(struct phia_tx *tx, int64_t lsn);
phia_cursor_delete(struct phia_cursor *cursor);

void
phia_tx_set_half_commit(struct phia_tx *tx, bool half_commit);
phia_cursor_set_read_commited(struct phia_cursor *cursor, bool read_commited);

struct phia_document *
phia_tx_get(struct phia_tx *t, struct phia_document *key);
phia_cursor_next(struct phia_cursor *cursor, struct phia_document *key);

/*
* Document
Expand All @@ -167,18 +184,21 @@ enum phia_order {
PHIA_EQ
};

struct phia_document *
phia_document_new(struct phia_index *index);

int
phia_document_open(struct phia_document *v);
phia_document_delete(struct phia_document *doc);

int
phia_document_delete(struct phia_document *v);
phia_document_open(struct phia_document *doc);

int
phia_document_set_field(struct phia_document *doc, const char *path,
const char *value, int size);

char *
phia_document_field(struct phia_document *v, const char *path, int *size);
phia_document_field(struct phia_document *doc, const char *path, int *size);

void
phia_document_set_cache_only(struct phia_document *doc, bool cache_only);
Expand Down

0 comments on commit 2d7d5f1

Please sign in to comment.