ianhorswill / TED

Strongly-typed Datalog implementation embedded in C#
MIT License
7 stars 2 forks source link

Tables derived from base table only update with accumulation #27

Closed SamuelHill closed 1 year ago

SamuelHill commented 1 year ago

E.g.

LocationInformation = FromCsv("LocationInformation", Csv("locationInformation"),
    locationType.Key, locationCategory.Indexed, operation, schedule);
NewLocations = Predicate("NewLocations", location, locationType, position, founded, opening);
Locations = Predicate("Locations", location.Key, locationType.Indexed, position.Key, founded, opening);
Locations.Initially.Where(PrimordialLocations);
Locations.Accumulates(NewLocations);
var LocationsOfCategory = Predicate("LocationsOfCategory", 
    location, locationCategory).If(LocationInformation, Locations);

In this case, ideally LocationsOfCategory would only need to be updated whenever Locations is updated, acting like a dynamic EBD but without a direct call to accumulation.


This might involve larger changes as it breaks with the current Update:

by requiring some IDBs that are only based on EDBs to not recompute but append with their associated dynamic EDB(s).

ianhorswill commented 1 year ago

I do see the argument for that. But as you say, it requires some fairly complicated analysis. You can achieve the same end now by saying:

var LocationsOfCategory = Predicate("LocationsOfCategory", 
                                            location, locationCategory)
    .Initially.Where(LocationInformation, PrimordialLocations)
    .Add.If(LocationInformation, NewLocations);
SamuelHill commented 1 year ago
var LocationsOfCategory = Predicate("LocationsOfCategory", 
                                            location, locationCategory)
    .Initially.Where(LocationInformation, PrimordialLocations)
    .Add.If(LocationInformation, NewLocations);

Yeah, this makes sense - maybe in Simulog I can have a way of generating that table automatically