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
|
|
|
|
2012-03-09 03:06:09 +00:00
|
|
|
#include <DB/Functions/FunctionsLibrary.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-03-09 03:06:09 +00:00
|
|
|
context.functions = DB::FunctionsLibrary::get();
|
2011-10-31 06:37:12 +00:00
|
|
|
context.path = "./";
|
|
|
|
|
2011-09-25 03:37:09 +00:00
|
|
|
context.aggregate_function_factory = new DB::AggregateFunctionFactory;
|
2011-10-31 06:37:12 +00:00
|
|
|
context.data_type_factory = new DB::DataTypeFactory;
|
2011-10-31 17:30:44 +00:00
|
|
|
context.storage_factory = new DB::StorageFactory;
|
2011-10-31 06:37:12 +00:00
|
|
|
|
|
|
|
DB::loadMetadata(context);
|
2011-09-25 03:37:09 +00:00
|
|
|
|
2011-08-28 08:02:11 +00:00
|
|
|
(*context.databases)["system"]["one"] = new DB::StorageSystemOne("one");
|
|
|
|
(*context.databases)["system"]["numbers"] = new DB::StorageSystemNumbers("numbers");
|
2011-08-28 05:13:24 +00:00
|
|
|
context.current_database = "default";
|
|
|
|
|
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)
|
|
|
|
{
|
2011-12-12 06:15:34 +00:00
|
|
|
std::cerr << e.what() << ", " << e.message() << std::endl
|
|
|
|
<< std::endl
|
|
|
|
<< "Stack trace:" << std::endl
|
|
|
|
<< e.getStackTrace().toString();
|
2011-08-28 05:13:24 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|