[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, debian, updated. upstream/0.9.5.5-717-g0f98819

Sebastian Krzyszkowiak seba.dos1 at gmail.com
Sat Aug 6 08:18:05 UTC 2011


The following commit has been merged in the debian branch:
commit bdae69937c29659611e196eb32bfff3b3682a9e9
Author: Sebastian Krzyszkowiak <seba.dos1 at gmail.com>
Date:   Wed Aug 26 01:01:58 2009 +0200

    opimd: add experimental support of "greater than" and "lesser than" queries
    
    Field names to use when quering:
    _lt_Field, _float_lt_Field, _gt_Field, _float_gt_Field - compare after casting to float
    _int_lt_Field, _int_gt_Field - compare after casting to int

diff --git a/framework/subsystems/opimd/docs/TODO b/framework/subsystems/opimd/docs/TODO
index b03b717..35c8186 100644
--- a/framework/subsystems/opimd/docs/TODO
+++ b/framework/subsystems/opimd/docs/TODO
@@ -12,7 +12,6 @@ After that:
 * Messages on GenericDomain
 Think about:
 * way for quering using all or multiple fields?
-* quering "greater than" and "lesser than"?
 * more domains?
 Finishing:
 * faster merging and avoiding duplicates
diff --git a/framework/subsystems/opimd/pimd_generic.py b/framework/subsystems/opimd/pimd_generic.py
index 0905732..9308fee 100644
--- a/framework/subsystems/opimd/pimd_generic.py
+++ b/framework/subsystems/opimd/pimd_generic.py
@@ -324,6 +324,51 @@ class GenericEntry():
         overall_match = 1.0
 
         for field_name in query_obj.keys():
+
+            if field_name.startswith('_') and (field_name.startswith('_int_') or field_name.startswith('_float_') or field_name.startswith('_gt_') or field_name.startswith('_lt_')):
+                if field_name.startswith('_int_'):
+                    mytype = int
+                    fieldname = field_name[8:]
+                    operator = field_name[5:7]
+                elif field_name.startswith('_float_'):
+                    mytype = float
+                    fieldname = field_name[10:]
+                    operator = field_name[7:9]
+                else:
+                    mytype = float
+                    fieldname = field_name[4:]
+                    operator = field_name[1:3]
+                field_value = mytype(query_obj[field_name])            
+                try:
+                    field_ids = self._field_idx[fieldname]
+
+                    for field_id in field_ids:
+
+                        comp_value = self._fields[field_id][2]
+                        if not comp_value:
+                            # Use the real value if no comparison value given
+                            comp_value = self._fields[field_id][1]
+                        if comp_value:
+                            comp_value = mytype(comp_value)
+                        else:
+                            overall_match *= 0.0
+                            continue
+
+                        if operator == 'gt':
+                            if comp_value > field_value:
+                                overall_match *= 1.0
+                            else:
+                                overall_match *= 0.0
+                        elif operator == 'lt':
+                            if comp_value < field_value:
+                                overall_match *= 1.0
+                            else:
+                                overall_match *= 0.0
+
+                except KeyError:
+                    overall_match *= 0.0
+                continue
+
             # Skip fields only meaningful to the parser
             if field_name[:1] == "_": continue
 

-- 
FSO frameworkd Debian packaging



More information about the pkg-fso-commits mailing list