com.emc.mongoose.common.io.collection.CircularListInput Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mongoose-common Show documentation
Show all versions of mongoose-common Show documentation
Mongoose is a high-load storage performance testing tool
The newest version!
package com.emc.mongoose.common.io.collection;
import java.io.EOFException;
import java.io.IOException;
import java.util.List;
/**
The data items input which may be get infinitely (if underlying collection allows).
*/
public class CircularListInput
extends ListInput {
/**
@param dataItems the source data items collection
*/
public CircularListInput(final List dataItems) {
super(dataItems);
}
/**
@return next data item
*/
@Override
public T get()
throws IOException {
if(i >= size) {
reset();
}
return items.get(i ++);
}
/**
@param buffer buffer for the data items
@param maxCount the count limit
@return the actual count of the items got in the buffer
@throws EOFException doesn't throw
*/
@Override
public int get(final List buffer, final int maxCount)
throws EOFException, IOException {
int n = 0;
while(n < maxCount) {
if(i >= size) {
reset();
}
n += super.get(buffer, Math.min(size - i, maxCount - n));
}
return n;
}
@Override
public String toString() {
return "CircularListItemInput<" + items.hashCode() + ">";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy