index_fst_counting_writer.c 1.4 KB
Newer Older
dengyihao's avatar
dengyihao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
dengyihao's avatar
dengyihao 已提交
15 16
#include "tutil.h"
#include "index_fst_counting_writer.h"
dengyihao's avatar
dengyihao 已提交
17 18 19 20

FstCountingWriter *fstCountingWriterCreate(void *wrt) {
  FstCountingWriter *cw = calloc(1, sizeof(FstCountingWriter)); 
  if (cw == NULL) { return NULL; }
dengyihao's avatar
dengyihao 已提交
21

dengyihao's avatar
dengyihao 已提交
22 23 24
  cw->wrt = wrt; 
  return cw; 
}
dengyihao's avatar
dengyihao 已提交
25
void fstCountingWriterDestroy(FstCountingWriter *cw) {
dengyihao's avatar
dengyihao 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38
  // free wrt object: close fd or free mem 
  free(cw);
}

uint64_t fstCountingWriterWrite(FstCountingWriter *write, uint8_t *buf, uint32_t bufLen) {
  if (write == NULL) { return 0; } 
  // update checksum 
  // write data to file/socket or mem
  
  write->count += bufLen;
  return bufLen; 
} 

dengyihao's avatar
dengyihao 已提交
39
int fstCountingWriterFlush(FstCountingWriter *write) {
dengyihao's avatar
dengyihao 已提交
40 41 42 43
  //write->wtr->flush
  return 1;
}

dengyihao's avatar
dengyihao 已提交
44 45 46
void fstCountingWriterPackUintIn(FstCountingWriter *writer, uint64_t n,  uint8_t nBytes) {
  return;
}
dengyihao's avatar
dengyihao 已提交
47 48