static couchstore_error_t open_view_group_file(const char *path, couchstore_open_flags open_flags, tree_file *file) { couchstore_error_t ret; const couch_file_ops *file_ops = couchstore_get_default_file_ops(); int flags = 0; if ((open_flags & COUCHSTORE_OPEN_FLAG_RDONLY) && (open_flags & COUCHSTORE_OPEN_FLAG_CREATE)) { return COUCHSTORE_ERROR_INVALID_ARGUMENTS; } if (open_flags & COUCHSTORE_OPEN_FLAG_RDONLY) { flags |= O_RDONLY; } else { flags |= O_RDWR; } if (open_flags & COUCHSTORE_OPEN_FLAG_CREATE) { flags |= O_CREAT; } ret = tree_file_open(file, path, flags, file_ops); return ret; }
int main(int argc, char** argv) { Db* source; couchstore_error_t errcode; time_purge_ctx timepurge = {0, 0}; couchstore_compact_hook hook = NULL; void* hook_ctx = NULL; int argp = 1; couchstore_compact_flags flags = 0; const couch_file_ops* target_io_ops = couchstore_get_default_file_ops(); if(argc < 3) { usage(argv[0]); } while(argv[argp][0] == '-') { if(!strcmp(argv[argp],"--purge-before")) { argp+=2; if(argc + argp < 2) { usage(argv[0]); } hook = time_purge_hook; hook_ctx = &timepurge; timepurge.purge_before_ts = atoi(argv[argp-1]); printf("Purging items before timestamp %"PRIu64"\n", timepurge.purge_before_ts); } if(!strcmp(argv[argp],"--purge-only-upto-seq")) { if(argc - argp < 3) { usage(argv[0]); } argp+=2; timepurge.purge_before_seq = (uint64_t)(atoll(argv[argp-1])); printf("Purging items only up-to seq %"PRIu64"\n", timepurge.purge_before_seq); } if(!strcmp(argv[argp],"--dropdeletes")) { argp++; if(argc + argp < 2) { usage(argv[0]); } flags = COUCHSTORE_COMPACT_FLAG_DROP_DELETES; } } errcode = couchstore_open_db(argv[argp++], COUCHSTORE_OPEN_FLAG_RDONLY, &source); if(errcode) { exit_error(errcode); } errcode = couchstore_compact_db_ex(source, argv[argp], flags, hook, hook_ctx, target_io_ops); if(errcode) { exit_error(errcode); } printf("Compacted %s -> %s\n", argv[argp - 1], argv[argp]); return 0; }
LIBCOUCHSTORE_API couchstore_error_t couchstore_open_db(const char *filename, couchstore_open_flags flags, Db **pDb) { return couchstore_open_db_ex(filename, flags, couchstore_get_default_file_ops(), pDb); }
int main(int argc, char** argv) { Db* source; couchstore_error_t errcode; if(argc < 3) { usage(argv[0]); } int argp = 1; couchstore_compact_flags flags = 0; const couch_file_ops* target_io_ops = couchstore_get_default_file_ops(); while((argp < argc) && (argv[argp][0] == '-')) { if(!strcmp(argv[argp],"--dropdeletes")) { argp++; if(argc < (argp + 2)) { usage(argv[0]); } flags |= COUCHSTORE_COMPACT_FLAG_DROP_DELETES; } if(!strcmp(argv[argp],"--evict")) { argp++; if(argc < (argp + 2)) { usage(argv[0]); } flags |= COUCHSTORE_COMPACT_FLAG_EVICT_BODIES; } } errcode = couchstore_open_db(argv[argp++], COUCHSTORE_OPEN_FLAG_RDONLY, &source); if(errcode) { exit_error(errcode); } errcode = couchstore_compact_db_ex(source, argv[argp], flags, target_io_ops); if(errcode) { exit_error(errcode); } printf("Compacted %s -> %s\n", argv[argp - 1], argv[argp]); return 0; }
static couch_file_handle buffered_constructor(void* cookie) { (void) cookie; return buffered_constructor_with_raw_ops(couchstore_get_default_file_ops()); }