From e174cac1b47616904fa4f8b58893aedae83eb21a Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 1 Mar 2016 12:10:27 -0800 Subject: [PATCH] Give HarbormasterBuildLogChunk a real table Summary: Ref T10457. Currently, this table is an ad-hoc table, but can easily be turned into a normal table. This will make iterating over log chunks to compress and archive them easier. Test Plan: Viewed logs, ran `bin/storage adjust` with no issues. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10457 Differential Revision: https://secure.phabricator.com/D15376 --- src/__phutil_library_map__.php | 2 ++ .../storage/HarbormasterSchemaSpec.php | 25 --------------- .../storage/build/HarbormasterBuildLog.php | 6 ++-- .../build/HarbormasterBuildLogChunk.php | 32 +++++++++++++++++++ 4 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 src/applications/harbormaster/storage/build/HarbormasterBuildLogChunk.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 740021f3c5..b16ece7018 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1044,6 +1044,7 @@ phutil_register_library_map(array( 'HarbormasterBuildGraph' => 'applications/harbormaster/engine/HarbormasterBuildGraph.php', 'HarbormasterBuildLintMessage' => 'applications/harbormaster/storage/build/HarbormasterBuildLintMessage.php', 'HarbormasterBuildLog' => 'applications/harbormaster/storage/build/HarbormasterBuildLog.php', + 'HarbormasterBuildLogChunk' => 'applications/harbormaster/storage/build/HarbormasterBuildLogChunk.php', 'HarbormasterBuildLogPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildLogPHIDType.php', 'HarbormasterBuildLogQuery' => 'applications/harbormaster/query/HarbormasterBuildLogQuery.php', 'HarbormasterBuildMessage' => 'applications/harbormaster/storage/HarbormasterBuildMessage.php', @@ -5191,6 +5192,7 @@ phutil_register_library_map(array( 'HarbormasterDAO', 'PhabricatorPolicyInterface', ), + 'HarbormasterBuildLogChunk' => 'HarbormasterDAO', 'HarbormasterBuildLogPHIDType' => 'PhabricatorPHIDType', 'HarbormasterBuildLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HarbormasterBuildMessage' => array( diff --git a/src/applications/harbormaster/storage/HarbormasterSchemaSpec.php b/src/applications/harbormaster/storage/HarbormasterSchemaSpec.php index b1ec953af9..b310db14de 100644 --- a/src/applications/harbormaster/storage/HarbormasterSchemaSpec.php +++ b/src/applications/harbormaster/storage/HarbormasterSchemaSpec.php @@ -21,31 +21,6 @@ final class HarbormasterSchemaSpec extends PhabricatorConfigSchemaSpec { ), )); - - $this->buildRawSchema( - id(new HarbormasterBuildable())->getApplicationName(), - HarbormasterBuildLog::CHUNK_TABLE, - array( - 'id' => 'auto', - 'logID' => 'id', - 'encoding' => 'text32', - - // T6203/NULLABILITY - // Both the type and nullability of this column are crazily wrong. - 'size' => 'uint32?', - - 'chunk' => 'bytes', - ), - array( - 'PRIMARY' => array( - 'columns' => array('id'), - 'unique' => true, - ), - 'key_log' => array( - 'columns' => array('logID'), - ), - )); - } } diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php index 50b1545c06..d5eaac8890 100644 --- a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php @@ -15,7 +15,6 @@ final class HarbormasterBuildLog private $isOpen; const CHUNK_BYTE_LIMIT = 102400; - const CHUNK_TABLE = 'harbormaster_buildlogchunk'; /** * The log is encoded as plain text. @@ -128,7 +127,7 @@ final class HarbormasterBuildLog // caller writes a single character over and over again, we'll currently // spend a lot of time flushing that. - $chunk_table = self::CHUNK_TABLE; + $chunk_table = id(new HarbormasterBuildLogChunk())->getTableName(); $chunk_limit = self::CHUNK_BYTE_LIMIT; $rope = $this->rope; @@ -198,9 +197,10 @@ final class HarbormasterBuildLog $result = queryfx_all( $conn, 'SELECT chunk '. - 'FROM harbormaster_buildlogchunk '. + 'FROM %T '. 'WHERE logID = %d '. 'ORDER BY id ASC', + id(new HarbormasterBuildLogChunk())->getTableName(), $this->getID()); $content = ''; diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildLogChunk.php b/src/applications/harbormaster/storage/build/HarbormasterBuildLogChunk.php new file mode 100644 index 0000000000..aa1c0e1185 --- /dev/null +++ b/src/applications/harbormaster/storage/build/HarbormasterBuildLogChunk.php @@ -0,0 +1,32 @@ + false, + self::CONFIG_COLUMN_SCHEMA => array( + 'logID' => 'id', + 'encoding' => 'text32', + + // T6203/NULLABILITY + // Both the type and nullability of this column are crazily wrong. + 'size' => 'uint32?', + + 'chunk' => 'bytes', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_log' => array( + 'columns' => array('logID'), + ), + ), + ) + parent::getConfiguration(); + } + +}