Introduced: caluclateMinimumFileEntryLength() which calculates the minimum length...
authorRoland Haeder <roland@mxchange.org>
Tue, 20 May 2014 19:10:32 +0000 (21:10 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 20 May 2014 19:10:32 +0000 (21:10 +0200)
Signed-off-by: Roland H├Ąder <roland@mxchange.org>
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/index/class_BaseIndex.php
inc/classes/main/stacker/file/class_BaseFileStack.php

index 6c9dad6..ddd03a4 100644 (file)
@@ -2979,10 +2979,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      $isInitialized  Whether the file header is initialized
         */
        protected function isFileHeaderInitialized () {
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
+
                // Is the method there?
                assert(is_callable(array($this, 'readFileHeader')));
 
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
                // Default is not initialized
                $isInitialized = FALSE;
 
@@ -3085,6 +3086,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        protected function preAllocateFile ($type) {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
 
+               // caluclateMinimumFileEntryLength() must be callable
+               assert(is_callable(array($this, 'caluclateMinimumFileEntryLength')));
+
                // Is it enabled?
                if ($this->getConfigInstance()->getConfigEntry($type . '_pre_allocate_enabled') != 'Y') {
                        // Not enabled
@@ -3097,11 +3101,8 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Message to user
                self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Pre-allocating file ...', __METHOD__, __LINE__));
 
-               /*
-                * Calculate minimum length for one entry:
-                * minimum length = hash length + separator + name + minimum entry size = ?? + 1 + 10 + 1 = ??
-                */
-               $minLengthEntry = self::getHashLength() + strlen(self::SEPARATOR_HASH_NAME) + self::LENGTH_NAME + 1;
+               // Calculate minimum length for one entry
+               $minLengthEntry = $this->caluclateMinimumFileEntryLength();
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] minLengthEntry=%s', __METHOD__, __LINE__, $minLengthEntry));
 
                // Calulcate seek position
index 72b2d43..389fdc9 100644 (file)
@@ -164,6 +164,20 @@ class BaseIndex extends BaseFrameworkSystem {
                //* 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
         *
index 5d198a3..5aa1c39 100644 (file)
@@ -237,6 +237,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
         *