From 1156045b377d838b9e94b8b0f252043acf658de3 Mon Sep 17 00:00:00 2001 From: Sergey Nikolaev Date: Fri, 27 Dec 2024 15:12:45 +0700 Subject: [PATCH] Made it possible to use the cache as an sql dump; minor fixes --- src/configuration.php | 3 ++- src/query_generator.php | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/configuration.php b/src/configuration.php index 40b7099..81e95a7 100644 --- a/src/configuration.php +++ b/src/configuration.php @@ -312,7 +312,8 @@ private function showUsage($error = null) { " Random integer between 1 and 100\n" . " Random float between 1 and 1000\n" . " Random true or false\n" . - " Array of 2-10 elements, values 100-1000\n\n" . + " Array of 2-10 elements, values 100-1000\n" . + " Array of 256-512 random floats, values between 0 and 1\n\n" . "Examples:\n\n" . "# Load 1M documents in batches of 1000:\n" . diff --git a/src/query_generator.php b/src/query_generator.php index ffbd725..7a662ab 100644 --- a/src/query_generator.php +++ b/src/query_generator.php @@ -435,19 +435,19 @@ private function generateAndCacheQueries($quiet) { if (count($batch) == $batch_size) { $full_query = $base_query . implode(",", $batch); - fwrite($cache_file, $full_query . "\n"); + fwrite($cache_file, $full_query . ";\n"); $queries[] = $full_query; $batch = []; } } else { - fwrite($cache_file, $query . "\n"); + fwrite($cache_file, $query . ";\n"); $queries[] = $query; } $c++; if ($c % 1000 == 0 && !$quiet) { $progress = sprintf("\r%-80s\r", ""); - $progress .= sprintf("Process {$this->process_index}: Generating new data cache... %d%%", + $progress .= sprintf("Process {$this->process_index}: Generating new data cache {$this->cache_file_name} ... %d%%", round($c * 100 / $this->config->get('total')) ); ConsoleOutput::write($progress); @@ -463,7 +463,7 @@ private function generateAndCacheQueries($quiet) { fclose($cache_file); if (!$quiet) { ConsoleOutput::write(sprintf("\r%-80s\r", "")); - ConsoleOutput::writeLine(sprintf("Process {$this->process_index}: Generating new data cache... 100%%")); + ConsoleOutput::writeLine(sprintf("Process {$this->process_index}: Generating new data cache {$this->cache_file_name} ... 100%%")); } return $queries; @@ -479,6 +479,7 @@ private function generateSingleQuery() { $value = $this->generateValue($pattern); $query = str_replace("<$pattern_text>", $value, $query); } + rtrim($query, ';'); return $query; }