more
This commit is contained in:
parent
89f9caeadd
commit
274d115a05
|
@ -17,53 +17,77 @@
|
||||||
#define _TD_COMMON_ROW_H_
|
#define _TD_COMMON_ROW_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "tbuffer.h"
|
||||||
|
#include "tdef.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// types
|
#define TD_OR_ROW 0
|
||||||
typedef void * SRow;
|
#define TD_KV_ROW 1
|
||||||
typedef struct SRowBatch SRowBatch;
|
|
||||||
typedef struct SRowBuilder SRowBuilder;
|
|
||||||
typedef struct SRowBatchIter SRowBatchIter;
|
|
||||||
typedef struct SRowBatchBuilder SRowBatchBuilder;
|
|
||||||
|
|
||||||
// SRow
|
typedef uint16_t col_id_t;
|
||||||
#define ROW_HEADER_SIZE (sizeof(uint8_t) + 2 * sizeof(uint16_t) + sizeof(uint64_t))
|
|
||||||
#define rowType(r) (*(uint8_t *)(r)) // row type
|
|
||||||
#define rowLen(r) (*(uint16_t *)POINTER_SHIFT(r, sizeof(uint8_t))) // row length
|
|
||||||
#define rowSVer(r) \
|
|
||||||
(*(uint16_t *)POINTER_SHIFT(r, sizeof(uint8_t) + sizeof(uint16_t))) // row schema version, only for SDataRow
|
|
||||||
#define rowNCols(r) rowSVer(r) // only for SKVRow
|
|
||||||
#define rowVer(r) (*(uint64_t)POINTER_SHIFT(r, sizeof(uint8_t) + 2 * sizeof(uint16_t))) // row version
|
|
||||||
#define rowCopy(dest, r) memcpy((dest), r, rowLen(r))
|
|
||||||
|
|
||||||
static FORCE_INLINE SRow rowDup(SRow row) {
|
typedef struct {
|
||||||
SRow r = malloc(rowLen(row));
|
TSKEY ts;
|
||||||
if (r == NULL) {
|
} SOrRow;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
rowCopy(r, row);
|
typedef struct {
|
||||||
|
col_id_t cid;
|
||||||
|
uint32_t offset;
|
||||||
|
} SKvRowIdx;
|
||||||
|
|
||||||
return r;
|
typedef struct {
|
||||||
}
|
uint16_t ncols;
|
||||||
|
SKvRowIdx cidx[];
|
||||||
|
} SKvRow;
|
||||||
|
|
||||||
// SRowBatch
|
typedef struct {
|
||||||
|
union {
|
||||||
|
/// union field for encode and decode
|
||||||
|
uint64_t info;
|
||||||
|
struct {
|
||||||
|
/// row type
|
||||||
|
uint64_t type : 2;
|
||||||
|
/// row schema version
|
||||||
|
uint64_t sver : 16;
|
||||||
|
/// row total length
|
||||||
|
uint64_t len : 46;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/// row version
|
||||||
|
uint64_t ver;
|
||||||
|
/// timestamp of the row
|
||||||
|
TSKEY ts;
|
||||||
|
char content[];
|
||||||
|
} SRow;
|
||||||
|
|
||||||
// SRowBuilder
|
typedef enum {
|
||||||
SRowBuilder *rowBuilderCreate();
|
/// ordinary row builder
|
||||||
void rowBuilderDestroy(SRowBuilder *);
|
TD_OR_ROW_BUILDER = 0,
|
||||||
|
/// kv row builder
|
||||||
|
TD_KV_ROW_BUILDER,
|
||||||
|
/// self-determined row builder
|
||||||
|
TD_SD_ROW_BUILDER
|
||||||
|
} ERowBbuilderT;
|
||||||
|
|
||||||
// SRowBatchIter
|
typedef struct {
|
||||||
SRowBatchIter *rowBatchIterCreate(SRowBatch *);
|
/// row builder type
|
||||||
void rowBatchIterDestroy(SRowBatchIter *);
|
ERowBbuilderT type;
|
||||||
const SRow rowBatchIterNext(SRowBatchIter *);
|
/// buffer writer
|
||||||
|
SBufferWriter bw;
|
||||||
|
/// target row
|
||||||
|
SRow *pRow;
|
||||||
|
} SRowBuilder;
|
||||||
|
|
||||||
// SRowBatchBuilder
|
typedef struct {
|
||||||
SRowBatchBuilder *rowBatchBuilderCreate();
|
/* TODO */
|
||||||
void rowBatchBuilderDestroy(SRowBatchBuilder *);
|
} SRowBatchBuilder;
|
||||||
|
|
||||||
|
#define tRBInit(type, allocator, endian) \
|
||||||
|
{ .type = (type), tbufInitWriter(allocator, endian), NULL }
|
||||||
|
void tRBClear(SRowBuilder *pRB);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,28 @@
|
||||||
#ifndef _TD_COMMON_SCHEMA_H_
|
#ifndef _TD_COMMON_SCHEMA_H_
|
||||||
#define _TD_COMMON_SCHEMA_H_
|
#define _TD_COMMON_SCHEMA_H_
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef struct SColAttr {
|
||||||
|
/* data */
|
||||||
|
} SColAttr;
|
||||||
|
|
||||||
|
typedef struct SColumn {
|
||||||
|
uint8_t type;
|
||||||
|
uint16_t cid;
|
||||||
|
uint16_t bytes;
|
||||||
|
} SColumn;
|
||||||
|
|
||||||
|
typedef struct SSchema {
|
||||||
|
/// schema version
|
||||||
|
uint16_t sver;
|
||||||
|
/* data */
|
||||||
|
} SSchema;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,11 +41,13 @@ void metaOptionsClear(SMetaOptions *pOptions);
|
||||||
|
|
||||||
// STableOpts
|
// STableOpts
|
||||||
#define META_TABLE_OPTS_DECLARE(name) STableOpts name = {0}
|
#define META_TABLE_OPTS_DECLARE(name) STableOpts name = {0}
|
||||||
void metaNormalTableOptsInit(STbOptions *pTbOptions, const char *name, const STSchema *pSchema);
|
void metaNormalTableOptsInit(STbOptions *pTbOptions, const char *name, const STSchema *pSchema);
|
||||||
void metaSuperTableOptsInit(STbOptions *pTbOptions, const char *name, tb_uid_t uid, const STSchema *pSchema,
|
void metaSuperTableOptsInit(STbOptions *pTbOptions, const char *name, tb_uid_t uid, const STSchema *pSchema,
|
||||||
const STSchema *pTagSchema);
|
const STSchema *pTagSchema);
|
||||||
void metaChildTableOptsInit(STbOptions *pTbOptions, const char *name, tb_uid_t suid, const SKVRow tags);
|
void metaChildTableOptsInit(STbOptions *pTbOptions, const char *name, tb_uid_t suid, const SKVRow tags);
|
||||||
void metaTableOptsClear(STbOptions *pTbOptions);
|
void metaTableOptsClear(STbOptions *pTbOptions);
|
||||||
|
uint64_t metaEncodeTbOptions(void **pBuf, STbOptions *pTbOptions);
|
||||||
|
STbOptions *metaDecodeTbOptions(void *pBuf, size_t size, bool endian);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "trow.h"
|
#include "trow.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* ------------ Structures ---------- */
|
/* ------------ Structures ---------- */
|
||||||
struct SRowBatch {
|
struct SRowBatch {
|
||||||
int32_t compress : 1; // if batch row is compressed
|
int32_t compress : 1; // if batch row is compressed
|
||||||
|
@ -86,4 +87,5 @@ const SRow rowBatchIterNext(SRowBatchIter *pRowBatchIter) {
|
||||||
|
|
||||||
// SRowBatchBuilder
|
// SRowBatchBuilder
|
||||||
SRowBatchBuilder *rowBatchBuilderCreate();
|
SRowBatchBuilder *rowBatchBuilderCreate();
|
||||||
void rowBatchBuilderDestroy(SRowBatchBuilder *);
|
void rowBatchBuilderDestroy(SRowBatchBuilder *);
|
||||||
|
#endif
|
Loading…
Reference in New Issue