git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
14a6f835f460c63dd8db7895b01d524c0e726b4e blob 3617 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
 
/*
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
*/

#ifndef BLOCK_H
#define BLOCK_H

#include "basics.h"
#include "record.h"
#include "reftable.h"

/*
  Writes reftable blocks. The block_writer is reused across blocks to minimize
  allocation overhead.
*/
struct block_writer {
	uint8_t *buf;
	uint32_t block_size;

	/* Offset ofof the global header. Nonzero in the first block only. */
	uint32_t header_off;

	/* How often to restart keys. */
	int restart_interval;
	int hash_size;

	/* Offset of next uint8_t to write. */
	uint32_t next;
	uint32_t *restarts;
	uint32_t restart_len;
	uint32_t restart_cap;

	struct strbuf last_key;
	int entries;
};

/*
  initializes the blockwriter to write `typ` entries, using `buf` as temporary
  storage. `buf` is not owned by the block_writer. */
void block_writer_init(struct block_writer *bw, uint8_t typ, uint8_t *buf,
		       uint32_t block_size, uint32_t header_off, int hash_size);

/*
  returns the block type (eg. 'r' for ref records.
*/
uint8_t block_writer_type(struct block_writer *bw);

/* appends the record, or -1 if it doesn't fit. */
int block_writer_add(struct block_writer *w, struct reftable_record *rec);

/* appends the key restarts, and compress the block if necessary. */
int block_writer_finish(struct block_writer *w);

/* clears out internally allocated block_writer members. */
void block_writer_clear(struct block_writer *bw);

/* Read a block. */
struct block_reader {
	/* offset of the block header; nonzero for the first block in a
	 * reftable. */
	uint32_t header_off;

	/* the memory block */
	struct reftable_block block;
	int hash_size;

	/* size of the data, excluding restart data. */
	uint32_t block_len;
	uint8_t *restart_bytes;
	uint16_t restart_count;

	/* size of the data in the file. For log blocks, this is the compressed
	 * size. */
	uint32_t full_block_size;
};

/* Iterate over entries in a block */
struct block_iter {
	/* offset within the block of the next entry to read. */
	uint32_t next_off;
	struct block_reader *br;

	/* key for last entry we read. */
	struct strbuf last_key;
};

/* initializes a block reader. */
int block_reader_init(struct block_reader *br, struct reftable_block *bl,
		      uint32_t header_off, uint32_t table_block_size,
		      int hash_size);

/* Position `it` at start of the block */
void block_reader_start(struct block_reader *br, struct block_iter *it);

/* Position `it` to the `want` key in the block */
int block_reader_seek(struct block_reader *br, struct block_iter *it,
		      struct strbuf *want);

/* Returns the block type (eg. 'r' for refs) */
uint8_t block_reader_type(struct block_reader *r);

/* Decodes the first key in the block */
int block_reader_first_key(struct block_reader *br, struct strbuf *key);

void block_iter_copy_from(struct block_iter *dest, struct block_iter *src);

/* return < 0 for error, 0 for OK, > 0 for EOF. */
int block_iter_next(struct block_iter *it, struct reftable_record *rec);

/* Seek to `want` with in the block pointed to by `it` */
int block_iter_seek(struct block_iter *it, struct strbuf *want);

/* deallocate memory for `it`. The block reader and its block is left intact. */
void block_iter_close(struct block_iter *it);

/* size of file header, depending on format version */
int header_size(int version);

/* size of file footer, depending on format version */
int footer_size(int version);

/* returns a block to its source. */
void reftable_block_done(struct reftable_block *ret);

#endif
debug log:

solving 14a6f835f4 ...
found 14a6f835f4 in https://public-inbox.org/git/1ba8e3eb3045b3ab6462febeaa8b90dc14910098.1600283416.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/757dd30fe2cdd19affc0208d8e8091d12810af80.1601568664.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/3c84f43cfa07708759b386f63dc4893ac45d0850.1592862921.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/169f6c7f543f1d3e5c91a0b38961c765d6900107.1593457018.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/12d98125c2bacdaab797cbaca47bdbfe000c293f.1596209238.git.gitgitgadget@gmail.com/

applying [1/5] https://public-inbox.org/git/1ba8e3eb3045b3ab6462febeaa8b90dc14910098.1600283416.git.gitgitgadget@gmail.com/
diff --git a/reftable/block.h b/reftable/block.h
new file mode 100644
index 0000000000..14a6f835f4

Checking patch reftable/block.h...
Applied patch reftable/block.h cleanly.

skipping https://public-inbox.org/git/757dd30fe2cdd19affc0208d8e8091d12810af80.1601568664.git.gitgitgadget@gmail.com/ for 14a6f835f4
skipping https://public-inbox.org/git/3c84f43cfa07708759b386f63dc4893ac45d0850.1592862921.git.gitgitgadget@gmail.com/ for 14a6f835f4
skipping https://public-inbox.org/git/169f6c7f543f1d3e5c91a0b38961c765d6900107.1593457018.git.gitgitgadget@gmail.com/ for 14a6f835f4
skipping https://public-inbox.org/git/12d98125c2bacdaab797cbaca47bdbfe000c293f.1596209238.git.gitgitgadget@gmail.com/ for 14a6f835f4
index at:
100644 14a6f835f460c63dd8db7895b01d524c0e726b4e	reftable/block.h

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git