more
This commit is contained in:
parent
473586ef77
commit
2da826f955
|
@ -1,7 +1,9 @@
|
||||||
#if !defined(_TD_TYPE_H_)
|
#if !defined(_TD_TYPE_H_)
|
||||||
#define _TD_TYPE_H_
|
#define _TD_TYPE_H_
|
||||||
|
|
||||||
typedef enum {
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef enum : uint8_t {
|
||||||
TD_DATATYPE_INVLD = 0,
|
TD_DATATYPE_INVLD = 0,
|
||||||
TD_DATATYPE_BOOL,
|
TD_DATATYPE_BOOL,
|
||||||
TD_DATATYPE_TINYINT,
|
TD_DATATYPE_TINYINT,
|
||||||
|
|
|
@ -4,21 +4,37 @@
|
||||||
#define _TD_TSTRING_H_
|
#define _TD_TSTRING_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define TD_TSTRING_INIT_SIZE 16
|
||||||
|
|
||||||
typedef char* tstring_t;
|
typedef char* tstring_t;
|
||||||
|
|
||||||
// The string header
|
// The string header
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t strLen; // Allocated data space
|
int32_t space; // Allocated data space
|
||||||
int32_t avail; // Available space
|
|
||||||
char data[];
|
char data[];
|
||||||
} STStrHdr;
|
} STStrHdr;
|
||||||
|
|
||||||
// Get the data length of the string
|
// Get the data length of the string
|
||||||
#define TSTRLEN(pstr) ((STStrHdr *)pstr)->strLen
|
#define TSTRLEN(pstr) strlen((char *)pstr)
|
||||||
// Get the available space
|
|
||||||
#define TSTRAVAIL(pstr) ((STStrHdr *)pstr)->avail
|
|
||||||
// Get the real allocated string length
|
// Get the real allocated string length
|
||||||
#define TSTRRLEN(pstr) ((STStrHdr *)pstr)->strLen + sizeof(STStrHdr)
|
#define TSTRSPACE(pstr) (*(int32_t *)((char *)pstr - sizeof(STStrHdr)))
|
||||||
|
// Get the available space
|
||||||
|
#define TSTAVAIL(pstr) (TSTRSPACE(pstr) - TSTRLEN(pstr))
|
||||||
|
|
||||||
|
// Create an empty tstring with default size
|
||||||
|
tstring_t tdNewTString();
|
||||||
|
// Create an empty tstring with size
|
||||||
|
tstring_t tdNewTStringWithSize(uint32_t size);
|
||||||
|
// Create a tstring with a init value
|
||||||
|
tstring_t tdNewTStringWithValue(char *value);
|
||||||
|
// Create a tstring with a init value & size
|
||||||
|
tstring_t tdNewTStringWithValueSize(char *value, uint32_t size);
|
||||||
|
|
||||||
|
tstring_t tstrcat(tstring_t dest, tstring_t src);
|
||||||
|
int32_t tstrcmp(tstring_t str1, tstring_t str2);
|
||||||
|
int32_t tstrncmp(tstring_t str1, tstring_t str2, int32_t n);
|
||||||
|
|
||||||
|
|
||||||
#endif // _TD_TSTRING_H_
|
#endif // _TD_TSTRING_H_
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#if !defined(_TD_TSDB_FILE_H_)
|
||||||
|
#define _TD_TSDB_FILE_H_
|
||||||
|
|
||||||
|
#include "tstring.h"
|
||||||
|
|
||||||
|
typedef int32_t file_id_t;
|
||||||
|
|
||||||
|
typedef enum : uint8_t {
|
||||||
|
TSDB_FILE_TYPE_HEAD,
|
||||||
|
TSDB_FILE_TYPE_DATA,
|
||||||
|
TSDB_FILE_TYPE_LAST,
|
||||||
|
TSDB_FILE_TYPE_META
|
||||||
|
} TSDB_FILE_TYPE;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int64_t fileSize;
|
||||||
|
} SFileInfo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
tstring_t fname;
|
||||||
|
SFileInfo;
|
||||||
|
} SFILE;
|
||||||
|
|
||||||
|
tstring_t tdGetHeadFileName(/* TODO */);
|
||||||
|
tstring_t tdGetDataFileName(/* TODO */);
|
||||||
|
tstring_t tdGetLastFileName(/* TODO */);
|
||||||
|
tstring_t tdGetMetaFileName(/* TODO */);
|
||||||
|
|
||||||
|
#endif // _TD_TSDB_FILE_H_
|
|
@ -51,6 +51,9 @@ typedef struct STable {
|
||||||
|
|
||||||
// Tag values for this table
|
// Tag values for this table
|
||||||
char *pTagVal;
|
char *pTagVal;
|
||||||
|
|
||||||
|
// Cached data
|
||||||
|
SSkipList *pData;
|
||||||
} STable;
|
} STable;
|
||||||
|
|
||||||
#define TSDB_GET_TABLE_ID(pTable) (((STable *)pTable)->tid).tableId
|
#define TSDB_GET_TABLE_ID(pTable) (((STable *)pTable)->tid).tableId
|
||||||
|
|
Loading…
Reference in New Issue