[patches] [PATCH 1/1] vinyl: introduce vy_run_writer
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sat Feb 10 02:12:29 MSK 2018
Vy_run_writer incapsulates logic of writing statements to a run.
It provides API to write statements one by one.
It is needed for #2129, where primary index dump, compaction, coalesce
and split generates one run for primary index and one run for each
secondary index.
In such a case task_..._execute() function must write into multiple
runs sequentially.
Signed-off-by: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
---
src/box/vy_run.c | 520 +++++++++++++++++++++++---------------------
src/box/vy_run.h | 94 +++++++-
src/box/vy_scheduler.c | 18 +-
src/box/xlog.c | 2 +-
src/box/xlog.h | 5 +-
test/unit/vy_point_lookup.c | 10 +-
6 files changed, 374 insertions(+), 275 deletions(-)
diff --git a/src/box/vy_run.c b/src/box/vy_run.c
index ccbb0ca1f..2ad505902 100644
--- a/src/box/vy_run.c
+++ b/src/box/vy_run.c
@@ -1965,242 +1965,6 @@ vy_run_alloc_page_info(struct vy_run *run, uint32_t *page_info_capacity)
return 0;
}
-/**
- * Write statements from the iterator to a new page in the run,
- * update page and run statistics.
- *
- * @retval 1 all is ok, the iterator is finished
- * @retval 0 all is ok, the iterator isn't finished
- * @retval -1 error occurred
- */
-static int
-vy_run_write_page(struct vy_run *run, struct xlog *data_xlog,
- struct vy_stmt_stream *wi, struct tuple **curr_stmt,
- uint64_t page_size, struct bloom_spectrum *bs,
- const struct key_def *cmp_def,
- const struct key_def *key_def, bool is_primary,
- uint32_t *page_info_capacity)
-{
- assert(curr_stmt != NULL);
- assert(*curr_stmt != NULL);
- struct vy_page_info *page = NULL;
- const char *region_key;
- bool end_of_run = false;
- /* Last written statement */
- struct tuple *last_stmt = *curr_stmt;
- vy_stmt_ref_if_possible(last_stmt);
-
- /* row offsets accumulator */
- struct ibuf row_index_buf;
- ibuf_create(&row_index_buf, &cord()->slabc, sizeof(uint32_t) * 4096);
-
- if (run->info.page_count >= *page_info_capacity &&
- vy_run_alloc_page_info(run, page_info_capacity) != 0)
- goto error_row_index;
- assert(*page_info_capacity >= run->info.page_count);
-
- /* See comment to run_info->max_key allocation below. */
- region_key = tuple_extract_key(*curr_stmt, cmp_def, NULL);
- if (region_key == NULL)
- goto error_row_index;
-
- if (run->info.page_count == 0) {
- assert(run->info.min_key == NULL);
- run->info.min_key = vy_key_dup(region_key);
- if (run->info.min_key == NULL)
- goto error_row_index;
- }
-
- page = run->page_info + run->info.page_count;
- if (vy_page_info_create(page, data_xlog->offset, region_key) != 0)
- goto error_row_index;
- xlog_tx_begin(data_xlog);
-
- do {
- uint32_t *offset = (uint32_t *) ibuf_alloc(&row_index_buf,
- sizeof(uint32_t));
- if (offset == NULL) {
- diag_set(OutOfMemory, sizeof(uint32_t),
- "ibuf", "row index");
- goto error_rollback;
- }
- *offset = page->unpacked_size;
-
- if (vy_run_dump_stmt(*curr_stmt, data_xlog, page,
- cmp_def, is_primary) != 0)
- goto error_rollback;
-
- bloom_spectrum_add(bs, tuple_hash(*curr_stmt, key_def));
-
- int64_t lsn = vy_stmt_lsn(*curr_stmt);
- run->info.min_lsn = MIN(run->info.min_lsn, lsn);
- run->info.max_lsn = MAX(run->info.max_lsn, lsn);
-
- if (wi->iface->next(wi, curr_stmt))
- goto error_rollback;
-
- if (*curr_stmt == NULL) {
- end_of_run = true;
- } else {
- vy_stmt_unref_if_possible(last_stmt);
- last_stmt = *curr_stmt;
- vy_stmt_ref_if_possible(last_stmt);
- }
- } while (end_of_run == false &&
- obuf_size(&data_xlog->obuf) < page_size);
-
- /* We don't write empty pages. */
- assert(last_stmt != NULL);
-
- if (end_of_run) {
- /*
- * Tuple_extract_key allocates the key on a
- * region, but the max_key must be allocated on
- * the heap, because the max_key can live longer
- * than a fiber. To reach this, we must copy the
- * key into malloced memory.
- */
- region_key = tuple_extract_key(last_stmt, cmp_def, NULL);
- if (region_key == NULL)
- goto error_rollback;
- assert(run->info.max_key == NULL);
- run->info.max_key = vy_key_dup(region_key);
- if (run->info.max_key == NULL)
- goto error_rollback;
- }
- vy_stmt_unref_if_possible(last_stmt);
- last_stmt = NULL;
-
- /* Save offset to row index */
- page->row_index_offset = page->unpacked_size;
-
- /* Write row index */
- struct xrow_header xrow;
- const uint32_t *row_index = (const uint32_t *) row_index_buf.rpos;
- assert(ibuf_used(&row_index_buf) == sizeof(uint32_t) * page->row_count);
- if (vy_row_index_encode(row_index, page->row_count, &xrow) < 0)
- goto error_rollback;
-
- ssize_t written = xlog_write_row(data_xlog, &xrow);
- if (written < 0)
- goto error_rollback;
-
- page->unpacked_size += written;
-
- written = xlog_tx_commit(data_xlog);
- if (written == 0)
- written = xlog_flush(data_xlog);
- if (written < 0)
- goto error_row_index;
-
- page->size = written;
-
- assert(page->row_count > 0);
-
- run->info.page_count++;
- vy_run_acct_page(run, page);
-
- ibuf_destroy(&row_index_buf);
- return !end_of_run ? 0: 1;
-
-error_rollback:
- xlog_tx_rollback(data_xlog);
-error_row_index:
- ibuf_destroy(&row_index_buf);
- if (last_stmt != NULL)
- vy_stmt_unref_if_possible(last_stmt);
- return -1;
-}
-
-/**
- * Write statements from the iterator to a new run file.
- *
- * @retval 0 success
- * @retval -1 error occurred
- */
-static int
-vy_run_write_data(struct vy_run *run, const char *dirpath,
- uint32_t space_id, uint32_t iid,
- struct vy_stmt_stream *wi, uint64_t page_size,
- const struct key_def *cmp_def,
- const struct key_def *key_def,
- size_t max_output_count, double bloom_fpr)
-{
- struct tuple *stmt;
-
- /* Start iteration. */
- if (wi->iface->start(wi) != 0)
- goto err;
- if (wi->iface->next(wi, &stmt) != 0)
- goto err;
-
- /* Do not create empty run files. */
- if (stmt == NULL)
- goto done;
-
- struct bloom_spectrum bs;
- if (bloom_spectrum_create(&bs, max_output_count,
- bloom_fpr, runtime.quota) != 0) {
- diag_set(OutOfMemory, 0,
- "bloom_spectrum_create", "bloom_spectrum");
- goto err;
- }
-
- char path[PATH_MAX];
- vy_run_snprint_path(path, sizeof(path), dirpath,
- space_id, iid, run->id, VY_FILE_RUN);
-
- say_info("writing `%s'", path);
-
- struct xlog data_xlog;
- struct xlog_meta meta = {
- .filetype = XLOG_META_TYPE_RUN,
- .instance_uuid = INSTANCE_UUID,
- };
- if (xlog_create(&data_xlog, path, 0, &meta) < 0)
- goto err_free_bloom;
-
- run->info.min_lsn = INT64_MAX;
- run->info.max_lsn = -1;
-
- assert(run->page_info == NULL);
- uint32_t page_info_capacity = 0;
- int rc;
- do {
- rc = vy_run_write_page(run, &data_xlog, wi, &stmt,
- page_size, &bs, cmp_def, key_def,
- iid == 0, &page_info_capacity);
- if (rc < 0)
- goto err_close_xlog;
- fiber_gc();
- } while (rc == 0);
-
- /* Sync data and link the file to the final name. */
- if (xlog_sync(&data_xlog) < 0 ||
- xlog_rename(&data_xlog) < 0)
- goto err_close_xlog;
-
- run->fd = data_xlog.fd;
- xlog_close(&data_xlog, true);
- fiber_gc();
-
- bloom_spectrum_choose(&bs, &run->info.bloom);
- run->info.has_bloom = true;
- bloom_spectrum_destroy(&bs, runtime.quota);
-done:
- wi->iface->stop(wi);
- return 0;
-
-err_close_xlog:
- xlog_close(&data_xlog, false);
- fiber_gc();
-err_free_bloom:
- bloom_spectrum_destroy(&bs, runtime.quota);
-err:
- wi->iface->stop(wi);
- return -1;
-}
-
/** {{{ vy_page_info */
/**
@@ -2433,16 +2197,249 @@ fail:
return -1;
}
-/*
- * Create a run file, write statements returned by a write
- * iterator to it, and create an index file.
+int
+vy_run_writer_create(struct vy_run_writer *writer, struct vy_run *run,
+ const char *dirpath, uint32_t space_id, uint32_t iid,
+ uint64_t page_size, const struct key_def *cmp_def,
+ const struct key_def *key_def, double bloom_fpr,
+ size_t max_output_count)
+{
+ memset(writer, 0, sizeof(*writer));
+ writer->run = run;
+ writer->dirpath = dirpath;
+ writer->space_id = space_id;
+ writer->iid = iid;
+ writer->page_size = page_size;
+ writer->cmp_def = cmp_def;
+ writer->key_def = key_def;
+ if (bloom_spectrum_create(&writer->bloom, max_output_count,
+ bloom_fpr, runtime.quota) != 0) {
+ diag_set(OutOfMemory, 0,
+ "bloom_spectrum_create", "bloom_spectrum");
+ return -1;
+ }
+ xlog_clear(&writer->data_xlog);
+ run->info.min_lsn = INT64_MAX;
+ run->info.max_lsn = -1;
+ assert(run->page_info == NULL);
+ return 0;
+}
+
+/**
+ * Create an xlog to write run.
+ * @param writer Run writer.
+ * @retval -1 Memory or IO error.
+ * @retval 0 Success.
+ */
+static inline int
+vy_run_writer_create_xlog(struct vy_run_writer *writer)
+{
+ assert(! xlog_is_open(&writer->data_xlog));
+ char path[PATH_MAX];
+ vy_run_snprint_path(path, sizeof(path), writer->dirpath,
+ writer->space_id, writer->iid, writer->run->id,
+ VY_FILE_RUN);
+ say_info("writing `%s'", path);
+ const struct xlog_meta meta = {
+ .filetype = XLOG_META_TYPE_RUN,
+ .instance_uuid = INSTANCE_UUID,
+ };
+ return xlog_create(&writer->data_xlog, path, 0, &meta);
+}
+
+/**
+ * Start a new page with a min_key stored in @a first_stmt.
+ * @param writer Run writer.
+ * @param first_stmt First statement of a page.
+ *
+ * @retval -1 Memory error.
+ * @retval 0 Success.
+ */
+static inline int
+vy_run_writer_start_page(struct vy_run_writer *writer,
+ const struct tuple *first_stmt)
+{
+ uint32_t *page_info_capacity = &writer->page_info_capacity;
+ struct vy_run *run = writer->run;
+ ibuf_create(&writer->row_index_buf, &cord()->slabc,
+ sizeof(uint32_t) * 4096);
+ if (run->info.page_count >= *page_info_capacity &&
+ vy_run_alloc_page_info(run, page_info_capacity) != 0)
+ return -1;
+ assert(*page_info_capacity >= run->info.page_count);
+ const char *key = tuple_extract_key(first_stmt, writer->cmp_def, NULL);
+ if (key == NULL)
+ return -1;
+ if (run->info.page_count == 0) {
+ assert(run->info.min_key == NULL);
+ run->info.min_key = vy_key_dup(key);
+ if (run->info.min_key == NULL)
+ return -1;
+ }
+ struct vy_page_info *page = run->page_info + run->info.page_count;
+ if (vy_page_info_create(page, writer->data_xlog.offset, key) != 0)
+ return -1;
+ xlog_tx_begin(&writer->data_xlog);
+ return 0;
+}
+
+/**
+ * Write @a stmt into a current page.
+ * @param writer Run writer.
+ * @param stmt Statement to write.
+ *
+ * @retval -1 Memory or IO error.
+ * @retval 0 Success.
+ */
+static inline int
+vy_run_writer_write_to_page(struct vy_run_writer *writer, struct tuple *stmt)
+{
+ if (writer->last_stmt != NULL)
+ vy_stmt_unref_if_possible(writer->last_stmt);
+ writer->last_stmt = stmt;
+ vy_stmt_ref_if_possible(stmt);
+ struct vy_run *run = writer->run;
+ struct vy_page_info *page = run->page_info + run->info.page_count;
+ uint32_t *offset = (uint32_t *) ibuf_alloc(&writer->row_index_buf,
+ sizeof(uint32_t));
+ if (offset == NULL) {
+ diag_set(OutOfMemory, sizeof(uint32_t),
+ "ibuf", "row index");
+ return -1;
+ }
+ *offset = page->unpacked_size;
+ if (vy_run_dump_stmt(stmt, &writer->data_xlog, page, writer->cmp_def,
+ writer->iid == 0) != 0)
+ return -1;
+
+ bloom_spectrum_add(&writer->bloom, tuple_hash(stmt, writer->key_def));
+ int64_t lsn = vy_stmt_lsn(stmt);
+ run->info.min_lsn = MIN(run->info.min_lsn, lsn);
+ run->info.max_lsn = MAX(run->info.max_lsn, lsn);
+ return 0;
+}
+
+/**
+ * Finish a current page.
+ * @param writer Run writer.
+ * @retval -1 Memory or IO error.
+ * @retval 0 Success.
*/
+static inline int
+vy_run_writer_end_page(struct vy_run_writer *writer)
+{
+ struct vy_run *run = writer->run;
+ struct vy_page_info *page = run->page_info + run->info.page_count;
+ assert(page->row_count > 0);
+ /* Save offset to row index */
+ page->row_index_offset = page->unpacked_size;
+
+ /* Write row index */
+ struct xrow_header xrow;
+ const uint32_t *row_index =
+ (const uint32_t *) writer->row_index_buf.rpos;
+ assert(ibuf_used(&writer->row_index_buf) ==
+ sizeof(uint32_t) * page->row_count);
+ if (vy_row_index_encode(row_index, page->row_count, &xrow) < 0)
+ return -1;
+
+ ssize_t written = xlog_write_row(&writer->data_xlog, &xrow);
+ if (written < 0)
+ return -1;
+ page->unpacked_size += written;
+
+ written = xlog_tx_commit(&writer->data_xlog);
+ if (written == 0)
+ written = xlog_flush(&writer->data_xlog);
+ if (written < 0)
+ return -1;
+ page->size = written;
+ run->info.page_count++;
+ vy_run_acct_page(run, page);
+ ibuf_destroy(&writer->row_index_buf);
+ memset(&writer->row_index_buf, 0, sizeof(writer->row_index_buf));
+ return 0;
+}
+
int
-vy_run_write(struct vy_run *run, const char *dirpath,
- uint32_t space_id, uint32_t iid,
- struct vy_stmt_stream *wi, uint64_t page_size,
- const struct key_def *cmp_def,
- const struct key_def *key_def,
+vy_run_writer_append_stmt(struct vy_run_writer *writer, struct tuple *stmt)
+{
+ if (!xlog_is_open(&writer->data_xlog) &&
+ vy_run_writer_create_xlog(writer) != 0)
+ return -1;
+ if (writer->row_index_buf.buf == NULL &&
+ vy_run_writer_start_page(writer, stmt) != 0)
+ return -1;
+ if (vy_run_writer_write_to_page(writer, stmt) != 0)
+ return -1;
+ if (obuf_size(&writer->data_xlog.obuf) >= writer->page_size)
+ return vy_run_writer_end_page(writer);
+ else
+ return 0;
+}
+
+/**
+ * Destroy a run writer.
+ * @param writer Writer to destroy.
+ * @param reuse_fd True in a case of success run write. And else
+ * false.
+ */
+static inline void
+vy_run_writer_destroy(struct vy_run_writer *writer, bool reuse_fd)
+{
+ if (writer->last_stmt != NULL)
+ vy_stmt_unref_if_possible(writer->last_stmt);
+ if (xlog_is_open(&writer->data_xlog))
+ xlog_close(&writer->data_xlog, reuse_fd);
+ bloom_spectrum_destroy(&writer->bloom, runtime.quota);
+ ibuf_destroy(&writer->row_index_buf);
+}
+
+int
+vy_run_writer_commit(struct vy_run_writer *writer)
+{
+ assert(writer->last_stmt != NULL);
+ const char *key = tuple_extract_key(writer->last_stmt, writer->cmp_def,
+ NULL);
+ if (key == NULL)
+ return -1;
+ struct vy_run *run = writer->run;
+ assert(run->info.max_key == NULL);
+ run->info.max_key = vy_key_dup(key);
+ if (run->info.max_key == NULL)
+ return -1;
+ if (writer->row_index_buf.buf != NULL &&
+ vy_run_writer_end_page(writer) != 0)
+ return -1;
+
+ /* Sync data and link the file to the final name. */
+ if (xlog_sync(&writer->data_xlog) < 0 ||
+ xlog_rename(&writer->data_xlog) < 0)
+ return -1;
+ run->fd = writer->data_xlog.fd;
+ bloom_spectrum_choose(&writer->bloom, &run->info.bloom);
+ run->info.has_bloom = true;
+ int rc;
+ if (vy_run_is_empty(run)) {
+ rc = 0;
+ } else {
+ rc = vy_run_write_index(run, writer->dirpath, writer->space_id,
+ writer->iid);
+ }
+ vy_run_writer_destroy(writer, true);
+ return rc;
+}
+
+void
+vy_run_writer_abort(struct vy_run_writer *writer)
+{
+ vy_run_writer_destroy(writer, false);
+}
+
+int
+vy_run_write(struct vy_run *run, const char *dirpath, uint32_t space_id,
+ uint32_t iid, struct vy_stmt_stream *wi, uint64_t page_size,
+ const struct key_def *cmp_def, const struct key_def *key_def,
size_t max_output_count, double bloom_fpr)
{
ERROR_INJECT(ERRINJ_VY_RUN_WRITE,
@@ -2453,18 +2450,37 @@ vy_run_write(struct vy_run *run, const char *dirpath,
if (inj != NULL && inj->dparam > 0)
usleep(inj->dparam * 1000000);
- if (vy_run_write_data(run, dirpath, space_id, iid,
- wi, page_size, cmp_def, key_def,
- max_output_count, bloom_fpr) != 0)
+ if (max_output_count == 0)
+ return 0;
+ struct vy_run_writer writer;
+ if (vy_run_writer_create(&writer, run, dirpath, space_id, iid,
+ page_size, cmp_def, key_def, bloom_fpr,
+ max_output_count) != 0)
return -1;
-
- if (vy_run_is_empty(run))
+ struct tuple *stmt = NULL;
+ if (wi->iface->start(wi) != 0)
+ goto error;
+ if (wi->iface->next(wi, &stmt) != 0)
+ goto error;
+ if (stmt == NULL)
return 0;
+ do {
+ if (vy_run_writer_append_stmt(&writer, stmt) != 0)
+ goto error;
+ if (wi->iface->next(wi, &stmt) != 0)
+ goto error;
+ } while (stmt != NULL);
- if (vy_run_write_index(run, dirpath, space_id, iid) != 0)
- return -1;
+ int rc = vy_run_writer_commit(&writer);
+ wi->iface->stop(wi);
+ fiber_gc();
+ return rc;
- return 0;
+error:
+ vy_run_writer_abort(&writer);
+ wi->iface->stop(wi);
+ fiber_gc();
+ return -1;
}
int
diff --git a/src/box/vy_run.h b/src/box/vy_run.h
index cf0569c27..e108fa9c9 100644
--- a/src/box/vy_run.h
+++ b/src/box/vy_run.h
@@ -41,6 +41,7 @@
#include "vy_read_view.h"
#include "vy_stat.h"
#include "index_def.h"
+#include "xlog.h"
#include "small/mempool.h"
#include "salad/bloom.h"
@@ -403,12 +404,14 @@ vy_run_snprint_path(char *buf, int size, const char *dir,
return total;
}
+/**
+ * Write statements returned by a write iterator to a new run
+ * file, create an index file.
+ */
int
-vy_run_write(struct vy_run *run, const char *dirpath,
- uint32_t space_id, uint32_t iid,
- struct vy_stmt_stream *wi, uint64_t page_size,
- const struct key_def *cmp_def,
- const struct key_def *key_def,
+vy_run_write(struct vy_run *run, const char *dirpath, uint32_t space_id,
+ uint32_t iid, struct vy_stmt_stream *wi, uint64_t page_size,
+ const struct key_def *cmp_def, const struct key_def *key_def,
size_t max_output_count, double bloom_fpr);
/**
@@ -560,6 +563,87 @@ vy_slice_stream_open(struct vy_slice_stream *stream, struct vy_slice *slice,
const struct key_def *cmp_def, struct tuple_format *format,
struct tuple_format *upsert_format, bool is_primary);
+/**
+ * Run_writer fills a created run with statements one by one,
+ * splitting them into pages.
+ */
+struct vy_run_writer {
+ /** Run to fill. */
+ struct vy_run *run;
+ /** Path to directory with run files. */
+ const char *dirpath;
+ /** Identifier of a space owning the run. */
+ uint32_t space_id;
+ /** Identifier of an index owning the run. */
+ uint32_t iid;
+ /**
+ * Minimal page size. When a page becames bigger, it is
+ * dumped.
+ */
+ uint64_t page_size;
+ /**
+ * Key definition to extract from tuple and store as page
+ * min key, run min/max keys, and secondary index
+ * statements.
+ */
+ const struct key_def *cmp_def;
+ /** Key definition to calculate bloom. */
+ const struct key_def *key_def;
+ /**
+ * Current page info capacity. Can grow with page number.
+ */
+ uint32_t page_info_capacity;
+ /** Xlog to write data. */
+ struct xlog data_xlog;
+ /** Bloom filter. */
+ struct bloom_spectrum bloom;
+ /** Buffer of a current page row offsets. */
+ struct ibuf row_index_buf;
+ /**
+ * Remember a last written statement to use it as a source
+ * of max key of a finished run.
+ */
+ struct tuple *last_stmt;
+};
+
+/** Create a run writer to fill a run with statements. */
+int
+vy_run_writer_create(struct vy_run_writer *writer, struct vy_run *run,
+ const char *dirpath, uint32_t space_id, uint32_t iid,
+ uint64_t page_size, const struct key_def *cmp_def,
+ const struct key_def *key_def, double bloom_fpr,
+ size_t max_output_count);
+
+/**
+ * Write a specified statement into a run.
+ * @param writer Writer to write a statement.
+ * @param stmt Statement to write.
+ *
+ * @retval -1 Memory error.
+ * @retval 0 Success.
+ */
+int
+vy_run_writer_append_stmt(struct vy_run_writer *writer, struct tuple *stmt);
+
+/**
+ * Finalize run writing by writing run index into file. The writer
+ * is deleted after call.
+ * @param writer Run writer.
+ * @retval -1 Memory or IO error.
+ * @retval 0 Success.
+ */
+int
+vy_run_writer_commit(struct vy_run_writer *writer);
+
+/**
+ * Abort run writing. Can not delete a run and run's file here,
+ * becase it must be done from tx thread. The writer is deleted
+ * after call.
+ * @param Run writer.
+ */
+void
+vy_run_writer_abort(struct vy_run_writer *writer);
+
#if defined(__cplusplus)
} /* extern "C" */
#endif /* defined(__cplusplus) */
diff --git a/src/box/vy_scheduler.c b/src/box/vy_scheduler.c
index 35fc24f43..35e46968b 100644
--- a/src/box/vy_scheduler.c
+++ b/src/box/vy_scheduler.c
@@ -626,11 +626,10 @@ vy_task_dump_execute(struct vy_task *task)
{
struct vy_index *index = task->index;
- return vy_run_write(task->new_run, index->env->path,
- index->space_id, index->id, task->wi,
- task->page_size, index->cmp_def,
- index->key_def, task->max_output_count,
- task->bloom_fpr);
+ return vy_run_write(task->new_run, index->env->path, index->space_id,
+ index->id, task->wi, task->page_size,
+ index->cmp_def, index->key_def,
+ task->max_output_count, task->bloom_fpr);
}
static int
@@ -995,11 +994,10 @@ vy_task_compact_execute(struct vy_task *task)
{
struct vy_index *index = task->index;
- return vy_run_write(task->new_run, index->env->path,
- index->space_id, index->id, task->wi,
- task->page_size, index->cmp_def,
- index->key_def, task->max_output_count,
- task->bloom_fpr);
+ return vy_run_write(task->new_run, index->env->path, index->space_id,
+ index->id, task->wi, task->page_size,
+ index->cmp_def, index->key_def,
+ task->max_output_count, task->bloom_fpr);
}
static int
diff --git a/src/box/xlog.c b/src/box/xlog.c
index 4655d53fa..d08c43e07 100644
--- a/src/box/xlog.c
+++ b/src/box/xlog.c
@@ -676,7 +676,7 @@ xlog_clear(struct xlog *l)
l->fd = -1;
}
-static void
+void
xlog_destroy(struct xlog *xlog)
{
obuf_destroy(&xlog->obuf);
diff --git a/src/box/xlog.h b/src/box/xlog.h
index 973910d1d..ced073570 100644
--- a/src/box/xlog.h
+++ b/src/box/xlog.h
@@ -354,11 +354,14 @@ xdir_create_xlog(struct xdir *dir, struct xlog *xlog,
* @retval 0 for success
* @retvl -1 if error
*/
-
int
xlog_create(struct xlog *xlog, const char *name, int flags,
const struct xlog_meta *meta);
+/** Destroy xlog writer. */
+void
+xlog_destroy(struct xlog *xlog);
+
/**
* Open an existing xlog file for appending.
* @param xlog xlog descriptor
diff --git a/test/unit/vy_point_lookup.c b/test/unit/vy_point_lookup.c
index d360b3b48..4cdae1907 100644
--- a/test/unit/vy_point_lookup.c
+++ b/test/unit/vy_point_lookup.c
@@ -163,9 +163,8 @@ test_basic()
struct vy_run *run = vy_run_new(&run_env, 1);
isnt(run, NULL, "vy_run_new");
- rc = vy_run_write(run, dir_name, 0, pk->id,
- write_stream, 4096, pk->cmp_def, pk->key_def,
- 100500, 0.1);
+ rc = vy_run_write(run, dir_name, 0, pk->id, write_stream, 4096,
+ pk->cmp_def, pk->key_def, 100500, 0.1);
is(rc, 0, "vy_run_write");
write_stream->iface->close(write_stream);
@@ -200,9 +199,8 @@ test_basic()
run = vy_run_new(&run_env, 2);
isnt(run, NULL, "vy_run_new");
- rc = vy_run_write(run, dir_name, 0, pk->id,
- write_stream, 4096, pk->cmp_def, pk->key_def,
- 100500, 0.1);
+ rc = vy_run_write(run, dir_name, 0, pk->id, write_stream, 4096,
+ pk->cmp_def, pk->key_def, 100500, 0.1);
is(rc, 0, "vy_run_write");
write_stream->iface->close(write_stream);
--
2.14.3 (Apple Git-98)
More information about the Tarantool-patches
mailing list