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.
16 * @package Zend_Search_Lucene
18 * @copyright Copyright (c) 2005-2009 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 16541 2009-07-07 06:59:03Z bkarwin $
23 /** Zend_Search_Lucene_Index_SegmentInfo */
24 require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
26 /** Zend_Search_Lucene_Index_SegmentWriter */
27 require_once 'Zend/Search/Lucene/Index/SegmentWriter.php';
31 * @package Zend_Search_Lucene
33 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
34 * @license http://framework.zend.com/license/new-bsd New BSD License
36 class Zend_Search_Lucene_Index_SegmentWriter_StreamWriter extends Zend_Search_Lucene_Index_SegmentWriter
41 * @param Zend_Search_Lucene_Storage_Directory $directory
44 public function __construct(Zend_Search_Lucene_Storage_Directory $directory, $name)
46 parent::__construct($directory, $name);
51 * Create stored fields files and open them for write
53 public function createStoredFieldsFiles()
55 $this->_fdxFile = $this->_directory->createFile($this->_name . '.fdx');
56 $this->_fdtFile = $this->_directory->createFile($this->_name . '.fdt');
58 $this->_files[] = $this->_name . '.fdx';
59 $this->_files[] = $this->_name . '.fdt';
62 public function addNorm($fieldName, $normVector)
64 if (isset($this->_norms[$fieldName])) {
65 $this->_norms[$fieldName] .= $normVector;
67 $this->_norms[$fieldName] = $normVector;
72 * Close segment, write it to disk and return segment info
74 * @return Zend_Search_Lucene_Index_SegmentInfo
76 public function close()
78 if ($this->_docCount == 0) {
83 $this->_generateCFS();
85 return new Zend_Search_Lucene_Index_SegmentInfo($this->_directory,