Commit Graph

342 Commits

Author SHA1 Message Date
Salvo 'LtWorf' Tomaselli
50647294cb Enable futile_union_intersection_subtraction 2020-06-09 11:43:14 +02:00
Salvo 'LtWorf' Tomaselli
0dcd639c9d Enable one optimization
Due to the fact that the nodes are different classes, this required some refactor.
2020-06-09 11:18:33 +02:00
Salvo 'LtWorf' Tomaselli
3e524278e8 Remove unused 2020-06-09 10:51:40 +02:00
Salvo 'LtWorf' Tomaselli
6c677452e8 Remove old things 2020-06-09 10:14:19 +02:00
Salvo 'LtWorf' Tomaselli
a8426840da Disable all optimizations for now
They are in need of a refactor
2020-06-09 02:06:57 +02:00
Salvo 'LtWorf' Tomaselli
b508149583 Major refactory of the parser
It uses subclasses rather than a kind variable.

This is way more typesafe.
2020-06-09 01:37:19 +02:00
Salvo 'LtWorf' Tomaselli
353b40e1ab Use the newer class name 2018-04-22 00:30:20 +02:00
Salvo 'LtWorf' Tomaselli
7b471709c4 Add more typing info 2018-04-22 00:29:37 +02:00
Salvo 'LtWorf' Tomaselli
9101cee7ab Use new class name 2018-01-21 16:55:48 +01:00
Salvo 'LtWorf' Tomaselli
22aef831ff mypy: use different variable for different type
Instead of reassigning the same one, changing its type
2017-08-18 08:37:34 +02:00
Salvo 'LtWorf' Tomaselli
b8152e2d23 mypy, read explicitly as binary 2017-08-18 07:39:49 +02:00
Salvo 'LtWorf' Tomaselli
7a88dc9076 Replace == None with is 2017-07-02 12:50:48 +02:00
Salvo 'LtWorf' Tomaselli
f459f0635a Add missing returns
The conditions were only checking valid values, now exceptions are thrown if
none of the conditions match.

Also correct the type of _find_matching_parenthesis.
2017-07-02 12:47:46 +02:00
Salvo 'LtWorf' Tomaselli
12f4459682 More type information
Add type information, change some imports and some style.
2017-06-24 13:01:22 +02:00
Salvo 'LtWorf' Tomaselli
2d9bbf39f0 make mypy happy 2017-06-24 11:31:07 +02:00
Salvo 'LtWorf' Tomaselli
0778be30a1 Forbid using python keywords as names
closes #4
2017-05-13 00:21:18 +02:00
Salvo 'LtWorf' Tomaselli
d61bfafe5c Do not send survey in case of swearwords
I'm getting tired of kids blaming their idiocy on me.

They can go begging for money, for all I care.
2017-05-13 00:21:10 +02:00
Salvo 'LtWorf' Tomaselli
418dce95db Strip spaces from survey 2017-05-13 00:17:23 +02:00
Salvo 'LtWorf' Tomaselli
6caf8bc741 replaced verbose loop with comprehension 2017-04-24 00:41:52 +02:00
Salvo 'LtWorf' Tomaselli
f0d50eabee Query splitter complete 2016-08-21 11:03:45 +02:00
Salvo 'LtWorf' Tomaselli
47bc995fd9 Revert "Query splitter complete"
This reverts commit c4e258bbf9.

Because I had committed by mistake changes to guihandler
2016-08-21 10:58:46 +02:00
Salvo 'LtWorf' Tomaselli
d1d781f3a3 Encode session in base64 to workaround a Qt bug
Recent updates of Qt can no longer store python's binary strings as settings,
so I encode it as an easy to handle base64 string to make the session storing
work again.
2016-08-20 09:28:12 +02:00
Salvo 'LtWorf' Tomaselli
c4e258bbf9 Query splitter complete 2016-08-16 11:15:56 +02:00
Salvo 'LtWorf' Tomaselli
bd1c3a208c Variable name generator 2016-08-15 09:16:22 +02:00
Salvo 'LtWorf' Tomaselli
36bc145ac3 Initial commit for module to split queries into programs 2016-08-15 09:15:57 +02:00
Salvo 'LtWorf' Tomaselli
57ea58e516 Removed debug print 2016-05-25 15:27:16 +02:00
Salvo 'LtWorf' Tomaselli
077eaa16bd oijqwe 2016-05-25 15:13:18 +02:00
Salvo 'LtWorf' Tomaselli
93fbd848dc optimize_all can return parse tree
This is nice, to avoid re-parsing it.
2016-05-25 15:08:30 +02:00
Salvo 'LtWorf' Tomaselli
e47bf59320 Multi-line optimizations
Added multi line optimizations.

So far, the code is not able to eliminate repetitions, but
I plan to address this problem later.
2016-05-25 14:59:23 +02:00
Salvo 'LtWorf' Tomaselli
722b164d56 Fix Python code generator to correctly escape strings
A string that contained escape symbols was not correctly escaped
when generating the Python code for the selection.

This could cause selection operations to fail to compile.
2016-04-23 15:19:32 +02:00
Salvo 'LtWorf' Tomaselli
4d1b610605 Correct optimization over selection and product 2016-04-19 17:47:36 +02:00
Salvo 'LtWorf' Tomaselli
3779a1de81 Remove useless joins in optimization
Along with removing intersections and unions, this
removes useless joins in the same function.
2016-04-15 14:56:09 +02:00
Salvo 'LtWorf' Tomaselli
7e61120beb Make failure in unions commutative
Right now, because of how _rearrange was implemented, a union with a subset
of attributes of another union could be united with it, but not viceversa.

This change makes both operations fail, hence making the union commutative
again.

Correct unions were always commutative.
2016-04-15 14:43:18 +02:00
Salvo 'LtWorf' Tomaselli
1b049e13f0 Better handling of parenthesis inside string literals
When scanning for the matching parenthesis, string literals
were not taken into account, which would inevitably lead to
errors if one wanted to do a selection on a string containing
a parenthesis.

Now it uses a state-machine to skip the ones that are located
inside literals.
2016-04-09 11:37:28 +02:00
Salvo 'LtWorf' Tomaselli
6bc219c635 Avoid proliferation of parenthesis
The str() function of the parse tree now emits expressions
with much less parenthesis.

This should allow optimized queries to be more readable.
2016-04-09 11:11:25 +02:00
Salvo 'LtWorf' Tomaselli
002aca3f68 Only holds for union
Does not hold for other operations.
2016-04-09 10:07:44 +02:00
Salvo 'LtWorf' Tomaselli
85f2b3c3ee Error message when compilation fails
Within selection, the compilation of the string into python bytecode
can fail.

This shows an appropriate message.
2016-03-31 21:45:59 +02:00
Salvo 'LtWorf' Tomaselli
7661d21da2 Better message for missing fields
Happens in projections, when trying to use a field that does not exist.
2016-03-31 21:45:59 +02:00
Salvo 'LtWorf' Tomaselli
72318bb0e8 Updated copyright notices
With the last year of modification of the file in question.
2016-03-31 21:45:59 +02:00
Salvo 'LtWorf' Tomaselli
ef209ea93f Do not crash on network error while sending survey 2016-03-21 14:50:50 +01:00
Salvo 'LtWorf' Tomaselli
f12e35fef9 Do not crash in case of connection failure
Return None to indicate a network failure.
2016-03-21 14:40:23 +01:00
Salvo 'LtWorf' Tomaselli
ce348149f1 Better code style 2016-01-03 19:43:38 +01:00
Salvo 'LtWorf' Tomaselli
1dd1298ee0 New optimization: useless projection
If a projection is done on every attribute it is useless and
can be removed.

The new optimization does this.
2016-01-03 17:15:04 +01:00
Salvo 'LtWorf' Tomaselli
17410a0b19 Styled code 2016-01-03 16:55:10 +01:00
Salvo 'LtWorf' Tomaselli
d384a902cf Removed redundant check
Assuming that the query is correct, the removed condition must
always be true.
2016-01-03 12:39:48 +01:00
Salvo 'LtWorf' Tomaselli
3b3888e9be New optimization
Turns
        π a,b,c(A) ∪ π a,b,c(B)

    into
        π a,b,c(A ∪ B)

    if A and B are union compatible

Works with union, intersection and difference.
2016-01-03 10:07:23 +01:00
Salvo 'LtWorf' Tomaselli
0dd2ef2f1d Style 2016-01-03 09:28:45 +01:00
Salvo 'LtWorf' Tomaselli
e3877a4682 Added function to split an assignment expression
In the UI, a common pattern was to check if a query was
prefixed by an assignment and in that case, assign the result
to the given name.

This function puts this in a common place, so it can be used from
all the parts where it is needed.
2016-01-02 15:25:43 +01:00
Salvo 'LtWorf' Tomaselli
950a2273c3 New query optimization
A * B ∪ A * C = A * (B ∪ C)
2015-12-31 14:26:28 +01:00
Salvo 'LtWorf' Tomaselli
cd6bd42a2b Use normal strings in intermediate steps
This uses the CallableString object only in the final step and not
during all the intermediate ones.

Since str is a native object, it is faster to use than a normal
object.

This is a very marginal optimization that will not yield any
gains :)
2015-11-20 15:50:09 +01:00