本文整理汇总了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());
}
示例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]);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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]);
}
}
}
示例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]);
}
示例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());
}
示例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());
}
示例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]);
}
}
}
示例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);
}
}
示例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);
}