• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Timestamps类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.embulk.spi.util.Timestamps的典型用法代码示例。如果您正苦于以下问题:Java Timestamps类的具体用法?Java Timestamps怎么用?Java Timestamps使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Timestamps类属于org.embulk.spi.util包,在下文中一共展示了Timestamps类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: create

import org.embulk.spi.util.Timestamps; //导入依赖的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


示例2: getTimestampParser

import org.embulk.spi.util.Timestamps; //导入依赖的package包/类
protected final TimestampParser getTimestampParser(Column column) {
	if (timestampParsers == null) {
		PluginTask task = visitorValue.getPluginTask();
		timestampParsers = Timestamps.newTimestampColumnParsers(task, task.getColumns());
	}
	return timestampParsers[column.getIndex()];
}
 
开发者ID:hishidama,项目名称:embulk-parser-poi_excel,代码行数:8,代码来源:TimestampCellVisitor.java


示例3: SpeedControlPageOutput

import org.embulk.spi.util.Timestamps; //导入依赖的package包/类
SpeedControlPageOutput(PluginTask task, Schema schema, PageOutput pageOutput) {
    this.controller = new SpeedometerSpeedController(task, SpeedometerSpeedAggregator.getInstance(task));
    this.schema = schema;
    this.allocator = task.getBufferAllocator();
    this.delimiterLength = task.getDelimiter().length();
    this.recordPaddingSize = task.getRecordPaddingSize();
    this.pageReader = new PageReader(schema);
    this.timestampFormatters = Timestamps.newTimestampColumnFormatters(task, schema, task.getColumnOptions());
    this.pageBuilder = new PageBuilder(allocator, schema, pageOutput);
}
 
开发者ID:hata,项目名称:embulk-filter-speedometer,代码行数:11,代码来源:SpeedometerFilterPlugin.java


示例4: createWriter

import org.embulk.spi.util.Timestamps; //导入依赖的package包/类
private ParquetWriter<PageReader> createWriter(PluginTask task, Schema schema, int processorIndex)
{
    final TimestampFormatter[] timestampFormatters = Timestamps.newTimestampColumnFormatters(task, schema, task.getColumnOptions());

    final Path path = new Path(buildPath(task, processorIndex));
    final CompressionCodecName codec = CompressionCodecName.valueOf(task.getCompressionCodec());
    final int blockSize = task.getBlockSize();
    final int pageSize = task.getPageSize();
    final Configuration conf = createConfiguration(task.getExtraConfigurations());
    final boolean overwrite = task.getOverwrite();

    ParquetWriter<PageReader> writer = null;
    try {
        EmbulkWriterBuilder builder = new EmbulkWriterBuilder(path, schema, timestampFormatters)
                .withCompressionCodec(codec)
                .withRowGroupSize(blockSize)
                .withPageSize(pageSize)
                .withDictionaryPageSize(pageSize)
                .withConf(conf);

        if (overwrite) {
            builder.withWriteMode(ParquetFileWriter.Mode.OVERWRITE);
        }

        writer = builder.build();
    }
    catch (IOException e) {
        Throwables.propagate(e);
    }
    return writer;
}
 
开发者ID:choplin,项目名称:embulk-output-parquet,代码行数:32,代码来源:ParquetOutputPlugin.java


示例5: ColumnVisitorImpl

import org.embulk.spi.util.Timestamps; //导入依赖的package包/类
ColumnVisitorImpl(Map<String, String> row, PluginTask task, PageBuilder pageBuilder) {
    this.row = row;
    this.pageBuilder = pageBuilder;

    this.timestampParsers = Timestamps.newTimestampColumnParsers(
            task, task.getColumns());
}
 
开发者ID:mikoto2000,项目名称:embulk-input-salesforce_bulk,代码行数:8,代码来源:SalesforceBulkInputPlugin.java


示例6: run

import org.embulk.spi.util.Timestamps; //导入依赖的package包/类
@Override
public void run(TaskSource taskSource, Schema schema, FileInput input, PageOutput output)
{
    PluginTask task = taskSource.loadTask(PluginTask.class);

    setColumnNameValues(schema);

    final SchemaConfig schemaConfig = getSchemaConfig(task);
    final TimestampParser[] timestampParsers = Timestamps.newTimestampColumnParsers(task, schemaConfig);
    final LineDecoder decoder = newLineDecoder(input, task);
    final JsonParser jsonParser = newJsonParser();
    final boolean stopOnInvalidRecord = task.getStopOnInvalidRecord();

    try (final PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), schema, output)) {
        ColumnVisitorImpl visitor = new ColumnVisitorImpl(task, schema, pageBuilder, timestampParsers);

        while (decoder.nextFile()) { // TODO this implementation should be improved with new JsonParser API on Embulk v0.8.3
            lineNumber = 0;

            while ((line = decoder.poll()) != null) {
                lineNumber++;

                try {
                    Value value = jsonParser.parse(line);

                    if (!value.isMapValue()) {
                        throw new JsonRecordValidateException("Json string is not representing map value.");
                    }

                    final Map<Value, Value> record = value.asMapValue().map();
                    for (Column column : schema.getColumns()) {
                        Value v = record.get(getColumnNameValue(column));
                        visitor.setValue(v);
                        column.visit(visitor);
                    }

                    pageBuilder.addRecord();
                }
                catch (JsonRecordValidateException | JsonParseException e) {
                    if (stopOnInvalidRecord) {
                        throw new DataException(String.format("Invalid record at line %d: %s", lineNumber, line), e);
                    }
                    log.warn(String.format("Skipped line %d (%s): %s", lineNumber, e.getMessage(), line));
                }
            }
        }

        pageBuilder.finish();
    }
}
 
开发者ID:shun0102,项目名称:embulk-parser-jsonl,代码行数:51,代码来源:JsonlParserPlugin.java


示例7: getTimestampFormatter

import org.embulk.spi.util.Timestamps; //导入依赖的package包/类
protected final TimestampFormatter getTimestampFormatter(Column column) {
	if (timestampFormatters == null) {
		timestampFormatters = Timestamps.newTimestampColumnFormatters(task, schema, task.getColumnOptions());
	}
	return timestampFormatters[column.getIndex()];
}
 
开发者ID:hishidama,项目名称:embulk-formatter-poi_excel,代码行数:7,代码来源:PoiExcelColumnVisitor.java


示例8: run

import org.embulk.spi.util.Timestamps; //导入依赖的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);
    TimestampParser[] timestampParsers = Timestamps.newTimestampColumnParsers(task, task.getSchemaConfig());

    Pattern pattern = Pattern.compile(task.getRegex());
    Map<String, DynamicColumnSetter> setterMap = setupSetters(pageBuilder, task.getSchemaConfig(),
            timestampParsers, taskSource.loadTask(PluginTaskFormatter.class));

    while (input.nextFile()) {

        int lineNumber = 0;

        while (true) {
            String line = lineDecoder.poll();
            lineNumber++;

            if (line == null) {
                break;
            }
            Matcher matcher = pattern.matcher(line);
            if (!matcher.matches()) {
                if (task.getSkipIfUnmatch()) {
                    log.warn(String.format("Skipped unmatched line %d: %s", lineNumber, line));
                    continue;
                } else {
                    throw new DataException(String.format("Unmatched Line at line %d: %s", lineNumber, line));
                }
            }

            for (Map.Entry<String, DynamicColumnSetter> pair : setterMap.entrySet()) {
                String value = matcher.group(pair.getKey());
                if (value == null) {
                    pair.getValue().setNull();
                } else {
                    pair.getValue().set(value);
                }
            }
            pageBuilder.addRecord();
        }
    }
    pageBuilder.finish();
}
 
开发者ID:mokemokechicken,项目名称:embulk-parser-regex,代码行数:46,代码来源:RegexParserPlugin.java



注:本文中的org.embulk.spi.util.Timestamps类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XMLWriter类代码示例发布时间:2022-05-22
下一篇:
Java VariableResolverFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap