git/reftable/stack.c

/*
Copyright 2020 Google LLC

Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file or at
https://developers.google.com/open-source/licenses/bsd
*/

#include "stack.h"

#include "../write-or-die.h"
#include "system.h"
#include "constants.h"
#include "merged.h"
#include "reader.h"
#include "reftable-error.h"
#include "reftable-record.h"
#include "reftable-merged.h"
#include "writer.h"
#include "tempfile.h"

static int stack_try_add(struct reftable_stack *st,
			 int (*write_table)(struct reftable_writer *wr,
					    void *arg),
			 void *arg);
static int stack_write_compact(struct reftable_stack *st,
			       struct reftable_writer *wr,
			       size_t first, size_t last,
			       struct reftable_log_expiry_config *config);
static void reftable_addition_close(struct reftable_addition *add);
static int reftable_stack_reload_maybe_reuse(struct reftable_stack *st,
					     int reuse_open);

static int stack_filename(struct reftable_buf *dest, struct reftable_stack *st,
			  const char *name)
{}

static ssize_t reftable_fd_write(void *arg, const void *data, size_t sz)
{}

static int reftable_fd_flush(void *arg)
{}

int reftable_new_stack(struct reftable_stack **dest, const char *dir,
		       const struct reftable_write_options *_opts)
{}

static int fd_read_lines(int fd, char ***namesp)
{}

int read_lines(const char *filename, char ***namesp)
{}

int reftable_stack_init_ref_iterator(struct reftable_stack *st,
				      struct reftable_iterator *it)
{}

int reftable_stack_init_log_iterator(struct reftable_stack *st,
				     struct reftable_iterator *it)
{}

struct reftable_merged_table *
reftable_stack_merged_table(struct reftable_stack *st)
{}

static int has_name(char **names, const char *name)
{}

/* Close and free the stack */
void reftable_stack_destroy(struct reftable_stack *st)
{}

static struct reftable_reader **stack_copy_readers(struct reftable_stack *st,
						   size_t cur_len)
{}

static int reftable_stack_reload_once(struct reftable_stack *st,
				      const char **names,
				      int reuse_open)
{}

/* return negative if a before b. */
static int tv_cmp(struct timeval *a, struct timeval *b)
{}

static int reftable_stack_reload_maybe_reuse(struct reftable_stack *st,
					     int reuse_open)
{}

/* -1 = error
 0 = up to date
 1 = changed. */
static int stack_uptodate(struct reftable_stack *st)
{}

int reftable_stack_reload(struct reftable_stack *st)
{}

int reftable_stack_add(struct reftable_stack *st,
		       int (*write)(struct reftable_writer *wr, void *arg),
		       void *arg)
{}

static int format_name(struct reftable_buf *dest, uint64_t min, uint64_t max)
{}

struct reftable_addition {};

#define REFTABLE_ADDITION_INIT

static int reftable_stack_init_addition(struct reftable_addition *add,
					struct reftable_stack *st,
					unsigned int flags)
{}

static void reftable_addition_close(struct reftable_addition *add)
{}

void reftable_addition_destroy(struct reftable_addition *add)
{}

int reftable_addition_commit(struct reftable_addition *add)
{}

int reftable_stack_new_addition(struct reftable_addition **dest,
				struct reftable_stack *st,
				unsigned int flags)
{}

static int stack_try_add(struct reftable_stack *st,
			 int (*write_table)(struct reftable_writer *wr,
					    void *arg),
			 void *arg)
{}

int reftable_addition_add(struct reftable_addition *add,
			  int (*write_table)(struct reftable_writer *wr,
					     void *arg),
			  void *arg)
{}

uint64_t reftable_stack_next_update_index(struct reftable_stack *st)
{}

static int stack_compact_locked(struct reftable_stack *st,
				size_t first, size_t last,
				struct reftable_log_expiry_config *config,
				struct tempfile **tab_file_out)
{}

static int stack_write_compact(struct reftable_stack *st,
			       struct reftable_writer *wr,
			       size_t first, size_t last,
			       struct reftable_log_expiry_config *config)
{}

enum stack_compact_range_flags {};

/*
 * Compact all tables in the range `[first, last)` into a single new table.
 *
 * This function returns `0` on success or a code `< 0` on failure. When the
 * stack or any of the tables in the specified range are already locked then
 * this function returns `REFTABLE_LOCK_ERROR`. This is a benign error that
 * callers can either ignore, or they may choose to retry compaction after some
 * amount of time.
 */
static int stack_compact_range(struct reftable_stack *st,
			       size_t first, size_t last,
			       struct reftable_log_expiry_config *expiry,
			       unsigned int flags)
{}

int reftable_stack_compact_all(struct reftable_stack *st,
			       struct reftable_log_expiry_config *config)
{}

static int segment_size(struct segment *s)
{}

struct segment suggest_compaction_segment(uint64_t *sizes, size_t n,
					  uint8_t factor)
{}

static uint64_t *stack_table_sizes_for_compaction(struct reftable_stack *st)
{}

int reftable_stack_auto_compact(struct reftable_stack *st)
{}

struct reftable_compaction_stats *
reftable_stack_compaction_stats(struct reftable_stack *st)
{}

int reftable_stack_read_ref(struct reftable_stack *st, const char *refname,
			    struct reftable_ref_record *ref)
{}

int reftable_stack_read_log(struct reftable_stack *st, const char *refname,
			    struct reftable_log_record *log)
{}

static int is_table_name(const char *s)
{}

static void remove_maybe_stale_table(struct reftable_stack *st, uint64_t max,
				     const char *name)
{}

static int reftable_stack_clean_locked(struct reftable_stack *st)
{}

int reftable_stack_clean(struct reftable_stack *st)
{}