2011-08-28 05:13:24 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
|
|
|
|
#include <boost/assign/list_inserter.hpp>
|
|
|
|
|
|
|
|
#include <Poco/SharedPtr.h>
|
|
|
|
#include <Poco/Stopwatch.h>
|
|
|
|
#include <Poco/NumberParser.h>
|
|
|
|
|
2011-10-31 06:37:12 +00:00
|
|
|
#include <DB/IO/ReadBufferFromIStream.h>
|
2011-08-28 05:13:24 +00:00
|
|
|
#include <DB/IO/WriteBufferFromOStream.h>
|
|
|
|
|
|
|
|
#include <DB/Storages/StorageLog.h>
|
2011-08-28 08:02:11 +00:00
|
|
|
#include <DB/Storages/StorageSystemNumbers.h>
|
|
|
|
#include <DB/Storages/StorageSystemOne.h>
|
2011-10-31 17:30:44 +00:00
|
|
|
#include <DB/Storages/StorageFactory.h>
|
2011-08-28 05:13:24 +00:00
|
|
|
|
2011-10-31 06:37:12 +00:00
|
|
|
#include <DB/Interpreters/loadMetadata.h>
|
|
|
|
#include <DB/Interpreters/executeQuery.h>
|
2011-08-28 05:13:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
using Poco::SharedPtr;
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char ** argv)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2011-10-15 23:40:56 +00:00
|
|
|
/// Заранее инициализируем DateLUT, чтобы первая инициализация потом не влияла на измеряемую скорость выполнения.
|
|
|
|
Yandex::DateLUTSingleton::instance();
|
|
|
|
|
2011-08-28 05:13:24 +00:00
|
|
|
DB::Context context;
|
|
|
|
|
2012-08-02 17:33:31 +00:00
|
|
|
context.setPath("./");
|
2011-10-31 06:37:12 +00:00
|
|
|
|
|
|
|
DB::loadMetadata(context);
|
2011-09-25 03:37:09 +00:00
|
|
|
|
2012-08-02 17:33:31 +00:00
|
|
|
context.addDatabase("system");
|
|
|
|
context.addTable("system", "one", new DB::StorageSystemOne("one"));
|
|
|
|
context.addTable("system", "numbers", new DB::StorageSystemNumbers("numbers"));
|
|
|
|
context.setCurrentDatabase("default");
|
2011-08-28 05:13:24 +00:00
|
|
|
|
2011-10-31 06:37:12 +00:00
|
|
|
DB::ReadBufferFromIStream in(std::cin);
|
|
|
|
DB::WriteBufferFromOStream out(std::cout);
|
|
|
|
DB::BlockInputStreamPtr query_plan;
|
2011-08-28 08:02:11 +00:00
|
|
|
|
2011-10-31 06:37:12 +00:00
|
|
|
DB::executeQuery(in, out, context, query_plan);
|
|
|
|
|
|
|
|
if (query_plan)
|
|
|
|
{
|
2012-03-05 07:58:34 +00:00
|
|
|
/* std::cerr << std::endl;
|
|
|
|
query_plan->dumpTreeWithProfile(std::cerr);*/
|
2011-10-31 06:37:12 +00:00
|
|
|
std::cerr << std::endl;
|
|
|
|
query_plan->dumpTree(std::cerr);
|
2012-03-05 02:34:20 +00:00
|
|
|
std::cerr << std::endl;
|
2011-10-31 06:37:12 +00:00
|
|
|
}
|
2011-08-28 05:13:24 +00:00
|
|
|
}
|
|
|
|
catch (const DB::Exception & e)
|
|
|
|
{
|
2012-11-08 18:30:49 +00:00
|
|
|
std::cerr << e.what() << ", " << e.displayText() << std::endl
|
2011-12-12 06:15:34 +00:00
|
|
|
<< std::endl
|
|
|
|
<< "Stack trace:" << std::endl
|
|
|
|
<< e.getStackTrace().toString();
|
2011-08-28 05:13:24 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|