10 namespace persistency {
17 std::pair<std::string, std::shared_ptr<void> > readBackPayload =
fetch(sourcePayloadId, sourceSession);
18 return import(sourceSession, sourcePayloadId, readBackPayload.first, readBackPayload.second.get(), destSession);
23 if (!sourceSession.
fetchPayloadData(sourcePayloadId, payloadType, payloadData, streamerInfoData)) {
24 cond::throwException(
"Payload with hash" + sourcePayloadId +
" has not been found in the source database.",
27 boost::posix_time::ptime
now = boost::posix_time::microsec_clock::universal_time();
28 return destSession.
storePayloadData(payloadType, std::make_pair(payloadData, streamerInfoData), now);
52 std::cout <<
" Loading source iov..." << std::endl;
55 if (
iovs.size() == 0) {
56 std::cout <<
" Tag contains 0 iovs." << std::endl;
65 std::cout <<
" No Iov in the selected range." << std::endl;
79 dp = destSession.
readIov(destTag);
80 editor = destSession.
editIov(destTag);
81 if (!description.empty())
82 std::cout <<
" INFO. Destination Tag " << destTag
83 <<
" already exists. Provided description will be ignored." << std::endl;
85 throwException(
"TimeType of the destination tag does not match with the source tag timeType.",
"importIovs");
87 throwException(
"PayloadType of the destination tag does not match with the source tag payloadType.",
92 if (description.empty())
98 std::set<cond::Hash> pids;
99 std::set<cond::Time_t>
sinces;
100 auto iiov =
iovs.find(begin);
102 while (iiov !=
iovs.end()) {
104 if (sinces.find(newSince) != sinces.end()) {
105 std::cout <<
" WARNING. Skipping duplicated since=" << newSince << std::endl;
116 auto ie = diovs.
find(newSince);
117 if (ie != diovs.end()) {
118 if (((*ie).since == newSince) && ((*ie).payloadId == usedIov.payloadId)) {
124 editor.
insert(newSince, ph);
125 sinces.insert(newSince);
127 if (niovs && (niovs % 1000 == 0))
128 std::cout <<
" Total of iov inserted: " << niovs <<
" payloads: " << pids.size() << std::endl;
131 if (iiov ==
iovs.end() || (*iiov).since >
end) {
134 newSince = (*iiov).since;
137 if (exists &&
override) {
138 std::cout <<
" Adding overlying iovs..." << std::endl;
141 std::set<cond::Time_t> extraSinces;
142 for (
const auto& iov : diovs) {
144 if (siov.since != iov.since) {
145 if (extraSinces.find(iov.since) == extraSinces.end()) {
146 editor.
insert(iov.since, siov.payloadId);
147 extraSinces.insert(iov.since);
149 if (niovs && (niovs % 1000 == 0))
150 std::cout <<
" Total of iov inserted: " << niovs <<
" payloads: " << pids.size() << std::endl;
155 std::cout <<
" Total of iov inserted: " << niovs <<
" payloads: " << pids.size() << std::endl;
156 std::cout <<
" Flushing changes..." << std::endl;
157 editor.
flush(editingNote, forceInsert);
171 std::cout <<
" Loading source iov..." << std::endl;
174 if (
iovs.size() == 0) {
175 std::cout <<
" Tag contains 0 iovs." << std::endl;
182 auto iiov =
iovs.find(sourceSince);
183 if (iiov ==
iovs.end()) {
184 std::cout <<
"ERROR: No Iov valid found for target time " << sourceSince << std::endl;
190 if (!description.empty())
191 std::cout <<
" INFO. Destination Tag " << destTag
192 <<
" already exists. Provided description will be ignored." << std::endl;
193 editor = session.
editIov(destTag);
195 throwException(
"TimeType of the destination tag does not match with the source tag timeType.",
"importIovs");
197 throwException(
"PayloadType of the destination tag does not match with the source tag payloadType.",
202 if (description.empty())
203 editor.
setDescription(
"Created copying iovs from tag " + sourceTag);
208 editor.
insert(destSince, (*iiov).payloadId);
210 std::cout <<
" Flushing changes..." << std::endl;
bool copyIov(Session &session, const std::string &sourceTag, const std::string &destTag, cond::Time_t souceSince, cond::Time_t destSince, const std::string &description)
size_t importIovs(const std::string &sourceTag, Session &sourceSession, const std::string &destTag, Session &destSession, cond::Time_t begin, cond::Time_t end, const std::string &description, const std::string &editingNote, bool override, bool serialize, bool forceInsert)
Iterator find(cond::Time_t time) const
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
void setDescription(const std::string &description)
Transaction & transaction()
void throwException(const std::string &message, const std::string &methodName)
SynchronizationType synchronizationType
unsigned long long Time_t
void start(bool readOnly=true)
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
cond::Iov_t getInterval(cond::Time_t time)
cond::Hash importPayload(Session &sourceSession, const cond::Hash &sourcePayloadId, Session &destSession, bool reserialize)
std::string connectionString()
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
IOVProxy readIov(const std::string &tag)
IOVEditor editIov(const std::string &tag)
void insert(cond::Time_t since, const cond::Hash &payloadHash, bool checkType=false)
bool existsIov(const std::string &tag)
cond::TimeType timeType() const
IOVArray selectRange(const cond::Time_t &begin, const cond::Time_t &end)
cond::Tag_t tagInfo() const
bool operator()(const cond::Time_t &x, const std::pair< cond::Time_t, boost::posix_time::ptime > &y)
std::pair< std::string, std::shared_ptr< void > > fetch(const cond::Hash &payloadId, Session &session)
std::string payloadType() const
void throwException(const std::string &message, const std::string &methodName)