下面列出了com.google.common.collect.Iterators#emptyIterator ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public Iterator<JobStatus> getJobStatusesForFlowExecution(String flowName, String flowGroup, long flowExecutionId,
String jobName, String jobGroup) {
Preconditions.checkArgument(flowName != null, "flowName cannot be null");
Preconditions.checkArgument(flowGroup != null, "flowGroup cannot be null");
Preconditions.checkArgument(jobName != null, "jobName cannot be null");
Preconditions.checkArgument(jobGroup != null, "jobGroup cannot be null");
List<JobStatus> jobStatuses = new ArrayList<>();
JobStatus jobStatus;
if (this.doesJobExist(flowName, flowGroup, flowExecutionId, JOB_DONE_SUFFIX)) {
jobStatus = JobStatus.builder().flowName(flowName).flowGroup(flowGroup).flowExecutionId(flowExecutionId).
jobName(jobName).jobGroup(jobGroup).jobExecutionId(flowExecutionId).eventName(ExecutionStatus.COMPLETE.name()).build();
} else if (this.doesJobExist(flowName, flowGroup, flowExecutionId, "")) {
jobStatus = JobStatus.builder().flowName(flowName).flowGroup(flowGroup).flowExecutionId(flowExecutionId).
jobName(jobName).jobGroup(jobGroup).jobExecutionId(flowExecutionId).eventName(ExecutionStatus.PENDING.name()).build();
} else {
return Iterators.emptyIterator();
}
jobStatuses.add(jobStatus);
return jobStatuses.iterator();
}
@Override
public Iterator<byte[][]> rangeDateTimeAsIDs(
final Value[] query,
final Literal lower,
final boolean equalsLower,
final Literal upper,
final boolean equalsUpper,
final boolean reverse,
final int limit) throws DataAccessLayerException {
if (query == null || query.length != 2 || isVariable(query[1])) {
return Iterators.emptyIterator();
}
final long lowerBound = lower == null ? Long.MIN_VALUE : Util.parseXMLSchemaDateTimeAsMSecs(lower), upperBound = upper == null ? Long.MAX_VALUE
: Util.parseXMLSchemaDateTimeAsMSecs(upper);
return _rdfIndexDAO.dateRangeQuery(query, lowerBound, equalsLower, upperBound, equalsUpper, reverse, limit);
}
/**
* Finds all files read by the table and generates CopyableFiles.
* For the specific semantics see {@link HiveCopyEntityHelper#getCopyEntities}.
*/
@Override
public Iterator<FileSet<CopyEntity>> getFileSetIterator(FileSystem targetFs, CopyConfiguration configuration,
Comparator<FileSet<CopyEntity>> prioritizer, PushDownRequestor<FileSet<CopyEntity>> requestor)
throws IOException {
if (!canCopyTable()) {
return Iterators.emptyIterator();
}
try {
List<FileSet<CopyEntity>> fileSetList = Lists.newArrayList(new HiveCopyEntityHelper(this, configuration, targetFs)
.getCopyEntities(configuration, prioritizer, requestor));
Collections.sort(fileSetList, prioritizer);
return fileSetList.iterator();
} catch (IOException ioe) {
log.error("Failed to copy table " + this.table, ioe);
return Iterators.emptyIterator();
}
}
@Override
public Iterator<? extends MapSource> loadNewSources() throws MapMissingException {
try {
git.pull()
.setCredentialsProvider(credentials)
.setFastForward(MergeCommand.FastForwardMode.FF)
.call();
} catch (GitAPIException e) {
throw new MapMissingException(
git.getRepository().getDirectory().getPath(), e.getMessage(), e.getCause());
}
return Iterators.emptyIterator();
}
public Iterator<RangeTombstone> iterator(Composite from, Composite till)
{
int startIdx = from.isEmpty() ? 0 : searchInternal(from, 0);
final int start = startIdx < 0 ? -startIdx-1 : startIdx;
if (start >= size)
return Iterators.<RangeTombstone>emptyIterator();
int finishIdx = till.isEmpty() ? size : searchInternal(till, start);
// if stopIdx is the first range after 'till' we care only until the previous range
final int finish = finishIdx < 0 ? -finishIdx-2 : finishIdx;
// Note: the following is true because we know 'from' is before 'till' in sorted order.
if (start > finish)
return Iterators.<RangeTombstone>emptyIterator();
else if (start == finish)
return Iterators.<RangeTombstone>singletonIterator(rangeTombstone(start));
return new AbstractIterator<RangeTombstone>()
{
private int idx = start;
protected RangeTombstone computeNext()
{
if (idx >= size || idx > finish)
return endOfData();
return rangeTombstone(idx++);
}
};
}
static RowTraversal empty() {
return new RowTraversal() {
@Override
public Stream<Row> stream() {
return Stream.empty();
}
@Override
public Iterator<Row> iterator() {
return Iterators.emptyIterator();
}
};
}
@Override
public Iterator<Change> getDeltaHistories(String table, String rowId) {
String key = getKey(table, rowId);
if (!_historyStore.containsKey(key)) {
return Iterators.emptyIterator();
}
return Lists.transform(_historyStore.get(key), new Function<History, Change>() {
@Override
public Change apply(History input) {
return new ChangeBuilder(input.getChangeId())
.with(input).with(input.getDelta()).build();
}
}).iterator();
}
@Override
protected Iterator<InternalRow> doExecute() {
Iterator<InternalRow> chidlResIter = child.execute();
//List<InternalRow> childResList = Helper.toList(chidlResIter);
//Iterator<InternalRow> iter = childResList.iterator();
boolean hasInput = chidlResIter.hasNext();
if (!hasInput && !groupingExpressions.isEmpty()) {
// This is a grouped aggregate and the input iterator is empty,
// so return an empty iterator.
return Iterators.emptyIterator();
} else {
TungstenAggregationIterator aggregationIterator =
new TungstenAggregationIterator(
groupingExpressions,
aggregateExpressions,
aggregateAttributes,
initialInputBufferOffset,
resultExpressions,
this::newMutableProjection,
child.output(),
chidlResIter);
if (!hasInput && groupingExpressions.isEmpty()) {
UnsafeRow singleRowResult = aggregationIterator.outputForEmptyGroupingKeyWithoutInput();
return Iterators.singletonIterator(singleRowResult);
} else {
List<InternalRow> aggResList = toList(aggregationIterator);
return aggResList.iterator();
//return StreamSupport.stream(Spliterators.spliteratorUnknownSize(aggregationIterator, 0), false);
}
}
}
private void appendScanRow(StringBuilder buf, Bound bound) {
ScanRanges scanRanges = context.getScanRanges();
// TODO: review this and potentially intersect the scan ranges
// with the minMaxRange in ScanRanges to prevent having to do all this.
KeyRange minMaxRange = scanRanges.getMinMaxRange();
Iterator<byte[]> minMaxIterator = Iterators.emptyIterator();
if (minMaxRange != KeyRange.EVERYTHING_RANGE) {
RowKeySchema schema = tableRef.getTable().getRowKeySchema();
if (!minMaxRange.isUnbound(bound)) {
minMaxIterator = new RowKeyValueIterator(schema, minMaxRange.getRange(bound));
}
}
int nRanges = scanRanges.getRanges().size();
for (int i = 0, minPos = 0; minPos < nRanges || minMaxIterator.hasNext(); i++) {
List<KeyRange> ranges = minPos >= nRanges ? EVERYTHING : scanRanges.getRanges().get(minPos++);
KeyRange range = bound == Bound.LOWER ? ranges.get(0) : ranges.get(ranges.size()-1);
byte[] b = range.getRange(bound);
Boolean isNull = KeyRange.IS_NULL_RANGE == range ? Boolean.TRUE : KeyRange.IS_NOT_NULL_RANGE == range ? Boolean.FALSE : null;
if (minMaxIterator.hasNext()) {
byte[] bMinMax = minMaxIterator.next();
int cmp = Bytes.compareTo(bMinMax, b) * (bound == Bound.LOWER ? 1 : -1);
if (cmp > 0) {
minPos = nRanges;
b = bMinMax;
isNull = null;
} else if (cmp < 0) {
minMaxIterator = Iterators.emptyIterator();
}
}
appendPKColumnValue(buf, b, isNull, i);
buf.append(',');
}
}
public Iterator<RangeTombstone> getRangeTombstoneIterator(final ColumnFamily source)
{
final DeletionInfo delInfo = source.deletionInfo();
if (!delInfo.hasRanges() || slices.length == 0)
return Iterators.<RangeTombstone>emptyIterator();
return new AbstractIterator<RangeTombstone>()
{
private int sliceIdx = 0;
private Iterator<RangeTombstone> sliceIter = currentRangeIter();
protected RangeTombstone computeNext()
{
while (true)
{
if (sliceIter.hasNext())
return sliceIter.next();
if (!nextSlice())
return endOfData();
sliceIter = currentRangeIter();
}
}
private Iterator<RangeTombstone> currentRangeIter()
{
ColumnSlice slice = slices[reversed ? (slices.length - 1 - sliceIdx) : sliceIdx];
return reversed ? delInfo.rangeIterator(slice.finish, slice.start)
: delInfo.rangeIterator(slice.start, slice.finish);
}
private boolean nextSlice()
{
return ++sliceIdx < slices.length;
}
};
}
/**
* Reads the ordered manifest for a channel. The read can either be weak or strong. A weak read will use CL1
* and may use the cached oldest slab from a previous strong call to improve performance. A strong read will use
* CL local_quorum and will always read the entire manifest row. This makes a weak read significantly faster than a
* strong read but also means the call is not guaranteed to return the entire manifest. Because of this at least
* every 10 seconds a weak read for a channel is automatically promoted to a strong read.
*
* The vast majority of calls to this method are performed during a "peek" or "poll" operation. Since these are
* typically called repeatedly a weak call provides improved performance while guaranteeing that at least every
* 10 seconds the manifest is strongly read so no slabs are missed over time. Calls which must guarantee
* the full manifest should explicitly request strong consistency.
*/
private Iterator<Column<ByteBuffer>> readManifestForChannel(final String channel, final boolean weak) {
final ByteBuffer oldestSlab = weak ? _oldestSlab.getIfPresent(channel) : null;
final ConsistencyLevel consistency;
RangeBuilder range = new RangeBuilder().setLimit(50);
if (oldestSlab != null) {
range.setStart(oldestSlab);
consistency = ConsistencyLevel.CL_LOCAL_ONE;
} else {
consistency = ConsistencyLevel.CL_LOCAL_QUORUM;
}
final Iterator<Column<ByteBuffer>> manifestColumns = executePaginated(
_keyspace.prepareQuery(ColumnFamilies.MANIFEST, consistency)
.getKey(channel)
.withColumnRange(range.build())
.autoPaginate(true));
if (oldestSlab != null) {
// Query was executed weakly using the cached oldest slab, so don't update the cache with an unreliable oldest value
return manifestColumns;
} else {
PeekingIterator<Column<ByteBuffer>> peekingManifestColumns = Iterators.peekingIterator(manifestColumns);
if (peekingManifestColumns.hasNext()) {
// Cache the first slab returned from querying the full manifest column family since it is the oldest.
cacheOldestSlabForChannel(channel, TimeUUIDSerializer.get().fromByteBuffer(peekingManifestColumns.peek().getName()));
return peekingManifestColumns;
} else {
// Channel was completely empty. Cache a TimeUUID for the current time. This will cause future calls
// to read at most 1 minute of tombstones until the cache expires 10 seconds later.
cacheOldestSlabForChannel(channel, TimeUUIDs.newUUID());
return Iterators.emptyIterator();
}
}
}
public Iterator<Pair<byte[],List<Mutation>>> toMutations(final boolean includeMutableIndexes) {
final Iterator<Map.Entry<TableRef, Map<ImmutableBytesPtr,Map<PColumn,byte[]>>>> iterator = this.mutations.entrySet().iterator();
if (!iterator.hasNext()) {
return Iterators.emptyIterator();
}
Long scn = connection.getSCN();
final long timestamp = scn == null ? HConstants.LATEST_TIMESTAMP : scn;
return new Iterator<Pair<byte[],List<Mutation>>>() {
private Map.Entry<TableRef, Map<ImmutableBytesPtr,Map<PColumn,byte[]>>> current = iterator.next();
private Iterator<Pair<byte[],List<Mutation>>> innerIterator = init();
private Iterator<Pair<byte[],List<Mutation>>> init() {
return addRowMutations(current.getKey(), current.getValue(), timestamp, includeMutableIndexes);
}
@Override
public boolean hasNext() {
return innerIterator.hasNext() || iterator.hasNext();
}
@Override
public Pair<byte[], List<Mutation>> next() {
if (!innerIterator.hasNext()) {
current = iterator.next();
}
return innerIterator.next();
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
DFSInotifyEventInputStream(Sampler traceSampler, ClientProtocol namenode,
long lastReadTxid) throws IOException {
this.traceSampler = traceSampler;
this.namenode = namenode;
this.it = Iterators.emptyIterator();
this.lastReadTxid = lastReadTxid;
}
DFSInotifyEventInputStream(Sampler traceSampler, ClientProtocol namenode,
long lastReadTxid) throws IOException {
this.traceSampler = traceSampler;
this.namenode = namenode;
this.it = Iterators.emptyIterator();
this.lastReadTxid = lastReadTxid;
}
@Override
public void close() {
resultIterator = Iterators.emptyIterator();
}
@Override
public Iterator<MultiTableScanResult> multiTableScan(MultiTableScanOptions query, TableSet tables, LimitCounter limit,
ReadConsistency consistency, @Nullable Instant cutoffTime) {
// TODO: Create a simulation for this method
return Iterators.emptyIterator();
}
@Override
public <V> Iterator<VertexProperty<V>> properties(String... propertyKeys) {
return Iterators.emptyIterator();
}
public Scan(ListIterator<ScriptEngineFactory> factories, RowType rowType) {
super(rowType);
this.factories = factories;
this.names = Iterators.emptyIterator();
}
/**
* Poorman's {@link Pageable} implementation that does
* skipping by simply fast-forwarding {@link Iterator}
*
* @param base base collection
* @param start starting index requested from collection
* @param limit max number of item requested in the page
* @param <T> type of Pageable item
* @return iterator with starting index==start and size < limit
*/
public static <T> Iterator<T> slice(Iterator<T> base, int start, int limit) {
// fast-forward
int skipped = skip(base,start);
if (skipped < start){ //already at the end, nothing to return
Iterators.emptyIterator();
}
return Iterators.limit(base, limit);
}
@Nonnull @Override public Iterator<DebugItem> iterator() { return Iterators.emptyIterator(); }