summaryrefslogtreecommitdiff
path: root/p2pvr/daemon
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-01-25 18:47:47 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-06-13 17:29:48 +0100
commite1f325f8fa80a077d41cc2874ebdba589a7512f2 (patch)
treec1a21d7b8de9bcb952a94053220da94e96080ed8 /p2pvr/daemon
parentNo longer required explicit impl (diff)
downloadp2pvr-e1f325f8fa80a077d41cc2874ebdba589a7512f2.tar.bz2
p2pvr-e1f325f8fa80a077d41cc2874ebdba589a7512f2.tar.xz
p2pvr-e1f325f8fa80a077d41cc2874ebdba589a7512f2.zip
Return the select columns from CreateColumns and pass it back into BindColumns (saves repeated metadata lookups)
Diffstat (limited to 'p2pvr/daemon')
-rw-r--r--p2pvr/daemon/maintenance/events.cpp16
-rw-r--r--p2pvr/daemon/maintenance/network.cpp16
-rw-r--r--p2pvr/daemon/maintenance/services.cpp4
-rw-r--r--p2pvr/daemon/schedules.cpp9
4 files changed, 25 insertions, 20 deletions
diff --git a/p2pvr/daemon/maintenance/events.cpp b/p2pvr/daemon/maintenance/events.cpp
index 92b214c..8c0834b 100644
--- a/p2pvr/daemon/maintenance/events.cpp
+++ b/p2pvr/daemon/maintenance/events.cpp
@@ -13,29 +13,32 @@ ResourceString(Maint_pruneEvents, sql_Maint_pruneEvents);
class SiEventsHandler : public SiEpgParser {
public:
- SiEventsHandler(const RowProcessorCallback & cb) :
+ SiEventsHandler(const RowProcessorCallback & cb, const SelectedColumns & sc) :
+ ecs(sc),
callBack(cb) {}
bool HandleTable(DVBSI::EventPtr e)
{
Logger()->messagebf(LOG_DEBUG, "Service Id: %d Program Id: %d Title: %s Time: %s - %s",
e->ServiceId, e->EventId, e->Title, e->StartTime, e->StopTime);
- BindColumns<DVBSI::EventPtr>(rowState, e);
+ BindColumns<DVBSI::EventPtr>(rowState, ecs, e);
rowState.process(callBack);
return false;
}
private:
ObjectRowState<DVBSI::EventPtr> rowState;
+ const SelectedColumns & ecs;
const RowProcessorCallback callBack;
};
class SiEventsMerger : public IHaveSubTasks {
public:
- SiEventsMerger(short t, const Ice::Current & i) :
+ SiEventsMerger(short t, const Ice::Current & i, const SelectedColumns & sc) :
SourceObject(__PRETTY_FUNCTION__),
IHaveSubTasks(NULL),
type(t),
+ ecs(sc),
ice(i) { }
void execute(ExecContext * ec) const
@@ -49,7 +52,7 @@ class SiEventsMerger : public IHaveSubTasks {
}
TemporarayIceAdapterObject<P2PVR::RawDataClient> parser(ice.adapter,
- new SiEventsHandler(boost::bind(&SiEventsMerger::executeChildren, this, ec)));
+ new SiEventsHandler(boost::bind(&SiEventsMerger::executeChildren, this, ec), ecs));
auto delivery = si->GetDeliveryForSi();
if (!delivery) {
@@ -65,6 +68,7 @@ class SiEventsMerger : public IHaveSubTasks {
private:
const short type;
+ const SelectedColumns & ecs;
const Ice::Current & ice;
void executeChildren(ExecContext * ec) const
@@ -80,8 +84,8 @@ Maintenance::UpdateEvents(short type, const Ice::Current & ice)
{
TxHelper tx(this);
SqlMergeTask mergeEvents("postgres", "events");
- CreateColumns<DVBSI::EventPtr>(boost::bind(SqlMergeColumnsInserter, &mergeEvents, _1, _2));
- mergeEvents.sources.insert(new SiEventsMerger(type, ice));
+ auto ecs = CreateColumns<DVBSI::EventPtr>(boost::bind(SqlMergeColumnsInserter, &mergeEvents, _1, _2));
+ mergeEvents.sources.insert(new SiEventsMerger(type, ice, ecs));
mergeEvents.insteadOfDelete = new DynamicSql::SqlText("SET current = false");
mergeEvents.updateWhere = new DynamicSql::SqlText("a.current");
mergeEvents.loadComplete(this);
diff --git a/p2pvr/daemon/maintenance/network.cpp b/p2pvr/daemon/maintenance/network.cpp
index 3c21639..97598ad 100644
--- a/p2pvr/daemon/maintenance/network.cpp
+++ b/p2pvr/daemon/maintenance/network.cpp
@@ -26,15 +26,15 @@ class SiNetworkInformationMerger : public SiNetworkInformationParser {
DatabaseClient::TxHelper tx(commonObjects);
SqlMergeTask mergeNetwork("postgres", "networks");
- CreateColumns<DVBSI::NetworkPtr>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeNetwork, _1, _2));
+ auto ncs = CreateColumns<DVBSI::NetworkPtr>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeNetwork, _1, _2));
std::vector<DVBSI::NetworkPtr> networks = { n };
- mergeNetwork.sources.insert(new ContainerIterator<std::vector<DVBSI::NetworkPtr>>(&networks));
+ mergeNetwork.sources.insert(new ContainerIterator<std::vector<DVBSI::NetworkPtr>>(&networks, ncs));
mergeNetwork.loadComplete(commonObjects);
mergeNetwork.execute(NULL);
SqlMergeTask mergeTransports("postgres", "transportstreams");
- CreateColumns<DVBSI::NetworkTransportStreamPtr>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeTransports, _1, _2));
- mergeTransports.sources.insert(new ContainerIterator<DVBSI::NetworkTransportStreams>(&n->TransportStreams));
+ auto tscs = CreateColumns<DVBSI::NetworkTransportStreamPtr>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeTransports, _1, _2));
+ mergeTransports.sources.insert(new ContainerIterator<DVBSI::NetworkTransportStreams>(&n->TransportStreams, tscs));
mergeTransports.loadComplete(commonObjects);
mergeTransports.execute(NULL);
@@ -43,9 +43,9 @@ class SiNetworkInformationMerger : public SiNetworkInformationParser {
mergeDelivery<DVBSI::CableDeliveryPtr, &DVBSI::NetworkTransportStream::Cable>("delivery_dvbc", n);
SqlMergeTask mergeServices("postgres", "services");
- CreateColumns<DVBSI::NetworkService>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeServices, _1, _2));
+ auto scs = CreateColumns<DVBSI::NetworkService>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeServices, _1, _2));
for (const auto & s : n->TransportStreams) {
- mergeServices.sources.insert(new ContainerIterator<DVBSI::NetworkServiceList>(&s->Services));
+ mergeServices.sources.insert(new ContainerIterator<DVBSI::NetworkServiceList>(&s->Services, scs));
}
mergeServices.loadComplete(commonObjects);
mergeServices.execute(NULL);
@@ -56,14 +56,14 @@ class SiNetworkInformationMerger : public SiNetworkInformationParser {
void mergeDelivery(const std::string & table, DVBSI::NetworkPtr n)
{
SqlMergeTask merge("postgres", table);
- CreateColumns<Delivery>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &merge, _1, _2));
+ auto dcs = CreateColumns<Delivery>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &merge, _1, _2));
std::vector<Delivery> dels;
for (const auto & s : n->TransportStreams) {
if (auto d = s.get()->*member) {
dels.push_back(d);
}
}
- merge.sources.insert(new ContainerIterator<decltype(dels)>(&dels));
+ merge.sources.insert(new ContainerIterator<decltype(dels)>(&dels, dcs));
merge.loadComplete(commonObjects);
merge.execute(NULL);
}
diff --git a/p2pvr/daemon/maintenance/services.cpp b/p2pvr/daemon/maintenance/services.cpp
index 50056ff..afa8084 100644
--- a/p2pvr/daemon/maintenance/services.cpp
+++ b/p2pvr/daemon/maintenance/services.cpp
@@ -23,11 +23,11 @@ class SiServicesMerger : public SiServicesParser {
DatabaseClient::TxHelper tx(commonObjects);
SqlMergeTask mergeServices("postgres", "services");
- CreateColumns<DVBSI::ServicePtr>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeServices, _1, _2));
+ auto scs = CreateColumns<DVBSI::ServicePtr>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeServices, _1, _2));
// Don't change the list of services available from the network
mergeServices.doDelete = VariableType(false);
mergeServices.doInsert = VariableType(false);
- mergeServices.sources.insert(new ContainerIterator<DVBSI::ServiceList>(&ts->Services));
+ mergeServices.sources.insert(new ContainerIterator<DVBSI::ServiceList>(&ts->Services, scs));
mergeServices.loadComplete(commonObjects);
mergeServices.execute(NULL);
return false;
diff --git a/p2pvr/daemon/schedules.cpp b/p2pvr/daemon/schedules.cpp
index 4ced9a7..5b0b5cd 100644
--- a/p2pvr/daemon/schedules.cpp
+++ b/p2pvr/daemon/schedules.cpp
@@ -54,17 +54,18 @@ typedef boost::shared_ptr<Record> RecordPtr;
typedef std::vector<RecordPtr> Records;
template<>
-void
+SelectedColumns
CreateColumns<RecordPtr>(const ColumnCreator & cc)
{
cc("eventuid", true);
cc("recordstatus", false);
cc("scheduleid", false);
+ return {true, true, true};
}
template<>
void
-BindColumns(RowState & rs, RecordPtr const & s)
+BindColumns(RowState & rs, const SelectedColumns &, RecordPtr const & s)
{
rs.fields[0] << s->EventUid;
rs.fields[1] << (int)s->RecordStatus;
@@ -325,8 +326,8 @@ Schedules::DoReschedule(const Ice::Current & ice)
TxHelper tx(this);
SqlMergeTask mergeRecords("postgres", "record");
- CreateColumns<RecordPtr>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeRecords, _1, _2));
- mergeRecords.sources.insert(new ContainerIterator<Records>(&records));
+ auto rcs = CreateColumns<RecordPtr>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeRecords, _1, _2));
+ mergeRecords.sources.insert(new ContainerIterator<Records>(&records, rcs));
mergeRecords.loadComplete(this);
mergeRecords.execute(NULL);
tx.Commit();