本文整理汇总了Java中org.embulk.spi.Schema.visitColumns方法的典型用法代码示例。如果您正苦于以下问题:Java Schema.visitColumns方法的具体用法?Java Schema.visitColumns怎么用?Java Schema.visitColumns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.embulk.spi.Schema
的用法示例。
在下文中一共展示了Schema.visitColumns方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filter
import org.embulk.spi.Schema; //导入方法依赖的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);
}
示例2: filter
import org.embulk.spi.Schema; //导入方法依赖的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);
}
示例3: open
import org.embulk.spi.Schema; //导入方法依赖的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();
}
}
};
}
示例4: open
import org.embulk.spi.Schema; //导入方法依赖的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();
}
}
};
}
示例5: open
import org.embulk.spi.Schema; //导入方法依赖的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();
}
}
};
}
示例6: open
import org.embulk.spi.Schema; //导入方法依赖的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()) {
outputSchema.visitColumns(visitor);
pageBuilder.addRecord();
}
}
};
}
示例7: open
import org.embulk.spi.Schema; //导入方法依赖的package包/类
@Override
public PageOutput open(TaskSource taskSource, final Schema schema, FileOutput output) {
final PluginTask task = taskSource.loadTask(PluginTask.class);
final Sheet sheet = newWorkbook(task);
final FileOutputOutputStream stream = new FileOutputOutputStream(output, task.getBufferAllocator(),
CloseMode.CLOSE);
stream.nextFile();
return new PageOutput() {
private final PageReader pageReader = new PageReader(schema);
@Override
public void add(Page page) {
pageReader.setPage(page);
PoiExcelColumnVisitor visitor = new PoiExcelColumnVisitor(task, schema, sheet, pageReader);
while (pageReader.nextRecord()) {
schema.visitColumns(visitor);
visitor.endRecord();
}
}
@Override
public void finish() {
Workbook book = sheet.getWorkbook();
try (FileOutputOutputStream os = stream) {
book.write(os);
os.finish();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
public void close() {
stream.close();
}
};
}
示例8: convertSchema
import org.embulk.spi.Schema; //导入方法依赖的package包/类
private MessageType convertSchema(Schema schema)
{
SchemaConvertColumnVisitor visitor = new SchemaConvertColumnVisitor();
schema.visitColumns(visitor);
String messageName = "embulk";
return new MessageType(messageName, visitor.getConvertedFields());
}
示例9: open
import org.embulk.spi.Schema; //导入方法依赖的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 boolean orCondition = task.getCondition().toLowerCase().equals("or");
final PageReader pageReader = new PageReader(inputSchema);
final PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), outputSchema, output);
final AbstractGuardColumnVisitor guradVisitor;
if (task.getWhere().isPresent()) {
ParserExp parserExp = new Parser(inputSchema).parse(task.getWhere().get());
guradVisitor = new GuardColumnVisitorWhereImpl(task, inputSchema, outputSchema, pageReader, parserExp);
}
else if (orCondition) {
guradVisitor = new GuardColumnVisitorOrImpl(task, inputSchema, outputSchema, pageReader);
}
else {
guradVisitor = new GuardColumnVisitorAndImpl(task, inputSchema, outputSchema, pageReader);
}
final BuilderColumnVisitorImpl builderVisitor;
builderVisitor = new BuilderColumnVisitorImpl(task, inputSchema, outputSchema, pageReader, pageBuilder);
return new PageOutput() {
@Override
public void finish()
{
pageBuilder.finish();
}
@Override
public void close()
{
pageBuilder.close();
}
@Override
public void add(Page page)
{
pageReader.setPage(page);
while (pageReader.nextRecord()) {
if (guradVisitor.visitColumns(inputSchema)) {
// output.add(page); did not work, double release() error occurred. We need to copy from reader to builder...
outputSchema.visitColumns(builderVisitor);
pageBuilder.addRecord();
}
}
}
};
}
示例10: run
import org.embulk.spi.Schema; //导入方法依赖的package包/类
protected void run(PluginTask task, Schema schema, Workbook workbook, List<String> sheetNames, PageOutput output) {
final int flushCount = task.getFlushCount();
try (PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), schema, output)) {
for (String sheetName : sheetNames) {
Sheet sheet = workbook.getSheet(sheetName);
if (sheet == null) {
if (task.getIgnoreSheetNotFound()) {
log.info("ignore: not found sheet={}", sheetName);
continue;
} else {
throw new RuntimeException(MessageFormat.format("not found sheet={0}", sheetName));
}
}
log.info("sheet={}", sheetName);
PoiExcelVisitorFactory factory = newPoiExcelVisitorFactory(task, schema, sheet, pageBuilder);
PoiExcelColumnVisitor visitor = factory.getPoiExcelColumnVisitor();
final int skipHeaderLines = factory.getVisitorValue().getSheetBean().getSkipHeaderLines();
int count = 0;
for (Row row : sheet) {
int rowIndex = row.getRowNum();
if (rowIndex < skipHeaderLines) {
log.debug("row({}) skipped", rowIndex);
continue;
}
if (log.isDebugEnabled()) {
log.debug("row({}) start", rowIndex);
}
visitor.setRow(row);
schema.visitColumns(visitor);
pageBuilder.addRecord();
if (++count >= flushCount) {
log.trace("flush");
pageBuilder.flush();
count = 0;
}
if (log.isDebugEnabled()) {
log.debug("row({}) end", rowIndex);
}
}
pageBuilder.flush();
}
pageBuilder.finish();
}
}