From: Roland Haeder Date: Sat, 17 May 2014 22:50:10 +0000 (+0200) Subject: Continued with hash-based stacks: X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=06b0b3f19b5a3aa84b911260cc17a85a36c317ad Continued with hash-based stacks: - added separator between count->seek position - changed separators: chr(0) is for pre-allocation Signed-off-by: Roland Häder --- diff --git a/contrib/file_stack/format.txt b/contrib/file_stack/format.txt index 9d88c78e..cb8c07ee 100644 --- a/contrib/file_stack/format.txt +++ b/contrib/file_stack/format.txt @@ -5,11 +5,11 @@ This is the format for a file-based stack which works as any Stackable class. General made up: -Purpose: | "magic" | separator | count | position | separator | ----------+-----------+-----------+----------+----------+-----------+ -Bytes: | 9 | 1 | 20 (hex) | 20 (hex) | 1 | ----------+-----------+-----------+----------+----------+-----------+ -Example: | STACKv1.0 | 00 | 00...ff | 00...ff | ff | +Purpose: | "magic" | separator | count | separator | position | separator | +---------+-----------+-----------+----------+-----------+------0---+-----------+ +Bytes: | 9 | 1 | 20 (hex) | 1 | 20 (hex) | 1 | +---------+-----------+-----------+----------+-----------+----------+-----------+ +Example: | STACKv1.0 | 01 | 00...ff | 02 | 00...ff | 03 | Continued: @@ -17,7 +17,7 @@ Purpose: | hash 0 | separator | name 0 | entry 0 | hash n | separator | name ---------+--------+-----------+--------+------------+--------+-----------+--------+------------+-----+ Bytes: | 64 | 1 | 10 | 1-n (pack) | 64 | 1 | 10 | 1-n (pack) | 1 | ---------+--------+-----------+--------+------------+--------+-----------+--------+------------+-----+ -Example: | abc | ??? | foo | ... | abc | ??? | bar | ... | EOF | +Example: | abc | 04 | foo | ... | abc | 04 | bar | ... | EOF | Explanations: ------------- @@ -29,4 +29,5 @@ Explanations: name X - Name of stack the entries belongs in entry X - The actual data, compressed with pack() EOF - End-of-file character + ... - Data ??? - Must be still found out which character/hashing algorthym fits best diff --git a/inc/classes/main/stacker/file/class_BaseFileStack.php b/inc/classes/main/stacker/file/class_BaseFileStack.php index 68d95fa1..8a31cfaf 100644 --- a/inc/classes/main/stacker/file/class_BaseFileStack.php +++ b/inc/classes/main/stacker/file/class_BaseFileStack.php @@ -30,17 +30,22 @@ class BaseFileStack extends BaseStacker { /** * Separator magic->count */ - const SEPARATOR_MAGIC_COUNT = 0x00; + const SEPARATOR_MAGIC_COUNT = 0x01; + + /** + * Separator count->position + */ + const SEPARATOR_COUNT_SEEK_POS = 0x02; /** * Separator position->entries */ - const SEPARATOR_SEEK_POS_ENTRIES = 0xff; + const SEPARATOR_SEEK_POS_ENTRIES = 0x03; /** * Separator hash->name */ - const SEPARATOR_HASH_NAME = 0x05; + const SEPARATOR_HASH_NAME = 0x04; /** * Length of name @@ -219,7 +224,7 @@ class BaseFileStack extends BaseStacker { /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); // Put all informations together - $header = sprintf('%s%s%s%s%s', + $header = sprintf('%s%s%s%s%s%s', // Magic self::STACK_MAGIC, @@ -229,8 +234,11 @@ class BaseFileStack extends BaseStacker { // Total entries (will be zero) and pad it to 20 chars str_pad($this->dec2hex($this->getCounter()), self::COUNT_LENGTH, '0', STR_PAD_LEFT), + // Separator count<->seek position + chr(self::SEPARATOR_COUNT_SEEK_POS), + // Position (will be zero) - str_pad($this->dec2hex(0, 2), self::COUNT_POSITION, '0', STR_PAD_LEFT), + str_pad($this->dec2hex($this->getSeekPosition(), 2), self::COUNT_POSITION, '0', STR_PAD_LEFT), // Separator position<->entries chr(self::SEPARATOR_SEEK_POS_ENTRIES)