62 Commits

Author SHA1 Message Date
Salvo 'LtWorf' Tomaselli
f0608c7212 Simply __str__ function 2015-11-17 15:44:59 +01:00
Salvo 'LtWorf' Tomaselli
3012a08ff3 Removed unused variable 2015-11-11 17:01:52 +01:00
Salvo 'LtWorf' Tomaselli
d5c5707213 load/save improvements 2015-10-10 02:10:33 +02:00
Salvo 'LtWorf' Tomaselli
be4217dec9 removed outdated comment 2015-10-10 02:02:35 +02:00
Salvo 'LtWorf' Tomaselli
d597076038 Subtle bug that occurred selecting after a join
Outer joins add the placeholder '---' that is used as some sort of NULL
value.

However select operations on such relations would always fail, because
relations are supposed to only contain values of class rstring, and
the placeholder was added as a regular string.

As a consequence, automatic casting would always fail, and the select
would always raise an exception.

Added a new test case with this specific case in mind.
2015-09-10 12:19:51 +02:00
Salvo 'LtWorf' Tomaselli
be7e6fe12d Classes have now names that begin with uppercase
This is more Pythonic and makes the code more readable.

Backwards compatibility is provided by giving an alias with the
previous name of the class.

It will not be broken until the next major release.
2015-07-14 15:39:35 +02:00
Salvo 'LtWorf' Tomaselli
af02b5a59b Improved docstring 2015-07-14 15:08:39 +02:00
Salvo 'LtWorf' Tomaselli
c275c1caf3 Improve performance of __eq__
If the cardinality of two relations does not match, the expensive
rearrange procedure is not performed at all.
2015-07-14 11:11:13 +02:00
Salvo 'LtWorf' Tomaselli
f787630edb Use isinstance rather than comparing class attribute
This allows to create subclasses
2015-07-14 11:09:42 +02:00
Salvo 'LtWorf' Tomaselli
73dd14d9dd Style 2015-07-14 11:01:35 +02:00
Salvo 'LtWorf' Tomaselli
98ac364dc7 Removed encoding string
Not needed in Python 3
2015-07-14 10:43:13 +02:00
Salvo 'LtWorf' Tomaselli
f6b4c6708b _rearrange() is an identity if not needed
Operations are possible even when the order of the attributes is
not the same. Because ordering is just an implementation detail and
not an actual part of relational algebra.

A _rearrange() function exists to convert relations to have a similar
format and be able to operate on them.

The function would perform a projection in any case, which would cause
the creation of a new temporary relation, even when the relations where
already using the same order of attributes.

This commit fixes the issue by making it return an identity if the
operation is not necessary.
2015-06-25 16:46:10 +02:00
Salvo 'LtWorf' Tomaselli
95e375f44a Use dictionary comprehension in selection
When doing a selection, a new context (in the form of a dictionary)
is created.

Instead of re-using the same dictionary re-assigning the values, now
use a comprehension to avoid redundant reads.
2015-06-25 16:34:47 +02:00
Salvo 'LtWorf' Tomaselli
5021f1f8cb Use the insert() method to load files
In this way, checks are performed automatically on every tuple
and code is simplified.

This should make it safer to raise exceptions on files that are
not relations.
2015-06-07 14:03:24 +02:00
Salvo 'LtWorf' Tomaselli
a033cb769a Make header inherit from tupl
Rather than having a header class that contains a list of header,
change it to directly be an immutable tuple.

This simplifies the code because header can now be compared and
indexed like any other tuple.

Code had to be changed all over the place to cope with this new
datatype.
2015-06-06 15:22:11 +02:00
Salvo 'LtWorf' Tomaselli
d754a166a1 Removed duplicated check 2015-06-06 14:17:27 +02:00
Salvo 'LtWorf' Tomaselli
b12ea8d27a Raise exception for duplicated attrs in projection
Rather than ignoring them, raise an exception
2015-06-06 14:15:47 +02:00
Salvo 'LtWorf' Tomaselli
bbc2855cc5 Use list comprehension 2015-06-06 14:12:02 +02:00
Salvo 'LtWorf' Tomaselli
229a83f3ad Missing import 2015-06-06 13:52:39 +02:00
Salvo 'LtWorf' Tomaselli
01dc9391d1 Adds len() to relation
Returns the cardinality
2015-06-05 18:28:44 +02:00
Salvo 'LtWorf' Tomaselli
d05c2e2d3c Replace intermediate lists with iterators
Some more intermediate lists created during joins are now
not created in favour of iterators instead
2015-06-05 18:15:03 +02:00
Salvo 'LtWorf' Tomaselli
f974fc316d Use intersection method of header
Rather than manually implement that with 2 for loops
2015-06-05 18:02:46 +02:00
Salvo 'LtWorf' Tomaselli
c8db7b619c Replace temp lists with iterators 2015-06-05 17:54:54 +02:00
Salvo 'LtWorf' Tomaselli
f0a9650174 Added iter function
Adds __iter__ and __contains__ to relations and headers.
2015-06-05 17:41:09 +02:00
Salvo 'LtWorf' Tomaselli
de405480b5 Moved casting function in rstring
rstring now has an autocast() function that returns the automatic casting
for that value.
The casting is cached so is really performed only once, at most, during
the lifetime of the object.
2015-06-01 09:12:22 +02:00
Salvo 'LtWorf' Tomaselli
e4158a3685 Refactored rename header
Now will directly raise an exception, requiring one less if
2015-06-01 08:58:54 +02:00
Salvo 'LtWorf' Tomaselli
1f7983309b Simplified getAttributesId() 2015-06-01 08:55:11 +02:00
Salvo 'LtWorf' Tomaselli
496a5c19d1 Raise an exception when trying to insert n-uples with the wrong cardinality 2015-06-01 08:49:40 +02:00
Salvo 'LtWorf' Tomaselli
3fca4edd15 Refactory of rearrange 2015-06-01 08:48:52 +02:00
Salvo 'LtWorf' Tomaselli
766a3a6527 Simplified delete method 2015-06-01 08:45:29 +02:00
Salvo 'LtWorf' Tomaselli
be6400c270 Mark both relations as read-only after a rename
Only one relation was marked as read-only after a rename, which means
that changes to the original relation would affect the other one
as well.
2015-06-01 08:43:41 +02:00
Salvo 'LtWorf' Tomaselli
acdd4629a6 Python3 change, replace file() with open() 2015-06-01 07:32:53 +02:00
Salvo 'LtWorf' Tomaselli
4af2230ced Use rstrings anywhere
Since rstrings are faster and provide some caching features,
keep the same rstring objects from the beginning rather than
continuously casting strings.
2015-06-01 07:31:19 +02:00
Salvo 'LtWorf' Tomaselli
0a562ff603 Check for duplicated attributes
Fails to work if attributes are duplicated, raising an appropriate
exception.
2015-02-23 14:17:50 +01:00
Salvo 'LtWorf' Tomaselli
a355762fc4 Switch core module to Python3
The core module (the relational algebra, not the interface) is now
using Python3

Tests are passing, so it should be ok.
2015-02-19 12:42:41 +01:00
Salvo 'LtWorf' Tomaselli
556eecc118 Changed about and README to not point to galileo anymore 2013-12-27 00:31:43 +01:00
Salvo 'LtWorf' Tomaselli
f1eb4e0b23 doc change 2013-06-29 16:51:20 +02:00
LtWorf
4c5915e854 - Minor changes to comments
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@313 014f5005-505e-4b48-8d0a-63407b615a7c
2011-10-08 17:04:07 +00:00
LtWorf
3ca26b10c6 - Forces relations to have correct attribute names
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@296 014f5005-505e-4b48-8d0a-63407b615a7c
2011-04-01 07:06:08 +00:00
LtWorf
dfb3f19acf - Raises exception for wrong relational operations
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@295 014f5005-505e-4b48-8d0a-63407b615a7c
2011-04-01 06:38:47 +00:00
LtWorf
b4dffea5cf - Changed header comments in modules
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@287 014f5005-505e-4b48-8d0a-63407b615a7c
2011-03-22 16:02:36 +00:00
LtWorf
4a6f2cc222 - Handles sign in numeric types
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@284 014f5005-505e-4b48-8d0a-63407b615a7c
2011-03-21 13:30:04 +00:00
LtWorf
1e51f9784f - test driver script is now executable
- adds more generic procedure to perform implicit casting, thus eliminating duplicate code



git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@271 014f5005-505e-4b48-8d0a-63407b615a7c
2011-03-03 09:27:53 +00:00
LtWorf
3b0392e867 - Float type recognition is more robust, now handled using a regexp
- Date type recognition is more robust, now using a combination of regexp plus date object
- Parsing of strings representing dates is now cached, eliminating the need for double parse



git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@270 014f5005-505e-4b48-8d0a-63407b615a7c
2011-03-03 08:46:04 +00:00
LtWorf
19ac2aaacd - Set hash method for the classes
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@265 014f5005-505e-4b48-8d0a-63407b615a7c
2010-11-26 09:12:34 +00:00
LtWorf
41de96997d - Removed debug print
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@259 014f5005-505e-4b48-8d0a-63407b615a7c
2010-10-08 05:52:09 +00:00
LtWorf
25c4c894c2 - Fixes __eq__ method
- Fixes tokenization of python expressions, using python's builtin module tokenizer


git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@256 014f5005-505e-4b48-8d0a-63407b615a7c
2010-10-04 13:44:25 +00:00
LtWorf
e375a65ec6 - Clearer and better code for handling relation comparisons
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@252 014f5005-505e-4b48-8d0a-63407b615a7c
2010-09-22 13:31:19 +00:00
LtWorf
d63d0e78c0 - Rename will mark the resulting relation as readonly and subsequent updates, insert or deletes will actually copy the content
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@251 014f5005-505e-4b48-8d0a-63407b615a7c
2010-09-22 13:12:02 +00:00
LtWorf
2073b4db4a - Internally uses set instead of lists to describe relation's content
- Discards the old and not so functional tlb format



git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@250 014f5005-505e-4b48-8d0a-63407b615a7c
2010-09-22 12:53:36 +00:00