[Tinyos-commits] CVS: tinyos-1.x/tos/lib/VM/languages/tinysql/src tinysql.in, 1.3, 1.4

David Gay idgay at users.sourceforge.net
Thu Nov 17 16:04:47 PST 2005


Update of /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/tinysql/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1909/src

Modified Files:
	tinysql.in 
Log Message:
support displaying results of global aggregates with the "tinysql log" command


Index: tinysql.in
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/tinysql/src/tinysql.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** tinysql.in	1 Nov 2005 02:28:11 -0000	1.3
--- tinysql.in	18 Nov 2005 00:04:45 -0000	1.4
***************
*** 15,18 ****
--- 15,23 ----
  $BROADCAST = 0xffff;
  
+ # Predefined expansions
+ $attribute_expansions{"avg"} = "epoch count sum";
+ $attribute_expansions{"min"} = "epoch value";
+ $attribute_expansions{"max"} = "epoch value";
+ 
  add_incdir(".");
  
***************
*** 118,121 ****
--- 123,127 ----
      $schema = current_schema();
      exit 1 if !$schema;
+     $schema = expand_schema($schema);
      $schema = "epoch $schema";
      print "#SCHEMA: $schema\n";
***************
*** 171,175 ****
      open QUERY, $qfile or return undef;
      while (<QUERY>) {
! 	$query = $1 if m!^// (SELECT .*)!;
      }
      close QUERY;
--- 177,181 ----
      open QUERY, $qfile or return undef;
      while (<QUERY>) {
! 	$query = $1 if m!^\s*//\s*(SELECT\s+.*)!;
      }
      close QUERY;
***************
*** 182,186 ****
      open QUERY, $qfile or return undef;
      while (<QUERY>) {
! 	$schema = $1 if m!^// SCHEMA: (.*)!;
      }
      close QUERY;
--- 188,193 ----
      open QUERY, $qfile or return undef;
      while (<QUERY>) {
! 	$schema = $1 if m!^\s*//\s*SCHEMA:\s*(.*)!;
! 	$attribute_expansions{lc $1} = $2 if m!^\s*//\s*(.*)_SCHEMA:\s*(.*)!;
      }
      close QUERY;
***************
*** 188,191 ****
--- 195,217 ----
  }
  
+ sub expand_schema {
+     my @schema, $name, $exp;
+ 
+     # Expand attributes that take more than one field, based on 
+     # attribute_expansions table. For instance, "avg" expands
+     # to "epoch count sum", so an avg_light attribute should
+     # become "avg_light_epoch avg_light_count avg_light_sum"
+     @schema = map {
+ 	if (/(.*)_.*/ && ($exp = $attribute_expansions{lc $1})) {
+ 	    $name = $_;
+ 	    join(' ', map "${name}_$_", (split / /, $exp));
+ 	}
+ 	else {
+ 	    $_;
+ 	}
+     } (split / /, $_[0]);
+     return join(' ', @schema);
+ }
+ 
  sub tsqllog {
      my ($schema) = @_;



More information about the Tinyos-commits mailing list