00001
00013 #ifndef _DRMS_RECORD_H
00014 #define _DRMS_RECORD_H
00015
00016 #include "drms_types.h"
00017 #include "db.h"
00018 #include "list.h"
00019
00020 #define kLocalSegName "local_data"
00021
00022
00023 #define kLocalPrimekey "primekey"
00024 #define kLocalPrimekeyType DRMS_TYPE_LONGLONG
00025
00026
00027 typedef enum {DRMS_COPY_SEGMENTS, DRMS_SHARE_SEGMENTS} DRMS_CloneAction_t;
00028 typedef enum {DRMS_FREE_RECORD, DRMS_INSERT_RECORD} DRMS_CloseAction_t;
00029
00030
00031
00032
00033
00034
00036 typedef enum {DRMS_QUERY_COUNT, DRMS_QUERY_FL, DRMS_QUERY_ALL, DRMS_QUERY_N, DRMS_QUERY_PARTIAL} DRMS_QueryType_t;
00037
00038
00039 enum DRMS_RecChunking_enum
00040 {
00041 kRecChunking_None = 0,
00042 kRecChunking_NoMoreRecs,
00043 kRecChunking_LastInChunk,
00044 kRecChunking_LastInRS
00045 };
00046
00047 typedef enum DRMS_RecChunking_enum DRMS_RecChunking_t;
00048
00049
00050
00051
00052
00053
00054
00055
00056 DRMS_RecordSet_t *drms_open_records(DRMS_Env_t *env, const char *recordsetname,
00057 int *status);
00058 DRMS_RecordSet_t *drms_open_nrecords(DRMS_Env_t *env,
00059 const char *recordsetname,
00060 int n,
00061 int *status);
00062 DRMS_RecordSet_t *drms_open_recordswithkeys(DRMS_Env_t *env, const char *specification, const char *keylist, int *status);
00063
00064 DRMS_RecordSet_t *drms_clone_records(DRMS_RecordSet_t *recset,
00065 DRMS_RecLifetime_t lifetime,
00066 DRMS_CloneAction_t mode, int *status);
00067 DRMS_RecordSet_t *drms_clone_records_nosums(DRMS_RecordSet_t *recset,
00068 DRMS_RecLifetime_t lifetime,
00069 DRMS_CloneAction_t mode, int *status);
00070
00071 DRMS_RecordSet_t *drms_create_records(DRMS_Env_t *env, int n,
00072 const char *seriesname, DRMS_RecLifetime_t lifetime,
00073 int *status);
00074
00075 DRMS_RecordSet_t *drms_create_recprotos(DRMS_RecordSet_t *recset, int *status);
00076 void drms_destroy_recprotos(DRMS_RecordSet_t **protos);
00077 DRMS_Record_t *drms_create_recproto(DRMS_Record_t *recSource, int *status);
00078 void drms_destroy_recproto(DRMS_Record_t **proto);
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 int drms_close_records(DRMS_RecordSet_t *rs, int action);
00090
00091 int drms_stage_records(DRMS_RecordSet_t *rs, int retrieve, int dontwait);
00092 int drms_sortandstage_records(DRMS_RecordSet_t *rs, int retrieve, int dontwait, HContainer_t **suinfo);
00093 int drms_record_getinfo(DRMS_RecordSet_t *rs);
00094
00095
00096 DRMS_Record_t *drms_clone_record(DRMS_Record_t *record,
00097 DRMS_RecLifetime_t lifetime,
00098 DRMS_CloneAction_t mode, int *status);
00099 DRMS_Record_t *drms_create_record(DRMS_Env_t *env, char *seriesname,
00100 DRMS_RecLifetime_t lifetime, int *status);
00101 int drms_close_record(DRMS_Record_t *rec, int action);
00103 void drms_print_record(DRMS_Record_t *rec);
00105 void drms_fprint_record(FILE *recfile, DRMS_Record_t *rec);
00107 long long drms_record_size(DRMS_Record_t *rec);
00109 int drms_record_numkeywords(DRMS_Record_t *rec);
00111 int drms_record_numlinks(DRMS_Record_t *rec);
00113 int drms_record_numsegments(DRMS_Record_t *rec);
00115 int drms_record_num_nonlink_segments(DRMS_Record_t *rec);
00116
00127 int drms_record_directory(DRMS_Record_t *rec, char *dirname, int retrieve);
00128 int drms_record_directory_nosums(DRMS_Record_t *rec, char *dirout, int size);
00129
00130
00131 int drms_recproto_setseriesinfo(DRMS_Record_t *rec,
00132 int *unitSize,
00133 int *bArchive,
00134 int *nDaysRetention,
00135 int *tapeGroup,
00136 const char *description);
00137
00138 DRMS_RecordSetType_t drms_record_getquerytype(const char *query);
00139
00141 long long drms_record_memsize(DRMS_Record_t *rec);
00142
00144 long long drms_keylist_memsize(DRMS_Record_t *rec, const char *keylist);
00145
00146
00147 char *drms_record_jsoc_version(DRMS_Env_t *env, DRMS_Record_t *rec);
00148
00149
00150 char *drms_recordset_acquireseriesname(const char *query);
00151
00152 static inline int drms_recordset_getnrecs(DRMS_RecordSet_t *rs)
00153 {
00154 return rs->n;
00155 }
00156
00158 static inline int drms_recordset_getnumss(DRMS_RecordSet_t *rs)
00159 {
00160 return rs->ss_n;
00161 }
00162
00164 const char *drms_recordset_getqueryss(DRMS_RecordSet_t *rs, unsigned int setnum, int *status);
00165
00167 DRMS_RecordSetType_t *drms_recordset_gettypess(DRMS_RecordSet_t *rs,
00168 unsigned int setnum,
00169 int *status);
00170
00172 DRMS_Record_t *drms_recordset_getss(DRMS_RecordSet_t *set, unsigned int setnum, int *status);
00173
00175 int drms_recordset_getssnrecs(DRMS_RecordSet_t *set, unsigned int setnum, int *status);
00176
00177 int drms_merge_record(DRMS_RecordSet_t *rs, DRMS_Record_t *rec);
00178
00179 static inline DRMS_Record_t *drms_recordset_getrec(DRMS_RecordSet_t *rs, long long recnum)
00180 {
00181 if (rs)
00182 {
00183 return rs->records[recnum];
00184 }
00185
00186 return NULL;
00187 }
00188
00189
00190 int drms_recordset_setchunksize(unsigned int size);
00191 unsigned int drms_recordset_getchunksize();
00192
00193 DRMS_RecordSet_t *drms_open_recordset(DRMS_Env_t *env,
00194 const char *rsquery,
00195 int *status);
00196 DRMS_Record_t *drms_recordset_fetchnext(DRMS_Env_t *env,
00197 DRMS_RecordSet_t *rs,
00198 int *drmsstatus,
00199 DRMS_RecChunking_t *chunkstat,
00200 int *newchunk);
00201 int drms_recordset_fetchnext_getcurrent(DRMS_RecordSet_t *rset);
00202 void drms_recordset_fetchnext_setcurrent(DRMS_RecordSet_t *rset, int current);
00203
00204 void drms_free_cursor(DRMS_RecSetCursor_t **cursor);
00205
00206 int drms_count_records(DRMS_Env_t *env, const char *recordsetname, int *status);
00207
00208 DRMS_Array_t *drms_record_getvector(DRMS_Env_t *env,
00209 const char *recordsetname,
00210 const char *keylist,
00211 DRMS_Type_t type,
00212 int unique,
00213 int *status);
00214
00215 DRMS_Segment_t *drms_record_nextseg(DRMS_Record_t *rec, HIterator_t **last, int followlink);
00216 DRMS_Segment_t *drms_record_nextseg2(DRMS_Record_t *rec, HIterator_t **last, int followlink, DRMS_Segment_t **orig);
00217 DRMS_Keyword_t *drms_record_nextkey(DRMS_Record_t *rec, HIterator_t **last, int followlink);
00218 DRMS_Link_t *drms_record_nextlink(DRMS_Record_t *rec, HIterator_t **last);
00219
00220 int drms_record_parserecsetspec(const char *recsetsStr,
00221 char **allvers,
00222 char ***sets,
00223 DRMS_RecordSetType_t **types,
00224 char ***snames,
00225 char ***filts,
00226 int *nsets,
00227 DRMS_RecQueryInfo_t *info);
00228
00229 int drms_record_parserecsetspec_plussegs(const char *recsetsStr, char **allvers, char ***sets, DRMS_RecordSetType_t **types, char ***snames, char ***filts, char ***segs, int *nsets, DRMS_RecQueryInfo_t *info);
00230
00231 int drms_record_freerecsetspecarr(char **allvers,
00232 char ***sets,
00233 DRMS_RecordSetType_t **types,
00234 char ***snames,
00235 char ***filts,
00236 int nsets);
00237
00238 int drms_record_freerecsetspecarr_plussegs(char **allvers, char ***sets, DRMS_RecordSetType_t **types, char ***snames, char ***filts, char ***segs, int nsets);
00239
00240
00241 int drms_record_isdsds(DRMS_Record_t *rec);
00242 int drms_record_islocal(DRMS_Record_t *rec);
00243
00244
00245
00589 #endif