Zend Framework  1.12
Public Member Functions | Public Attributes | List of all members
Zend_Search_Lucene_Index_SegmentInfo Class Reference

Public Member Functions

 __construct (Zend_Search_Lucene_Storage_Directory $directory, $name, $docCount, $delGen=0, $docStoreOptions=null, $hasSingleNormFile=false, $isCompound=null)
 Zend_Search_Lucene_Index_SegmentInfo constructor.
 
 openCompoundFile ($extension, $shareHandler=true)
 Opens index file stoted within compound index file.
 
 compoundFileLength ($extension)
 Get compound file length.
 
 getFieldNum ($fieldName)
 Returns field index or -1 if field is not found.
 
 getField ($fieldNum)
 Returns field info for specified field.
 
 getFields ($indexed=false)
 Returns array of fields.
 
 getFieldInfos ()
 Returns array of FieldInfo objects.
 
 getDelGen ()
 Returns actual deletions file generation number.
 
 count ()
 Returns the total number of documents in this segment (including deleted documents).
 
 numDocs ()
 Returns the total number of non-deleted documents in this segment.
 
 getName ()
 Return segment name.
 
 getTermInfo (Zend_Search_Lucene_Index_Term $term)
 Scans terms dictionary and returns term info.
 
 termDocs (Zend_Search_Lucene_Index_Term $term, $shift=0, $docsFilter=null)
 Returns IDs of all the documents containing term.
 
 termFreqs (Zend_Search_Lucene_Index_Term $term, $shift=0, $docsFilter=null)
 Returns term freqs array.
 
 termPositions (Zend_Search_Lucene_Index_Term $term, $shift=0, $docsFilter=null)
 Returns term positions array.
 
 norm ($id, $fieldName)
 Returns normalization factor for specified documents.
 
 normVector ($fieldName)
 Returns norm vector, encoded in a byte string.
 
 hasDeletions ()
 Returns true if any documents have been deleted from this index segment.
 
 hasSingleNormFile ()
 Returns true if segment has single norms file.
 
 isCompound ()
 Returns true if segment is stored using compound segment file.
 
 delete ($id)
 Deletes a document from the index segment.
 
 isDeleted ($id)
 Checks, that document is deleted.
 
 writeChanges ()
 Write changes if it's necessary.
 
 resetTermsStream ()
 Reset terms stream.
 
 skipTo (Zend_Search_Lucene_Index_Term $prefix)
 Skip terms stream up to the specified term preffix.
 
 nextTerm ()
 Scans terms dictionary and returns next term.
 
 closeTermsStream ()
 Close terms stream.
 
 currentTerm ()
 Returns term in current position.
 
 currentTermPositions ()
 Returns an array of all term positions in the documents.
 

Public Attributes

const FULL_SCAN_VS_FETCH_BOUNDARY = 5
 "Full scan vs fetch" boundary.
 
const SM_TERMS_ONLY = 0
 Scan modes.
 
const SM_FULL_INFO = 1
 
const SM_MERGE_INFO = 2
 

Constructor & Destructor Documentation

__construct ( Zend_Search_Lucene_Storage_Directory  $directory,
  $name,
  $docCount,
  $delGen = 0,
  $docStoreOptions = null,
  $hasSingleNormFile = false,
  $isCompound = null 
)

Zend_Search_Lucene_Index_SegmentInfo constructor.

Parameters
Zend_Search_Lucene_Storage_Directory$directory
string$name
integer$docCount
integer$delGen
array | null$docStoreOptions
boolean$hasSingleNormFile
boolean$isCompound

Member Function Documentation

closeTermsStream ( )

Close terms stream.

Should be used for resources clean up if stream is not read up to the end

Implements Zend_Search_Lucene_Index_TermsStream_Interface.

compoundFileLength (   $extension)

Get compound file length.

Parameters
string$extension
Returns
integer
count ( )

Returns the total number of documents in this segment (including deleted documents).

Returns
integer
currentTerm ( )

Returns term in current position.

Returns
Zend_Search_Lucene_Index_Term|null

Implements Zend_Search_Lucene_Index_TermsStream_Interface.

currentTermPositions ( )

Returns an array of all term positions in the documents.

Return array structure: array( docId => array( pos1, pos2, ...), ...)

Returns
array
delete (   $id)

Deletes a document from the index segment.

$id is an internal document id

Parameters
integer
getDelGen ( )

Returns actual deletions file generation number.

Returns
integer
getField (   $fieldNum)

Returns field info for specified field.

Parameters
integer$fieldNum
Returns
Zend_Search_Lucene_Index_FieldInfo
getFieldInfos ( )

Returns array of FieldInfo objects.

Returns
array
getFieldNum (   $fieldName)

Returns field index or -1 if field is not found.

Parameters
string$fieldName
Returns
integer
getFields (   $indexed = false)

Returns array of fields.

if $indexed parameter is true, then returns only indexed fields.

Parameters
boolean$indexed
Returns
array
getName ( )

Return segment name.

Returns
string
getTermInfo ( Zend_Search_Lucene_Index_Term  $term)

Scans terms dictionary and returns term info.

Parameters
Zend_Search_Lucene_Index_Term$term
Returns
Zend_Search_Lucene_Index_TermInfo
hasDeletions ( )

Returns true if any documents have been deleted from this index segment.

Returns
boolean
hasSingleNormFile ( )

Returns true if segment has single norms file.

Returns
boolean
isCompound ( )

Returns true if segment is stored using compound segment file.

Returns
boolean
isDeleted (   $id)

Checks, that document is deleted.

Parameters
integer
Returns
boolean
nextTerm ( )

Scans terms dictionary and returns next term.

Returns
Zend_Search_Lucene_Index_Term|null

Implements Zend_Search_Lucene_Index_TermsStream_Interface.

norm (   $id,
  $fieldName 
)

Returns normalization factor for specified documents.

Parameters
integer$id
string$fieldName
Returns
float
normVector (   $fieldName)

Returns norm vector, encoded in a byte string.

Parameters
string$fieldName
Returns
string
numDocs ( )

Returns the total number of non-deleted documents in this segment.

Returns
integer
openCompoundFile (   $extension,
  $shareHandler = true 
)

Opens index file stoted within compound index file.

Parameters
string$extension
boolean$shareHandler
Exceptions
Zend_Search_Lucene_Exception
Returns
Zend_Search_Lucene_Storage_File
resetTermsStream ( )

Reset terms stream.

$startId - id for the fist document $compact - remove deleted documents

Returns start document id for the next segment

Parameters
integer$startId
integer$mode
Exceptions
Zend_Search_Lucene_Exception
Returns
integer

SegmentInfo->resetTermsStream() method actually takes two optional parameters: $startId (default value is 0) $mode (default value is self::SM_TERMS_ONLY)

Implements Zend_Search_Lucene_Index_TermsStream_Interface.

skipTo ( Zend_Search_Lucene_Index_Term  $prefix)

Skip terms stream up to the specified term preffix.

Prefix contains fully specified field info and portion of searched term

Parameters
Zend_Search_Lucene_Index_Term$prefix
Exceptions
Zend_Search_Lucene_Exception

Field is not presented in this segment Go to the end of dictionary

Implements Zend_Search_Lucene_Index_TermsStream_Interface.

termDocs ( Zend_Search_Lucene_Index_Term  $term,
  $shift = 0,
  $docsFilter = null 
)

Returns IDs of all the documents containing term.

Parameters
Zend_Search_Lucene_Index_Term$term
integer$shift
Zend_Search_Lucene_Index_DocsFilter | null$docsFilter
Returns
array
termFreqs ( Zend_Search_Lucene_Index_Term  $term,
  $shift = 0,
  $docsFilter = null 
)

Returns term freqs array.

Result array structure: array(docId => freq, ...)

Parameters
Zend_Search_Lucene_Index_Term$term
integer$shift
Zend_Search_Lucene_Index_DocsFilter | null$docsFilter
Returns
Zend_Search_Lucene_Index_TermInfo
termPositions ( Zend_Search_Lucene_Index_Term  $term,
  $shift = 0,
  $docsFilter = null 
)

Returns term positions array.

Result array structure: array(docId => array(pos1, pos2, ...), ...)

Parameters
Zend_Search_Lucene_Index_Term$term
integer$shift
Zend_Search_Lucene_Index_DocsFilter | null$docsFilter
Returns
Zend_Search_Lucene_Index_TermInfo
writeChanges ( )

Write changes if it's necessary.

This method must be invoked only from the Writer _updateSegments() method, so index Write lock has to be already obtained.

Member Data Documentation

const FULL_SCAN_VS_FETCH_BOUNDARY = 5

"Full scan vs fetch" boundary.

If filter selectivity is less than this value, then full scan is performed (since term entries fetching has some additional overhead).

const SM_FULL_INFO = 1
const SM_MERGE_INFO = 2
const SM_TERMS_ONLY = 0

Scan modes.