Commit 6ddf3131 authored by Marco De Marco's avatar Marco De Marco
Browse files

Metadata transfer works, needs further bugfix

parent 7b57cba0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ CXX_RELEASE_FLAGS=-O3
CXX_DEFAULT_FLAGS=-c -Wall -Wextra -std=c++11 -std=gnu++11
LDFLAGS=-Wall -lomniORB4 -lomniDynamic4 -lCOS4 -lomnithread -ltango -llog4tango \
	-lsoci_core -lsoci_mysql -lboost_system -lboost_thread -lboost_filesystem \
	-lprotobuf -lssl
	-lboost_date_time-mt -lprotobuf -lssl
INC_PARM=$(foreach d, $(INC_DIR), -I$d)
LIB_PARM=$(foreach d, $(LIB_DIR), -L$d)
PROTOC :=/usr/local/protobuf-2.5.0/bin/protoc
+1 −3
Original line number Diff line number Diff line
@@ -46,9 +46,7 @@ message Request

	message Metadata
	{
		required string schema = 1;
		required string table = 2;
		required sfixed64 timestamp = 3;
		required sfixed64 timestamp = 1;
	}

	optional Metadata metadata = 4;
+61 −62
Original line number Diff line number Diff line
@@ -49,14 +49,6 @@ message Response

	message Metadata
	{
		//Metadata response partial

		required uint64 partial = 1;
	
		//Metadata response total

		required uint64 total = 2;	

		//Metadata response state

		enum State
@@ -65,12 +57,16 @@ message Response
			REJECTED = 1;
		}

		required State state = 3;
		required State state = 1;

		//Metadata response status

		required string status = 4;
		required string status = 2;

		//Block of rows with same timestamp

		message Row
		{
			//Mysql: FLOAT, DOUBLE, DECIMAL
			//SOCI:  dt_double
			//C++:   double
@@ -81,7 +77,7 @@ message Response
				required double value = 2;
			}

		repeated DtDouble double_list = 5;
			repeated DtDouble double_list = 1;

			//Mysql: TINYINT, SMALLINT, INT, BIGINT
			//SOCI:  dt_integer 
@@ -93,7 +89,7 @@ message Response
				required int32 value = 2;
			}

		repeated DtInteger integer_list = 6;
			repeated DtInteger integer_list = 2;

			//Mysql: not used with mysql, needed for postgres
			//SOCI:  dt_unsigned_long 
@@ -105,7 +101,7 @@ message Response
				required uint64 value = 2;
			}

		repeated DtUnsignedLong unsinged_long_list = 7;
			repeated DtUnsignedLong unsinged_long_list = 3;

			//Mysql: not used with mysql, needed for postgres
			//SOCI:  dt_long_long
@@ -117,7 +113,7 @@ message Response
				required int64 value = 2;
			}

		repeated DtLongLong long_long_list = 8;
			repeated DtLongLong long_long_list = 4;

			//Mysql: STRING/BINARY, VARCHAR/VARBINARY
			//SOCI:  dt_string
@@ -129,7 +125,7 @@ message Response
				required string value = 2;
			}

		repeated DtString strings_list = 9;
			repeated DtString strings_list = 5;

			//Mysql: TIMESTAMP DATE, TIME, DATETIME
			//SOCI:  dt_date 
@@ -141,7 +137,10 @@ message Response
				required sfixed64 value = 2;
			}

		repeated DtDate date_list = 10;
			repeated DtDate date_list = 6;
		}

		repeated Row rows = 3;
	}

	optional Metadata metadata = 4;
+12 −7
Original line number Diff line number Diff line
#include <DBManager.h>

#include <boost/date_time.hpp>

#include <soci/mysql/soci-mysql.h>
#include <soci/use.h>

@@ -116,22 +118,25 @@ DBManager::InformationList DBManager::retrieveInformation(std::string schema,
//==============================================================================
//      DBManager::retrieveNewTuples()
//==============================================================================
soci::rowset<soci::row> DBManager::retrieveNewTuples(std::string schema,
DBManager::RowsetSP DBManager::retrieveNewTuples(std::string schema,
    std::string table, std::tm update_time) throw(soci::soci_error)
{
    DEBUG_STREAM << "DBManager::retrieveNewTuples()" << endl;

    soci::session session(*m_connectionPool_sp);

    soci::rowset<soci::row> rows = (session.prepare << "select * from "
        << schema << "." << table << " where update_time>=:timestamp",
        soci::use(update_time,"timestamp"));
    //@workaround: this does not work: timestamp parameter not passed
//    RowsetSP rows(new soci::rowset<soci::row>((session.prepare << "select * from "
//        << schema << "." << table << " where update_time > :timestamp "
//        << "order by update_time asc", soci::use(update_time,"timestamp"))));

    MetadataList metadataList;
    boost::posix_time::ptime timestamp = boost::posix_time::ptime_from_tm(update_time);

    std::copy(rows.begin(), rows.end(), std::back_inserter(metadataList));
    RowsetSP rows(new soci::rowset<soci::row>(session.prepare << "select * from "
        << schema << "." << table << " where update_time>'"
        << boost::posix_time::to_iso_string(timestamp) << "' order by update_time asc"));

    return metadataList;
    return rows;
}

}   //namespace
+3 −3
Original line number Diff line number Diff line
@@ -75,10 +75,10 @@ public:
//------------------------------------------------------------------------------
//  [Public] Search new tuple method
//------------------------------------------------------------------------------
    typedef std::vector<soci::row> MetadataList;
    typedef boost::shared_ptr< soci::rowset<soci::row> > RowsetSP;

    virtual MetadataList retrieveNewTuples(std::string, std::string,
        std::tm) throw(soci::soci_error);
    virtual RowsetSP retrieveNewTuples(std::string, std::string, std::tm)
        throw(soci::soci_error);

protected:
//------------------------------------------------------------------------------
Loading