gpt4 book ai didi

io.druid.java.util.common.guava.Yielder类的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 16:05:31 27 4
gpt4 key购买 nike

本文整理了Java中io.druid.java.util.common.guava.Yielder类的一些代码示例,展示了Yielder类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Yielder类的具体详情如下:
包路径:io.druid.java.util.common.guava.Yielder
类名称:Yielder

Yielder介绍

[英]A Yielder is an object that tries to act like the yield() command/continuations in other languages. It's not necessarily good at this job, but it works. I think. Essentially, you can think of a Yielder as a linked list of items where the Yielder gives you access to the current head via get() and it will give you another Yielder representing the next item in the chain via next(). A Yielder that isDone() may return anything from both get() and next(), there is no contract and depending on those return values will likely lead to bugs. Once next is called, there is no guarantee and no requirement that references to old Yielder objects will continue to obey the contract. Yielders are Closeable and must be closed in order to prevent resource leaks. Once close() is called, the behavior of the whole chain of Yielders is undefined.
[中]Yielder是一个试图像其他语言中的yield()命令/continuations那样工作的对象。它不一定擅长这项工作,但它很管用。我想。本质上,你可以把一个Yielder看作是一个项目的链表,Yielder通过get()让你访问当前头部,它会给你另一个Yielder,通过next()代表链中的下一个项目。如果isDone()可能同时返回get()和next()中的任何内容,则没有约定,根据这些返回值可能会导致错误。一旦调用next,就不能保证也不要求对老Yielder对象的引用将继续遵守合同。YiElder是可关闭的,必须关闭,以防止资源泄漏。一旦调用close(),整个数据链的行为就没有定义。

代码示例

代码示例来源:origin: io.druid/druid-server

@Override
public void close() throws IOException
{
 rowYielder.close();
}

代码示例来源:origin: io.druid/java-util

@Override
public OutType get()
{
 return baseYielder.get();
}

代码示例来源:origin: io.druid/druid-server

@Override
public boolean hasMore()
{
 return !rowYielder.isDone();
}

代码示例来源:origin: io.druid/druid-processing

@Override
 public void serialize(Yielder yielder, final JsonGenerator jgen, SerializerProvider provider)
   throws IOException, JsonProcessingException
 {
  try {
   jgen.writeStartArray();
   while (!yielder.isDone()) {
    final Object o = yielder.get();
    jgen.writeObject(o);
    yielder = yielder.next(null);
   }
   jgen.writeEndArray();
  }
  finally {
   yielder.close();
  }
 }
}

代码示例来源:origin: io.druid/java-util

OutType nextInit = yielder.get();
try {
 yielder.close();
return makeYielder(yielderYielder.next(null), nextInit, accumulator);

代码示例来源:origin: io.druid/druid-server

@Nullable
@Override
public InputRow nextRow()
{
 final InputRow inputRow = rowYielder.get();
 rowYielder = rowYielder.next(null);
 return transformer.transform(inputRow);
}

代码示例来源:origin: io.druid/java-util

if (!yielder.isDone()) {
 queue.add(yielder);
} else {
 try {
  yielder.close();

代码示例来源:origin: io.druid/java-util

@Override
public Yielder<OutType> next(OutType initValue)
{
 return wrapYielder(yielder.next(initValue), accumulator);
}

代码示例来源:origin: io.druid/java-util

public <OutType> Yielder<OutType> makeYielder(
  Yielder<Sequence<T>> yielderYielder,
  OutType initValue,
  YieldingAccumulator<OutType, T> accumulator
)
{
 while (!yielderYielder.isDone()) {
  Yielder<OutType> yielder = yielderYielder.get().toYielder(initValue, accumulator);
  if (accumulator.yielded()) {
   return wrapYielder(yielder, yielderYielder, accumulator);
  }
  initValue = yielder.get();
  try {
   yielder.close();
  }
  catch (IOException e) {
   throw Throwables.propagate(e);
  }
  yielderYielder = yielderYielder.next(null);
 }
 return Yielders.done(initValue, yielderYielder);
}

代码示例来源:origin: io.druid/druid-processing

@Override
public ScanResultValue next()
{
 ScanResultValue batch = yielder.get();
 if (ScanQuery.RESULT_FORMAT_COMPACTED_LIST.equals(resultFormat) ||
   ScanQuery.RESULT_FORMAT_LIST.equals(resultFormat)) {
  List events = (List) batch.getEvents();
  if (events.size() <= limit - count) {
   count += events.size();
   yielder = yielder.next(null);
   return batch;
  } else {
   // last batch
   // single batch length is <= Integer.MAX_VALUE, so this should not overflow
   int left = (int) (limit - count);
   count = limit;
   return new ScanResultValue(batch.getSegmentId(), batch.getColumns(), events.subList(0, left));
  }
 }
 throw new UnsupportedOperationException(ScanQuery.RESULT_FORMAT_VALUE_VECTOR + " is not supported yet");
}

代码示例来源:origin: io.druid/java-util

@Override
public Yielder<OutType> next(OutType initValue)
{
 return wrapYielder(yielder.next(initValue), yielderYielder, accumulator);
}

代码示例来源:origin: io.druid/java-util

while (!accumulator.yielded() && !pQueue.isEmpty()) {
 Yielder<T> yielder = pQueue.remove();
 retVal = accumulator.accumulate(retVal, yielder.get());
 yielder = yielder.next(null);
 if (yielder.isDone()) {
  try {
   yielder.close();

代码示例来源:origin: io.druid/druid-processing

@Override
 public void close() throws IOException
 {
  yielder.close();
 }
}

代码示例来源:origin: io.druid/java-util

@Override
 public T apply(Yielder<T> input)
 {
  return input.get();
 }
}

代码示例来源:origin: io.druid/druid-processing

@Override
public boolean hasNext()
{
 return !yielder.isDone() && count < limit;
}

代码示例来源:origin: io.druid/java-util

@Override
 public Yielder<OutType> get()
 {
  return new WrappingYielder<>(baseYielder.next(initValue), wrapper);
 }
});

代码示例来源:origin: io.druid/java-util

@Override
 public void close() throws IOException
 {
  try (Closeable toClose = yielderYielder) {
   yielder.close();
  }
 }
};

代码示例来源:origin: io.druid/java-util

@Override
public OutType get()
{
 return yielder.get();
}

代码示例来源:origin: io.druid/java-util

@Override
public boolean isDone()
{
 return baseYielder.isDone();
}

代码示例来源:origin: io.druid/java-util

@Override
public Yielder<T> next(T initValue)
{
 return new ExecuteWhenDoneYielder<>(baseYielder.next(initValue), runnable, executor);
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com