gpt4 book ai didi

cz.seznam.euphoria.core.client.io.Writer类的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 08:55:05 25 4
gpt4 key购买 nike

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

Writer介绍

[英]Writer for data to a particular partition.
[中]将数据写入特定分区。

代码示例

代码示例来源:origin: seznam/euphoria

@Override
public void write(NullWritable k, V v) throws IOException {
 writer.write(v);
}

代码示例来源:origin: seznam/euphoria

@Override
public void close() throws Exception {
 if (writer != null) {
  writer.flush();
  writer.commit();
  writer.close();
 }
}

代码示例来源:origin: seznam/euphoria

@Override
public void abortTask(TaskAttemptContext tac) throws IOException {
 if (innerWriter != null) {
  innerWriter.rollback();
  closeWriter(tac, innerWriter);
 }
}

代码示例来源:origin: seznam/euphoria

if (datum.isEndOfStream()) {
   writer.flush();
   writer.commit();
   writer.write(datum.getElement());
} finally {
 try {
  writer.close();
 } catch (IOException ioex) {
  LOG.warn("Something went wrong", ioex);

代码示例来源:origin: seznam/euphoria

@Test
 public void testMultipleSinks() throws Exception {
  ListDataSink<String> sink1 = ListDataSink.get();
  ListDataSink<String> sink2 = ListDataSink.get();

  // write to first sink
  Writer<String> w = sink1.openWriter(0);
  w.write("first");
  w.commit();

  // write to seconds sink
  w = sink2.openWriter(0);
  w.write("second-0");
  w.commit();

  w = sink2.openWriter(1);
  w.write("second-1");
  w.commit();

  assertEquals("first", Iterables.getOnlyElement(sink1.getOutputs()));

  DatasetAssert.unorderedEquals(sink2.getOutputs(), "second-0", "second-1");
 }
}

代码示例来源:origin: seznam/euphoria

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

代码示例来源:origin: seznam/euphoria

@Override
public void close(TaskAttemptContext tac) throws IOException {
 writer.flush();
}

代码示例来源:origin: seznam/euphoria

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

代码示例来源:origin: seznam/euphoria

if (datum.isEndOfStream()) {
   writer.flush();
   writer.commit();
   writer.write(datum.getElement());
} finally {
 try {
  writer.close();
 } catch (IOException ioex) {
  LOG.warn("Something went wrong", ioex);

代码示例来源:origin: seznam/euphoria

@Test
public void testMultiDataSinkWrites() throws IOException {
 ListDataSink<String> firstDataSink = ListDataSink.get();
 ListDataSink<String> secondDataSink = ListDataSink.get();
 ListDataSink<String> thirdDataSink = ListDataSink.get();
 DataSink<InputElement> output = createMultiDataSink(firstDataSink, secondDataSink,
   thirdDataSink);
 // write to first sink
 Writer<InputElement> wr = output.openWriter(0);
 wr.write(new InputElement(InputElement.Type.FIRST, "first-Data1"));
 wr.write(new InputElement(InputElement.Type.FIRST, "first-Data2"));
 wr.write(new InputElement(InputElement.Type.THIRD, "third-Data1"));
 wr.write(new InputElement(InputElement.Type.SECOND, "second-Data1"));
 wr.write(new InputElement(InputElement.Type.FIRST, "first-Data3"));
 wr.commit();
 output.commit();
 assertEquals(3, firstDataSink.getOutputs().size());
 assertEquals("first-Data1", firstDataSink.getOutputs().get(0));
 assertEquals("second-Data1", secondDataSink.getOutputs().get(0));
 assertEquals(1, secondDataSink.getOutputs().size());
 assertEquals(1, thirdDataSink.getOutputs().size());
}

代码示例来源:origin: seznam/euphoria

@Override
public void commitTask(TaskAttemptContext tac) throws IOException {
 if (innerWriter != null) {
  innerWriter.commit();
  closeWriter(tac, innerWriter);
 }
}

代码示例来源:origin: seznam/euphoria

@Override
public void snapshotState(FunctionSnapshotContext fsc) throws Exception {
 writer.flush();
 state.clear();
 state.add(writer);
}

代码示例来源:origin: seznam/euphoria

private void closeWriter(TaskAttemptContext tac, Writer<V> writer) throws IOException {
 try {
  writer.close();
 } finally{
  writers.remove(tac.getTaskAttemptID());
 }
}

代码示例来源:origin: seznam/euphoria

@Override
public void write(E elem) throws IOException {
 impl.write(Pair.of(elem == null ? null : elem.toString(), NullWritable.get()));
}

代码示例来源:origin: seznam/euphoria

@Override
 public void close() throws IOException {
  if (writer != null) {
   writer.flush();
   writer.commit();
   writer.close();
  }
 }
}

代码示例来源:origin: seznam/euphoria

@Override
public void commit() throws IOException {
 impl.commit();
}

代码示例来源:origin: seznam/euphoria

private void rollbackWriterUnchecked(Writer writer) {
 try {
  writer.rollback();
 } catch (IOException ex) {
  LOG.error("Failed to rollback writer", ex);
 }
}

代码示例来源:origin: seznam/euphoria

@Override
public void invoke(StreamingElement<?, T> elem, Context context) throws Exception {
 writer.write(elem.getElement());
}

代码示例来源:origin: seznam/euphoria

@Override
public void commit() throws IOException {
 wrap.commit();
}

代码示例来源:origin: seznam/euphoria

private void rollbackWriterUnchecked(Writer writer) {
 try {
  writer.rollback();
 } catch (IOException ex) {
  LOG.error("Failed to rollback writer", ex);
 }
}

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