svn: /phd/trunk/phpdotnet/phd/ Config.php Format.php Index.php Options/Handler.php
| From: | Hannes Magnusson | Date: | Wed, 27 Apr 2011 18:33:37 +0000 |
| Subject: | svn: /phd/trunk/phpdotnet/phd/ Config.php Format.php Index.php Options/Handler.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-8027@lists.php.net to get a copy of this message | ||
bjori Wed, 27 Apr 2011 18:33:37 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=310590
Log:
Add --memoryindex (-M) to just store the index in memory
# couple of percentages less :)
Changed paths:
U phd/trunk/phpdotnet/phd/Config.php
U phd/trunk/phpdotnet/phd/Format.php
U phd/trunk/phpdotnet/phd/Index.php
U phd/trunk/phpdotnet/phd/Options/Handler.php
Modified: phd/trunk/phpdotnet/phd/Config.php
===================================================================
--- phd/trunk/phpdotnet/phd/Config.php 2011-04-27 18:25:29 UTC (rev 310589)
+++ phd/trunk/phpdotnet/phd/Config.php 2011-04-27 18:33:37 UTC (rev 310590)
@@ -51,6 +51,8 @@
'package_dirs' => array(__INSTALLDIR__),
'saveconfig' => false,
'quit' => false,
+ 'indexcache' => '',
+ 'memoryindex' => '',
);
private static $optionArray = null;
Modified: phd/trunk/phpdotnet/phd/Format.php
===================================================================
--- phd/trunk/phpdotnet/phd/Format.php 2011-04-27 18:25:29 UTC (rev 310589)
+++ phd/trunk/phpdotnet/phd/Format.php 2011-04-27 18:33:37 UTC (rev 310590)
@@ -53,8 +53,14 @@
protected $buffer = "";
public function __construct() {
- if (file_exists(Config::output_dir() . "index.sqlite")) {
- $this->sqlite = new \SQLite3(Config::output_dir() . 'index.sqlite');
+ $sqlite = Config::indexcache();
+ if (!$sqlite) {
+ if (file_exists(Config::output_dir() . "index.sqlite")) {
+ $sqlite = new \SQLite3(Config::output_dir() . 'index.sqlite');
+ }
+ }
+ if ($sqlite) {
+ $this->sqlite = $sqlite;
$this->sortIDs();
}
}
Modified: phd/trunk/phpdotnet/phd/Index.php
===================================================================
--- phd/trunk/phpdotnet/phd/Index.php 2011-04-27 18:25:29 UTC (rev 310589)
+++ phd/trunk/phpdotnet/phd/Index.php 2011-04-27 18:33:37 UTC (rev 310590)
@@ -149,13 +149,15 @@
break;
case Render::INIT:
if ($value) {
- if (file_exists(Config::output_dir() . "index.sqlite")) {
- $db = new \SQLite3(Config::output_dir() . 'index.sqlite');
- $db->exec('DELETE FROM ids');
- $db->exec('DELETE FROM indexing');
+ if (Config::memoryindex()) {
+ $db = new \SQLite3(":memory:");
} else {
$db = new \SQLite3(Config::output_dir() . 'index.sqlite');
- $create = <<<SQL
+ $db->exec('DROP TABLE IF EXISTS ids');
+ $db->exec('DROP TABLE IF EXISTS indexing');
+ }
+
+ $create = <<<SQL
CREATE TABLE ids (
docbook_id TEXT,
filename TEXT,
@@ -171,13 +173,16 @@
time INTEGER PRIMARY KEY
);
SQL;
- $db->exec('PRAGMA default_synchronous=OFF');
- $db->exec('PRAGMA count_changes=OFF');
- $db->exec('PRAGMA cache_size=100000');
- $db->exec($create);
+ $db->exec('PRAGMA default_synchronous=OFF');
+ $db->exec('PRAGMA count_changes=OFF');
+ $db->exec('PRAGMA cache_size=100000');
+ $db->exec($create);
+
+ if (Config::memoryindex()) {
+ Config::set_indexcache($db);
}
+
$this->db = $db;
-
$this->chunks = array();
} else {
print_r($this->chunks);
Modified: phd/trunk/phpdotnet/phd/Options/Handler.php
===================================================================
--- phd/trunk/phpdotnet/phd/Options/Handler.php 2011-04-27 18:25:29 UTC (rev 310589)
+++ phd/trunk/phpdotnet/phd/Options/Handler.php 2011-04-27 18:33:37 UTC (rev 310590)
@@ -28,9 +28,19 @@
'ext:' => 'e:', // The file-format extension to
use, including the dot
'saveconfig::' => 'S::', // Save the generated config ?
'quit' => 'Q', // Do not run the render. Use
with -S to just save the config.
+ 'memoryindex' => 'M', // Use sqlite in memory rather
then file
);
}
+ public function option_M($k, $v)
+ {
+ $this->option_memoryindex($k, $v);
+ }
+ public function option_memoryindex($k, $v)
+ {
+ Config::set_memoryindex(true);
+ }
+
public function option_f($k, $v)
{
$this->option_format($k, $v);
@@ -347,6 +357,9 @@
-I
--noindex Do not index before rendering but load from cache
(default: false)
+ -M
+ --memoryindex Do not save indexing into a file, store it in memory.
+ (default: false)
-r
--forceindex Force re-indexing under all circumstances
(default: false)