Skip to content

Commit e174cac

Browse files
author
epriestley
committed
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
1 parent 0daa9ad commit e174cac

File tree

4 files changed

+37
-28
lines changed

4 files changed

+37
-28
lines changed

src/__phutil_library_map__.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,7 @@
10441044
'HarbormasterBuildGraph' => 'applications/harbormaster/engine/HarbormasterBuildGraph.php',
10451045
'HarbormasterBuildLintMessage' => 'applications/harbormaster/storage/build/HarbormasterBuildLintMessage.php',
10461046
'HarbormasterBuildLog' => 'applications/harbormaster/storage/build/HarbormasterBuildLog.php',
1047+
'HarbormasterBuildLogChunk' => 'applications/harbormaster/storage/build/HarbormasterBuildLogChunk.php',
10471048
'HarbormasterBuildLogPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildLogPHIDType.php',
10481049
'HarbormasterBuildLogQuery' => 'applications/harbormaster/query/HarbormasterBuildLogQuery.php',
10491050
'HarbormasterBuildMessage' => 'applications/harbormaster/storage/HarbormasterBuildMessage.php',
@@ -5191,6 +5192,7 @@
51915192
'HarbormasterDAO',
51925193
'PhabricatorPolicyInterface',
51935194
),
5195+
'HarbormasterBuildLogChunk' => 'HarbormasterDAO',
51945196
'HarbormasterBuildLogPHIDType' => 'PhabricatorPHIDType',
51955197
'HarbormasterBuildLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
51965198
'HarbormasterBuildMessage' => array(

src/applications/harbormaster/storage/HarbormasterSchemaSpec.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,6 @@ public function buildSchemata() {
2121
),
2222
));
2323

24-
25-
$this->buildRawSchema(
26-
id(new HarbormasterBuildable())->getApplicationName(),
27-
HarbormasterBuildLog::CHUNK_TABLE,
28-
array(
29-
'id' => 'auto',
30-
'logID' => 'id',
31-
'encoding' => 'text32',
32-
33-
// T6203/NULLABILITY
34-
// Both the type and nullability of this column are crazily wrong.
35-
'size' => 'uint32?',
36-
37-
'chunk' => 'bytes',
38-
),
39-
array(
40-
'PRIMARY' => array(
41-
'columns' => array('id'),
42-
'unique' => true,
43-
),
44-
'key_log' => array(
45-
'columns' => array('logID'),
46-
),
47-
));
48-
4924
}
5025

5126
}

src/applications/harbormaster/storage/build/HarbormasterBuildLog.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ final class HarbormasterBuildLog
1515
private $isOpen;
1616

1717
const CHUNK_BYTE_LIMIT = 102400;
18-
const CHUNK_TABLE = 'harbormaster_buildlogchunk';
1918

2019
/**
2120
* The log is encoded as plain text.
@@ -128,7 +127,7 @@ private function flush() {
128127
// caller writes a single character over and over again, we'll currently
129128
// spend a lot of time flushing that.
130129

131-
$chunk_table = self::CHUNK_TABLE;
130+
$chunk_table = id(new HarbormasterBuildLogChunk())->getTableName();
132131
$chunk_limit = self::CHUNK_BYTE_LIMIT;
133132
$rope = $this->rope;
134133

@@ -198,9 +197,10 @@ public function getLogText() {
198197
$result = queryfx_all(
199198
$conn,
200199
'SELECT chunk '.
201-
'FROM harbormaster_buildlogchunk '.
200+
'FROM %T '.
202201
'WHERE logID = %d '.
203202
'ORDER BY id ASC',
203+
id(new HarbormasterBuildLogChunk())->getTableName(),
204204
$this->getID());
205205

206206
$content = '';
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
final class HarbormasterBuildLogChunk
4+
extends HarbormasterDAO {
5+
6+
protected $logID;
7+
protected $encoding;
8+
protected $size;
9+
protected $chunk;
10+
11+
protected function getConfiguration() {
12+
return array(
13+
self::CONFIG_TIMESTAMPS => false,
14+
self::CONFIG_COLUMN_SCHEMA => array(
15+
'logID' => 'id',
16+
'encoding' => 'text32',
17+
18+
// T6203/NULLABILITY
19+
// Both the type and nullability of this column are crazily wrong.
20+
'size' => 'uint32?',
21+
22+
'chunk' => 'bytes',
23+
),
24+
self::CONFIG_KEY_SCHEMA => array(
25+
'key_log' => array(
26+
'columns' => array('logID'),
27+
),
28+
),
29+
) + parent::getConfiguration();
30+
}
31+
32+
}

0 commit comments

Comments
 (0)