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


Java Pages.toObjects方法代码示例

本文整理汇总了Java中org.embulk.spi.util.Pages.toObjects方法的典型用法代码示例。如果您正苦于以下问题:Java Pages.toObjects方法的具体用法?Java Pages.toObjects怎么用?Java Pages.toObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.embulk.spi.util.Pages的用法示例。


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

示例1: skipRecords

import org.embulk.spi.util.Pages; //导入方法依赖的package包/类
@Test
public void skipRecords()
        throws Exception
{
    SchemaConfig schema = schema(
            column("_c0", BOOLEAN), column("_c1", LONG), column("_c2", DOUBLE),
            column("_c3", STRING), column("_c4", TIMESTAMP), column("_c5", JSON));
    ConfigSource config = this.config.deepCopy().set("columns", schema);

    transaction(config, fileInput(
            "[",
            "[]",
            "\"embulk\"",
            "10",
            "true",
            "false",
            "null",
            " ",
            "]"
    ));

    List<Object[]> records = Pages.toObjects(schema.toSchema(), output.pages);
    assertEquals(0, records.size());
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-parser-jsonpath,代码行数:25,代码来源:TestJsonpathParserPlugin.java

示例2: booleanStrings

import org.embulk.spi.util.Pages; //导入方法依赖的package包/类
@Test
public void booleanStrings()
        throws Exception
{
    SchemaConfig schema = schema(column("_c1", BOOLEAN), column("_c2", BOOLEAN),
            column("_c3", BOOLEAN), column("_c4", BOOLEAN), column("_c5", BOOLEAN),
            column("_c6", BOOLEAN), column("_c7", BOOLEAN), column("_c8", BOOLEAN),
            column("_c9", BOOLEAN), column("_c10", BOOLEAN), column("_c11", BOOLEAN),
            column("_c12", BOOLEAN));
    ConfigSource config = this.config.deepCopy().set("columns", schema);

    transaction(config, fileInput("[{\"_c1\" : \"yes\", \"_c2\" : \"true\", \"_c3\" : \"1\",",
            "\"_c4\" : \"on\", \"_c5\" : \"y\", \"_c6\" : \"t\",",
            "\"_c7\" : \"no\", \"_c8\" : \"false\", \"_c9\" : \"0\"," ,
            "\"_c10\" : \"off\", \"_c11\" : \"n\", \"_c12\" : \"f\"}]"));
    List<Object[]> records = Pages.toObjects(schema.toSchema(), output.pages);
    assertEquals(1, records.size());

    Object[] record = records.get(0);
    for (int i = 0; i < 5; i++) {
        assertTrue((boolean) record[i]);
    }
    for (int i = 6; i < 11; i++) {
        assertFalse((boolean) record[i]);
    }
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-parser-jsonpath,代码行数:27,代码来源:TestJsonpathParserPlugin.java

示例3: filter

import org.embulk.spi.util.Pages; //导入方法依赖的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

示例4: filter

import org.embulk.spi.util.Pages; //导入方法依赖的package包/类
private List<Object[]> filter(PluginTask task, Schema inputSchema, Object ... objects)
{
    MockPageOutput output = new MockPageOutput();
    Schema outputSchema = plugin.buildOutputSchema(task, inputSchema);
    PageBuilder pageBuilder = new PageBuilder(runtime.getBufferAllocator(), outputSchema, output);
    PageReader pageReader = new PageReader(inputSchema);
    final Map<String, List<Base58FilterPlugin.Base58Column>> base58ColumnMap = Base58FilterPlugin.convertBase58ColumnListToMap(task.getColumns());
    final Map<String, Column> outputColumnMap = Base58FilterPlugin.convertColumnListToMap(outputSchema.getColumns(), null);

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

        while (pageReader.nextRecord()) {
            plugin.setValue(base58ColumnMap, outputColumnMap, pageReader, outputSchema, pageBuilder);
            pageBuilder.addRecord();
        }
    }
    pageBuilder.finish();
    pageBuilder.close();
    return Pages.toObjects(outputSchema, output.pages);
}
 
开发者ID:kfitzgerald,项目名称:embulk-filter-base58,代码行数:23,代码来源:TestBase58FilterImpl.java

示例5: filter

import org.embulk.spi.util.Pages; //导入方法依赖的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

示例6: skipRecords

import org.embulk.spi.util.Pages; //导入方法依赖的package包/类
@Test
public void skipRecords()
        throws Exception
{
    SchemaConfig schema = schema(
            column("_c0", BOOLEAN), column("_c1", LONG), column("_c2", DOUBLE),
            column("_c3", STRING), column("_c4", TIMESTAMP), column("_c5", JSON));
    ConfigSource config = this.config.deepCopy().set("columns", schema);

    transaction(config, fileInput(
            "[]",
            "\"embulk\"",
            "10",
            "true",
            "false",
            "null",
            " "
    ));

    List<Object[]> records = Pages.toObjects(schema.toSchema(), output.pages);
    assertEquals(0, records.size());
}
 
开发者ID:shun0102,项目名称:embulk-parser-jsonl,代码行数:23,代码来源:TestJsonlParserPlugin.java

示例7: writeNils

import org.embulk.spi.util.Pages; //导入方法依赖的package包/类
@Test
public void writeNils()
        throws Exception
{
    SchemaConfig schema = schema(
            column("_c0", BOOLEAN), column("_c1", LONG), column("_c2", DOUBLE),
            column("_c3", STRING), column("_c4", TIMESTAMP), column("_c5", JSON));
    ConfigSource config = this.config.deepCopy().set("columns", schema);

    transaction(config, fileInput(
            "{}",
            "{\"_c0\":null,\"_c1\":null,\"_c2\":null}",
            "{\"_c3\":null,\"_c4\":null,\"_c5\":null}",
            "{}"
    ));

    List<Object[]> records = Pages.toObjects(schema.toSchema(), output.pages);
    assertEquals(4, records.size());

    for (Object[] record : records) {
        for (int i = 0; i < 6; i++) {
            assertNull(record[i]);
        }
    }
}
 
开发者ID:shun0102,项目名称:embulk-parser-jsonl,代码行数:26,代码来源:TestJsonlParserPlugin.java

示例8: useNoColumnsOption

import org.embulk.spi.util.Pages; //导入方法依赖的package包/类
@Test
public void useNoColumnsOption()
        throws Exception
{
    SchemaConfig schema = schema(
            column("id", LONG),
            column("code", LONG),
            column("name", STRING),
            column("description", STRING),
            column("flag", BOOLEAN),
            column("created_at", STRING),
            column("created_at_utc", DOUBLE),
            column("price", DOUBLE),
            column("spec", JSON),
            column("tags", JSON),
            column("options", JSON),
            column("item_type", STRING),
            column("dummy", STRING)
    );

    ConfigSource config = this.config.deepCopy().set("avsc", this.getClass().getResource("item.avsc").getPath());

    transaction(config, fileInput(new File(this.getClass().getResource("items.avro").getPath())));

    List<Object[]> records = Pages.toObjects(schema.toSchema(), output.pages);
    assertEquals(6, records.size());

    Object[] record = records.get(0);
    assertEquals(1L, record[0]);
    assertEquals(123456789012345678L, record[1]);
    assertEquals("Desktop", record[2]);
    assertEquals(true, record[4]);
    assertEquals("D", record[11]);
    assertEquals("[\"tag1\",\"tag2\"]", record[9].toString());
    assertEquals("bar", ((MapValue)record[10]).map().get(ValueFactory.newString("foo")).toString());
    assertEquals("opt1", ((MapValue)record[8]).map().get(ValueFactory.newString("key")).toString());
    assertEquals("2016-05-09T04:35:43+09:00", record[5].toString());
    assertNull(record[12]);
}
 
开发者ID:joker1007,项目名称:embulk-parser-avro,代码行数:40,代码来源:TestAvroParserPlugin.java

示例9: skipBrokenJson

import org.embulk.spi.util.Pages; //导入方法依赖的package包/类
@Test
public void skipBrokenJson()
        throws Exception
{
    SchemaConfig schema = schema(
            column("_c0", BOOLEAN), column("_c1", LONG), column("_c2", DOUBLE),
            column("_c3", STRING), column("_c4", TIMESTAMP), column("_c5", JSON));
    ConfigSource config = this.config.deepCopy().set("columns", schema);

    transaction(config, fileInput("BROKEN"));
    List<Object[]> records = Pages.toObjects(schema.toSchema(), output.pages);
    assertEquals(0, records.size());
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-parser-jsonpath,代码行数:14,代码来源:TestJsonpathParserPlugin.java

示例10: skipBrokenColumn

import org.embulk.spi.util.Pages; //导入方法依赖的package包/类
@Test
public void skipBrokenColumn()
        throws Exception
{
    SchemaConfig schema = schema(column("_c1", TIMESTAMP));
    ConfigSource config = this.config.deepCopy().set("columns", schema).
            set("stop_on_invalid_record", false);

    transaction(config, fileInput("{\"_c1\" : \"INVALID\"}"));
    List<Object[]> records = Pages.toObjects(schema.toSchema(), output.pages);
    assertEquals(0, records.size());
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-parser-jsonpath,代码行数:13,代码来源:TestJsonpathParserPlugin.java

示例11: writeNils

import org.embulk.spi.util.Pages; //导入方法依赖的package包/类
@Test
public void writeNils()
        throws Exception
{
    SchemaConfig schema = schema(
            column("_c0", BOOLEAN), column("_c1", LONG), column("_c2", DOUBLE),
            column("_c3", STRING), column("_c4", TIMESTAMP), column("_c5", JSON));
    ConfigSource config = this.config.deepCopy().set("columns", schema);

    transaction(config, fileInput(
            "[",
            "{},",
            "{\"_c0\":null,\"_c1\":null,\"_c2\":null},",
            "{\"_c3\":null,\"_c4\":null,\"_c5\":null},",
            "{}",
            "]"
    ));

    List<Object[]> records = Pages.toObjects(schema.toSchema(), output.pages);
    assertEquals(4, records.size());

    for (Object[] record : records) {
        for (int i = 0; i < 6; i++) {
            assertNull(record[i]);
        }
    }
}
 
开发者ID:hiroyuki-sato,项目名称:embulk-parser-jsonpath,代码行数:28,代码来源:TestJsonpathParserPlugin.java

示例12: useColumnOptions

import org.embulk.spi.util.Pages; //导入方法依赖的package包/类
@Test
public void useColumnOptions()
        throws Exception
{

    SchemaConfig schema = schema(
            column("_c0", BOOLEAN), column("_c1", LONG), column("_c2", DOUBLE));
    File yamlFile = getResourceFile("use_column_options.yml");
    ConfigSource config = getConfigFromYamlFile(yamlFile);

    transaction(config, fileInput(
            "{\"_c0\":\"true\",\"_c1\":\"10\",\"_c2\":\"0.1\"}",
            "{\"_c0\":\"false\",\"_c1\":\"-10\",\"_c2\":\"1.0\"}"
    ));

    List<Object[]> records = Pages.toObjects(schema.toSchema(), output.pages);
    assertEquals(2, records.size());

    Object[] record;
    {
        record = records.get(0);
        assertEquals(true, record[0]);
        assertEquals(10L, record[1]);
        assertEquals(0.1, (Double) record[2], 0.0001);
    }
    {
        record = records.get(1);
        assertEquals(false, record[0]);
        assertEquals(-10L, record[1]);
        assertEquals(1.0, (Double) record[2], 0.0001);
    }
}
 
开发者ID:shun0102,项目名称:embulk-parser-jsonl,代码行数:33,代码来源:TestJsonlParserPlugin.java

示例13: getRecords

import org.embulk.spi.util.Pages; //导入方法依赖的package包/类
private List<Object[]> getRecords(ConfigSource config, MockPageOutput output)
{
    Schema schema = config.getNested("parser").loadConfig(CsvParserPlugin.PluginTask.class).getSchemaConfig().toSchema();
    return Pages.toObjects(schema, output.pages);
}
 
开发者ID:civitaspo,项目名称:embulk-input-hdfs,代码行数:6,代码来源:TestHdfsFileInputPlugin.java


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