Changeset: 0a605c4973ea for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0a605c4973ea
Modified Files:
        sql/backends/monet5/LSST/lsst.c
        sql/backends/monet5/LSST/lsst.h
        sql/backends/monet5/LSST/lsst.mal
        sql/backends/monet5/LSST/lsst.sql
Branch: default
Log Message:

Example HTM template function
The template should be further extended to perform a HtmID
distance metric to determing the pairs to be inserted in the
(oid,oid) result set.


diffs (82 lines):

diff --git a/sql/backends/monet5/LSST/lsst.c b/sql/backends/monet5/LSST/lsst.c
--- a/sql/backends/monet5/LSST/lsst.c
+++ b/sql/backends/monet5/LSST/lsst.c
@@ -431,3 +431,50 @@
        GDKfree(edges);
        return MAL_SUCCEED;
 }
+/* 
+ * the remainder is an example of hooking up a fast cross match operation
+ * using two HtmID columns bounded by the delta distance.
+ * Ideally the two columns are sorted upfront.
+*/
+
+str
+xmatch(int *ret, int *lid, int *rid, lng *delta)
+{
+    BAT *bn, *bl, *br;
+       lng *l, *r;
+       lng *lend, *rend;
+
+    if( (bl= BATdescriptor(*lid)) == NULL )
+         throw(MAL, "algebra.xmatch", RUNTIME_OBJECT_MISSING);
+ 
+    if( (br= BATdescriptor(*rid)) == NULL )
+         throw(MAL, "algebra.xmatch", RUNTIME_OBJECT_MISSING);
+       l= (lng*) Tloc(bl, BUNfirst(bl));
+       lend= (lng*) Tloc(bl, BUNlast(bl));
+       r= (lng*) Tloc(br, BUNfirst(br));
+       rend= (lng*) Tloc(br, BUNlast(br));
+
+       bn = BATnew(TYPE_oid, TYPE_oid, MIN(BATcount(bl), BATcount(br)));
+       if ( bn == NULL)
+         throw(MAL, "algebra.xmatch", MAL_MALLOC_FAIL);
+    bn->hsorted = bn->tsorted = 0;
+       bn->T->nonil = 1;
+       bn->H->nonil = 1;
+
+
+    BATaccessBegin(bl, USE_TAIL, MMAP_SEQUENTIAL);
+    BATaccessBegin(br, USE_TAIL, MMAP_SEQUENTIAL);
+       for(; l < lend; l++) {
+        for(; r < rend; r++)
+                       if ( *l != lng_nil && *r != lng_nil)
+                       {
+                               /* here comes the HtmID distance test */
+                               (void) delta;
+                       }
+       }
+    BATaccessEnd(bl, USE_TAIL, MMAP_SEQUENTIAL);
+    BATaccessEnd(br, USE_TAIL, MMAP_SEQUENTIAL);
+
+       BBPkeepref(*ret = bn->batCacheid);
+       return MAL_SUCCEED;
+}
diff --git a/sql/backends/monet5/LSST/lsst.h b/sql/backends/monet5/LSST/lsst.h
--- a/sql/backends/monet5/LSST/lsst.h
+++ b/sql/backends/monet5/LSST/lsst.h
@@ -41,4 +41,5 @@
 lsst_export str qserv_ptInSphCircle(int *ret, dbl *ra, dbl *dec, dbl *ra_cen, 
dbl *dec_cen, dbl *radius);
 lsst_export str qserv_ptInSphPoly(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 
+lsst_export str xmatch(int *ret, int *lid, int *rid, lng *delta);
 #endif /* _SQL_UDF_H_ */
diff --git a/sql/backends/monet5/LSST/lsst.mal 
b/sql/backends/monet5/LSST/lsst.mal
--- a/sql/backends/monet5/LSST/lsst.mal
+++ b/sql/backends/monet5/LSST/lsst.mal
@@ -38,3 +38,7 @@
 pattern lsst.ptinsphpoly(ra:dbl, dec:dbl, list:dbl...) :int
 address qserv_ptInSphPoly
 comment "Returns 1 if the given spherical longitude/latitude polyline contains 
the given position";
+
+command lsst.xmatch(l:bat[:oid,:lng], r:bat[:oid,:lng], 
delta:lng):bat[:oid,:oid]
+address LSSTxmatch
+comment "Return the HtmID pairs whose distances is within a delta distance";
diff --git a/sql/backends/monet5/LSST/lsst.sql 
b/sql/backends/monet5/LSST/lsst.sql
--- a/sql/backends/monet5/LSST/lsst.sql
+++ b/sql/backends/monet5/LSST/lsst.sql
@@ -31,3 +31,4 @@
 
 create function ptInSphPoly(ra1 double, dec1 double, list double)
 returns int external name lsst.ptinsphpoly;
+
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to