Commit Graph

1690 Commits

Author SHA1 Message Date
Grigorii Kirgizov 65f1198a60 Prune the whole related state in RuleMatchers on removal-phase. Add test case. 2019-06-13 20:10:08 +03:00
Grigorii Kirgizov 7acbbc3988 Fix tests 2019-06-13 18:01:35 +03:00
Grigorii Kirgizov d1152128da Remove kotlin imports 2019-06-13 18:00:04 +03:00
Grigorii Kirgizov 9863569323 Tests for incrementally removing and removing+adding rules 2019-06-12 19:09:06 +03:00
Grigorii Kirgizov d7b7d40f8a Don't expose InitialRule to RuleDiff. Add first test for rm algo stage. 2019-06-12 14:56:57 +03:00
Grigorii Kirgizov 0bfe9e8a47 minor: remove usages of Constraint.isPrincipal in ProcessingStateImpl, use IncrementalProgramSpec instead 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov ae20c334b4 Discern incremental reactivation from usual one. Fix postponedMatches logic. 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov b3e0770939 minor: slightly rearrange code in ProcessingStateImpl 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov a5a46d6c67 Add incrementality test for one nontrivial case in RuleMatchFront.expand 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov db80dc7ab6 Extract rule ordering logic from ProcessingStateImpl 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 175d9f7623 Move StateFrameStack class to its own file 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov a2d55e92b9 Remove accidental line duplication 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 2a5f9e28dc Fix handling of postponed matches (match order comparison was slightly wrong) 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 5a9019e85c Fix bits of logic responsible for launching 'at-start' rules through 'main'. Fix handling of discarded occs 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 767eb057f5 Add helper method in Tests builder, adjust few tests with it 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 50fcfd0d8a Add initial version of logic for handling future matches in processActivated() 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov dffab2016c upd gitignore 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov fa380c9f36 Fix failing build of coderules because of changed interfaces 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 3e50f47f73 Add MatchJournal.Index for additional queries and operations involving ordering of occurrences 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov eec343f902 Add stub code for handling case of adding headless ('at-start') rules 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov c0cb26d598 Add two more tests for addition phase. Handle one additional case and make one test pass. 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov ddb67690f4 Add partial sketch of removal phase of incremental algorithm.
For that: Extend DispatchingFront and RuleMatcherImpl interface with
'forget' methods which completely drops related matches from matchers' state;
Extend MatchJournal & Chunk interfaces with helper methods.
2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 8b4d98f6e2 Add few more checks in TestIncrementalProgram tests and one test in TestStoreAwareJournal 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 5b500340e5 Make StoreAwareJournal a pure interface, move delegated inheritance to StoreAwareJournalImpl (hide journal) 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 71eac08775 Move replayOccurrences back to MatchJournal again, fix tests 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 8d615852c6 Remove Controller from Occurrence and instead pass a new one each time through OccurrenceObserver
It caused a situation when on the very next incremental evaluation session
occurrences carried a stale Controller along with all the state from previous session.
As a result, incorrect logic of program evaluation.
2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 4e60ef9909 Add tests for incremental additions (one fails for now). Don't log reactivations in journal. 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 95b5f97869 Add equals() to MatchJournal.Pos. Handle corner case in 'replay', when it happens to the same pos. Same for 'reset'. 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov e33df7aac2 Hide mutable collection of occurrences in Chunk and add 'principleConstraint' fun to its interface 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov c9b486c170 Fix StoreAwareJournal test given updated journal's iterator starting pos 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 97d36d8d1f Fix corner case in algo stage. Add test for it. 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 6a3aad364c Add SessionToken to preserve eval state between sessions. Add IncrementalProgramSpec. Add impl of one algo stage, in ProcessingStateImpl.
SessionToken includes MatchJournal.View and a state of all RuleMatchers.
IncrementalProgramSpec specifies information needed for incremental evaluation.
In essence, it answers on queries of type 'isPrincipal' for Rules and Constraints.
It decouples specific incremental info from entities, allows to inject it easily in tests.
Its presence also enables incremental version of evaluation, in EvaluationSessionImpl.
2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 6932e99774 Enable tracking justification in Controller for principal constraints' occ-s 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 76194a62ae Refactor tests to make them more readable. Remove unsafe cast from journal's reset. 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 11bec29410 Use journal for aborting execution of alternative branches, fix 'reset' method
All tests for Controller pass, but one test from StoreAwareJournal fails, mute for now
2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 0fb54fc5ba Add invariant to Journal that it always has at least initial chunk, with EmptyRuleMatch
Also slightly fix tests and add tracking (i.e. using journal) to ProcessingStateImpl
2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 225bd9861e Separate concerns b/w ProcessingStateImpl and StateAwareJournal, construct in a new way
ProcessingStateImpl has only processing logic and inherits frame stack logic from StateAwareJournal
2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 77bc7538a4 Prepare before merging StoreAwareJournal & ProcessingStateImpl: extract FrameStack from ProcState, inherit StoreAwareJ from MatchJ by delegation 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 799b57c74e minor: remove usages of rule.tag() in tests 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 0cbc32d4a0 Get rid off nullability of Justs 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 52fd54afce Hide use of TIntSet from trove behind typealias; one usage in ConstraintOccurrence.java is left 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov f8b7ac1d50 Few renames in MatchJournal; throw exceptions at invalid iteration states 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov d3883effaf Extract frame-independent logic from MatchHistory to its base class MatchJournal
Small changes: rename MatchHistory -> StateAwareJournal; use referential
eq when iterating through chunks; provide only Pos, not Chunk from
current()/currentPos(); fix tests according to all this.
2019-06-12 13:28:05 +03:00
Grigorii Kirgizov e5942d2c77 Fix MatchHistory tests: fix impl of storeView, taking into account current pos in history (not all of it) 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov c4309084c5 Refactor: remove match-logic from StateFrame (now it's only about Observers), mvoe it to ProcessingState 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov b2f65e1510 Implement storeView() method to MatchHistory, remove it from ProcessingImpl (but not its single usage yet) and stored occurrences from StateFrame 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov cbddd108bb Subst FrameStack in MatchHistory for ProcessingImpl 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov cd5ad91caf minor: fix type in 'logOccurence' method 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov c322cf5c70 Add test with more complex and representative manipulation of MatchHistory 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov a360abc59e Add MatchHistory.View class (snapshot of history), refine one test, fix mistake in history.reset() 2019-06-12 13:28:05 +03:00