From: Roland Haeder Date: Tue, 20 May 2014 19:10:32 +0000 (+0200) Subject: Introduced: caluclateMinimumFileEntryLength() which calculates the minimum length... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=82845d401adc07626618b74bf155951bcc68e280;p=core.git Introduced: caluclateMinimumFileEntryLength() which calculates the minimum length for one file entry. Signed-off-by: Roland Häder --- diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 6c9dad6f..ddd03a40 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -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 diff --git a/inc/classes/main/index/class_BaseIndex.php b/inc/classes/main/index/class_BaseIndex.php index 72b2d439..389fdc9a 100644 --- a/inc/classes/main/index/class_BaseIndex.php +++ b/inc/classes/main/index/class_BaseIndex.php @@ -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 * diff --git a/inc/classes/main/stacker/file/class_BaseFileStack.php b/inc/classes/main/stacker/file/class_BaseFileStack.php index 5d198a30..5aa1c39b 100644 --- a/inc/classes/main/stacker/file/class_BaseFileStack.php +++ b/inc/classes/main/stacker/file/class_BaseFileStack.php @@ -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 *