Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / search / Zend / Search / Lucene / Index / SegmentWriter / StreamWriter.php
blobba0e202522af0c4d4e0cabeb6c3ca126da899a2d
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
16 * @package Zend_Search_Lucene
17 * @subpackage Index
18 * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
23 /** Zend_Search_Lucene_Exception */
24 require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Exception.php';
26 /** Zend_Search_Lucene_Index_SegmentInfo */
27 require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/SegmentInfo.php';
29 /** Zend_Search_Lucene_Index_SegmentWriter */
30 require_once $CFG->dirroot.'/search/Zend/Search/Lucene/Index/SegmentWriter.php';
33 /**
34 * @category Zend
35 * @package Zend_Search_Lucene
36 * @subpackage Index
37 * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
38 * @license http://framework.zend.com/license/new-bsd New BSD License
40 class Zend_Search_Lucene_Index_SegmentWriter_StreamWriter extends Zend_Search_Lucene_Index_SegmentWriter
42 /**
43 * Object constructor.
45 * @param Zend_Search_Lucene_Storage_Directory $directory
46 * @param string $name
48 public function __construct(Zend_Search_Lucene_Storage_Directory $directory, $name)
50 parent::__construct($directory, $name);
54 /**
55 * Create stored fields files and open them for write
57 public function createStoredFieldsFiles()
59 $this->_fdxFile = $this->_directory->createFile($this->_name . '.fdx');
60 $this->_fdtFile = $this->_directory->createFile($this->_name . '.fdt');
62 $this->_files[] = $this->_name . '.fdx';
63 $this->_files[] = $this->_name . '.fdt';
66 public function addNorm($fieldName, $normVector)
68 if (isset($this->_norms[$fieldName])) {
69 $this->_norms[$fieldName] .= $normVector;
70 } else {
71 $this->_norms[$fieldName] = $normVector;
75 /**
76 * Close segment, write it to disk and return segment info
78 * @return Zend_Search_Lucene_Index_SegmentInfo
80 public function close()
82 if ($this->_docCount == 0) {
83 return null;
86 $this->_dumpFNM();
87 $this->_generateCFS();
89 return new Zend_Search_Lucene_Index_SegmentInfo($this->_name,
90 $this->_docCount,
91 $this->_directory);