]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/index/class_BaseIndex.php
Moved even more code to BaseFile where a much better place is for it (clear encapsula...
[core.git] / inc / classes / main / index / class_BaseIndex.php
index 29d0d52e10246f3824cb1db90afda4dae80c201d..fd57724131a179bf518a159ad54e7d141684ef75 100644 (file)
@@ -27,16 +27,6 @@ class BaseIndex extends BaseFrameworkSystem {
         */
        const INDEX_MAGIC = 'INDEXv0.1';
 
-       /**
-        * Separator for header data
-        */
-       const SEPARATOR_HEADER_DATA = 0x01;
-
-       /**
-        * Separator header->entries
-        */
-       const SEPARATOR_HEADER_ENTRIES = 0x02;
-
        /**
         * Protected constructor
         *
@@ -148,57 +138,22 @@ class BaseIndex extends BaseFrameworkSystem {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
        }
 
-       /**
-        * Analyzes entries in index file. This will count all found (and valid)
-        * entries, mark invalid as damaged and count gaps ("fragmentation"). If
-        * only gaps are found, the file is considered as "virgin" (no entries).
-        *
-        * @return      void
-        */
-       private function analyzeFile () {
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
-
-               // Make sure the file is initialized
-               assert($this->isFileInitialized());
-
-               // Init counters and gaps array
-               $this->initGapsArray();
-
-               // Output message (as this may take some time)
-               self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Analyzing file structure ... (this may take some time)', __METHOD__, __LINE__));
-
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
-       }
-
-       /**
-        * Calculates minimum length for one entry
-        *
-        * @return      $length         Minimum length for one entry
-        */
-       protected function caluclateMinimumFileEntryLength () {
-               // Calulcate it
-               // @TODO Not finished yet
-               $length = 0;
-
-               // Return it
-               return $length;
-       }
-
        /**
         * Initializes this index
         *
         * @param       $fileName       File name of this index
         * @return      void
+        * @todo        Currently the index file is not cached, please implement a memory-handling class and if enough RAM is found, cache the whole index file.
         */
        protected function initIndex ($fileName) {
                // Append index file extension
                $fileName .= $this->getConfigInstance()->getConfigEntry('index_extension');
 
                // Get a file i/o pointer instance for index file
-               $pointerInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_output_class', array($fileName));
+               $fileInstance = ObjectFactory::createObjectByConfiguredName('index_file_class', array($fileName, $this));
 
                // Get iterator instance
-               $iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_io_iterator_class', array($pointerInstance));
+               $iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_io_iterator_class', array($fileInstance));
 
                // Is the instance implementing the right interface?
                assert($iteratorInstance instanceof SeekableWritableFileIterator);
@@ -219,7 +174,21 @@ class BaseIndex extends BaseFrameworkSystem {
                $this->readFileHeader();
 
                // Count all entries in file
-               $this->analyzeFile();
+               $this->getIteratorInstance()->analyzeFile();
+       }
+
+       /**
+        * Calculates minimum length for one entry/block
+        *
+        * @return      $length         Minimum length for one entry/block
+        */
+       public function caluclateMinimumBlockLength () {
+               // Calulcate it
+               // @TODO Not finished yet
+               $length = 0;
+
+               // Return it
+               return $length;
        }
 }