本文整理汇总了Java中org.embulk.spi.PageOutput类的典型用法代码示例。如果您正苦于以下问题:Java PageOutput类的具体用法?Java PageOutput怎么用?Java PageOutput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PageOutput类属于org.embulk.spi包,在下文中一共展示了PageOutput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.embulk.spi.PageOutput; //导入依赖的package包/类
@Override
public TaskReport run(TaskSource taskSource,
Schema schema, int taskIndex,
PageOutput output)
{
PluginTask task = taskSource.loadTask(PluginTask.class);
Integer rows = task.getRows();
final HashMap<Column, Map<String, Integer>> columnOptions = getColumnOptions(task);
try (PageBuilder pagebuilder =
new PageBuilder(Exec.getBufferAllocator(), schema, output)) {
IntStream.rangeClosed(
taskIndex * rows + 1,
taskIndex * rows + rows
).boxed().forEach(rowNumber -> {
RandomjColumnVisitor visitor = new RandomjColumnVisitor(pagebuilder, task, rowNumber, columnOptions);
schema.visitColumns(visitor);
pagebuilder.addRecord();
});
pagebuilder.finish();
}
TaskReport taskReport = Exec.newTaskReport();
taskReport.set("columns", schema.size());
taskReport.set("rows", rows);
return taskReport;
}
示例2: testQueryString
import org.embulk.spi.PageOutput; //导入依赖的package包/类
private void testQueryString(ConfigSource configSource, final Schema inputSchema, final String path, final AssertionWithPage assertion)
{
final QueryStringFilterPlugin plugin = new QueryStringFilterPlugin();
plugin.transaction(configSource, inputSchema, new FilterPlugin.Control()
{
@Override
public void run(TaskSource taskSource, Schema outputSchema)
{
TestPageBuilderReader.MockPageOutput mockPageOutput = new TestPageBuilderReader.MockPageOutput();
PageOutput pageOutput = plugin.open(taskSource, inputSchema, outputSchema, mockPageOutput);
List<Page> pages = PageTestUtils.buildPage(runtime.getBufferAllocator(), inputSchema, "before", path, "after");
for (Page page : pages) {
pageOutput.add(page);
}
pageOutput.finish();
pageOutput.close();
PageReader pageReader = new PageReader(outputSchema);
assertion.run(pageReader, mockPageOutput);
;
}
});
}
示例3: Icu4jPageOutput
import org.embulk.spi.PageOutput; //导入依赖的package包/类
public Icu4jPageOutput(TaskSource taskSource, Schema inputSchema, Schema outputSchema, PageOutput output) {
this.task = taskSource.loadTask(PluginTask.class);
this.keyNameColumns = Lists.newArrayList();
this.transliteratorsList = Lists.newArrayList();
this.inputSchema = inputSchema;
this.outputSchema = outputSchema;
for (String keyName : task.getKeyNames()) {
keyNameColumns.add(inputSchema.lookupColumn(keyName));
}
for (Map<String, String> setting : task.getSettings()) {
List<Transliterator> tokenizers = Lists.newArrayList();
for (String convertType : setting.get("transliterators").split(",")) {
Transliterator transliterator = Transliterator.getInstance(convertType);
tokenizers.add(transliterator);
}
transliteratorsList.add(tokenizers);
}
reader = new PageReader(inputSchema);
builder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, output);
}
示例4: WootheePageOutput
import org.embulk.spi.PageOutput; //导入依赖的package包/类
public WootheePageOutput(TaskSource taskSource, Schema inputSchema, Schema outputSchema, PageOutput output) {
this.task = taskSource.loadTask(PluginTask.class);
this.outputColumns = outputSchema.getColumns();
this.inputColumns = inputSchema.getColumns();
Map<String, Column> inputColumnMap = Maps.newHashMap();
this.wootheeColumnMap = Maps.newHashMap();
for (Column column : outputColumns) {
if (!inputColumns.contains(column)) {
wootheeColumnMap.put(column.getName(), column);
} else {
inputColumnMap.put(column.getName(), column);
}
}
this.reader = new PageReader(inputSchema);
this.builder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, output);
this.keyNameColumn = inputColumnMap.get(task.getKeyName());
}
示例5: testOpen
import org.embulk.spi.PageOutput; //导入依赖的package包/类
@Test
public void testOpen(final @Mocked PageReader reader, final @Mocked PageBuilder builder, final @Mocked Page page) throws Exception {
new NonStrictExpectations() {{
taskSource.loadTask(PluginTask.class); result = task;
task.getDelimiter(); result = "";
reader.nextRecord(); result = true; result = false;
}};
SpeedometerFilterPlugin plugin = new SpeedometerFilterPlugin();
PageOutput output = plugin.open(taskSource, schema, schema, inPageOutput);
output.add(page);
new Verifications() {{
taskSource.loadTask(PluginTask.class); times = 1;
builder.addRecord(); times = 1;
builder.finish(); times = 0;
reader.nextRecord(); times = 2;
reader.setPage(page); times = 1;
schema.visitColumns(withInstanceOf(ColumnVisitor.class)); times = 1;
}};
}
示例6: testFinish
import org.embulk.spi.PageOutput; //导入依赖的package包/类
@Test
public void testFinish(final @Mocked PageReader reader, final @Mocked PageBuilder builder, final @Mocked Page page) throws Exception {
new NonStrictExpectations() {{
taskSource.loadTask(PluginTask.class); result = task;
task.getDelimiter(); result = "";
}};
SpeedometerFilterPlugin plugin = new SpeedometerFilterPlugin();
PageOutput output = plugin.open(taskSource, schema, schema, inPageOutput);
output.finish();
new Verifications() {{
taskSource.loadTask(PluginTask.class); times = 1;
builder.finish(); times = 1;
}};
}
示例7: testClose
import org.embulk.spi.PageOutput; //导入依赖的package包/类
@Test
public void testClose(final @Mocked PageReader reader, final @Mocked PageBuilder builder, final @Mocked Page page) throws Exception {
new NonStrictExpectations() {{
taskSource.loadTask(PluginTask.class); result = task;
task.getDelimiter(); result = "";
}};
SpeedometerFilterPlugin plugin = new SpeedometerFilterPlugin();
PageOutput output = plugin.open(taskSource, schema, schema, inPageOutput);
output.close();
new Verifications() {{
taskSource.loadTask(PluginTask.class); times = 1;
builder.close(); times = 1;
reader.close(); times = 1;
}};
}
示例8: JoinFilePageOutput
import org.embulk.spi.PageOutput; //导入依赖的package包/类
JoinFilePageOutput(
Schema inputSchema,
Schema outputSchema,
Column joinBaseColumn,
HashMap<String, HashMap<String, String>> table,
List<Column> joinColumns,
HashMap<String, TimestampParser> timestampParserMap,
PageOutput pageOutput
)
{
this.pageReader = new PageReader(inputSchema);
this.pageBuilder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, pageOutput);
this.joinBaseColumn = joinBaseColumn;
this.table = table;
this.joinColumns = joinColumns;
this.timestampParserMap = timestampParserMap;
}
示例9: run
import org.embulk.spi.PageOutput; //导入依赖的package包/类
@Override
public void run(TaskSource taskSource, Schema schema,
FileInput input, PageOutput output)
{
PluginTask task = taskSource.loadTask(PluginTask.class);
LineDecoder lineDecoder = new LineDecoder(input,task);
PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), schema, output);
String line = null;
final String columnName = task.getColumnName();
while( input.nextFile() ){
while(true){
line = lineDecoder.poll();
if( line == null ){
break;
}
pageBuilder.setString(0, line);
pageBuilder.addRecord();
}
}
pageBuilder.finish();
}
示例10: open
import org.embulk.spi.PageOutput; //导入依赖的package包/类
@Override
public PageOutput open(TaskSource taskSource, Schema inputSchema,
Schema outputSchema, PageOutput output)
{
System.out.println("open!");
System.out.print("taskSource: ");
System.out.println(taskSource);
System.out.print("inputSchema: ");
System.out.println(inputSchema);
System.out.print("outputSchema: ");
System.out.println(outputSchema);
System.out.print("output: ");
System.out.println(output);
PluginTask task = taskSource.loadTask(PluginTask.class);
System.out.print("task: ");
System.out.println(task);
return new MyPageOutput(inputSchema, outputSchema, output);
}
示例11: GoogleTranslateApiPageOutput
import org.embulk.spi.PageOutput; //导入依赖的package包/类
public GoogleTranslateApiPageOutput(TaskSource taskSource, Schema inputSchema, Schema outputSchema, PageOutput output) {
this.task = taskSource.loadTask(PluginTask.class);
this.outputSchema = outputSchema;
this.inputColumns = inputSchema.getColumns();
this.reader = new PageReader(inputSchema);
this.builder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, output);
this.keyNameColumns = Lists.newArrayList();
for (String keyName : task.getKeyNames()) {
this.keyNameColumns.add(outputSchema.lookupColumn(keyName));
}
this.translate = createTranslateService();
this.srcLang = task.getSourceLang().isPresent() ? TranslateOption.sourceLanguage(task.getSourceLang().get()) : null;
this.model = task.getModel().isPresent() ? TranslateOption.model(task.getModel().get()) : null;
}
开发者ID:toyama0919,项目名称:embulk-filter-google_translate_api,代码行数:16,代码来源:GoogleTranslateApiPageOutput.java
示例12: open
import org.embulk.spi.PageOutput; //导入依赖的package包/类
@Override
public PageOutput open(TaskSource taskSource, final Schema inputSchema,
final Schema outputSchema, final PageOutput output)
{
final PluginTask task = taskSource.loadTask(PluginTask.class);
return new PageOutput()
{
private PageReader pageReader = new PageReader(inputSchema);
private PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, output);
private BuildJsonVisitorImpl visitor = new BuildJsonVisitorImpl(task, inputSchema, outputSchema, pageReader, pageBuilder);
@Override
public void finish()
{
pageBuilder.finish();
}
@Override
public void close()
{
pageBuilder.close();
}
@Override
public void add(Page page)
{
pageReader.setPage(page);
while (pageReader.nextRecord()) {
outputSchema.visitColumns(visitor);
pageBuilder.addRecord();
}
}
};
}
示例13: open
import org.embulk.spi.PageOutput; //导入依赖的package包/类
@Override
public PageOutput open(final TaskSource taskSource, final Schema inputSchema,
final Schema outputSchema, final PageOutput output)
{
final PluginTask task = taskSource.loadTask(PluginTask.class);
return new PageOutput() {
private PageReader pageReader = new PageReader(inputSchema);
private PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, output);
private ColumnVisitorImpl visitor = new ColumnVisitorImpl(task, inputSchema, outputSchema, pageReader, pageBuilder);
@Override
public void finish()
{
pageBuilder.finish();
}
@Override
public void close()
{
pageBuilder.close();
}
@Override
public void add(Page page)
{
pageReader.setPage(page);
while (pageReader.nextRecord()) {
inputSchema.visitColumns(visitor);
pageBuilder.addRecord();
}
}
};
}
示例14: open
import org.embulk.spi.PageOutput; //导入依赖的package包/类
@Override
public PageOutput open(final TaskSource taskSource, final Schema inputSchema,
final Schema outputSchema, final PageOutput output) {
final PluginTask task = taskSource.loadTask(PluginTask.class);
final Map<String, List<Base58Column>> base58ColumnMap = convertBase58ColumnListToMap(task.getColumns());
final Map<String, Column> outputColumnMap = convertColumnListToMap(outputSchema.getColumns(), logger);
return new PageOutput() {
private PageReader reader = new PageReader(inputSchema);
private PageBuilder builder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, output);
@Override
public void add(Page page) {
reader.setPage(page);
while (reader.nextRecord()) {
setValue(base58ColumnMap, outputColumnMap, reader, outputSchema, builder);
builder.addRecord();
}
}
@Override
public void finish() {
builder.finish();
}
@Override
public void close() {
builder.close();
}
};
}
示例15: open
import org.embulk.spi.PageOutput; //导入依赖的package包/类
@Override
public PageOutput open(final TaskSource taskSource, final Schema inputSchema,
final Schema outputSchema, final PageOutput output)
{
final PluginTask task = taskSource.loadTask(PluginTask.class);
return new PageOutput() {
private PageReader pageReader = new PageReader(inputSchema);
private PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, output);
private ColumnVisitorImpl visitor = new ColumnVisitorImpl(task, inputSchema, outputSchema, pageReader, pageBuilder);
@Override
public void finish()
{
pageBuilder.finish();
}
@Override
public void close()
{
pageBuilder.close();
}
@Override
public void add(Page page)
{
pageReader.setPage(page);
while (pageReader.nextRecord()) {
inputSchema.visitColumns(visitor);
pageBuilder.addRecord();
}
}
};
}