\seekquarry\yioop\library\index_bundle_iteratorsDocIterator

Used to iterate through all the documents and links associated with a an IndexArchiveBundle. It iterates through each doc or link regarless of the words it contains. It also makes it easy to get the summaries of these documents.

A description of how words and the documents containing them are stored is given in the documentation of IndexArchiveBundle.

Summary

Methods
Properties
Constants
reset()
advance()
currentGenDocOffsetWithWord()
findDocsWithWord()
plan()
genDocOffsetCmp()
getDirection()
currentDocsWithWord()
getCurrentDocsForKeys()
nextDocsWithWord()
advanceSeenDocs()
setResultsPerBlock()
__construct()
getShardInfo()
getPreviousDocOffset()
advanceGeneration()
$num_docs
$seen_docs
$count_block
$pages
$current_block_fresh
$results_per_block
$index_name
$next_offset
$last_offset
$current_offset
$shard_lens
$num_generations
$current_generation
$filter
RESULTS_PER_BLOCK
HOST_KEY_POS
KEY_LEN
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

RESULTS_PER_BLOCK

RESULTS_PER_BLOCK

Default number of documents returned for each block (at most)

HOST_KEY_POS

HOST_KEY_POS

Host Key position + 1 (first char says doc, inlink or eternal link)

KEY_LEN

KEY_LEN

Length of a doc key

Properties

$num_docs

$num_docs : integer

Estimate of the number of documents that this iterator can return

Type

integer

$seen_docs

$seen_docs : integer

The number of documents already iterated over

Type

integer

$count_block

$count_block : integer

The number of documents in the current block

Type

integer

$pages

$pages : array

Cache of what currentDocsWithWord returns

Type

array

$current_block_fresh

$current_block_fresh : boolean

Says whether the value in $this->count_block is up to date

Type

boolean

$results_per_block

$results_per_block : integer

Number of documents returned for each block (at most)

Type

integer

$index_name

$index_name : string

The timestamp of the index is associated with this iterator

Type

string

$next_offset

$next_offset : integer

The next byte offset of a doc in the IndexShard

Type

integer

$last_offset

$last_offset : integer

Last offset of a doc occurrence in the IndexShard

Type

integer

$current_offset

$current_offset : integer

The current byte offset in the IndexShard

Type

integer

$shard_lens

$shard_lens : array

An array of shard docids_lens

Type

array

$num_generations

$num_generations : integer

The total number of shards that have data for this word

Type

integer

$current_generation

$current_generation : integer

Numeric number of current shard

Type

integer

$filter

$filter : \seekquarry\yioop\library\index_bundle_iterators\SearchfiltersModel

Model responsible for keeping track of edited and deleted search results

Type

\seekquarry\yioop\library\index_bundle_iterators\SearchfiltersModel

Methods

reset()

reset() 

Returns the iterators to the first document block that it could iterate over

advance()

advance(array  $gen_doc_offset = null) 

Forwards the iterator one group of docs

Parameters

array $gen_doc_offset

a generation, doc_offset pair. If set, the must be of greater than or equal generation, and if equal the next block must all have $doc_offsets larger than or equal to this value

currentGenDocOffsetWithWord()

currentGenDocOffsetWithWord() : mixed

Gets the doc_offset and generation for the next document that would be return by this iterator

Returns

mixed —

an array with the desired document offset and generation; -1 on fail

findDocsWithWord()

findDocsWithWord() : mixed

Hook function used by currentDocsWithWord to return the current block of docs if it is not cached

Returns

mixed —

doc ids and score if there are docs left, -1 otherwise

plan()

plan() : string

Returns a string representation of a plan by which the current iterator finds its results

Returns

string —

a representation of the current iterator and its subiterators, useful for determining how a query will be processed

genDocOffsetCmp()

genDocOffsetCmp(array  $gen_doc1, array  $gen_doc2, integer  $direction = self::ASCENDING) : integer

Compares two arrays each containing a (generation, offset) pair.

Parameters

array $gen_doc1

first ordered pair

array $gen_doc2

second ordered pair

integer $direction

whether the comparison should be done for a self::ASCEDNING or a self::DESCENDING search

Returns

integer —

-1,0,1 depending on which is bigger

getDirection()

getDirection() : integer

Returns the direction of a IndexBundleIterator. Depending on the iterator could be either forward from the start of an index (self::ASCENDING) or backward from the end of the index (self::DESCENDING). For this base class, the function always returns self::ASCENDING, but subclasses might return different values.

Returns

integer —

either CrawlConstants::ASCENDING or CrawlConstants::DESCENDING

currentDocsWithWord()

currentDocsWithWord() : mixed

Gets the current block of doc ids and score associated with the this iterators word

Returns

mixed —

doc ids and score if there are docs left, -1 otherwise

getCurrentDocsForKeys()

getCurrentDocsForKeys(array  $keys = null) : array

Gets the summaries associated with the keys provided the keys can be found in the current block of docs returned by this iterator

Parameters

array $keys

keys to try to find in the current block of returned results

Returns

array —

doc summaries that match provided keys

nextDocsWithWord()

nextDocsWithWord(  $doc_offset = null) : array

Get the current block of doc summaries for the word iterator and advances the current pointer to the next block of documents. If a doc index is the next block must be of docs after this doc_index

Parameters

$doc_offset

if set the next block must all have $doc_offsets equal to or larger than this value

Returns

array —

doc summaries matching the $this->restrict_phrases

advanceSeenDocs()

advanceSeenDocs() 

Updates the seen_docs count during an advance() call

setResultsPerBlock()

setResultsPerBlock(integer  $num) 

Sets the value of the result_per_block field. This field controls the maximum number of results that can be returned in one go by currentDocsWithWord()

Parameters

integer $num

the maximum number of results that can be returned by a block

__construct()

__construct(string  $index_name, \seekquarry\yioop\library\index_bundle_iterators\SearchfiltersModel  $filter = null, integer  $results_per_block = \seekquarry\yioop\library\index_bundle_iterators\IndexBundleIterator::RESULTS_PER_BLOCK, integer  $direction = self::ASCENDING) 

Creates a word iterator with the given parameters.

Parameters

string $index_name

time_stamp of the to use

\seekquarry\yioop\library\index_bundle_iterators\SearchfiltersModel $filter

Model responsible for keeping track of edited and deleted search results

integer $results_per_block

the maximum number of results that can be returned by a findDocsWithWord call

integer $direction

when results are access from $index_name in which order they should be presented. self::ASCENDING is from first added to last added, self::DESCENDING is from last added to first added. Note: this value is not saved permanently. So you could in theory open two read only versions of the same bundle but reading the results in different directions

getShardInfo()

getShardInfo(  $generation) 

Mainly used to get the last_offset in shard $generation of the current index bundle. In the case where this wasn't previously cached it loads in the index bundle, sets the current generation to $generation, stores the docids_len (the last offset) of this shard in shard_lens and sets up last_offset as $generation's docids_len

Parameters

$generation

to get last offset for

getPreviousDocOffset()

getPreviousDocOffset(integer  $doc_offset) : integer

Get the document offset prior to the current $doc_offset

Parameters

integer $doc_offset

an offset into the document map of an IndexShard

Returns

integer —

previous doc_offset

advanceGeneration()

advanceGeneration(integer  $generation = null) 

Switches which index shard is being used to return occurrences of the word to the next shard containing the word

Parameters

integer $generation

generation to advance beyond