Skip to content

Commit

Permalink
Merge pull request #1 from trocco-io/feature/embulk-v0.9
Browse files Browse the repository at this point in the history
embulk v0.9 supported
  • Loading branch information
NamedPython authored Dec 3, 2024
2 parents c54dfd9 + 7f76910 commit a09d794
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/main/java/org/embulk/input/mongodb/MongodbInputPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public TaskReport run(TaskSource taskSource,
final TaskMapper taskMapper = CONFIG_MAPPER_FACTORY.createTaskMapper();
final PluginTask task = taskMapper.map(taskSource, PluginTask.class);
BufferAllocator allocator = Exec.getBufferAllocator();
PageBuilder pageBuilder = Exec.getPageBuilder(allocator, schema, output);
PageBuilder pageBuilder = getPageBuilder(allocator, schema, output);
final Column column = pageBuilder.getSchema().getColumns().get(0);

ValueCodec valueCodec = new ValueCodec(task.getStopOnInvalidRecord(), task);
Expand Down Expand Up @@ -480,4 +480,23 @@ private void validateJsonField(String name, String jsonString)
throw new ConfigException(String.format("Invalid JSON string was given for '%s' parameter. [%s]", name, jsonString));
}
}

@SuppressWarnings("deprecation")
private static PageBuilder getPageBuilder(final BufferAllocator bufferAllocator, final Schema schema, final PageOutput output)
{
return HAS_EXEC_GET_PAGE_BUILDER ? Exec.getPageBuilder(bufferAllocator, schema, output) : new PageBuilder(bufferAllocator, schema, output);
}

private static boolean hasExecGetPageBuilder()
{
try {
Exec.class.getMethod("getPageBuilder", BufferAllocator.class, Schema.class, PageOutput.class);
}
catch (final NoSuchMethodException ex) {
return false;
}
return true;
}

private static final boolean HAS_EXEC_GET_PAGE_BUILDER = hasExecGetPageBuilder();
}

0 comments on commit a09d794

Please sign in to comment.