[Tritonn-commit 145] [svn] [159] first implementation of table scan (under development)

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2008年 6月 25日 (水) 18:23:52 JST


Revision: 159
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=tritonn&view=rev&rev=159
Author:   mir
Date:     2008-06-25 18:23:52 +0900 (Wed, 25 Jun 2008)

Log Message:
-----------
first implementation of table scan (under development)

Modified Paths:
--------------
    trunk/src/ha_tritonn.cc


-------------- next part --------------
Modified: trunk/src/ha_tritonn.cc
===================================================================
--- trunk/src/ha_tritonn.cc	2008-06-25 08:04:57 UTC (rev 158)
+++ trunk/src/ha_tritonn.cc	2008-06-25 09:23:52 UTC (rev 159)
@@ -40,7 +40,7 @@
 static void dump_create(const char *name, TABLE *table_arg,
 			HA_CREATE_INFO *create_info);
 
-static void call_senna_ql(sen_ctx *ctx, const char *str);
+static void call_senna_ql(sen_ctx *ctx, const char *str, bool disp=true);
 
 static char *mysqltype2sennatype_string(enum_field_types types);
 
@@ -278,6 +278,16 @@
   thr_lock_data_init(&share->lock,&lock,NULL);
   share->short_name = table_share->table_name.str;
   ctx = sen_ctx_open(get_sen_db(table_share->db.str),SEN_CTX_USEQL);
+  call_senna_ql(ctx, "(define (select recs expr) (reverse (letrec "
+		"((func (lambda (r x) (if x (let ((y (expr x))) "
+		"(func (if y (cons y r) r) (recs ::+ x))) r)))) "
+		"(func () (recs ::)))))");
+  call_senna_ql(ctx, "(define (slot-exps class) (select <db> "
+		"(lambda (x) (let ((s (x ::schema))) (and (pair? s) "
+		"(eq? class (car s)) (list () (car (cdr (cdr s)))))))))");
+  call_senna_ql(ctx, "(define (dump-table class) (if (< 0 class.:nrecords) "
+		"(begin (disp `(: ,class (.:key ,@(slot-exps class)) 0 0) "
+		":tsv))))");
 
   DBUG_RETURN(0);
 }
@@ -294,14 +304,27 @@
 {
   DBUG_ENTER("ha_tritonn::rnd_init");
   DBTN;
-  DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+  call_senna_ql(ctx,"(dump-table <t1>)", false);
+  DBUG_RETURN(0);
 }
 
 int ha_tritonn::rnd_next(uchar *buf)
 {
   DBUG_ENTER("ha_tritonn::rnd_next");
   DBTN;
-  DBUG_RETURN(HA_ERR_END_OF_FILE);
+  char *res;
+  unsigned int res_len;
+  int res_flags;
+  char *row;
+  sen_ctx_recv(ctx,&res,&res_len,&res_flags);
+  if (res_flags & SEN_CTX_MORE) {
+    row = (char*) calloc(1,1024);
+    printf("[SennaQL] returned row => %s\n",strncat(row,res,res_len));
+    free(row);
+    DBUG_RETURN(0);
+  } else {
+    DBUG_RETURN(HA_ERR_END_OF_FILE);
+  }
 }
 
 void ha_tritonn::position(const uchar *record)
@@ -322,6 +345,7 @@
 {
   DBUG_ENTER("ha_tritonn::info");
   DBTN;
+  stats.records=100;
   DBUG_RETURN(0);
 }
 
@@ -518,7 +542,7 @@
   }
 }
 
-void call_senna_ql(sen_ctx *ctx, const char *str)
+void call_senna_ql(sen_ctx *ctx, const char *str, bool disp)
 {
   char *ql;
   char *res;
@@ -529,12 +553,14 @@
   ql = (char*) malloc(ql_len);
   strncpy(ql,str,ql_len);
   sen_ctx_send(ctx,ql,ql_len,0);
-  do {
-    sen_ctx_recv(ctx,&res,&res_len,&res_flags);
-    buf = (char*) calloc(1,1024);
-    printf("[SennaQL] %s => %s\n",str,strncat(buf,res,res_len));
-    free(buf);
-  } while (res_flags & SEN_CTX_MORE);
+  if (disp == true) {
+    do {
+      sen_ctx_recv(ctx,&res,&res_len,&res_flags);
+      buf = (char*) calloc(1,1024);
+      printf("[SennaQL] %s => %s\n",str,strncat(buf,res,res_len));
+      free(buf);
+    } while (res_flags & SEN_CTX_MORE);
+  }
   free(ql);
 }
 
@@ -652,3 +678,4 @@
   pthread_mutex_unlock(&tritonn_mutex);
   return cur->next->db;
 }
+


Tritonn-commit メーリングリストの案内
Back to archive index