com.uber.hoodie.common.util.queue.IteratorBasedQueueProducer Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2017 Uber Technologies, Inc. ([email protected])
*
* Licensed 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.
*
*
*/
package com.uber.hoodie.common.util.queue;
import java.util.Iterator;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
/**
* Iterator based producer which pulls entry from iterator and produces items for the queue
*
* @param Item type produced for the buffer.
*/
public class IteratorBasedQueueProducer implements BoundedInMemoryQueueProducer {
private static final Logger logger = LogManager.getLogger(IteratorBasedQueueProducer.class);
// input iterator for producing items in the buffer.
private final Iterator inputIterator;
public IteratorBasedQueueProducer(Iterator inputIterator) {
this.inputIterator = inputIterator;
}
@Override
public void produce(BoundedInMemoryQueue queue) throws Exception {
logger.info("starting to buffer records");
while (inputIterator.hasNext()) {
queue.insertRecord(inputIterator.next());
}
logger.info("finished buffering records");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy