/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * License); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

#include "reader/task/device_task_iterator.h"

namespace storage {

void DeviceTaskIterator::flush_remaining_device_meta_cache() {
    device_meta_iterator_->destroy_remaining_cached_devices();
}

bool DeviceTaskIterator::has_next() const {
    return device_meta_iterator_->has_next();
}

int DeviceTaskIterator::next(DeviceQueryTask*& task) {
    int ret = common::E_OK;
    std::pair<std::shared_ptr<IDeviceID>, MetaIndexNode*> device_meta_pair;
    if (RET_FAIL(device_meta_iterator_->next(device_meta_pair))) {
    } else {
        task = DeviceQueryTask::create_device_query_task(
            device_meta_pair.first, column_names_, column_mapping_,
            device_meta_pair.second, table_schema_, pa_);
    }
    return ret;
}
}  // namespace storage
