Loading ...
Sorry, an error occurred while loading the content.

9682Re: "ocaml_beginners"::[] Writing to many files

Expand Messages
  • Peng Zang
    Apr 22, 2008
    • 0 Attachment
      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      Just looking at this code without trying it in the toplevel, I think you mean
      this:

      match !last_date,!last_auth, !last_acc with

      | Some d, Some oc, Some ot when d = date -> oc,ot
      | Some d, None, None when d = date ->

      Peng


      On Tuesday 22 April 2008 05:39:51 am Johann Spies wrote:
      > On Fri, Mar 28, 2008 at 07:24:52AM -0600, William D. Neumann wrote:
      > > 2: If you have too many files to keep open, or if you have really long
      > > runs of the same date in your data, you can just coche the last date and
      > > channel in outputfile.
      >
      > I have adapted your code because I want to use two different output
      > files. My code produces an error which I do not understand:
      >
      > Characters 226-250:
      > This pattern matches values of type 'a option * 'b option * 'c option
      > but is here used to match values of type 'd option * 'e option
      >
      > The code:
      >
      >
      > let last_date = ref None
      > and last_auth = ref None
      > and last_acc = ref None
      >
      > let outputfile date =
      > match !last_date,!last_auth, !last_acc with
      >
      > | Some d, Some oc when d = date, Some ot -> oc,ot
      > | Some d, None when d = date, None ->
      >
      > failwith "Yipes! Cached date but no cached channel!"
      >
      > | Some d, Some oc, Some ot ->
      >
      > close_out oc;
      > close_out ot;
      > let new_oc = open_out_gen
      > [Open_creat;Open_append;Open_wronly]
      > 0o644
      > ( date ^ "_acc.csv" ) in
      > let new_ot = open_out_gen
      > [Open_creat;Open_append;Open_wronly]
      > 0o644
      > ( date ^ "_auth.csv")
      > in
      > last_date := Some date;
      > last_acc := Some new_oc;
      > last_auth := Some new_ot;
      > new_oc, new_ot
      >
      > | None,None,_ ->
      >
      > let new_oc = open_out_gen
      > [Open_creat;Open_append;Open_wronly]
      > 0o644
      > ( date ^ "_acc.csv" ) in
      > let new_ot = open_out_gen
      > [Open_creat;Open_append;Open_wronly]
      > 0o644
      > ( date ^ "_auth.csv")
      > in
      > last_date := Some date;
      > last_acc := Some new_oc;
      > last_auth := Some new_ot;
      > new_oc, new_ot
      >
      > | _ ->
      >
      > (* None for date, some open channel -- should never hapen *)
      > assert false
      >
      >
      > Can somebody enlighten me on this one please?
      >
      > Regards
      > Johann
      -----BEGIN PGP SIGNATURE-----
      Version: GnuPG v2.0.7 (GNU/Linux)

      iD8DBQFIDeSmfIRcEFL/JewRAoAaAKDWz6duaFxSbgIZc6DQaICcV7/U4gCeJDRw
      E9WQg4m1AoUXNeydTnwU4Y0=
      =Kd4n
      -----END PGP SIGNATURE-----
    • Show all 17 messages in this topic