Removed old comment and move an array a bit later in function

This commit is contained in:
Adrien Bouvais 2025-02-12 14:54:10 +01:00
parent 84f5749aa2
commit 7352ec45c7
6 changed files with 8 additions and 13 deletions

View File

@ -312,8 +312,6 @@ pub const Filter = struct {
else => unreachable,
},
// TODO: Also be able to it for array to array. Like names in ['something']
// And it is true if at least one value are shared between array.
.in => switch (condition.data_type) {
.link => condition.value.link.contains(UUID{ .bytes = row_value.UUID }),
.int => in(i32, row_value.Int, condition.value.int_array),

View File

@ -16,8 +16,6 @@
// Then for each RelationMap, I parse the files again this time to update the first JSON that now have {<||>}
// With a sub additionalData. If there is an additional data relation, I recurcive.
// So I need an option in parseEntity to either write the first JSON or update the existing one
//
// FIXME: I think if 2 different struct have the same member name it can cause issue but maybe not tho
const std = @import("std");
const AdditionalData = @import("additionalData.zig").AdditionalData;

View File

@ -190,9 +190,6 @@ pub fn parseEntities(
var safe_allocator = std.heap.ThreadSafeAllocator{ .child_allocator = arena.allocator() };
const allocator = safe_allocator.allocator();
var buff = std.ArrayList(u8).init(entry_allocator);
const writer = buff.writer();
const sstruct = try self.schema_engine.structName2SchemaStruct(struct_name);
const to_parse = try self.allFileIndex(allocator, struct_name);
@ -235,6 +232,9 @@ pub fn parseEntities(
wg.wait();
// Append all writer to each other
var buff = std.ArrayList(u8).init(entry_allocator);
const writer = buff.writer();
writer.writeByte('[') catch return ZipponError.WriteError;
for (thread_writer_list) |list| writer.writeAll(list.items) catch return ZipponError.WriteError;
writer.writeByte(']') catch return ZipponError.WriteError;

View File

@ -268,7 +268,7 @@ pub fn deleteEntities(
writer.writeByte(']') catch return ZipponError.WriteError;
// FIXME: Stop doing that and just remove UUID from the map itself instead of reparsing everything at the end
// It's just that I can't do it in deleteEntitiesOneFile itself
// It's just that I can't do it in deleteEntitiesOneFile itself because of multi thread that update the map at same time
sstruct.uuid_file_index.map.clearRetainingCapacity();
_ = sstruct.uuid_file_index.reset();
try self.populateFileIndexUUIDMap(sstruct, sstruct.uuid_file_index);

View File

@ -72,7 +72,7 @@ test "GRAB filter with string" { // OK
test "GRAB with additional data" { // OK
const db = DB{ .path = "test1", .schema = "schema/test" };
try testParsing(db, "GRAB User [1] {age < 18}"); // FIXME: Return nothing
try testParsing(db, "GRAB User [1] {age < 18}");
try testParsing(db, "GRAB User [id, name] {age < 18}");
try testParsing(db, "GRAB User [100; name, age] {age < 18}");
}
@ -100,16 +100,15 @@ test "GRAB filter with date" { // OK
try testParsing(db, "GRAB User {last_order > 2000/01/01-12:45}");
}
// FIXME: GRAB User [1] return nothing
test "Specific query" { // NOT OK
const db = DB{ .path = "test1", .schema = "schema/test" };
try testParsing(db, "GRAB User");
try testParsing(db, "GRAB User {}");
try testParsing(db, "GRAB User [1]"); // FIXME: Return nothing
try testParsing(db, "GRAB User [1]");
try testParsing(db, "GRAB User [*, friends]");
}
test "Specific query ADD" { // OK
test "Specific query ADD" { // OK - Test if array and relationship are empty by default if not specify
const db = DB{ .path = "test1", .schema = "schema/test" };
try testParsing(db, "ADD User (name = 'Bob1', email='bob@email.com', age=55, best_friend=none, friends=none, bday=2000/01/01, a_time=12:04, last_order=2000/01/01-12:45)");
try testParsing(db, "ADD User (name = 'Bob2', email='bob@email.com', age=55, best_friend=none, bday=2000/01/01, a_time=12:04, last_order=2000/01/01-12:45)");

View File

@ -21,7 +21,7 @@ pub fn init(allocator: std.mem.Allocator) !ThreadEngine {
const cpu_core = if (CPU_CORE == 0) std.Thread.getCpuCount() catch 1 else CPU_CORE;
log.debug("Using {d} cpu core.", .{cpu_core});
log.debug("Using {d}Mb stack size.", .{std.Thread.SpawnConfig.default_stack_size / 1024 / 1024});
// log.debug("Using {d}Mb stack size.", .{std.Thread.SpawnConfig.default_stack_size / 1024 / 1024});
const thread_pool = try allocator.create(std.Thread.Pool);
try thread_pool.init(std.Thread.Pool.Options{