web/lib/Zend/Search/Lucene/Index/SegmentWriter/StreamWriter.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Search_Lucene
       
    17  * @subpackage Index
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: StreamWriter.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 /** Zend_Search_Lucene_Index_SegmentWriter */
       
    24 require_once 'Zend/Search/Lucene/Index/SegmentWriter.php';
       
    25 
       
    26 /**
       
    27  * @category   Zend
       
    28  * @package    Zend_Search_Lucene
       
    29  * @subpackage Index
       
    30  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    31  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    32  */
       
    33 class Zend_Search_Lucene_Index_SegmentWriter_StreamWriter extends Zend_Search_Lucene_Index_SegmentWriter
       
    34 {
       
    35     /**
       
    36      * Object constructor.
       
    37      *
       
    38      * @param Zend_Search_Lucene_Storage_Directory $directory
       
    39      * @param string $name
       
    40      */
       
    41     public function __construct(Zend_Search_Lucene_Storage_Directory $directory, $name)
       
    42     {
       
    43         parent::__construct($directory, $name);
       
    44     }
       
    45 
       
    46 
       
    47     /**
       
    48      * Create stored fields files and open them for write
       
    49      */
       
    50     public function createStoredFieldsFiles()
       
    51     {
       
    52         $this->_fdxFile = $this->_directory->createFile($this->_name . '.fdx');
       
    53         $this->_fdtFile = $this->_directory->createFile($this->_name . '.fdt');
       
    54 
       
    55         $this->_files[] = $this->_name . '.fdx';
       
    56         $this->_files[] = $this->_name . '.fdt';
       
    57     }
       
    58 
       
    59     public function addNorm($fieldName, $normVector)
       
    60     {
       
    61         if (isset($this->_norms[$fieldName])) {
       
    62             $this->_norms[$fieldName] .= $normVector;
       
    63         } else {
       
    64             $this->_norms[$fieldName] = $normVector;
       
    65         }
       
    66     }
       
    67 
       
    68     /**
       
    69      * Close segment, write it to disk and return segment info
       
    70      *
       
    71      * @return Zend_Search_Lucene_Index_SegmentInfo
       
    72      */
       
    73     public function close()
       
    74     {
       
    75         if ($this->_docCount == 0) {
       
    76             return null;
       
    77         }
       
    78 
       
    79         $this->_dumpFNM();
       
    80         $this->_generateCFS();
       
    81 
       
    82         /** Zend_Search_Lucene_Index_SegmentInfo */
       
    83         require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
       
    84 
       
    85         return new Zend_Search_Lucene_Index_SegmentInfo($this->_directory,
       
    86                                                         $this->_name,
       
    87                                                         $this->_docCount,
       
    88                                                         -1,
       
    89                                                         null,
       
    90                                                         true,
       
    91                                                         true);
       
    92     }
       
    93 }
       
    94