Bläddra i källkod

Inline compare functions; remove OpenMP support until needed.

Stefano Cossu 6 år sedan
förälder
incheckning
b209cfecef
3 ändrade filer med 10 tillägg och 16 borttagningar
  1. 5 9
      lakesuperior/model/graph/callbacks.pyx
  2. 1 3
      lakesuperior/store/ldp_rs/lmdb_triplestore.pyx
  3. 4 4
      setup.py

+ 5 - 9
lakesuperior/model/graph/callbacks.pyx

@@ -13,7 +13,7 @@ from lakesuperior.model.graph.triple cimport BufferTriple
 logger = logging.getLogger(__name__)
 
 
-cdef int term_cmp_fn(const void* key1, const void* key2):
+cdef inline int term_cmp_fn(const void* key1, const void* key2):
     """
     Compare function for two Buffer objects.
 
@@ -27,12 +27,10 @@ cdef int term_cmp_fn(const void* key1, const void* key2):
         #logger.info(f'Sizes differ: {b1.sz} != {b2.sz}. Return 1.')
         return 1
 
-    cdef int cmp = memcmp(b1.addr, b2.addr, b1.sz)
-    #logger.info(f'term memcmp: {cmp}')
-    return cmp
+    return memcmp(b1.addr, b2.addr, b1.sz)
 
 
-cdef int trp_cmp_fn(const void* key1, const void* key2):
+cdef inline int trp_cmp_fn(const void* key1, const void* key2):
     """
     Compare function for two triples in a set.
 
@@ -45,15 +43,13 @@ cdef int trp_cmp_fn(const void* key1, const void* key2):
     t1 = <BufferTriple *>key1
     t2 = <BufferTriple *>key2
 
-    diff = (
+    # Compare in order of probability (largest sets first).
+    return (
         term_cmp_fn(t1.o, t2.o) or
         term_cmp_fn(t1.s, t2.s) or
         term_cmp_fn(t1.p, t2.p)
     )
 
-    #logger.info(f'Triples match: {not(diff)}')
-    return diff
-
 
 #cdef int trp_cmp_fn(const void* key1, const void* key2):
 #    """

+ 1 - 3
lakesuperior/store/ldp_rs/lmdb_triplestore.pyx

@@ -782,9 +782,7 @@ cdef class LmdbTriplestore(BaseLmdbStore):
         #        'Getting triples for: {}, {}'.format(triple_pattern, context))
 
         match = self.triple_keys(triple_pattern, context)
-        logger.info(f'Matches in graph_lookup: {match.ct}')
-        #btrp = <BufferTriple*>gr.pool.alloc(match.ct, sizeof(BufferTriple))
-        #buffers = <Buffer*>gr.pool.alloc(3 * match.ct, sizeof(Buffer))
+        logger.debug(f'Matches in graph_lookup: {match.ct}')
 
         match.seek()
         while match.get_next(&spok):

+ 4 - 4
setup.py

@@ -113,8 +113,8 @@ extensions = [
             path.join('lakesuperior', 'model', 'graph', f'*.{ext}'),
         ],
         include_dirs=include_dirs,
-        extra_compile_args=['-fopenmp'],
-        extra_link_args=['-fopenmp']
+        #extra_compile_args=['-fopenmp'],
+        #extra_link_args=['-fopenmp']
     ),
     Extension(
         'lakesuperior.store.base_lmdb_store',
@@ -143,8 +143,8 @@ extensions = [
                 'lakesuperior', 'store', 'ldp_rs', f'lmdb_triplestore.{ext}'),
         ],
         include_dirs=include_dirs,
-        extra_compile_args=['-fopenmp'],
-        extra_link_args=['-fopenmp']
+        #extra_compile_args=['-fopenmp'],
+        #extra_link_args=['-fopenmp']
     ),
 ]