/* * Copyright (c) 2019 TAOS Data, Inc. * * 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 . */ //#define _DEFAULT_SOURCE #include "os.h" #include "tutil.h" #include "tglobal.h" #include "tlog.h" #include "twal.h" int64_t ver = 0; void *pWal = NULL; int writeToQueue(void *pVnode, void *data, int type, void *pMsg) { // do nothing SWalHead *pHead = data; if (pHead->version > ver) ver = pHead->version; walWrite(pWal, pHead); return 0; } int main(int argc, char *argv[]) { char path[128] = "/home/jhtao/test/wal"; int max = 3; int level = 2; int total = 5; int rows = 10000; int size = 128; int keep = 0; for (int i=1; iversion = ++ver; pHead->len = size; walWrite(pWal, pHead); } printf("renew a wal, i:%d\n", i); walRenew(pWal); } printf("%d wal files are written\n", total); int64_t index = 0; char name[256]; while (1) { int code = walGetWalFile(pWal, name, &index); if (code == -1) { printf("failed to get wal file, index:%" PRId64 "\n", index); break; } printf("index:%" PRId64 " wal:%s\n", index, name); if (code == 0) break; index++; } getchar(); walClose(pWal); return 0; }