本文整理汇总了Java中org.embulk.spi.PageBuilder类的典型用法代码示例。如果您正苦于以下问题:Java PageBuilder类的具体用法?Java PageBuilder怎么用?Java PageBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PageBuilder类属于org.embulk.spi包,在下文中一共展示了PageBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.embulk.spi.PageBuilder; //导入依赖的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: setValue
import org.embulk.spi.PageBuilder; //导入依赖的package包/类
/**
* @param builder
*/
private void setValue(PageBuilder builder) {
for (Column inputColumn: inputColumns) {
if (reader.isNull(inputColumn)) {
builder.setNull(inputColumn);
continue;
}
if (Types.STRING.equals(inputColumn.getType())) {
builder.setString(inputColumn, reader.getString(inputColumn));
} else if (Types.BOOLEAN.equals(inputColumn.getType())) {
builder.setBoolean(inputColumn, reader.getBoolean(inputColumn));
} else if (Types.DOUBLE.equals(inputColumn.getType())) {
builder.setDouble(inputColumn, reader.getDouble(inputColumn));
} else if (Types.LONG.equals(inputColumn.getType())) {
builder.setLong(inputColumn, reader.getLong(inputColumn));
} else if (Types.TIMESTAMP.equals(inputColumn.getType())) {
builder.setTimestamp(inputColumn, reader.getTimestamp(inputColumn));
} else if (Types.JSON.equals(inputColumn.getType())) {
builder.setJson(inputColumn, reader.getJson(inputColumn));
}
}
}
开发者ID:toyama0919,项目名称:embulk-filter-google_translate_api,代码行数:25,代码来源:GoogleTranslateApiPageOutput.java
示例3: filter
import org.embulk.spi.PageBuilder; //导入依赖的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: ColumnCaster
import org.embulk.spi.PageBuilder; //导入依赖的package包/类
ColumnCaster(PluginTask task, Schema inputSchema, Schema outputSchema, PageReader pageReader, PageBuilder pageBuilder)
{
this.task = task;
this.inputSchema = inputSchema;
this.outputSchema = outputSchema;
this.pageReader = pageReader;
this.pageBuilder = pageBuilder;
buildTimestampParserMap();
buildTimestampFormatterMap();
buildFromTimestampUnitMap();
buildToTimestampUnitMap();
JsonCaster jsonCaster = new JsonCaster(task, timestampParserMap, timestampFormatterMap, fromTimestampUnitMap, toTimestampUnitMap);
this.jsonVisitor = new JsonVisitor(task, jsonCaster);
}
示例5: testRun
import org.embulk.spi.PageBuilder; //导入依赖的package包/类
@Test
public void testRun() throws IOException
{
RecordPagingIterable<ObjectNode> mockRecordPagingIterable = Mockito.mock(RecordPagingIterable.class);
JavaType javaType = OBJECT_MAPPER.getTypeFactory().constructParametrizedType(List.class, List.class, ObjectNode.class);
List<ObjectNode> objectNodeList = OBJECT_MAPPER.readValue(this.getClass().getResourceAsStream("/fixtures/campaign_response_full.json"), javaType);
Mockito.when(mockRecordPagingIterable.iterator()).thenReturn(objectNodeList.iterator());
Mockito.when(mockMarketoRestClient.getCampaign()).thenReturn(mockRecordPagingIterable);
CampaignInputPlugin.PluginTask task = configSource.loadConfig(CampaignInputPlugin.PluginTask.class);
ServiceResponseMapper<? extends ValueLocator> mapper = campaignInputPlugin.buildServiceResponseMapper(task);
RecordImporter recordImporter = mapper.createRecordImporter();
PageBuilder mockPageBuilder = Mockito.mock(PageBuilder.class);
campaignInputPlugin.ingestServiceData(task, recordImporter, 1, mockPageBuilder);
Mockito.verify(mockMarketoRestClient, Mockito.times(1)).getCampaign();
Schema embulkSchema = mapper.getEmbulkSchema();
ArgumentCaptor<Long> longArgumentCaptor = ArgumentCaptor.forClass(Long.class);
Mockito.verify(mockPageBuilder, Mockito.times(10)).setLong(Mockito.eq(embulkSchema.lookupColumn("id")), longArgumentCaptor.capture());
List<Long> allValues = longArgumentCaptor.getAllValues();
assertArrayEquals(new Long[]{1003L, 1004L, 1005L, 1006L, 1007L, 1008L, 1029L, 1048L, 1051L, 1065L}, allValues.toArray());
}
示例6: Icu4jPageOutput
import org.embulk.spi.PageBuilder; //导入依赖的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);
}
示例7: WootheePageOutput
import org.embulk.spi.PageBuilder; //导入依赖的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());
}
示例8: filter
import org.embulk.spi.PageBuilder; //导入依赖的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);
}
示例9: testOpen
import org.embulk.spi.PageBuilder; //导入依赖的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;
}};
}
示例10: testFinish
import org.embulk.spi.PageBuilder; //导入依赖的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;
}};
}
示例11: testClose
import org.embulk.spi.PageBuilder; //导入依赖的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;
}};
}
示例12: JoinFilePageOutput
import org.embulk.spi.PageBuilder; //导入依赖的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;
}
示例13: setInputValues
import org.embulk.spi.PageBuilder; //导入依赖的package包/类
private void setInputValues(PageBuilder pageBuilder) {
for (Column inputColumn: pageReader.getSchema().getColumns()) {
if (pageReader.isNull(inputColumn)) {
pageBuilder.setNull(inputColumn);
continue;
}
if (Types.STRING.equals(inputColumn.getType())) {
pageBuilder.setString(inputColumn, pageReader.getString(inputColumn));
}
else if (Types.BOOLEAN.equals(inputColumn.getType())) {
pageBuilder.setBoolean(inputColumn, pageReader.getBoolean(inputColumn));
}
else if (Types.DOUBLE.equals(inputColumn.getType())) {
pageBuilder.setDouble(inputColumn, pageReader.getDouble(inputColumn));
}
else if (Types.LONG.equals(inputColumn.getType())) {
pageBuilder.setLong(inputColumn, pageReader.getLong(inputColumn));
}
else if (Types.TIMESTAMP.equals(inputColumn.getType())) {
pageBuilder.setTimestamp(inputColumn, pageReader.getTimestamp(inputColumn));
}
}
}
示例14: run
import org.embulk.spi.PageBuilder; //导入依赖的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();
}
示例15: RandomjColumnVisitor
import org.embulk.spi.PageBuilder; //导入依赖的package包/类
public RandomjColumnVisitor(PageBuilder pageBuilder, PluginTask task, Integer row, Map<Column, Map<String, Integer>> columnOptions)
{
this.task = task;
this.pageBuilder = pageBuilder;
this.row = row;
this.columnOptions = columnOptions;
this.rnd = new Random();
}