Renamed members of AdditionalData
This commit is contained in:
parent
c901ec2b06
commit
57a9eecdb3
@ -17,7 +17,7 @@ pub const EntityWriter = struct {
|
||||
data_types: []const DataType,
|
||||
) !void {
|
||||
try writer.writeAll("| ");
|
||||
for (additional_data.member_to_find.items) |member| {
|
||||
for (additional_data.childrens.items) |member| {
|
||||
try writeValue(writer, row[member.index], data_types[member.index]);
|
||||
try writer.writeAll(" \t| ");
|
||||
}
|
||||
@ -31,7 +31,7 @@ pub const EntityWriter = struct {
|
||||
data_types: []const DataType,
|
||||
) !void {
|
||||
try writer.writeByte('{');
|
||||
for (additional_data.member_to_find.items) |member| {
|
||||
for (additional_data.childrens.items) |member| {
|
||||
try writer.print("{s}: ", .{member.name});
|
||||
try writeValue(writer, row[member.index], data_types[member.index]);
|
||||
try writer.writeAll(", ");
|
||||
|
@ -294,7 +294,7 @@ pub const FileEngine = struct {
|
||||
|
||||
// Multi-threading setup
|
||||
var sync_context = ThreadSyncContext.init(
|
||||
additional_data.entity_count_to_find,
|
||||
additional_data.limit,
|
||||
max_file_index + 1,
|
||||
);
|
||||
|
||||
@ -327,10 +327,10 @@ pub const FileEngine = struct {
|
||||
for (list.items) |uuid| _ = map.getOrPut(uuid) catch return ZipponError.MemoryError;
|
||||
}
|
||||
|
||||
if (additional_data.entity_count_to_find == 0) return;
|
||||
if (additional_data.limit == 0) return;
|
||||
|
||||
if (map.count() > additional_data.entity_count_to_find) {
|
||||
log.err("Found {d} entity in populateVoidUUIDMap but max is: {d}", .{ map.count(), additional_data.entity_count_to_find });
|
||||
if (map.count() > additional_data.limit) {
|
||||
log.err("Found {d} entity in populateVoidUUIDMap but max is: {d}", .{ map.count(), additional_data.limit });
|
||||
var iter = map.iterator();
|
||||
while (iter.next()) |entry| {
|
||||
log.debug("{s}", .{UUID.format_bytes(entry.key_ptr.bytes)});
|
||||
@ -402,7 +402,7 @@ pub const FileEngine = struct {
|
||||
log.debug("Max file index {d}", .{max_file_index});
|
||||
|
||||
// If there is no member to find, that mean we need to return all members, so let's populate additional data with all of them
|
||||
if (additional_data.member_to_find.items.len == 0) {
|
||||
if (additional_data.childrens.items.len == 0) {
|
||||
additional_data.populateWithEverythingExceptLink(allocator, sstruct.members, sstruct.types) catch return FileEngineError.MemoryError;
|
||||
}
|
||||
|
||||
@ -411,7 +411,7 @@ pub const FileEngine = struct {
|
||||
|
||||
// Multi thread stuffs
|
||||
var sync_context = ThreadSyncContext.init(
|
||||
additional_data.entity_count_to_find,
|
||||
additional_data.limit,
|
||||
max_file_index + 1,
|
||||
);
|
||||
|
||||
@ -543,7 +543,7 @@ pub const FileEngine = struct {
|
||||
|
||||
// Multi-threading setup
|
||||
var sync_context = ThreadSyncContext.init(
|
||||
additional_data.entity_count_to_find,
|
||||
additional_data.limit,
|
||||
max_file_index + 1,
|
||||
);
|
||||
|
||||
@ -708,7 +708,7 @@ pub const FileEngine = struct {
|
||||
|
||||
// Multi-threading setup
|
||||
var sync_context = ThreadSyncContext.init(
|
||||
additional_data.entity_count_to_find,
|
||||
additional_data.limit,
|
||||
max_file_index + 1,
|
||||
);
|
||||
|
||||
|
@ -6,25 +6,25 @@ const DataType = dtype.DataType;
|
||||
/// This is the [] part
|
||||
/// TODO: Include the part ".friends.comments" in "GRAB User.firends.comments {age > 10}"
|
||||
pub const AdditionalData = struct {
|
||||
entity_count_to_find: usize = 0,
|
||||
member_to_find: std.ArrayList(AdditionalDataMember),
|
||||
limit: usize = 0,
|
||||
childrens: std.ArrayList(AdditionalDataMember),
|
||||
|
||||
pub fn init(allocator: Allocator) AdditionalData {
|
||||
return AdditionalData{ .member_to_find = std.ArrayList(AdditionalDataMember).init(allocator) };
|
||||
return AdditionalData{ .childrens = std.ArrayList(AdditionalDataMember).init(allocator) };
|
||||
}
|
||||
|
||||
pub fn deinit(self: *AdditionalData) void {
|
||||
for (0..self.member_to_find.items.len) |i| {
|
||||
self.member_to_find.items[i].additional_data.deinit();
|
||||
for (0..self.childrens.items.len) |i| {
|
||||
self.childrens.items[i].additional_data.deinit();
|
||||
}
|
||||
|
||||
self.member_to_find.deinit();
|
||||
self.childrens.deinit();
|
||||
}
|
||||
|
||||
pub fn populateWithEverythingExceptLink(self: *AdditionalData, allocator: Allocator, members: [][]const u8, dtypes: []DataType) !void {
|
||||
for (members, dtypes, 0..) |member, dt, i| {
|
||||
if (dt == .link or dt == .link_array) continue;
|
||||
try self.member_to_find.append(AdditionalDataMember.init(allocator, member, i));
|
||||
try self.childrens.append(AdditionalDataMember.init(allocator, member, i));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -654,7 +654,7 @@ pub const Parser = struct {
|
||||
token.loc.end,
|
||||
);
|
||||
};
|
||||
additional_data.entity_count_to_find = count;
|
||||
additional_data.limit = count;
|
||||
state = .expect_semicolon_OR_right_bracket;
|
||||
},
|
||||
else => {
|
||||
@ -694,7 +694,7 @@ pub const Parser = struct {
|
||||
token.loc.end,
|
||||
);
|
||||
}
|
||||
additional_data.member_to_find.append(
|
||||
additional_data.childrens.append(
|
||||
AdditionalDataMember.init(
|
||||
allocator,
|
||||
self.toker.getTokenSlice(token),
|
||||
@ -719,7 +719,7 @@ pub const Parser = struct {
|
||||
.l_bracket => {
|
||||
try self.parseAdditionalData(
|
||||
allocator,
|
||||
&additional_data.member_to_find.items[additional_data.member_to_find.items.len - 1].additional_data,
|
||||
&additional_data.childrens.items[additional_data.childrens.items.len - 1].additional_data,
|
||||
struct_name,
|
||||
);
|
||||
state = .expect_comma_OR_r_bracket;
|
||||
@ -962,7 +962,7 @@ pub const Parser = struct {
|
||||
token.* = self.toker.next();
|
||||
}
|
||||
|
||||
additional_data.entity_count_to_find = 1;
|
||||
additional_data.limit = 1;
|
||||
|
||||
if (token.tag == .l_brace) filter = try self.parseFilter(allocator, struct_name, false) else return printError(
|
||||
"Error: Expected filter",
|
||||
|
Loading…
x
Reference in New Issue
Block a user