]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/stacker/file/class_BaseFileStack.php
InputOutputPointer is the right interface.
[core.git] / inc / classes / main / stacker / file / class_BaseFileStack.php
index 5d198a300a5232210c73d82c99bb7b53d567bac8..53afecbd50b5aede20952acbc1327a242ad3f141 100644 (file)
@@ -140,7 +140,7 @@ class BaseFileStack extends BaseStacker {
         *
         * @return      void
         */
-       private function flushFileHeader () {
+       protected function flushFileHeader () {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
 
                // Put all informations together
@@ -165,7 +165,7 @@ class BaseFileStack extends BaseStacker {
                );
 
                // Write it to disk (header is always at seek position 0)
-               $this->writeData(0, $header);
+               $this->writeData(0, $header, FALSE);
 
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
        }
@@ -198,13 +198,14 @@ class BaseFileStack extends BaseStacker {
         * @param       $fileName       File name of this stack
         * @param       $type           Type of this stack (e.g. url_source for URL sources)
         * @return      void
+        * @todo        Currently the stack file is not cached, please implement a memory-handling class and if enough RAM is found, cache the whole stack file.
         */
        protected function initFileStack ($fileName, $type) {
-               // Get a file i/o pointer instance for stack file
-               $pointerInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_output_class', array($fileName));
+               // Get a stack file instance
+               $fileInstance = ObjectFactory::createObjectByConfiguredName('stack_file_class', array($fileName));
 
                // 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);
@@ -237,6 +238,19 @@ class BaseFileStack extends BaseStacker {
                $this->setIndexInstance($indexInstance);
        }
 
+       /**
+        * Calculates minimum length for one entry
+        *
+        * @return      $length         Minimum length for one entry
+        */
+       protected function caluclateMinimumFileEntryLength () {
+               // Calulcate it
+               $length = self::getHashLength() + strlen(self::SEPARATOR_HASH_NAME) + self::LENGTH_NAME + 1;
+
+               // Return it
+               return $length;
+       }
+
        /**
         * Adds a value to given stack
         *