Changeset 3195

Show
Ignore:
Timestamp:
2007-08-16 03:20:18 (1 year ago)
Author:
shans
Message:

Fixed sorting (was waiting for end-of-stream, and suffering from order-n append on lists, so I added exception handling and Queues instead).
Added print debug function to sort input module

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • oogg/trunk/oogg_dump_packets.ml

    r3194 r3195  
    44let pps = Packet.to_packetStream ps;; 
    55let ppps = Packet.reconstruct_timing pps;; 
    6 let all_streams = Packet.sort ppps;; 
    7 Packet_util.print_packetStream  
    8         (*ppps;;*)  
    9         (snd (List.nth all_streams (int_of_string Sys.argv.(2))));; 
     6Packet_util.print_packetStream ppps;; 
  • oogg/trunk/packet.ml

    r3194 r3195  
    115115    let eq = (=) 
    116116    let get_key p = p.p_page.raw.serialno 
    117     let is_first p = p.p_page.raw.bos && p.p_pageno = 0 
     117    let is_first p = p.p_page.raw.bos 
    118118    let is_last p = p.p_page.raw.eos 
     119    let printKey s = print_oogg32 s 
    119120  end;; 
    120121 
  • oogg/trunk/streamSort.ml

    r3194 r3195  
    77    val is_first : s -> bool 
    88    val is_last : s -> bool 
     9    val printKey : k -> unit 
    910  end;; 
    1011 
     
    2122              ( 
    2223                Stream.junk i;  
    23                 (I.get_key page, ref (Some [page]))::(get_first_pages i) 
     24                let q = Queue.create () in 
     25                Queue.add page q; 
     26                (I.get_key page, ref (Some q))::(get_first_pages i) 
    2427              ) 
    2528          | Some page                       -> [] in 
     
    3134          match !cache with 
    3235            | None        -> None 
    33             | Some (h::t) -> 
     36            | Some q when not (Queue.is_empty q) -> 
    3437                ( 
     38                  let h = Queue.take q in 
    3539                  if I.is_last h  
    3640                  then cache := None 
    37                   else cache := Some t
     41                  else cache := Some q
    3842                  Some h 
    3943                ) 
    40             | Some [] -> 
    41                 ( let p = Stream.next i in 
     44            | Some _ -> 
     45                try ( 
     46                  let p = Stream.next i in 
    4247                  let ik = I.get_key p in 
    4348                  if ik = k then ( 
     
    4853                    (match !icache with 
    4954                      | None   -> raise PagesAfterEOS 
    50                       | Some l -> icache := Some (l @ [p])); 
     55                      | Some q -> Queue.add p q); 
    5156                    get_next_page k 
    5257                  ) 
    53                 ) in 
     58                ) with Stream.Failure -> None in 
    5459 
    5560        let generator k _ = get_next_page k in 
  • oogg/trunk/streamSort.mli

    r3194 r3195  
    77    val is_first : s -> bool 
    88    val is_last : s -> bool 
     9    val printKey : k -> unit 
    910  end;; 
    1011