X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fmetadata%2FsqlStatements.ml;h=35abac28b4fa58b7133e1fbf93f0af7bb2a95500;hb=f981a524748846acc29b76b6e616af110b4ee13d;hp=97c7685db7704ee3aba91643edaecf84cd66f92d;hpb=0331b47a13331b97e65994c1cdb5298dabc99eb3;p=helm.git diff --git a/helm/ocaml/metadata/sqlStatements.ml b/helm/ocaml/metadata/sqlStatements.ml index 97c7685db..35abac28b 100644 --- a/helm/ocaml/metadata/sqlStatements.ml +++ b/helm/ocaml/metadata/sqlStatements.ml @@ -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] @@ -70,11 +94,11 @@ let sprintf_refSort_index name = [ 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] +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 ] + +