本文整理汇总了Java中org.embulk.spi.type.TimestampType类的典型用法代码示例。如果您正苦于以下问题:Java TimestampType类的具体用法?Java TimestampType怎么用?Java TimestampType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimestampType类属于org.embulk.spi.type包,在下文中一共展示了TimestampType类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: configure
import org.embulk.spi.type.TimestampType; //导入依赖的package包/类
private void configure(PluginTask task, Schema inputSchema)
{
List<ColumnConfig> columns = task.getColumns();
if (columns.size() < 2) {
throw new ConfigException("\"columns\" should be specified 2~ columns.");
}
// throw if column type is not supported
for (ColumnConfig columnConfig : columns) {
String name = columnConfig.getName();
Type type = inputSchema.lookupColumn(name).getType();
if (type instanceof JsonType) {
throw new ConfigException(String.format("casting to json is not available: \"%s\"", name));
}
if (type instanceof TimestampType) {
throw new ConfigException(String.format("casting to timestamp is not available: \"%s\"", name));
}
}
}
开发者ID:toru-takahashi,项目名称:embulk-filter-concat,代码行数:22,代码来源:ConcatFilterPlugin.java
示例2: setFromBoolean
import org.embulk.spi.type.TimestampType; //导入依赖的package包/类
public void setFromBoolean(Column outputColumn, boolean value)
{
Type outputType = outputColumn.getType();
if (outputType instanceof BooleanType) {
pageBuilder.setBoolean(outputColumn, BooleanCast.asBoolean(value));
}
else if (outputType instanceof LongType) {
pageBuilder.setLong(outputColumn, BooleanCast.asLong(value));
}
else if (outputType instanceof DoubleType) {
pageBuilder.setDouble(outputColumn, BooleanCast.asDouble(value));
}
else if (outputType instanceof StringType) {
pageBuilder.setString(outputColumn, BooleanCast.asString(value));
}
else if (outputType instanceof TimestampType) {
pageBuilder.setTimestamp(outputColumn, BooleanCast.asTimestamp(value));
}
else if (outputType instanceof JsonType) {
pageBuilder.setJson(outputColumn, BooleanCast.asJson(value));
}
else {
assert (false);
}
}
开发者ID:sonots,项目名称:embulk-filter-typecast,代码行数:26,代码来源:ColumnCaster.java
示例3: buildTimestampParserMap
import org.embulk.spi.type.TimestampType; //导入依赖的package包/类
private void buildTimestampParserMap()
{
// columnName => TimestampParser
for (ColumnConfig columnConfig : task.getColumns()) {
if (PathCompiler.isProbablyJsonPath(columnConfig.getName())) {
continue; // type: json columns do not support type: timestamp
}
Column inputColumn = inputSchema.lookupColumn(columnConfig.getName());
if (inputColumn.getType() instanceof StringType && columnConfig.getType() instanceof TimestampType) {
TimestampParser parser = createTimestampParser(task, columnConfig);
this.timestampParserMap.put(columnConfig.getName(), parser);
}
}
}
开发者ID:sonots,项目名称:embulk-filter-typecast,代码行数:15,代码来源:ColumnCaster.java
示例4: buildTimestampFormatterMap
import org.embulk.spi.type.TimestampType; //导入依赖的package包/类
private void buildTimestampFormatterMap()
{
// columnName => TimestampFormatter
for (ColumnConfig columnConfig : task.getColumns()) {
if (PathCompiler.isProbablyJsonPath(columnConfig.getName())) {
continue; // type: json columns do not have type: timestamp
}
Column inputColumn = inputSchema.lookupColumn(columnConfig.getName());
if (inputColumn.getType() instanceof TimestampType && columnConfig.getType() instanceof StringType) {
TimestampFormatter parser = createTimestampFormatter(task, columnConfig);
this.timestampFormatterMap.put(columnConfig.getName(), parser);
}
}
}
开发者ID:sonots,项目名称:embulk-filter-typecast,代码行数:15,代码来源:ColumnCaster.java
示例5: getDefault
import org.embulk.spi.type.TimestampType; //导入依赖的package包/类
static Value getDefault(PluginTask task, String name, Type type, ColumnConfig columnConfig)
{
Object defaultValue = ColumnVisitorImpl.getDefault(task, name, type, columnConfig);
if (defaultValue == null) {
return ValueFactory.newNil();
}
if (type instanceof BooleanType) {
return ValueFactory.newBoolean((Boolean) defaultValue);
}
else if (type instanceof LongType) {
return ValueFactory.newInteger((Long) defaultValue);
}
else if (type instanceof DoubleType) {
return ValueFactory.newFloat((Double) defaultValue);
}
else if (type instanceof StringType) {
return ValueFactory.newString((String) defaultValue.toString());
}
else if (type instanceof JsonType) {
return (Value) defaultValue;
}
else if (type instanceof TimestampType) {
throw new ConfigException("type: timestamp is not available in json path");
}
else {
throw new ConfigException(String.format("type: '%s' is not supported", type));
}
}
开发者ID:sonots,项目名称:embulk-filter-column,代码行数:29,代码来源:JsonVisitor.java
示例6: create
import org.embulk.spi.type.TimestampType; //导入依赖的package包/类
public static List<DateParser> create(GrokParserPlugin.PluginTask task) {
switch (task.getTimestampParser().toLowerCase()) {
case "ruby":
TimestampParser[] ps = Timestamps.newTimestampColumnParsers(task, task.getColumns());
return Arrays.stream(ps)
.map(parser -> (DateParser) (text) -> parser.parse(text))
.collect(Collectors.toList());
case "epoch":
return task.getColumns().getColumns().stream()
.map(x -> (DateParser) (text) -> Timestamp.ofEpochMilli(Long.parseLong(text)))
.collect(Collectors.toList());
case "sdf":
case "simpledateformat":
default:
SimpleDateFormat[] parsers = new SimpleDateFormat[task.getColumns().getColumnCount()];
int i = 0;
for (ColumnConfig column : task.getColumns().getColumns()) {
if (column.getType() instanceof TimestampType) {
TimestampColumnOption option = column.getOption().loadConfig(TimestampColumnOption.class);
String format = convertToJavaDateFormat(option.getFormat().or("yyyy-MM-dd HH:MM:ss.SSS z"));
SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.ENGLISH);
sdf.setTimeZone(option.getTimeZone().or(DateTimeZone.UTC).toTimeZone());
parsers[i] = sdf;
}
i++;
}
return Arrays.stream(parsers).map(parser ->
(DateParser) (String date) -> {
try {
return Timestamp.ofEpochMilli(parser.parse(date).getTime());
} catch (ParseException e) {
throw new GrokRecordValidateException(e);
}
}).collect(Collectors.toList());
}
}
开发者ID:arielnetworks,项目名称:embulk-parser-grok,代码行数:37,代码来源:TimestampParserFactory.java
示例7: isTimestamp
import org.embulk.spi.type.TimestampType; //导入依赖的package包/类
public boolean isTimestamp()
{
return (column.getType() instanceof TimestampType);
}
开发者ID:sonots,项目名称:embulk-filter-row,代码行数:5,代码来源:ParserLiteral.java
注:本文中的org.embulk.spi.type.TimestampType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论