当前位置: 首页>>代码示例>>Java>>正文


Java Page类代码示例

本文整理汇总了Java中org.embulk.spi.Page的典型用法代码示例。如果您正苦于以下问题:Java Page类的具体用法?Java Page怎么用?Java Page使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Page类属于org.embulk.spi包,在下文中一共展示了Page类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: add

import org.embulk.spi.Page; //导入依赖的package包/类
@Override
public void add(Page page) {
    reader.setPage(page);

    try {
        while (reader.nextRecord()) {
            List<String> sourceTexts = Lists.newArrayList();
            for (Column keyNameColumn : keyNameColumns) {
                String text = reader.isNull(keyNameColumn) ? "" : reader.getString(keyNameColumn);
                logger.debug(text);
                sourceTexts.add(text);
            }
            List<Translation> translations = translate(sourceTexts);
            for (int i = 0; i < keyNameColumns.size(); i++) {
                builder.setString(outputSchema.lookupColumn(keyNameColumns.get(i).getName() + task.getOutKeyNameSuffix()), translations.get(i).getTranslatedText());
            }
            setValue(builder);
            builder.addRecord();
            Thread.sleep(task.getSleep().get());
        }
    } catch (Exception  e) {
        throw new RuntimeException(e);
    } 
}
 
开发者ID:toyama0919,项目名称:embulk-filter-google_translate_api,代码行数:25,代码来源:GoogleTranslateApiPageOutput.java

示例2: testOpenSuccessfully

import org.embulk.spi.Page; //导入依赖的package包/类
@Test
public void testOpenSuccessfully()
{
    ConfigSource configSource = loadConfigSource("testOpen.yml");
    final Schema inputSchema = Schema.builder()
            .add("qb", STRING)
            .add("qs", STRING)
            .add("qa", STRING)
            .build();
    testQueryString(configSource, inputSchema, "/path?q1=1&q2=2#fragment", new AssertionWithPage()
    {
        @Override
        public void run(PageReader pageReader, TestPageBuilderReader.MockPageOutput pageOutput)
        {
            for (Page page : pageOutput.pages) {
                pageReader.setPage(page);

                assertThat(pageReader.getString(0), is("before"));
                assertThat(pageReader.getString(1), is("1"));
                assertEquals(2L, pageReader.getLong(2));
                assertThat(pageReader.getString(3), is("after"));
            }
        }
    });
}
 
开发者ID:mwed,项目名称:embulk-filter-query_string,代码行数:26,代码来源:TestQueryStringFilterPlugin.java

示例3: testOpenSuccessfullyWithHashbang

import org.embulk.spi.Page; //导入依赖的package包/类
@Test
public void testOpenSuccessfullyWithHashbang()
{
    ConfigSource configSource = loadConfigSource("testOpen.yml");
    final Schema inputSchema = Schema.builder()
            .add("qb", STRING)
            .add("qs", STRING)
            .add("qa", STRING)
            .build();

    testQueryString(configSource, inputSchema, "/#!/path?q1=one&q2=2#fragment", new AssertionWithPage()
    {
        @Override
        public void run(PageReader pageReader, TestPageBuilderReader.MockPageOutput pageOutput)
        {
            for (Page page : pageOutput.pages) {
                pageReader.setPage(page);

                assertThat(pageReader.getString(0), is("before"));
                assertThat(pageReader.getString(1), is("one"));
                assertEquals(2L, pageReader.getLong(2));
                assertThat(pageReader.getString(3), is("after"));
            }
        }
    });
}
 
开发者ID:mwed,项目名称:embulk-filter-query_string,代码行数:27,代码来源:TestQueryStringFilterPlugin.java

示例4: testQueryString

import org.embulk.spi.Page; //导入依赖的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);
            ;
        }
    });
}
 
开发者ID:mwed,项目名称:embulk-filter-query_string,代码行数:26,代码来源:TestQueryStringFilterPlugin.java

示例5: filter

import org.embulk.spi.Page; //导入依赖的package包/类
private List<Object[]> filter(PluginTask task, Schema inputSchema, Object ... objects)
{
    TestPageBuilderReader.MockPageOutput output = new TestPageBuilderReader.MockPageOutput();
    Schema outputSchema = BuildJsonFilterPlugin.buildOutputSchema(task, inputSchema);
    PageBuilder pageBuilder = new PageBuilder(runtime.getBufferAllocator(), outputSchema, output);
    PageReader pageReader = new PageReader(inputSchema);
    BuildJsonVisitorImpl visitor = new BuildJsonVisitorImpl(task, inputSchema, outputSchema, pageReader, pageBuilder);

    List<Page> pages = PageTestUtils.buildPage(runtime.getBufferAllocator(), inputSchema, objects);
    for (Page page : pages) {
        pageReader.setPage(page);

        while (pageReader.nextRecord()) {
            outputSchema.visitColumns(visitor);
            pageBuilder.addRecord();
        }
    }
    pageBuilder.finish();
    pageBuilder.close();
    return Pages.toObjects(outputSchema, output.pages);
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-filter-build_json,代码行数:22,代码来源:TestBuildJsonVisitorImpl.java

示例6: add

import org.embulk.spi.Page; //导入依赖的package包/类
@Override
public void add(Page page) {
    reader.setPage(page);

    while (reader.nextRecord()) {
        String userAgentString = reader.isNull(keyNameColumn) ? null : reader.getString(keyNameColumn);
        Map<String, String> ua = Classifier.parse(userAgentString);
        setValue(builder, ua);
        if (task.getFilterCategories().isPresent()) {
            if (task.getFilterCategories().orNull().contains(ua.get("category"))) {
                builder.addRecord();
            }
        } else if (task.getDropCategories().isPresent()) {
            if (!task.getDropCategories().orNull().contains(ua.get("category"))) {
                builder.addRecord();
            }
        } else {
            builder.addRecord();
        }
    }
}
 
开发者ID:toyama0919,项目名称:embulk-filter-woothee,代码行数:22,代码来源:WootheePageOutput.java

示例7: filter

import org.embulk.spi.Page; //导入依赖的package包/类
private List<Object[]> filter(PluginTask task, Schema inputSchema, Object ... objects)
{
    MockPageOutput output = new MockPageOutput();
    Schema outputSchema = ColumnFilterPlugin.buildOutputSchema(task, inputSchema);
    PageBuilder pageBuilder = new PageBuilder(runtime.getBufferAllocator(), outputSchema, output);
    PageReader pageReader = new PageReader(inputSchema);
    ColumnVisitorImpl visitor = new ColumnVisitorImpl(task, inputSchema, outputSchema, pageReader, pageBuilder);

    List<Page> pages = PageTestUtils.buildPage(runtime.getBufferAllocator(), inputSchema, objects);
    for (Page page : pages) {
        pageReader.setPage(page);

        while (pageReader.nextRecord()) {
            outputSchema.visitColumns(visitor);
            pageBuilder.addRecord();
        }
    }
    pageBuilder.finish();
    pageBuilder.close();
    return Pages.toObjects(outputSchema, output.pages);
}
 
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:22,代码来源:TestColumnVisitorImpl.java

示例8: add

import org.embulk.spi.Page; //导入依赖的package包/类
@Override
public void add(Page page)
{
    pageReader.setPage(page);
    while (pageReader.nextRecord()) {
        try {
            setExpandedJsonColumns();
            setUnchangedColumns();
            pageBuilder.addRecord();
        }
        catch (DataException | JsonProcessingException e) {
            if (stopOnInvalidRecord) {
                throw new DataException(String.format("Found an invalid record"), e);
            }
            logger.warn(String.format("Skipped an invalid record (%s)", e.getMessage()));
        }
    }
}
 
开发者ID:civitaspo,项目名称:embulk-filter-expand_json,代码行数:19,代码来源:FilteredPageOutput.java

示例9: testOpen

import org.embulk.spi.Page; //导入依赖的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;
    }};
}
 
开发者ID:hata,项目名称:embulk-filter-speedometer,代码行数:22,代码来源:TestSpeedometerFilterPlugin.java

示例10: testFinish

import org.embulk.spi.Page; //导入依赖的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;
    }};
}
 
开发者ID:hata,项目名称:embulk-filter-speedometer,代码行数:17,代码来源:TestSpeedometerFilterPlugin.java

示例11: testClose

import org.embulk.spi.Page; //导入依赖的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;
    }};
}
 
开发者ID:hata,项目名称:embulk-filter-speedometer,代码行数:18,代码来源:TestSpeedometerFilterPlugin.java

示例12: open

import org.embulk.spi.Page; //导入依赖的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();
            }
        }
    };
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-filter-build_json,代码行数:37,代码来源:BuildJsonFilterPlugin.java

示例13: open

import org.embulk.spi.Page; //导入依赖的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();
            }
        }
    };
}
 
开发者ID:sonots,项目名称:embulk-filter-typecast,代码行数:36,代码来源:TypecastFilterPlugin.java

示例14: open

import org.embulk.spi.Page; //导入依赖的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();
        }
    };
}
 
开发者ID:kfitzgerald,项目名称:embulk-filter-base58,代码行数:33,代码来源:Base58FilterPlugin.java

示例15: open

import org.embulk.spi.Page; //导入依赖的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();
            }
        }
    };
}
 
开发者ID:sonots,项目名称:embulk-filter-timestamp_format,代码行数:36,代码来源:TimestampFormatFilterPlugin.java


注:本文中的org.embulk.spi.Page类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。