void TrackingSyncSource::checkStatus(SyncSourceReport &changes) { // use the most reliable (and most expensive) method by default ChangeMode mode = CHANGES_FULL; // assume that we do a regular sync, with reusing stored information // if possible string oldRevision = m_metaNode->readProperty("databaseRevision"); if (!oldRevision.empty()) { string newRevision = databaseRevision(); SE_LOG_DEBUG(this, NULL, "old database revision '%s', new revision '%s'", oldRevision.c_str(), newRevision.c_str()); if (newRevision == oldRevision) { SE_LOG_DEBUG(this, NULL, "revisions match, no item changes"); mode = CHANGES_NONE; } } if (mode == CHANGES_FULL) { SE_LOG_DEBUG(this, NULL, "using full item scan to detect changes"); } detectChanges(*m_trackingNode, mode); // copy our item counts into the report changes.setItemStat(ITEM_LOCAL, ITEM_ADDED, ITEM_TOTAL, getNewItems().size()); changes.setItemStat(ITEM_LOCAL, ITEM_UPDATED, ITEM_TOTAL, getUpdatedItems().size()); changes.setItemStat(ITEM_LOCAL, ITEM_REMOVED, ITEM_TOTAL, getDeletedItems().size()); changes.setItemStat(ITEM_LOCAL, ITEM_ANY, ITEM_TOTAL, getAllItems().size()); }
int main(){ height = 5, width = 5; freopen("rays.in", "r", stdin); initialize(); getInputAtoms(); getHitOrder(); detectChanges(); printBoard(); }
void TrackingSyncSource::beginSync(const std::string &lastToken, const std::string &resumeToken) { // use the most reliable (and most expensive) method by default ChangeMode mode = CHANGES_FULL; // resume token overrides the normal token; safe to ignore in most // cases and this detectChanges() is done independently of the // token, but let's do it right here anyway string token; if (!resumeToken.empty()) { token = resumeToken; } else { token = lastToken; } // slow sync if token is empty if (token.empty()) { SE_LOG_DEBUG(this, NULL, "slow sync or testing, do full item scan to detect changes"); mode = CHANGES_SLOW; } else { string oldRevision = m_metaNode->readProperty("databaseRevision"); if (!oldRevision.empty()) { string newRevision = databaseRevision(); SE_LOG_DEBUG(this, NULL, "old database revision '%s', new revision '%s'", oldRevision.c_str(), newRevision.c_str()); if (newRevision == oldRevision) { SE_LOG_DEBUG(this, NULL, "revisions match, no item changes"); mode = CHANGES_NONE; } // Reset old revision. If anything goes wrong, then we // don't want to rely on a possibly incorrect optimization. m_metaNode->setProperty("databaseRevision", ""); m_metaNode->flush(); } } if (mode == CHANGES_FULL) { SE_LOG_DEBUG(this, NULL, "using full item scan to detect changes"); } detectChanges(*m_trackingNode, mode); }