Skip to content

Commit dcef066

Browse files
hazeycodeSrekelgmodarelli
committed
zpool: make unchecked column accessors public
This satifies the usecase where the user is storing many AddressableHandles instead of full fat Handles to save space and can guarentee their validity. Co-authored-by: Anders Elfgren <srekel@gmail.com> Co-authored-by: Giuseppe Modarelli <giuseppe.modarelli@gmail.com>
1 parent 161d948 commit dcef066

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

libs/zpool/src/pool.zig

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,16 +451,19 @@ pub fn Pool(
451451

452452
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
453453

454-
fn getColumnPtrUnchecked(self: Self, handle: AddressableHandle, comptime column: Column) *ColumnType(column) {
454+
/// Gets a column pointer. In most cases, `getColumnPtrAssumeLive` should be used instead.
455+
pub fn getColumnPtrUnchecked(self: Self, handle: AddressableHandle, comptime column: Column) *ColumnType(column) {
455456
const column_field = meta.fieldInfo(Columns, column);
456457
return &@field(self.columns, column_field.name)[handle.index];
457458
}
458459

459-
fn getColumnUnchecked(self: Self, handle: AddressableHandle, comptime column: Column) ColumnType(column) {
460+
/// Gets a column value. In most cases, `getColumnAssumeLive` should be used instead.
461+
pub fn getColumnUnchecked(self: Self, handle: AddressableHandle, comptime column: Column) ColumnType(column) {
460462
return self.getColumnPtrUnchecked(handle, column).*;
461463
}
462464

463-
fn getColumnsUnchecked(self: Self, handle: AddressableHandle) Columns {
465+
/// Gets column values. In most cases, `getColumnsAssumeLive` should be used instead.
466+
pub fn getColumnsUnchecked(self: Self, handle: AddressableHandle) Columns {
464467
var values: Columns = undefined;
465468
inline for (column_fields) |column_field| {
466469
@field(values, column_field.name) =
@@ -469,13 +472,15 @@ pub fn Pool(
469472
return values;
470473
}
471474

472-
fn setColumnUnchecked(self: Self, handle: AddressableHandle, comptime column: Column, value: ColumnType(column)) void {
475+
/// Sets a column value. In most cases, `setColumnAssumeLive` should be used instead.
476+
pub fn setColumnUnchecked(self: Self, handle: AddressableHandle, comptime column: Column, value: ColumnType(column)) void {
473477
const column_field = meta.fieldInfo(Columns, column);
474478
self.deinitColumnAt(handle.index, column_field);
475479
@field(self.columns, column_field.name)[handle.index] = value;
476480
}
477481

478-
fn setColumnsUnchecked(self: Self, handle: AddressableHandle, values: Columns) void {
482+
/// Sets column values. In most cases, `setColumnsAssumeLive` should be used instead.
483+
pub fn setColumnsUnchecked(self: Self, handle: AddressableHandle, values: Columns) void {
479484
self.deinitColumnsAt(handle.index);
480485
self.initColumnsAt(handle.index, values);
481486
}

0 commit comments

Comments
 (0)