more
This commit is contained in:
parent
dd44e5f994
commit
194ffc9438
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "tstring.h"
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
|
|
||||||
typedef struct _scolumn {
|
typedef struct _scolumn {
|
||||||
|
@ -15,4 +16,25 @@ typedef struct SSchema {
|
||||||
SColumn *columns;
|
SColumn *columns;
|
||||||
} SSchema;
|
} SSchema;
|
||||||
|
|
||||||
|
// Column with version
|
||||||
|
typedef struct {
|
||||||
|
td_datatype_t type;
|
||||||
|
int32_t colId;
|
||||||
|
int32_t bytes;
|
||||||
|
} SVColumn;
|
||||||
|
|
||||||
|
// Schema with version
|
||||||
|
typedef struct {
|
||||||
|
int32_t version; // Schema with version
|
||||||
|
int32_t numOfCols;
|
||||||
|
int32_t columnId;
|
||||||
|
SVColumn *columns;
|
||||||
|
} SVSchema;
|
||||||
|
|
||||||
|
int32_t tdAddColumnToSchema(tstring_t pSchema, SColumn col);
|
||||||
|
|
||||||
|
td_datatype_t tdGetTypeOfCol(SSchema *pSchema, int32_t col);
|
||||||
|
int32_t tdGetLengthOfCol(SSchema *pSchema, int32_t col);
|
||||||
|
|
||||||
|
|
||||||
#endif // _TD_SCHEMA_H_
|
#endif // _TD_SCHEMA_H_
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "schema.h"
|
||||||
|
|
||||||
/* The row data should in the form of
|
/* The row data should in the form of
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
/* A dynamic string library
|
||||||
|
*/
|
||||||
|
#if !defined(_TD_TSTRING_H_)
|
||||||
|
#define _TD_TSTRING_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef char* tstring_t;
|
||||||
|
|
||||||
|
// The string header
|
||||||
|
typedef struct {
|
||||||
|
int32_t strLen; // Allocated data space
|
||||||
|
int32_t avail; // Available space
|
||||||
|
char data[];
|
||||||
|
} STStrHdr;
|
||||||
|
|
||||||
|
// Get the data length of the string
|
||||||
|
#define TSTRLEN(pstr) ((STStrHdr *)pstr)->strLen
|
||||||
|
// Get the available space
|
||||||
|
#define TSTRAVAIL(pstr) ((STStrHdr *)pstr)->avail
|
||||||
|
// Get the real allocated string length
|
||||||
|
#define TSTRRLEN(pstr) ((STStrHdr *)pstr)->strLen + sizeof(STStrHdr)
|
||||||
|
|
||||||
|
#endif // _TD_TSTRING_H_
|
Loading…
Reference in New Issue