AbstractQoreNode *command::read_rows(const Placeholders *ph, ExceptionSink* xsink) { if (ensure_colinfo(xsink)) return 0; ReferenceHolder<AbstractQoreNode> rv(xsink); QoreListNode *l = 0; while (fetch_row_into_buffers(xsink)) { ReferenceHolder<QoreHashNode> h(output_buffers_to_hash(ph, xsink), xsink); if (*xsink) return 0; if (rv) { if (!l) { ReferenceHolder<QoreListNode> lholder(new QoreListNode(), xsink); l = *lholder; l->push(rv.release()); rv = lholder.release(); } l->push(h.release()); } else rv = h.release(); } return rv.release(); }
void MultiSymbolCache::addPriceData(CppUtils::String const& symbol, PriceData const& pdata) { SymbolDescriptor sdescr(symbol, ST_Physical); if (symbols_m.find(sdescr) == symbols_m.end()) THROW(CppUtils::OperationFailed, "exc_SymbolNotRegistered", "ctx_addPriceData", symbol); if (!pdata.isValid()) THROW(CppUtils::OperationFailed, "exc_InvalidPriceData", "ctx_addPriceData", ""); // we have only milliseconds Math::DoubleLongHolder<3> lholder( pdata.time_m); if (maxSize_m != 0) { bool inserted = false; map<CppUtils::Int64, RowType >::iterator itr = cache_m.find(lholder.getLongInternalValue()); if (itr == cache_m.end()) { // not found pair< map<CppUtils::Int64, RowType >::iterator, bool> ins_res = cache_m.insert( pair<CppUtils::Int64, RowType >(lholder.getLongInternalValue(), RowType())); HTASSERT(ins_res.second); map<CppUtils::Int64, RowType >::iterator& inserted_it= ins_res.first; RowType &new_row = inserted_it->second; new_row[symbol] = pdata; inserted = true; // notify propagate_onUpdateCaclulatedField(lholder.getLongInternalValue(), pdata.time_m, new_row); } else { // already found RowType& row = itr->second; row[symbol] = pdata; // notify propagate_onUpdateCaclulatedField(lholder.getLongInternalValue(), pdata.time_m, row); } if (inserted) { if (cache_m.size() <= maxSize_m || maxSize_m < 0) return; map<CppUtils::Int64, RowType >::iterator it_first = cache_m.begin(); map<CppUtils::Int64, RowType >::iterator it_last = cache_m.end(); it_last--; // actual insert if (removeLatest_m) { cache_m.erase(it_last); } else { cache_m.erase(it_first); } } } else { // do nothing } }