Version française
Home     About     Download     Resources     Contact us    
Browse thread
large hash tables
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Gabriel Kerneis <kerneis@e...>
Subject: Re: [Caml-list] large hash tables
Hello,

it won't solve any of you problems but I have a few remarks on your
code:

> exception SplitError
> 
> let read_whole_chan chan =
>     let movieMajor = Hashtbl.create 777777 in

Here, movieMajor in declared inside read_whole_chan and never returned,
so you won't be able to use it (but it might as well be a test program
I guess).

>     let rec loadLines count =
>         let line = input_line chan in
>         let murList = Pcre.split line in
>         match murList with
>             | m::u::r::[] ->
>                 let rFloat = float_of_string r in
>                 Hashtbl.add movieMajor m (u, rFloat);
>                 loadLines (count + 1)

You use tail-recursion properly so your Stack overflow doesn't come
from there. No idea why it occurs, though...

>             | _ -> raise SplitError
>   in
> 
>     try
>         loadLines 0
>     with
>         End_of_file -> ()
>     ;;
> 
> let read_whole_file filename =
>     let chan = open_in filename in
>     read_whole_chan chan
>     ;;

You should close the chan when you're done.

> let filename = Sys.argv.(1);;
> 
> let str = read_whole_file filename;;


Regards,
-- 
Gabriel Kerneis