dbms: probably faster loading [#CONV-2944].

This commit is contained in:
Alexey Milovidov 2013-01-17 19:36:34 +00:00
parent 94f5cb6101
commit 2f433b28a9

View File

@ -7,6 +7,10 @@
#include <DB/Interpreters/InterpreterCreateQuery.h> #include <DB/Interpreters/InterpreterCreateQuery.h>
#include <DB/Interpreters/loadMetadata.h> #include <DB/Interpreters/loadMetadata.h>
#include <DB/IO/ReadBufferFromFile.h>
#include <DB/IO/WriteBufferFromString.h>
#include <DB/IO/copyData.h>
namespace DB namespace DB
{ {
@ -68,16 +72,16 @@ void loadMetadata(Context & context)
if (jt.name().compare(jt.name().size() - 4, 4, ".sql")) if (jt.name().compare(jt.name().size() - 4, 4, ".sql"))
throw Exception("Incorrect file extension: " + jt.name() + " in metadata directory " + it->path(), ErrorCodes::INCORRECT_FILE_NAME); throw Exception("Incorrect file extension: " + jt.name() + " in metadata directory " + it->path(), ErrorCodes::INCORRECT_FILE_NAME);
Poco::FileInputStream istr(jt->path()); String s;
std::stringstream s; {
s << istr.rdbuf(); ReadBufferFromFile in(jt->path(), 32768);
WriteBufferFromString out(s);
if (!istr.good()) copyData(in, out);
throw Exception("Cannot read from file " + jt->path(), ErrorCodes::CANNOT_READ_FROM_ISTREAM); }
try try
{ {
executeCreateQuery(s.str(), context, it.name(), jt->path()); executeCreateQuery(s, context, it.name(), jt->path());
} }
catch (const DB::Exception & e) catch (const DB::Exception & e)
{ {