// TODO(wangli): ideally, fetching blocks from child iterator in cases // that the limit is exhausted is not necessary. However, in the current // implementation, the child iterator sub-tree leaded by exchange // lower iterator cannot be closed if not all the blocks are called. bool PhysicalLimit::Next(BlockStreamBase* block) { while (state_.child_->Next(block_for_asking_)) { void* tuple_from_child; BlockStreamBase::BlockStreamTraverseIterator* it = block_for_asking_->createIterator(); while (NULL != (tuple_from_child = it->currentTuple())) { if (!LimitExhausted()) { if (!ShouldSkip()) { const unsigned tuple_size = state_.schema_->getTupleActualSize(tuple_from_child); void* target_tuple; if (NULL != (target_tuple = block->allocateTuple(tuple_size))) { state_.schema_->copyTuple(tuple_from_child, target_tuple); received_tuples_++; tuple_cur_++; it->increase_cur_(); } else { it->~BlockStreamTraverseIterator(); return true; } } else { tuple_cur_++; it->increase_cur_(); continue; } } else { break; // maybe the below statement is right ---YuKai // return !block->Empty(); // to consume the next block; } } } return !block->Empty(); }
int CVzConfig::load() { QFile file(m_qsPath); if (!file.open(QIODevice::ReadOnly)) return 1; QTextStream in(&file); while (!in.atEnd()) { QString line = in.readLine(); if (!ShouldSkip(line)) { m_qsData.append(line); m_qsData.append("\n"); } } return 0; }
nsRefPtr<MediaDecoderReader::VideoDataPromise> MP4Reader::RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold) { MOZ_ASSERT(GetTaskQueue()->IsCurrentThreadIn()); VLOG("skip=%d time=%lld", aSkipToNextKeyframe, aTimeThreshold); if (!EnsureDecodersSetup()) { NS_WARNING("Error constructing MP4 decoders"); return VideoDataPromise::CreateAndReject(DECODE_ERROR, __func__); } if (mShutdown) { NS_WARNING("RequestVideoData on shutdown MP4Reader!"); return VideoDataPromise::CreateAndReject(CANCELED, __func__); } MOZ_ASSERT(HasVideo() && mPlatform && mVideo.mDecoder); bool eos = false; if (ShouldSkip(aSkipToNextKeyframe, aTimeThreshold)) { uint32_t parsed = 0; eos = !SkipVideoDemuxToNextKeyFrame(aTimeThreshold, parsed); if (!eos && NS_FAILED(mVideo.mDecoder->Flush())) { NS_WARNING("Failed to skip/flush video when skipping-to-next-keyframe."); } mDecoder->NotifyDecodedFrames(parsed, 0, parsed); } MonitorAutoLock lock(mVideo.mMonitor); nsRefPtr<VideoDataPromise> p = mVideo.mPromise.Ensure(__func__); if (mVideo.mError) { mVideo.mPromise.Reject(DECODE_ERROR, __func__); } else if (eos) { mVideo.mPromise.Reject(END_OF_STREAM, __func__); } else { ScheduleUpdate(kVideo); } return p; }