Skip to content

Instantly share code, notes, and snippets.

View frsyuki's full-sized avatar

Sadayuki Furuhashi frsyuki

View GitHub Profile
require 'msgpack'
class PageSchema
def initialize(*keys)
@struct = Struct.new(*keys)
@struct.class_eval do
def to_msgpack(arg=nil)
packer = (arg.is_a?(MessagePack::Packer) ? arg : MessagePack::Packer.new(arg))
packer.write_array_header(self.size)
self.each_pair {|k,v| packer.write(k).write(v) }
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@frsyuki
frsyuki / postgresql.log.1
Last active August 29, 2015 14:07
PostgreSQL DROP TABLE before checkpointing
LOG: statement: create table dt (data text);
LOG: statement: insert into dt (data) values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
LOG: statement: insert into dt select * from dt;
LOG: statement: insert into dt select * from dt;
LOG: statement: insert into dt select * from dt;
LOG: statement: insert into dt select * from dt;
LOG: statement: insert into dt select * from dt;
LOG: statement: insert into dt select * from dt;
LOG: statement: insert into dt select * from dt;
LOG: statement: insert into dt select * from dt;
public class X {
public static void main(String[] args) {
System.out.println("doit: "+doit());
}
public static int doit() {
try {
System.out.println("try");
throw new RuntimeException("exception");
@frsyuki
frsyuki / embulk-overview.png
Last active August 29, 2015 14:14
Embulk README images
embulk-overview.png
@frsyuki
frsyuki / comments.md
Last active August 29, 2015 14:14
"Embulk-plugin-input-pcapng-files書いた" にコメント

Embulk-plugin-input-pcapng-files書いた にコメント。

本来的にはinputプラグインではなくFile input内のparser/decoderプラグインとして造るべきでは?

その通りで、本来はparserプラグインでしょう。Java側にはParserプラグインを書くAPIがあるのですが、まだそれをJRubyで書く仕組みが無いのです。書きます。 (https://github.com/embulk/embulk/issues/33)

処理対象のファイル一覧→スレッドへの分配あたりを再開発してる感

ファイルを読み込むタイプのプラグインはスレッド数を考えなくても良くて、基本的にファイル数 = タスク数にすればOKです(example_input.rbがまぎらわしいかもしれませんが…)。なぜなら、設定ファイルのexec:のところにスレッド数を書けるからです。

def self.transaction(config, &control)
task = {
'charset' => 'utf-8',
'newline' => 'CRLF', # or LF
}
# ...
yield(task)
end
@frsyuki
frsyuki / strptime-sec-fraction
Created February 25, 2015 05:32
Time.strptime with "%s.%N" format ignores millis/micro/nanoeconds
reqirb(main):001:0> require 'time'
=> true
irb(main):002:0> Time.strptime("2015-02-24 21:02:57.321", "%Y-%m-%d %H:%m:%S.%N").strftime("%Y-%m-%d %H:%m:%S.%N")
=> "2015-02-24 21:02:57.321000000"
irb(main):003:0> Time.strptime("1424842137.321", "%s.%N").strftime("%Y-%m-%d %H:%m:%S.%N")
=> "2015-02-24 21:02:57.000000000"
irb(main):004:0> RUBY_VERSION
=> "2.1.3"
package org.embulk.input;
import java.util.List;
import java.util.ArrayList;
import com.google.common.base.Optional;
import org.embulk.config.CommitReport;
import org.embulk.config.Config;
import org.embulk.config.ConfigDefault;
import org.embulk.config.ConfigDiff;
import org.embulk.config.ConfigSource;
@frsyuki
frsyuki / embulk-logo.png
Last active August 29, 2015 14:17
Embulk logo
embulk-logo.png