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 6c9dad6fad00f90653590482eda7f91cd4de341c..ddd03a4007a70fac05e025bc03ae5a9aeed8ba93 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 72b2d4398ccbe0174a262530783cd6b2405680be..389fdc9a92efcde4ae8f635693492ee8de935315 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 5d198a300a5232210c73d82c99bb7b53d567bac8..5aa1c39b3fb4cf0defb84e9b019b539279b98af1 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
         *