Patch to MogileFS::Client to fetch only a range of bytes from a file

Ask Bjørn Hansen ask at develooper.com
Wed May 23 01:38:43 UTC 2007


On May 22, 2007, at 18:12, Arthur Bebak wrote:

The feature would be nice - the patch needs a little cleaning up...

* How about making the new features just be options to  
get_file_data?  I don't think it's worthwhile to have a separate  
method (and code duplication) for this.

* In the documentation example having an extra line to setup % 
arg_hash is strange. Better just make the examples $mogc- 
 >get_file_data($key, %args) and ...get_file_data($key, length =>  
1000) etc.

* I'd take out the "Note that the offset byte is included, so in  
general the formula is: ..." comment. That's kinda obvious and Too  
Much Information.

* the nested(?) conditionals like the following hurts my eyes. :-)
> if( exists $arg_hash{'range'} ) {
> +        $range = $arg_hash{'range'};
> +        } # if
> +    else {

* Likewise the conditional to run ->get is unnecessary.  Instead of  
having an if, else with duplicate code do something like:
     $res = $ua->get($path, ($range ? ("Range" => "bytes=$range") :  
()));

* When a range request is done and it's not supported; I think the  
client should die (croak? -- at least warn with carp)  rather than  
just return undef.


  - ask

-- 
http://develooper.com/ - http://askask.com/




More information about the mogilefs mailing list