InterMine
and 1 contributors

NAME

Webservice::InterMine::ResultIterator - An object for iterating through result rows

SYNOPSIS

  my $results = $query->result_iterator;
  while (<$results>) {
    # do something with $_
  }

DESCRIPTION

This package provides objects for iterating through result sets, where those result sets are rows from a database query.

CONSTRUCTION ARGUMENTS

The following arguments are required when constructing a new ResultIterator.

  • url: ro, URI|Str

    The url of the resource to request. EG:

      http://some.mine.org/path/to/resource
  • parameters: ro, HashRef[Str], default: {}

    The parameters for this request.

  • authorization: ro, Str

    A base 64 encoded string to use as the authorization header for basic authentication.

  • request_format: ro, RequestFormat

    The format that will be actually requested from the server.

  • row_parser: ro, Webservice::InterMine::Parser

    The parser to return a formatted row of data.

ATTRIBUTES

Other properties of the object. These attributes are derived from the original construction arguments.

  • user_agent: ro, Str,

    A label to use to identify this request to the server. Defaults to "Webservice::InterMine-${version}"

  • connection: ro, Net::HTTP

    A connection to the source of results

  • content: ro, Glob

    A Glob with content. Can be a glob linked to any file-handle or other IO. This can be used to supply results for testing.

  • error_code: ro, HTTP Status Code

    The status code of the request. Once the request has been made and the headers parsed, the error code is available to be read.

  • error_message: ro, Str

    The error message from the request, if any.

  • headers: ro, HashRef

    The headers from the request.

  • content_is_binary: ro, Bool

    Whether or not the content should be treated as binary data, for example if it is gzipped.

  • is_chunked: ro, Bool

    Whether or not the results are returned in chunked transfer encoding.

  • chunk_bytes_left: rw, Num

    A number referring to the bytes left in the current chunk.

  • is_finished: ro, Bool

    Whether or not all the available results have been read.

######## ERROR CHECKING METHODS

METHODS - ERROR CHECKING

[Bool] is_success

Returns true if the server responded with a success-y status.

[Bool] is_error

Returns true if the server responded with an error-ish status.

[Str] status_line

Returns a human readable status line.

METHODS - RESULTS HANDLING (EXTERNAL API)

next

returns the next row in the appropriate format

get_all

Return all rows from the result set.

Returns a list of rows in list context, or an arrayref of rows in scalar context.

METHODS - RESULTS HANDLING (INTERNAL)

[Str] read_line

Read the next line from either the content blob, or the open connection, in the correct encoding, with the new line characters stripped.

connect

Connect to the resource specified by the url construction argument.

OVERLOADING

The following operators are overloaded:

Iteration: <>

Return the next row of data.

SEE ALSO

AUTHOR

Alex Kalderimis <dev@intermine.org>

BUGS

Please report any bugs or feature requests to dev@intermine.org.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Webservice::InterMine::ResultIterator

You can also look for information at:

COPYRIGHT AND LICENSE

Copyright 2006 - 2011 FlyMine, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.