java类com.google.common.collect.AbstractIterator的实例源码

AstyanaxTableDAO.java 文件源码 项目:emodb 阅读 44 收藏 0 点赞 0 评论 0
@Timed(name = "bv.emodb.table.AstyanaxTableDAO.list", absolute = true)
@Override
public Iterator<Table> list(@Nullable String fromNameExclusive, LimitCounter limit) {
    checkArgument(limit.remaining() > 0, "Limit must be >0");

    final Iterator<Map<String, Object>> tableIter =
            _backingStore.scan(_systemTable, fromNameExclusive, limit, ReadConsistency.STRONG);

    // Filter out dropped tables.
    return new AbstractIterator<Table>() {
        @Override
        protected Table computeNext() {
            while (tableIter.hasNext()) {
                Table table = tableFromJson(new TableJson(tableIter.next()));
                if (table != null) {
                    return table;
                }
            }
            return endOfData();
        }
    };
}
AstyanaxBlockedDataReaderDAO.java 文件源码 项目:emodb 阅读 33 收藏 0 点赞 0 评论 0
@Override
public Iterator<String> scanKeys(AstyanaxStorage storage, final ReadConsistency consistency) {
    checkNotNull(storage, "storage");
    checkNotNull(consistency, "consistency");

    final DeltaPlacement placement = (DeltaPlacement) storage.getPlacement();

    // We just want row keys, but get at least one column so we can ignore range ghosts.
    final ByteBufferRange columnRange = new RangeBuilder().setLimit(1).build();
    final LimitCounter unlimited = LimitCounter.max();

    // Loop over all the range prefixes (2^shardsLog2 of them) and, for each, execute Cassandra queries to
    // page through the records with that prefix.
    final Iterator<ByteBufferRange> scanIter = storage.scanIterator(null);
    return touch(Iterators.concat(new AbstractIterator<Iterator<String>>() {
        @Override
        protected Iterator<String> computeNext() {
            if (scanIter.hasNext()) {
                ByteBufferRange keyRange = scanIter.next();
                return decodeKeys(rowScan(placement, keyRange, columnRange, unlimited, consistency));
            }
            return endOfData();
        }
    }));
}
AstyanaxDataReaderDAO.java 文件源码 项目:emodb 阅读 28 收藏 0 点赞 0 评论 0
@Override
public Iterator<String> scanKeys(AstyanaxStorage storage, final ReadConsistency consistency) {
    checkNotNull(storage, "storage");
    checkNotNull(consistency, "consistency");

    final DeltaPlacement placement = (DeltaPlacement) storage.getPlacement();

    // We just want row keys, but get at least one column so we can ignore range ghosts.
    final ByteBufferRange columnRange = new RangeBuilder().setLimit(1).build();
    final LimitCounter unlimited = LimitCounter.max();

    // Loop over all the range prefixes (2^shardsLog2 of them) and, for each, execute Cassandra queries to
    // page through the records with that prefix.
    final Iterator<ByteBufferRange> scanIter = storage.scanIterator(null);
    return touch(Iterators.concat(new AbstractIterator<Iterator<String>>() {
        @Override
        protected Iterator<String> computeNext() {
            if (scanIter.hasNext()) {
                ByteBufferRange keyRange = scanIter.next();
                return decodeKeys(rowScan(placement, keyRange, columnRange, unlimited, consistency));
            }
            return endOfData();
        }
    }));
}
DefaultDataStore.java 文件源码 项目:emodb 阅读 30 收藏 0 点赞 0 评论 0
@Override
public Iterator<com.bazaarvoice.emodb.sor.api.Table> listTables(@Nullable String fromTableExclusive, long limit) {
    checkArgument(limit > 0, "Limit must be >0");

    LimitCounter remaining = new LimitCounter(limit);
    final Iterator<Table> tableIter = _tableDao.list(fromTableExclusive, remaining);
    return remaining.limit(new AbstractIterator<com.bazaarvoice.emodb.sor.api.Table>() {
        @Override
        protected com.bazaarvoice.emodb.sor.api.Table computeNext() {
            while (tableIter.hasNext()) {
                Table table = tableIter.next();
                if (!table.isInternal()) {
                    return toDefaultTable(table);
                }
            }
            return endOfData();
        }
    });
}
DefaultDataStore.java 文件源码 项目:emodb 阅读 21 收藏 0 点赞 0 评论 0
private Iterator<Map<String, Object>> resolveScanResults(final Iterator<Record> records,
                                                         final ReadConsistency consistency,
                                                         final boolean includeDeletes) {
    return new AbstractIterator<Map<String, Object>>() {
        @Override
        protected Map<String, Object> computeNext() {
            while (records.hasNext()) {
                Record record = records.next();

                // Collapse the deltas into a Resolved object.
                Resolved resolved = resolve(record, consistency);

                // Skip deleted objects, if not desired
                if (!includeDeletes && !resolved.matches(Conditions.isDefined())) {
                    continue;
                }

                // Convert to the final JSON format including intrinsic fields
                return toContent(resolved, consistency);
            }
            return endOfData();
        }
    };
}
CharSource.java 文件源码 项目:codebuff 阅读 39 收藏 0 点赞 0 评论 0
/**
 * Returns an iterable over the lines in the string. If the string ends in a newline, a final
 * empty string is not included to match the behavior of BufferedReader/LineReader.readLine().
 */

private Iterable<String> lines() {
  return new Iterable<String>() {
    @Override
    public Iterator<String> iterator() {
      return new AbstractIterator<String>() {
        Iterator<String> lines = LINE_SPLITTER.split(seq).iterator();


        @Override
        protected String computeNext() {
          if (lines.hasNext()) {
            String next = lines.next();
            // skip last line if it's empty
            if (lines.hasNext() || !next.isEmpty()) {
              return next;
            }
          }
          return endOfData();
        }
      };
    }
  };
        }
CharSource.java 文件源码 项目:codebuff 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Returns an iterable over the lines in the string. If the string ends in a newline, a final
 * empty string is not included to match the behavior of BufferedReader/LineReader.readLine().
 */

private Iterable<String> lines() {
  return new Iterable<String>() {
    @Override
    public Iterator<String> iterator() {
      return new AbstractIterator<String>() {
        Iterator<String> lines = LINE_SPLITTER.split(seq).iterator();


        @Override
        protected String computeNext() {
          if (lines.hasNext()) {
            String next = lines.next();
            // skip last line if it's empty
            if (lines.hasNext() || !next.isEmpty()) {
              return next;
            }
          }
          return endOfData();
        }
      };
    }
  };
        }
CharSource.java 文件源码 项目:codebuff 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Returns an iterable over the lines in the string. If the string ends in a newline, a final
 * empty string is not included to match the behavior of BufferedReader/LineReader.readLine().
 */

private Iterable<String> lines() {
  return new Iterable<String>() {
    @Override
    public Iterator<String> iterator() {
      return new AbstractIterator<String>() {
        Iterator<String> lines = LINE_SPLITTER.split(seq).iterator();


        @Override
        protected String computeNext() {
          if (lines.hasNext()) {
            String next = lines.next();
            // skip last line if it's empty
            if (lines.hasNext() || !next.isEmpty()) {
              return next;
            }
          }
          return endOfData();
        }
      };
    }
  };
        }
CharSource.java 文件源码 项目:codebuff 阅读 37 收藏 0 点赞 0 评论 0
/**
 * Returns an iterable over the lines in the string. If the string ends in a newline, a final
 * empty string is not included to match the behavior of BufferedReader/LineReader.readLine().
 */

private Iterable<String> lines() {
  return new Iterable<String>() {
    @Override
    public Iterator<String> iterator() {
      return new AbstractIterator<String>() {
        Iterator<String> lines = LINE_SPLITTER.split(seq).iterator();


        @Override
        protected String computeNext() {
          if (lines.hasNext()) {
            String next = lines.next();
            // skip last line if it's empty
            if (lines.hasNext() || !next.isEmpty()) {
              return next;
            }
          }
          return endOfData();
        }
      };
    }
  };
        }
CharSource.java 文件源码 项目:codebuff 阅读 32 收藏 0 点赞 0 评论 0
/**
 * Returns an iterable over the lines in the string. If the string ends in a newline, a final
 * empty string is not included to match the behavior of BufferedReader/LineReader.readLine().
 */
private Iterable<String> lines() {
  return new Iterable<String>() {
    @Override
    public Iterator<String> iterator() {
      return new AbstractIterator<String>() {
        Iterator<String> lines = LINE_SPLITTER.split(seq).iterator();

        @Override
        protected String computeNext() {
          if (lines.hasNext()) {
            String next = lines.next();
            // skip last line if it's empty
            if (lines.hasNext() || !next.isEmpty()) {
              return next;
            }
          }
          return endOfData();
        }
      };
    }
  };
}


问题


面经


文章

微信
公众号

扫码关注公众号