tigerbeetle-node 0.11.13 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/aarch64-linux-gnu/client.node +0 -0
- package/dist/bin/aarch64-linux-musl/client.node +0 -0
- package/dist/bin/aarch64-macos/client.node +0 -0
- package/dist/bin/x86_64-linux-gnu/client.node +0 -0
- package/dist/bin/x86_64-linux-musl/client.node +0 -0
- package/dist/bin/x86_64-macos/client.node +0 -0
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/package-lock.json +66 -0
- package/package.json +6 -16
- package/src/index.ts +56 -1
- package/src/node.zig +9 -9
- package/dist/.client.node.sha256 +0 -1
- package/scripts/build_lib.sh +0 -61
- package/scripts/download_node_headers.sh +0 -32
- package/src/tigerbeetle/scripts/benchmark.bat +0 -55
- package/src/tigerbeetle/scripts/benchmark.sh +0 -66
- package/src/tigerbeetle/scripts/confirm_image.sh +0 -44
- package/src/tigerbeetle/scripts/fail_on_diff.sh +0 -9
- package/src/tigerbeetle/scripts/fuzz_loop.sh +0 -15
- package/src/tigerbeetle/scripts/fuzz_loop_hash_log.sh +0 -12
- package/src/tigerbeetle/scripts/fuzz_unique_errors.sh +0 -7
- package/src/tigerbeetle/scripts/install.bat +0 -7
- package/src/tigerbeetle/scripts/install.sh +0 -21
- package/src/tigerbeetle/scripts/install_zig.bat +0 -113
- package/src/tigerbeetle/scripts/install_zig.sh +0 -90
- package/src/tigerbeetle/scripts/lint.zig +0 -199
- package/src/tigerbeetle/scripts/pre-commit.sh +0 -9
- package/src/tigerbeetle/scripts/scripts/benchmark.bat +0 -55
- package/src/tigerbeetle/scripts/scripts/benchmark.sh +0 -66
- package/src/tigerbeetle/scripts/scripts/confirm_image.sh +0 -44
- package/src/tigerbeetle/scripts/scripts/fail_on_diff.sh +0 -9
- package/src/tigerbeetle/scripts/scripts/fuzz_loop.sh +0 -15
- package/src/tigerbeetle/scripts/scripts/fuzz_loop_hash_log.sh +0 -12
- package/src/tigerbeetle/scripts/scripts/fuzz_unique_errors.sh +0 -7
- package/src/tigerbeetle/scripts/scripts/install.bat +0 -7
- package/src/tigerbeetle/scripts/scripts/install.sh +0 -21
- package/src/tigerbeetle/scripts/scripts/install_zig.bat +0 -113
- package/src/tigerbeetle/scripts/scripts/install_zig.sh +0 -90
- package/src/tigerbeetle/scripts/scripts/lint.zig +0 -199
- package/src/tigerbeetle/scripts/scripts/pre-commit.sh +0 -9
- package/src/tigerbeetle/scripts/scripts/shellcheck.sh +0 -5
- package/src/tigerbeetle/scripts/scripts/tests_on_alpine.sh +0 -10
- package/src/tigerbeetle/scripts/scripts/tests_on_ubuntu.sh +0 -14
- package/src/tigerbeetle/scripts/scripts/upgrade_ubuntu_kernel.sh +0 -48
- package/src/tigerbeetle/scripts/scripts/validate_docs.sh +0 -23
- package/src/tigerbeetle/scripts/scripts/vr_state_enumerate +0 -46
- package/src/tigerbeetle/scripts/shellcheck.sh +0 -5
- package/src/tigerbeetle/scripts/tests_on_alpine.sh +0 -10
- package/src/tigerbeetle/scripts/tests_on_ubuntu.sh +0 -14
- package/src/tigerbeetle/scripts/upgrade_ubuntu_kernel.sh +0 -48
- package/src/tigerbeetle/scripts/validate_docs.sh +0 -23
- package/src/tigerbeetle/scripts/vr_state_enumerate +0 -46
- package/src/tigerbeetle/src/benchmark.zig +0 -336
- package/src/tigerbeetle/src/config.zig +0 -233
- package/src/tigerbeetle/src/constants.zig +0 -428
- package/src/tigerbeetle/src/ewah.zig +0 -286
- package/src/tigerbeetle/src/ewah_benchmark.zig +0 -120
- package/src/tigerbeetle/src/ewah_fuzz.zig +0 -130
- package/src/tigerbeetle/src/fifo.zig +0 -120
- package/src/tigerbeetle/src/io/benchmark.zig +0 -213
- package/src/tigerbeetle/src/io/darwin.zig +0 -814
- package/src/tigerbeetle/src/io/linux.zig +0 -1071
- package/src/tigerbeetle/src/io/test.zig +0 -643
- package/src/tigerbeetle/src/io/windows.zig +0 -1183
- package/src/tigerbeetle/src/io.zig +0 -34
- package/src/tigerbeetle/src/iops.zig +0 -107
- package/src/tigerbeetle/src/lsm/README.md +0 -308
- package/src/tigerbeetle/src/lsm/binary_search.zig +0 -341
- package/src/tigerbeetle/src/lsm/bloom_filter.zig +0 -125
- package/src/tigerbeetle/src/lsm/compaction.zig +0 -603
- package/src/tigerbeetle/src/lsm/composite_key.zig +0 -77
- package/src/tigerbeetle/src/lsm/direction.zig +0 -11
- package/src/tigerbeetle/src/lsm/eytzinger.zig +0 -587
- package/src/tigerbeetle/src/lsm/eytzinger_benchmark.zig +0 -330
- package/src/tigerbeetle/src/lsm/forest.zig +0 -205
- package/src/tigerbeetle/src/lsm/forest_fuzz.zig +0 -450
- package/src/tigerbeetle/src/lsm/grid.zig +0 -573
- package/src/tigerbeetle/src/lsm/groove.zig +0 -1036
- package/src/tigerbeetle/src/lsm/k_way_merge.zig +0 -474
- package/src/tigerbeetle/src/lsm/level_iterator.zig +0 -332
- package/src/tigerbeetle/src/lsm/manifest.zig +0 -617
- package/src/tigerbeetle/src/lsm/manifest_level.zig +0 -878
- package/src/tigerbeetle/src/lsm/manifest_log.zig +0 -789
- package/src/tigerbeetle/src/lsm/manifest_log_fuzz.zig +0 -691
- package/src/tigerbeetle/src/lsm/merge_iterator.zig +0 -106
- package/src/tigerbeetle/src/lsm/node_pool.zig +0 -235
- package/src/tigerbeetle/src/lsm/posted_groove.zig +0 -381
- package/src/tigerbeetle/src/lsm/segmented_array.zig +0 -1329
- package/src/tigerbeetle/src/lsm/segmented_array_benchmark.zig +0 -148
- package/src/tigerbeetle/src/lsm/segmented_array_fuzz.zig +0 -9
- package/src/tigerbeetle/src/lsm/set_associative_cache.zig +0 -850
- package/src/tigerbeetle/src/lsm/table.zig +0 -1009
- package/src/tigerbeetle/src/lsm/table_immutable.zig +0 -192
- package/src/tigerbeetle/src/lsm/table_iterator.zig +0 -340
- package/src/tigerbeetle/src/lsm/table_mutable.zig +0 -203
- package/src/tigerbeetle/src/lsm/test.zig +0 -439
- package/src/tigerbeetle/src/lsm/tree.zig +0 -1169
- package/src/tigerbeetle/src/lsm/tree_fuzz.zig +0 -479
- package/src/tigerbeetle/src/message_bus.zig +0 -1013
- package/src/tigerbeetle/src/message_pool.zig +0 -156
- package/src/tigerbeetle/src/ring_buffer.zig +0 -399
- package/src/tigerbeetle/src/simulator.zig +0 -580
- package/src/tigerbeetle/src/state_machine/auditor.zig +0 -578
- package/src/tigerbeetle/src/state_machine/workload.zig +0 -883
- package/src/tigerbeetle/src/state_machine.zig +0 -2099
- package/src/tigerbeetle/src/static_allocator.zig +0 -65
- package/src/tigerbeetle/src/stdx.zig +0 -171
- package/src/tigerbeetle/src/storage.zig +0 -393
- package/src/tigerbeetle/src/testing/cluster/message_bus.zig +0 -82
- package/src/tigerbeetle/src/testing/cluster/network.zig +0 -237
- package/src/tigerbeetle/src/testing/cluster/state_checker.zig +0 -169
- package/src/tigerbeetle/src/testing/cluster/storage_checker.zig +0 -202
- package/src/tigerbeetle/src/testing/cluster.zig +0 -444
- package/src/tigerbeetle/src/testing/fuzz.zig +0 -140
- package/src/tigerbeetle/src/testing/hash_log.zig +0 -66
- package/src/tigerbeetle/src/testing/id.zig +0 -99
- package/src/tigerbeetle/src/testing/packet_simulator.zig +0 -374
- package/src/tigerbeetle/src/testing/priority_queue.zig +0 -645
- package/src/tigerbeetle/src/testing/reply_sequence.zig +0 -139
- package/src/tigerbeetle/src/testing/state_machine.zig +0 -250
- package/src/tigerbeetle/src/testing/storage.zig +0 -757
- package/src/tigerbeetle/src/testing/table.zig +0 -247
- package/src/tigerbeetle/src/testing/time.zig +0 -84
- package/src/tigerbeetle/src/tigerbeetle.zig +0 -227
- package/src/tigerbeetle/src/time.zig +0 -112
- package/src/tigerbeetle/src/tracer.zig +0 -529
- package/src/tigerbeetle/src/unit_tests.zig +0 -40
- package/src/tigerbeetle/src/vopr.zig +0 -495
- package/src/tigerbeetle/src/vsr/README.md +0 -209
- package/src/tigerbeetle/src/vsr/client.zig +0 -544
- package/src/tigerbeetle/src/vsr/clock.zig +0 -855
- package/src/tigerbeetle/src/vsr/journal.zig +0 -2415
- package/src/tigerbeetle/src/vsr/journal_format_fuzz.zig +0 -111
- package/src/tigerbeetle/src/vsr/marzullo.zig +0 -309
- package/src/tigerbeetle/src/vsr/replica.zig +0 -6616
- package/src/tigerbeetle/src/vsr/replica_format.zig +0 -219
- package/src/tigerbeetle/src/vsr/superblock.zig +0 -1631
- package/src/tigerbeetle/src/vsr/superblock_client_table.zig +0 -256
- package/src/tigerbeetle/src/vsr/superblock_free_set.zig +0 -929
- package/src/tigerbeetle/src/vsr/superblock_free_set_fuzz.zig +0 -334
- package/src/tigerbeetle/src/vsr/superblock_fuzz.zig +0 -390
- package/src/tigerbeetle/src/vsr/superblock_manifest.zig +0 -615
- package/src/tigerbeetle/src/vsr/superblock_quorums.zig +0 -394
- package/src/tigerbeetle/src/vsr/superblock_quorums_fuzz.zig +0 -314
- package/src/tigerbeetle/src/vsr.zig +0 -1425
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
const std = @import("std");
|
|
2
|
-
const assert = std.debug.assert;
|
|
3
|
-
const math = std.math;
|
|
4
|
-
const mem = std.mem;
|
|
5
|
-
const stdx = @import("stdx.zig");
|
|
6
|
-
const div_ceil = stdx.div_ceil;
|
|
7
|
-
const disjoint_slices = stdx.disjoint_slices;
|
|
8
|
-
|
|
9
|
-
/// Encode or decode a bitset using Daniel Lemire's EWAH codec.
|
|
10
|
-
/// ("Histogram-Aware Sorting for Enhanced Word-Aligned Compression in Bitmap Indexes")
|
|
11
|
-
///
|
|
12
|
-
/// EWAH uses only two types of words, where the first type is a 64-bit verbatim ("literal") word.
|
|
13
|
-
/// The second type of word is a marker word:
|
|
14
|
-
/// * The first bit indicates which uniform word will follow.
|
|
15
|
-
/// * The next 31 bits are used to store the number of uniform words.
|
|
16
|
-
/// * The last 32 bits are used to store the number of literal words following the uniform words.
|
|
17
|
-
/// EWAH bitmaps begin with a marker word. A 'marker' looks like (assuming a 64-bit word):
|
|
18
|
-
///
|
|
19
|
-
/// [uniform_bit:u1][uniform_word_count:u31(LE)][literal_word_count:u32(LE)]
|
|
20
|
-
///
|
|
21
|
-
/// and is immediately followed by `literal_word_count` 64-bit literals.
|
|
22
|
-
/// When decoding a marker, the uniform words precede the literal words.
|
|
23
|
-
///
|
|
24
|
-
/// This encoding requires that the architecture is little-endian with 64-bit words.
|
|
25
|
-
pub fn ewah(comptime Word: type) type {
|
|
26
|
-
const word_bits = @bitSizeOf(Word);
|
|
27
|
-
|
|
28
|
-
return struct {
|
|
29
|
-
const Self = @This();
|
|
30
|
-
|
|
31
|
-
const marker_uniform_word_count_max = (1 << ((word_bits / 2) - 1)) - 1;
|
|
32
|
-
const marker_literal_word_count_max = (1 << (word_bits / 2)) - 1;
|
|
33
|
-
|
|
34
|
-
pub const MarkerUniformCount = math.IntFittingRange(0, marker_uniform_word_count_max); // Word=usize → u31
|
|
35
|
-
pub const MarkerLiteralCount = math.IntFittingRange(0, marker_literal_word_count_max); // Word=usize → u32
|
|
36
|
-
|
|
37
|
-
const Marker = packed struct {
|
|
38
|
-
uniform_bit: u1, // Whether the uniform word is all 0s or all 1s.
|
|
39
|
-
uniform_word_count: MarkerUniformCount, // 31-bit number of uniform words following the marker.
|
|
40
|
-
literal_word_count: MarkerLiteralCount, // 32-bit number of literal words following the uniform words.
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
comptime {
|
|
44
|
-
assert(@import("builtin").target.cpu.arch.endian() == std.builtin.Endian.Little);
|
|
45
|
-
assert(@typeInfo(Word).Int.signedness == .unsigned);
|
|
46
|
-
assert(word_bits % 8 == 0); // A multiple of a byte, so that words can be cast to bytes.
|
|
47
|
-
assert(@bitSizeOf(Marker) == word_bits);
|
|
48
|
-
assert(@sizeOf(Marker) == @sizeOf(Word));
|
|
49
|
-
|
|
50
|
-
assert(@bitSizeOf(MarkerUniformCount) % 2 == 1);
|
|
51
|
-
assert(math.maxInt(MarkerUniformCount) == marker_uniform_word_count_max);
|
|
52
|
-
|
|
53
|
-
assert(@bitSizeOf(MarkerLiteralCount) % 2 == 0);
|
|
54
|
-
assert(math.maxInt(MarkerLiteralCount) == marker_literal_word_count_max);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
inline fn marker_word(mark: Marker) Word {
|
|
58
|
-
return @bitCast(Word, mark);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/// Decodes the compressed bitset in `source` into `target_words`.
|
|
62
|
-
/// Returns the number of *words* written to `target_words`.
|
|
63
|
-
// TODO Refactor to return an error when `source` is invalid,
|
|
64
|
-
// so that we can test invalid encodings.
|
|
65
|
-
pub fn decode(source: []align(@alignOf(Word)) const u8, target_words: []Word) usize {
|
|
66
|
-
assert(source.len % @sizeOf(Word) == 0);
|
|
67
|
-
assert(disjoint_slices(u8, Word, source, target_words));
|
|
68
|
-
|
|
69
|
-
const source_words = mem.bytesAsSlice(Word, source);
|
|
70
|
-
var source_index: usize = 0;
|
|
71
|
-
var target_index: usize = 0;
|
|
72
|
-
while (source_index < source_words.len) {
|
|
73
|
-
const marker = @ptrCast(*const Marker, &source_words[source_index]);
|
|
74
|
-
source_index += 1;
|
|
75
|
-
std.mem.set(
|
|
76
|
-
Word,
|
|
77
|
-
target_words[target_index..][0..marker.uniform_word_count],
|
|
78
|
-
if (marker.uniform_bit == 1) ~@as(Word, 0) else 0,
|
|
79
|
-
);
|
|
80
|
-
target_index += marker.uniform_word_count;
|
|
81
|
-
stdx.copy_disjoint(
|
|
82
|
-
.exact,
|
|
83
|
-
Word,
|
|
84
|
-
target_words[target_index..][0..marker.literal_word_count],
|
|
85
|
-
source_words[source_index..][0..marker.literal_word_count],
|
|
86
|
-
);
|
|
87
|
-
source_index += marker.literal_word_count;
|
|
88
|
-
target_index += marker.literal_word_count;
|
|
89
|
-
}
|
|
90
|
-
assert(source_index == source_words.len);
|
|
91
|
-
assert(target_index <= target_words.len);
|
|
92
|
-
return target_index;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Returns the number of bytes written to `target`.
|
|
96
|
-
pub fn encode(source_words: []const Word, target: []align(@alignOf(Word)) u8) usize {
|
|
97
|
-
assert(target.len == encode_size_max(source_words.len));
|
|
98
|
-
assert(disjoint_slices(Word, u8, source_words, target));
|
|
99
|
-
|
|
100
|
-
const target_words = mem.bytesAsSlice(Word, target);
|
|
101
|
-
std.mem.set(Word, target_words, 0);
|
|
102
|
-
|
|
103
|
-
var target_index: usize = 0;
|
|
104
|
-
var source_index: usize = 0;
|
|
105
|
-
while (source_index < source_words.len) {
|
|
106
|
-
const word = source_words[source_index];
|
|
107
|
-
|
|
108
|
-
const uniform_word_count = count: {
|
|
109
|
-
if (is_literal(word)) break :count 0;
|
|
110
|
-
// Measure run length.
|
|
111
|
-
const uniform_max = math.min(source_words.len - source_index, marker_uniform_word_count_max);
|
|
112
|
-
var uniform: usize = 1;
|
|
113
|
-
while (uniform < uniform_max and source_words[source_index + uniform] == word) uniform += 1;
|
|
114
|
-
break :count uniform;
|
|
115
|
-
};
|
|
116
|
-
source_index += uniform_word_count;
|
|
117
|
-
// For consistent encoding, set the run/uniform bit to 0 when there is no run.
|
|
118
|
-
const uniform_bit = if (uniform_word_count == 0) 0 else @intCast(u1, word & 1);
|
|
119
|
-
|
|
120
|
-
// Count sequential literals that immediately follow the run.
|
|
121
|
-
const literals_max = math.min(source_words.len - source_index, marker_literal_word_count_max);
|
|
122
|
-
const literal_word_count = for (source_words[source_index..][0..literals_max]) |w, i| {
|
|
123
|
-
if (!is_literal(w)) break i;
|
|
124
|
-
} else literals_max;
|
|
125
|
-
|
|
126
|
-
target_words[target_index] = marker_word(.{
|
|
127
|
-
.uniform_bit = uniform_bit,
|
|
128
|
-
.uniform_word_count = @intCast(MarkerUniformCount, uniform_word_count),
|
|
129
|
-
.literal_word_count = @intCast(MarkerLiteralCount, literal_word_count),
|
|
130
|
-
});
|
|
131
|
-
target_index += 1;
|
|
132
|
-
stdx.copy_disjoint(
|
|
133
|
-
.exact,
|
|
134
|
-
Word,
|
|
135
|
-
target_words[target_index..][0..literal_word_count],
|
|
136
|
-
source_words[source_index..][0..literal_word_count],
|
|
137
|
-
);
|
|
138
|
-
source_index += literal_word_count;
|
|
139
|
-
target_index += literal_word_count;
|
|
140
|
-
}
|
|
141
|
-
assert(source_index == source_words.len);
|
|
142
|
-
|
|
143
|
-
return target_index * @sizeOf(Word);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/// Returns the maximum number of bytes required to encode `word_count` words.
|
|
147
|
-
/// Assumes (pessimistically) that every word will be encoded as a literal.
|
|
148
|
-
pub fn encode_size_max(word_count: usize) usize {
|
|
149
|
-
const marker_count = div_ceil(word_count, marker_literal_word_count_max);
|
|
150
|
-
return marker_count * @sizeOf(Marker) + word_count * @sizeOf(Word);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
inline fn is_literal(word: Word) bool {
|
|
154
|
-
return word != 0 and word != ~@as(Word, 0);
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
test "ewah encode→decode cycle" {
|
|
160
|
-
const fuzz = @import("./ewah_fuzz.zig");
|
|
161
|
-
var prng = std.rand.DefaultPrng.init(123);
|
|
162
|
-
|
|
163
|
-
inline for (.{ u8, u16, u32, u64, usize }) |Word| {
|
|
164
|
-
var decoded: [4096]Word = undefined;
|
|
165
|
-
|
|
166
|
-
std.mem.set(Word, &decoded, 0);
|
|
167
|
-
try fuzz.fuzz_encode_decode(Word, std.testing.allocator, &decoded);
|
|
168
|
-
|
|
169
|
-
std.mem.set(Word, &decoded, std.math.maxInt(Word));
|
|
170
|
-
try fuzz.fuzz_encode_decode(Word, std.testing.allocator, &decoded);
|
|
171
|
-
|
|
172
|
-
prng.random().bytes(std.mem.asBytes(&decoded));
|
|
173
|
-
try fuzz.fuzz_encode_decode(Word, std.testing.allocator, &decoded);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
test "ewah Word=u8" {
|
|
178
|
-
try test_decode_with_word(u8);
|
|
179
|
-
|
|
180
|
-
const codec = ewah(u8);
|
|
181
|
-
var uniform_word_count: usize = 0;
|
|
182
|
-
while (uniform_word_count <= math.maxInt(codec.MarkerUniformCount)) : (uniform_word_count += 1) {
|
|
183
|
-
try test_decode(u8, &.{
|
|
184
|
-
codec.marker_word(.{
|
|
185
|
-
.uniform_bit = 0,
|
|
186
|
-
.uniform_word_count = @intCast(codec.MarkerUniformCount, uniform_word_count),
|
|
187
|
-
.literal_word_count = 3,
|
|
188
|
-
}),
|
|
189
|
-
12,
|
|
190
|
-
34,
|
|
191
|
-
56,
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
try std.testing.expectEqual(codec.encode_size_max(0), 0);
|
|
196
|
-
try std.testing.expectEqual(codec.encode(&.{}, &.{}), 0);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
test "ewah Word=u16" {
|
|
200
|
-
try test_decode_with_word(u16);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// decode → encode → decode
|
|
204
|
-
fn test_decode_with_word(comptime Word: type) !void {
|
|
205
|
-
const codec = ewah(Word);
|
|
206
|
-
|
|
207
|
-
// No set bits.
|
|
208
|
-
try test_decode(Word, &.{});
|
|
209
|
-
// Alternating runs, no literals.
|
|
210
|
-
try test_decode(Word, &.{
|
|
211
|
-
codec.marker_word(.{ .uniform_bit = 0, .uniform_word_count = 2, .literal_word_count = 0 }),
|
|
212
|
-
codec.marker_word(.{ .uniform_bit = 1, .uniform_word_count = 3, .literal_word_count = 0 }),
|
|
213
|
-
codec.marker_word(.{ .uniform_bit = 0, .uniform_word_count = 4, .literal_word_count = 0 }),
|
|
214
|
-
});
|
|
215
|
-
// Alternating runs, with literals.
|
|
216
|
-
try test_decode(Word, &.{
|
|
217
|
-
codec.marker_word(.{ .uniform_bit = 0, .uniform_word_count = 2, .literal_word_count = 1 }),
|
|
218
|
-
12,
|
|
219
|
-
codec.marker_word(.{ .uniform_bit = 1, .uniform_word_count = 3, .literal_word_count = 1 }),
|
|
220
|
-
34,
|
|
221
|
-
codec.marker_word(.{ .uniform_bit = 0, .uniform_word_count = 4, .literal_word_count = 1 }),
|
|
222
|
-
56,
|
|
223
|
-
});
|
|
224
|
-
// Consecutive run marker overflow.
|
|
225
|
-
try test_decode(Word, &.{
|
|
226
|
-
codec.marker_word(.{
|
|
227
|
-
.uniform_bit = 0,
|
|
228
|
-
.uniform_word_count = math.maxInt(codec.MarkerUniformCount),
|
|
229
|
-
.literal_word_count = 0,
|
|
230
|
-
}),
|
|
231
|
-
codec.marker_word(.{ .uniform_bit = 0, .uniform_word_count = 2, .literal_word_count = 0 }),
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
var encoding = std.ArrayList(Word).init(std.testing.allocator);
|
|
235
|
-
defer encoding.deinit();
|
|
236
|
-
|
|
237
|
-
{
|
|
238
|
-
// Consecutive literal marker overflow.
|
|
239
|
-
try encoding.append(codec.marker_word(.{
|
|
240
|
-
.uniform_bit = 0,
|
|
241
|
-
.uniform_word_count = 0,
|
|
242
|
-
.literal_word_count = math.maxInt(codec.MarkerLiteralCount),
|
|
243
|
-
}));
|
|
244
|
-
var i: Word = 0;
|
|
245
|
-
while (i < math.maxInt(codec.MarkerLiteralCount)) : (i += 1) try encoding.append(i + 1);
|
|
246
|
-
try encoding.append(codec.marker_word(.{
|
|
247
|
-
.uniform_bit = 0,
|
|
248
|
-
.uniform_word_count = 0,
|
|
249
|
-
.literal_word_count = 2,
|
|
250
|
-
}));
|
|
251
|
-
try encoding.append(i + 2);
|
|
252
|
-
try encoding.append(i + 3);
|
|
253
|
-
try test_decode(Word, encoding.items);
|
|
254
|
-
encoding.items.len = 0;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
fn test_decode(comptime Word: type, encoded_expect_words: []Word) !void {
|
|
259
|
-
const encoded_expect = mem.sliceAsBytes(encoded_expect_words);
|
|
260
|
-
const codec = ewah(Word);
|
|
261
|
-
const decoded_expect_data = try std.testing.allocator.alloc(Word, 4 * math.maxInt(Word));
|
|
262
|
-
defer std.testing.allocator.free(decoded_expect_data);
|
|
263
|
-
|
|
264
|
-
const decoded_expect_length = codec.decode(encoded_expect, decoded_expect_data);
|
|
265
|
-
const decoded_expect = decoded_expect_data[0..decoded_expect_length];
|
|
266
|
-
const encoded_actual = try std.testing.allocator.alignedAlloc(
|
|
267
|
-
u8,
|
|
268
|
-
@alignOf(Word),
|
|
269
|
-
codec.encode_size_max(decoded_expect.len),
|
|
270
|
-
);
|
|
271
|
-
defer std.testing.allocator.free(encoded_actual);
|
|
272
|
-
|
|
273
|
-
const encoded_actual_length = codec.encode(decoded_expect, encoded_actual);
|
|
274
|
-
try std.testing.expectEqual(encoded_expect.len, encoded_actual_length);
|
|
275
|
-
try std.testing.expectEqualSlices(u8, encoded_expect, encoded_actual[0..encoded_actual_length]);
|
|
276
|
-
|
|
277
|
-
const encoded_size_max = codec.encode_size_max(decoded_expect.len);
|
|
278
|
-
try std.testing.expect(encoded_expect.len <= encoded_size_max);
|
|
279
|
-
|
|
280
|
-
const decoded_actual = try std.testing.allocator.alloc(Word, decoded_expect.len);
|
|
281
|
-
defer std.testing.allocator.free(decoded_actual);
|
|
282
|
-
|
|
283
|
-
const decoded_actual_length = codec.decode(encoded_actual, decoded_actual);
|
|
284
|
-
try std.testing.expectEqual(decoded_expect.len, decoded_actual_length);
|
|
285
|
-
try std.testing.expectEqualSlices(Word, decoded_expect, decoded_actual);
|
|
286
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
const std = @import("std");
|
|
2
|
-
const assert = std.debug.assert;
|
|
3
|
-
const ewah = @import("ewah.zig").ewah(usize);
|
|
4
|
-
|
|
5
|
-
const BitSetConfig = struct {
|
|
6
|
-
words: usize,
|
|
7
|
-
run_length_e: usize,
|
|
8
|
-
literals_length_e: usize,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const samples = 100;
|
|
12
|
-
const repeats: usize = 100_000;
|
|
13
|
-
|
|
14
|
-
// Explanation of fields:
|
|
15
|
-
// - "n": Number of randomly generate bitsets to test.
|
|
16
|
-
// - "words": The length of the decoded bitset, in u64s.
|
|
17
|
-
// - "run_length_e": The expected length of a run, ignoring truncation due to reaching the end of
|
|
18
|
-
// the bitset.
|
|
19
|
-
// - "literals_length_e": Expected length of a sequence of literals.
|
|
20
|
-
const configs = [_]BitSetConfig{
|
|
21
|
-
// primarily runs
|
|
22
|
-
.{ .words = 640, .run_length_e = 10, .literals_length_e = 10 },
|
|
23
|
-
.{ .words = 640, .run_length_e = 100, .literals_length_e = 10 },
|
|
24
|
-
.{ .words = 640, .run_length_e = 200, .literals_length_e = 10 },
|
|
25
|
-
// primarily literals
|
|
26
|
-
.{ .words = 640, .run_length_e = 1, .literals_length_e = 100 },
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
var prng = std.rand.DefaultPrng.init(42);
|
|
30
|
-
|
|
31
|
-
pub fn main() !void {
|
|
32
|
-
const stdout = std.io.getStdOut().writer();
|
|
33
|
-
|
|
34
|
-
for (configs) |config| {
|
|
35
|
-
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
|
36
|
-
defer arena.deinit();
|
|
37
|
-
|
|
38
|
-
const allocator = arena.allocator();
|
|
39
|
-
var i: usize = 0;
|
|
40
|
-
var bitsets: [samples][]usize = undefined;
|
|
41
|
-
var bitsets_encoded: [samples][]align(@alignOf(usize)) u8 = undefined;
|
|
42
|
-
var bitsets_decoded: [samples][]usize = undefined;
|
|
43
|
-
var bitset_lengths: [samples]usize = undefined;
|
|
44
|
-
while (i < samples) : (i += 1) {
|
|
45
|
-
bitsets[i] = try make_bitset(allocator, config);
|
|
46
|
-
bitsets_encoded[i] = try allocator.alignedAlloc(u8, @alignOf(usize), ewah.encode_size_max(bitsets[0].len));
|
|
47
|
-
bitsets_decoded[i] = try allocator.alloc(usize, config.words);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Benchmark encoding.
|
|
51
|
-
const encode_timer = try std.time.Timer.start();
|
|
52
|
-
i = 0;
|
|
53
|
-
while (i < samples) : (i += 1) {
|
|
54
|
-
var j: usize = 0;
|
|
55
|
-
var size: usize = undefined;
|
|
56
|
-
while (j < repeats) : (j += 1) {
|
|
57
|
-
size = ewah.encode(bitsets[i], bitsets_encoded[i]);
|
|
58
|
-
}
|
|
59
|
-
bitset_lengths[i] = size;
|
|
60
|
-
}
|
|
61
|
-
const encode_time = encode_timer.read() / samples / repeats;
|
|
62
|
-
|
|
63
|
-
const decode_timer = try std.time.Timer.start();
|
|
64
|
-
// Benchmark decoding.
|
|
65
|
-
i = 0;
|
|
66
|
-
while (i < samples) : (i += 1) {
|
|
67
|
-
const bitset_encoded = bitsets_encoded[i][0..bitset_lengths[i]];
|
|
68
|
-
var j: usize = 0;
|
|
69
|
-
while (j < repeats) : (j += 1) {
|
|
70
|
-
_ = ewah.decode(bitset_encoded, bitsets_decoded[i]);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const decode_time = decode_timer.read() / samples / repeats;
|
|
74
|
-
|
|
75
|
-
i = 0;
|
|
76
|
-
while (i < samples) : (i += 1) {
|
|
77
|
-
assert(std.mem.eql(usize, bitsets[i], bitsets_decoded[i]));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Compute compression ratio.
|
|
81
|
-
var total_uncompressed: f64 = 0.0;
|
|
82
|
-
var total_compressed: f64 = 0.0;
|
|
83
|
-
i = 0;
|
|
84
|
-
while (i < samples) : (i += 1) {
|
|
85
|
-
total_uncompressed += @intToFloat(f64, bitsets[i].len * @sizeOf(usize));
|
|
86
|
-
total_compressed += @intToFloat(f64, bitset_lengths[i]);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
try stdout.print("Words={:_>3} E(Run)={:_>3} E(Literal)={:_>3} EncTime={:_>6}ns DecTime={:_>6}ns Ratio={d:_>6.2}\n", .{
|
|
90
|
-
config.words,
|
|
91
|
-
config.run_length_e,
|
|
92
|
-
config.literals_length_e,
|
|
93
|
-
encode_time,
|
|
94
|
-
decode_time,
|
|
95
|
-
total_uncompressed / total_compressed,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
fn make_bitset(allocator: std.mem.Allocator, config: BitSetConfig) ![]usize {
|
|
101
|
-
var words = try allocator.alloc(usize, config.words);
|
|
102
|
-
var w: usize = 0;
|
|
103
|
-
var literal: usize = 1;
|
|
104
|
-
while (w < words.len) : (w += 1) {
|
|
105
|
-
const run_length = prng.random().uintLessThan(usize, 2 * config.run_length_e);
|
|
106
|
-
const literals_length = prng.random().uintLessThan(usize, 2 * config.literals_length_e);
|
|
107
|
-
const run_bit = prng.random().boolean();
|
|
108
|
-
|
|
109
|
-
const run_end = std.math.min(w + run_length, words.len);
|
|
110
|
-
while (w < run_end) : (w += 1) {
|
|
111
|
-
words[w] = if (run_bit) std.math.maxInt(usize) else 0;
|
|
112
|
-
}
|
|
113
|
-
const literals_end = std.math.min(w + literals_length, words.len);
|
|
114
|
-
while (w < literals_end) : (w += 1) {
|
|
115
|
-
words[w] = literal;
|
|
116
|
-
literal += 1;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return words;
|
|
120
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
//! Fuzz EWAH encode/decode cycle.
|
|
2
|
-
const std = @import("std");
|
|
3
|
-
const assert = std.debug.assert;
|
|
4
|
-
const log = std.log.scoped(.fuzz_ewah);
|
|
5
|
-
|
|
6
|
-
const ewah = @import("./ewah.zig");
|
|
7
|
-
const fuzz = @import("./testing/fuzz.zig");
|
|
8
|
-
|
|
9
|
-
pub const tigerbeetle_config = @import("config.zig").configs.test_min;
|
|
10
|
-
|
|
11
|
-
pub fn main() !void {
|
|
12
|
-
const allocator = std.testing.allocator;
|
|
13
|
-
const args = try fuzz.parse_fuzz_args(allocator);
|
|
14
|
-
|
|
15
|
-
inline for (.{ u8, u16, u32, u64, usize }) |Word| {
|
|
16
|
-
var prng = std.rand.DefaultPrng.init(args.seed);
|
|
17
|
-
const random = prng.random();
|
|
18
|
-
|
|
19
|
-
const decoded_size_max = @divExact(1024 * 1024, @sizeOf(Word));
|
|
20
|
-
const decoded_size = random.uintLessThan(usize, 1 + decoded_size_max);
|
|
21
|
-
const decoded = try allocator.alloc(Word, decoded_size);
|
|
22
|
-
defer allocator.free(decoded);
|
|
23
|
-
|
|
24
|
-
const decoded_bits_total = decoded_size * @bitSizeOf(Word);
|
|
25
|
-
const decoded_bits = random.uintLessThan(usize, decoded_bits_total);
|
|
26
|
-
generate_bits(random, std.mem.sliceAsBytes(decoded[0..decoded_size]), decoded_bits);
|
|
27
|
-
|
|
28
|
-
var context = try ContextType(Word).init(allocator, decoded.len);
|
|
29
|
-
defer context.deinit(allocator);
|
|
30
|
-
|
|
31
|
-
const encoded_size = try context.test_encode_decode(decoded);
|
|
32
|
-
|
|
33
|
-
log.info("word={} decoded={} encoded={} compression_ratio={d:.2} set={d:.2}", .{
|
|
34
|
-
Word,
|
|
35
|
-
decoded_size,
|
|
36
|
-
encoded_size,
|
|
37
|
-
@intToFloat(f64, decoded_size) / @intToFloat(f64, encoded_size),
|
|
38
|
-
@intToFloat(f64, decoded_bits) / @intToFloat(f64, decoded_bits_total),
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
pub fn fuzz_encode_decode(
|
|
44
|
-
comptime Word: type,
|
|
45
|
-
allocator: std.mem.Allocator,
|
|
46
|
-
decoded: []const Word,
|
|
47
|
-
) !void {
|
|
48
|
-
var context = try ContextType(Word).init(allocator, decoded.len);
|
|
49
|
-
defer context.deinit(allocator);
|
|
50
|
-
|
|
51
|
-
_ = try context.test_encode_decode(decoded);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/// Modify `data` such that it has exactly `bits_set_total` randomly-chosen bits set,
|
|
55
|
-
/// with the remaining bits unset.
|
|
56
|
-
fn generate_bits(random: std.rand.Random, data: []u8, bits_set_total: usize) void {
|
|
57
|
-
const bits_total = data.len * @bitSizeOf(u8);
|
|
58
|
-
assert(bits_set_total <= bits_total);
|
|
59
|
-
|
|
60
|
-
// Start off full or empty to save some work.
|
|
61
|
-
const init_empty = bits_set_total < @divExact(bits_total, 2);
|
|
62
|
-
std.mem.set(u8, data, if (init_empty) @as(u8, 0) else std.math.maxInt(u8));
|
|
63
|
-
|
|
64
|
-
var bits_set = if (init_empty) 0 else bits_total;
|
|
65
|
-
while (bits_set != bits_set_total) {
|
|
66
|
-
const bit = random.uintLessThan(usize, bits_total);
|
|
67
|
-
const word = @divFloor(bit, @bitSizeOf(u8));
|
|
68
|
-
const mask = @as(u8, 1) << @intCast(std.math.Log2Int(u8), bit % @bitSizeOf(u8));
|
|
69
|
-
|
|
70
|
-
if (init_empty) {
|
|
71
|
-
if (data[word] & mask != 0) continue;
|
|
72
|
-
data[word] |= mask;
|
|
73
|
-
bits_set += 1;
|
|
74
|
-
} else {
|
|
75
|
-
if (data[word] & mask == 0) continue;
|
|
76
|
-
data[word] &= ~mask;
|
|
77
|
-
bits_set -= 1;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
fn ContextType(comptime Word: type) type {
|
|
83
|
-
return struct {
|
|
84
|
-
const Self = @This();
|
|
85
|
-
const Codec = ewah.ewah(Word);
|
|
86
|
-
|
|
87
|
-
decoded_actual: []Word,
|
|
88
|
-
encoded_actual: []align(@alignOf(Word)) u8,
|
|
89
|
-
|
|
90
|
-
fn init(allocator: std.mem.Allocator, size_max: usize) !Self {
|
|
91
|
-
const decoded_actual = try allocator.alloc(Word, size_max);
|
|
92
|
-
errdefer allocator.free(decoded_actual);
|
|
93
|
-
|
|
94
|
-
const encoded_actual = try allocator.alignedAlloc(
|
|
95
|
-
u8,
|
|
96
|
-
@alignOf(Word),
|
|
97
|
-
Codec.encode_size_max(size_max),
|
|
98
|
-
);
|
|
99
|
-
errdefer allocator.free(encoded_actual);
|
|
100
|
-
|
|
101
|
-
return Self{
|
|
102
|
-
.decoded_actual = decoded_actual,
|
|
103
|
-
.encoded_actual = encoded_actual,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
fn deinit(context: *Self, allocator: std.mem.Allocator) void {
|
|
108
|
-
allocator.free(context.decoded_actual);
|
|
109
|
-
allocator.free(context.encoded_actual);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
fn test_encode_decode(context: Self, decoded_expect: []const Word) !usize {
|
|
113
|
-
assert(decoded_expect.len > 0);
|
|
114
|
-
|
|
115
|
-
const encoded_size = Codec.encode(decoded_expect, context.encoded_actual);
|
|
116
|
-
const decoded_actual_size = Codec.decode(
|
|
117
|
-
context.encoded_actual[0..encoded_size],
|
|
118
|
-
context.decoded_actual[0..],
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
try std.testing.expectEqual(decoded_expect.len, decoded_actual_size);
|
|
122
|
-
try std.testing.expectEqualSlices(
|
|
123
|
-
Word,
|
|
124
|
-
decoded_expect,
|
|
125
|
-
context.decoded_actual[0..decoded_actual_size],
|
|
126
|
-
);
|
|
127
|
-
return encoded_size;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
const std = @import("std");
|
|
2
|
-
const assert = std.debug.assert;
|
|
3
|
-
|
|
4
|
-
/// An intrusive first in/first out linked list.
|
|
5
|
-
/// The element type T must have a field called "next" of type ?*T
|
|
6
|
-
pub fn FIFO(comptime T: type) type {
|
|
7
|
-
return struct {
|
|
8
|
-
const Self = @This();
|
|
9
|
-
|
|
10
|
-
in: ?*T = null,
|
|
11
|
-
out: ?*T = null,
|
|
12
|
-
|
|
13
|
-
pub fn push(self: *Self, elem: *T) void {
|
|
14
|
-
assert(elem.next == null);
|
|
15
|
-
if (self.in) |in| {
|
|
16
|
-
in.next = elem;
|
|
17
|
-
self.in = elem;
|
|
18
|
-
} else {
|
|
19
|
-
assert(self.out == null);
|
|
20
|
-
self.in = elem;
|
|
21
|
-
self.out = elem;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
pub fn pop(self: *Self) ?*T {
|
|
26
|
-
const ret = self.out orelse return null;
|
|
27
|
-
self.out = ret.next;
|
|
28
|
-
ret.next = null;
|
|
29
|
-
if (self.in == ret) self.in = null;
|
|
30
|
-
return ret;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
pub fn peek(self: Self) ?*T {
|
|
34
|
-
return self.out;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
pub fn empty(self: Self) bool {
|
|
38
|
-
return self.peek() == null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/// Remove an element from the FIFO. Asserts that the element is
|
|
42
|
-
/// in the FIFO. This operation is O(N), if this is done often you
|
|
43
|
-
/// probably want a different data structure.
|
|
44
|
-
pub fn remove(self: *Self, to_remove: *T) void {
|
|
45
|
-
if (to_remove == self.out) {
|
|
46
|
-
_ = self.pop();
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
var it = self.out;
|
|
50
|
-
while (it) |elem| : (it = elem.next) {
|
|
51
|
-
if (to_remove == elem.next) {
|
|
52
|
-
if (to_remove == self.in) self.in = elem;
|
|
53
|
-
elem.next = to_remove.next;
|
|
54
|
-
to_remove.next = null;
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
} else unreachable;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
test "push/pop/peek/remove/empty" {
|
|
63
|
-
const testing = @import("std").testing;
|
|
64
|
-
|
|
65
|
-
const Foo = struct { next: ?*@This() = null };
|
|
66
|
-
|
|
67
|
-
var one: Foo = .{};
|
|
68
|
-
var two: Foo = .{};
|
|
69
|
-
var three: Foo = .{};
|
|
70
|
-
|
|
71
|
-
var fifo: FIFO(Foo) = .{};
|
|
72
|
-
try testing.expect(fifo.empty());
|
|
73
|
-
|
|
74
|
-
fifo.push(&one);
|
|
75
|
-
try testing.expect(!fifo.empty());
|
|
76
|
-
try testing.expectEqual(@as(?*Foo, &one), fifo.peek());
|
|
77
|
-
|
|
78
|
-
fifo.push(&two);
|
|
79
|
-
fifo.push(&three);
|
|
80
|
-
try testing.expect(!fifo.empty());
|
|
81
|
-
try testing.expectEqual(@as(?*Foo, &one), fifo.peek());
|
|
82
|
-
|
|
83
|
-
fifo.remove(&one);
|
|
84
|
-
try testing.expect(!fifo.empty());
|
|
85
|
-
try testing.expectEqual(@as(?*Foo, &two), fifo.pop());
|
|
86
|
-
try testing.expectEqual(@as(?*Foo, &three), fifo.pop());
|
|
87
|
-
try testing.expectEqual(@as(?*Foo, null), fifo.pop());
|
|
88
|
-
try testing.expect(fifo.empty());
|
|
89
|
-
|
|
90
|
-
fifo.push(&one);
|
|
91
|
-
fifo.push(&two);
|
|
92
|
-
fifo.push(&three);
|
|
93
|
-
fifo.remove(&two);
|
|
94
|
-
try testing.expect(!fifo.empty());
|
|
95
|
-
try testing.expectEqual(@as(?*Foo, &one), fifo.pop());
|
|
96
|
-
try testing.expectEqual(@as(?*Foo, &three), fifo.pop());
|
|
97
|
-
try testing.expectEqual(@as(?*Foo, null), fifo.pop());
|
|
98
|
-
try testing.expect(fifo.empty());
|
|
99
|
-
|
|
100
|
-
fifo.push(&one);
|
|
101
|
-
fifo.push(&two);
|
|
102
|
-
fifo.push(&three);
|
|
103
|
-
fifo.remove(&three);
|
|
104
|
-
try testing.expect(!fifo.empty());
|
|
105
|
-
try testing.expectEqual(@as(?*Foo, &one), fifo.pop());
|
|
106
|
-
try testing.expect(!fifo.empty());
|
|
107
|
-
try testing.expectEqual(@as(?*Foo, &two), fifo.pop());
|
|
108
|
-
try testing.expect(fifo.empty());
|
|
109
|
-
try testing.expectEqual(@as(?*Foo, null), fifo.pop());
|
|
110
|
-
try testing.expect(fifo.empty());
|
|
111
|
-
|
|
112
|
-
fifo.push(&one);
|
|
113
|
-
fifo.push(&two);
|
|
114
|
-
fifo.remove(&two);
|
|
115
|
-
fifo.push(&three);
|
|
116
|
-
try testing.expectEqual(@as(?*Foo, &one), fifo.pop());
|
|
117
|
-
try testing.expectEqual(@as(?*Foo, &three), fifo.pop());
|
|
118
|
-
try testing.expectEqual(@as(?*Foo, null), fifo.pop());
|
|
119
|
-
try testing.expect(fifo.empty());
|
|
120
|
-
}
|