]> matita.cs.unibo.it Git - helm.git/commitdiff
added support for hits table
authorStefano Zacchiroli <zack@upsilon.cc>
Fri, 13 May 2005 13:01:25 +0000 (13:01 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Fri, 13 May 2005 13:01:25 +0000 (13:01 +0000)
helm/ocaml/metadata/metadataTypes.ml
helm/ocaml/metadata/metadataTypes.mli
helm/ocaml/metadata/sqlStatements.ml
helm/ocaml/metadata/sqlStatements.mli

index 51f79c8288c9e9c6cecddb310f434df4618fd264..5284d96b5dd48377585ce62d8133cd0459dd824e 100644 (file)
@@ -69,6 +69,7 @@ let rel_tbl_original = "refRel"
 let obj_tbl_original = "refObj"
 let name_tbl_original = "objectName"
 let count_tbl_original = "count"
+let hits_tbl_original = "hits"
 
   (** the names currently used *)
 let sort_tbl_real = ref sort_tbl_original
@@ -98,6 +99,7 @@ let library_rel_tbl = rel_tbl_original
 let library_obj_tbl = obj_tbl_original
 let library_name_tbl = name_tbl_original
 let library_count_tbl = count_tbl_original
+let library_hits_tbl = hits_tbl_original
 
 let are_tables_ownerized () =
   sort_tbl () <> library_sort_tbl
index d775fc587ecbda4b0fe6df3dedf531d969eb9879..73f9a703e8625eb659fdbcc1daacf6fb11757dd9 100644 (file)
@@ -73,4 +73,5 @@ val library_rel_tbl:  string
 val library_obj_tbl:  string
 val library_name_tbl:  string
 val library_count_tbl: string
+val library_hits_tbl: string
 
index e02e9128bc68a35b6320c31dc274741d334113e0..35abac28b4fa58b7133e1fbf93f0af7bb2a95500 100644 (file)
@@ -1,6 +1,30 @@
+(* Copyright (C) 2004-2005, HELM Team.
+ * 
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ * 
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * For details, see the HELM World-Wide-Web page,
+ * http://helm.cs.unibo.it/
+ *)
 
 open Printf;;
-type tbl = [ `RefObj| `RefSort| `RefRel| `ObjectName| `Owners| `Count]
+type tbl = [ `RefObj| `RefSort| `RefRel| `ObjectName| `Hits| `Count]
 
 (* TABLES *)
 
@@ -33,10 +57,10 @@ sprintf "CREATE TABLE %s (
     value varchar(255) binary not null
 );" name]
 
-let sprintf_owners_format name = [
+let sprintf_hits_format name = [
 sprintf "CREATE TABLE %s (
     source varchar(255) binary not null,
-    owner varchar(255) binary not null
+    no integer not null
 );" name]
 
 let sprintf_count_format name = [
@@ -55,7 +79,7 @@ let sprintf_refRel_drop name = [sprintf "DROP TABLE %s;" name]
 
 let sprintf_objectName_drop name = [sprintf "DROP TABLE %s;" name]
 
-let sprintf_owners_drop name = [sprintf "DROP TABLE %s;" name]
+let sprintf_hits_drop name = [sprintf "DROP TABLE %s;" name]
 
 let sprintf_count_drop name = [sprintf "DROP TABLE %s;" name]
 
@@ -72,9 +96,9 @@ sprintf "CREATE INDEX %s_source ON %s (source);" name name]
 let sprintf_objectName_index name = [
 sprintf "CREATE INDEX %s_value ON %s (value);" name name]
 
-let sprintf_owners_index name = [
-sprintf "CREATE INDEX %s_owner ON %s (owner);" name name ;
-sprintf "CREATE INDEX %s_source ON %s (source);" name name] 
+let sprintf_hits_index name = [
+sprintf "CREATE INDEX %s_source ON %s (source);" name name ;
+sprintf "CREATE INDEX %s_no ON %s (no);" name name] 
 
 let sprintf_count_index name = [
 sprintf "CREATE INDEX %s_source ON %s (source);" name name;
@@ -97,9 +121,9 @@ sprintf "DROP INDEX %s_source ON %s;" name name ]
 let sprintf_objectName_index_drop name = [
 sprintf "DROP INDEX %s_value ON %s;" name name]
 
-let sprintf_owners_index_drop name = [
-sprintf "DROP INDEX %s_owner ON %s;" name name ;
-sprintf "DROP INDEX %s_source ON %s;" name name] 
+let sprintf_hits_index_drop name = [
+sprintf "DROP INDEX %s_source ON %s;" name name ;
+sprintf "DROP INDEX %s_no ON %s;" name name] 
 
 let sprintf_count_index_drop name = [
 sprintf "DROP INDEX %s_source ON %s;" name name;
@@ -123,7 +147,7 @@ let get_table_format t named =
   | `RefSort -> sprintf_refSort_format named
   | `RefRel -> sprintf_refRel_format named
   | `ObjectName -> sprintf_objectName_format named
-  | `Owners -> sprintf_owners_format named
+  | `Hits -> sprintf_hits_format named
   | `Count -> sprintf_count_format named
 
 let get_index_format t named =
@@ -132,7 +156,7 @@ let get_index_format t named =
   | `RefSort -> sprintf_refSort_index named
   | `RefRel -> sprintf_refRel_index named
   | `ObjectName -> sprintf_objectName_index named
-  | `Owners -> sprintf_owners_index named
+  | `Hits -> sprintf_hits_index named
   | `Count -> sprintf_count_index named
 
 let get_table_drop t named =
@@ -141,7 +165,7 @@ let get_table_drop t named =
   | `RefSort -> sprintf_refSort_drop named
   | `RefRel -> sprintf_refRel_drop named
   | `ObjectName -> sprintf_objectName_drop named
-  | `Owners -> sprintf_owners_drop named
+  | `Hits -> sprintf_hits_drop named
   | `Count -> sprintf_count_drop named
 
 let get_index_drop t named =
@@ -150,7 +174,7 @@ let get_index_drop t named =
   | `RefSort -> sprintf_refSort_index_drop named
   | `RefRel -> sprintf_refRel_index_drop named
   | `ObjectName -> sprintf_objectName_index_drop named
-  | `Owners -> sprintf_owners_index_drop named
+  | `Hits -> sprintf_hits_index_drop named
   | `Count -> sprintf_count_index_drop named
 
 let create_tables l =
@@ -168,3 +192,12 @@ let drop_indexes l =
 let rename_tables l = 
   List.fold_left (fun s (o,n) ->  s @ sprintf_rename_table o n) [] l
 
+let fill_hits refObj hits =
+  [ sprintf
+        "INSERT INTO %s
+        SELECT h_occurrence, COUNT(source)
+        FROM %s
+        GROUP BY h_occurrence;"
+      hits refObj ]
+
+
index 18e50e209c16bc6d66af00a8723a5ac7de0e169d..9f9af55ef91d8b7b459bdaa45b7734d6fb86861c 100644 (file)
@@ -1,12 +1,45 @@
+(* Copyright (C) 2004-2005, HELM Team.
+ * 
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ * 
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * For details, see the HELM World-Wide-Web page,
+ * http://helm.cs.unibo.it/
+ *)
 
-type tbl = [ `RefObj| `RefSort| `RefRel| `ObjectName| `Owners| `Count]
+(** table shape kinds *)
+type tbl = [ `RefObj| `RefSort| `RefRel| `ObjectName| `Hits| `Count]
+
+(** all functions below return either an SQL statement or a list of SQL
+ * statements.
+ * For functions taking as argument (string * tbl) list, the meaning is a list
+ * of pairs <table name, table type>; where the type specify the desired kind of
+ * table and name the desired name (e.g. create a `RefObj like table name
+ * refObj_NEW) *)
 
 val create_tables: (string * tbl) list -> string list
-    
 val create_indexes: (string * tbl) list -> string list
-
 val drop_tables: (string * tbl) list -> string list
-
 val drop_indexes: (string * tbl) list -> string list
-
 val rename_tables: (string * string) list -> string list
+
+(** @param refObj name of the refObj table
+ * @param hits name of the hits table *)
+val fill_hits: string -> string -> string list
+