File indexing completed on 2025-01-19 05:21:25
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Search_Lucene 0017 * @subpackage Index 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** Zend_Search_Lucene_Index_SegmentWriter */ 0024 // require_once 'Zend/Search/Lucene/Index/SegmentWriter.php'; 0025 0026 /** 0027 * @category Zend 0028 * @package Zend_Search_Lucene 0029 * @subpackage Index 0030 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0031 * @license http://framework.zend.com/license/new-bsd New BSD License 0032 */ 0033 class Zend_Search_Lucene_Index_SegmentWriter_StreamWriter extends Zend_Search_Lucene_Index_SegmentWriter 0034 { 0035 /** 0036 * Object constructor. 0037 * 0038 * @param Zend_Search_Lucene_Storage_Directory $directory 0039 * @param string $name 0040 */ 0041 public function __construct(Zend_Search_Lucene_Storage_Directory $directory, $name) 0042 { 0043 parent::__construct($directory, $name); 0044 } 0045 0046 0047 /** 0048 * Create stored fields files and open them for write 0049 */ 0050 public function createStoredFieldsFiles() 0051 { 0052 $this->_fdxFile = $this->_directory->createFile($this->_name . '.fdx'); 0053 $this->_fdtFile = $this->_directory->createFile($this->_name . '.fdt'); 0054 0055 $this->_files[] = $this->_name . '.fdx'; 0056 $this->_files[] = $this->_name . '.fdt'; 0057 } 0058 0059 public function addNorm($fieldName, $normVector) 0060 { 0061 if (isset($this->_norms[$fieldName])) { 0062 $this->_norms[$fieldName] .= $normVector; 0063 } else { 0064 $this->_norms[$fieldName] = $normVector; 0065 } 0066 } 0067 0068 /** 0069 * Close segment, write it to disk and return segment info 0070 * 0071 * @return Zend_Search_Lucene_Index_SegmentInfo 0072 */ 0073 public function close() 0074 { 0075 if ($this->_docCount == 0) { 0076 return null; 0077 } 0078 0079 $this->_dumpFNM(); 0080 $this->_generateCFS(); 0081 0082 /** Zend_Search_Lucene_Index_SegmentInfo */ 0083 // require_once 'Zend/Search/Lucene/Index/SegmentInfo.php'; 0084 0085 return new Zend_Search_Lucene_Index_SegmentInfo($this->_directory, 0086 $this->_name, 0087 $this->_docCount, 0088 -1, 0089 null, 0090 true, 0091 true); 0092 } 0093 } 0094