Skip to content

Instantly share code, notes, and snippets.

View komamitsu's full-sized avatar

Mitsunori Komatsu komamitsu

View GitHub Profile
BasicBuffer:
has a map and a queue. the map's value is a chunk. the queue's element is a chunk.
BasicBuffer#push(key):
the chunk = identified by the key
call enqueue(the chunk):abstract method
@queue << the chunk
delete the KV
@komamitsu
komamitsu / gist:5511319
Created May 3, 2013 17:02
td query sample: count per day
$ td query -w -d nginx " ¥
select ¥
count(td_time_format(td_time_parse(v['time']), 'yyyyMMdd')), ¥
td_time_format(td_time_parse(v['time']), 'yyyyMMdd') as d ¥
from ¥
access ¥
group by ¥
td_time_format(td_time_parse(v['time']), 'yyyyMMdd') ¥
order by d ¥
"
#!/usr/bin/env ruby
%w|20130429 20130430 20130501 20130502|.each do |ymd|
y, m, d = *[ymd[0, 4], ymd[4, 2], ymd[6, 2]]
ym = y + m
dirname = "logs_#{ym}"
Dir.mkdir dirname unless Dir.exist? dirname
File.open("#{dirname}/#{ymd}.csv", "a") do |f|
1000.times do |i|
h = i / 60
set expandtab
set smartindent
" where ^H is entered with CTRL-V CTRL-H.
inoremap # X^H#
set nowrapscan
set ruler
set background=dark
filetype on
filetype indent on
au filetype ruby set ts=2 sw=2
#!/usr/bin/env ruby
require 'rubydns'
port = Integer(ARGV[0] || '53')
INTERFACES = [
[:udp, "0.0.0.0", port],
[:tcp, "0.0.0.0", port]
]
Name = Resolv::DNS::Name
## web interface
### port numbers
* name node: 50070
* job tracker: 50030
* data node: 50075
* task tracker: 50060
### operations
exec_request.per_node_scan_ranges???
Status ImpalaServer::ExecuteInternal(
> RETURN_IF_ERROR((*exec_state)->UpdateQueryStatus(GetExecRequest(request, &result)));
>> Java:FrontEnd
> RETURN_IF_ERROR((*exec_state)->Exec(&result));
>> return ExecQueryOrDmlRequest();
>>> // If desc_tbl is not set, query has SELECT with no FROM. In that
>>> // case, the query can only have a single fragment, and that fragment needs to be
>>> // executed by the coordinator. This check confirms that.
@komamitsu
komamitsu / trie.ml
Last active April 11, 2020 19:58
Trie in OCaml
module Trie : sig
type t
val empty : t
val update : string -> int -> t -> t
val find : t -> string -> int list option
val create_from_text : string -> t
end =
struct
type node = {c:char; poslist:int list; children:t}
and t = node list
$ RUBY_LIB=lib irb
irb(main):001:0> require 'fluent/load'
=> true
irb(main):002:0> tp = Fluent::TextParser.new
=> #<Fluent::TextParser:0x007f91cab5c3a0 @parser=nil>
irb(main):003:0> tp.configure({'format' => 'apache2'})
=> true
irb(main):004:0> s = %q|64.242.88.10 - - [07/Mar/2004:16:06:51 -0800] "GET /twiki/bin/rdiff/TWiki/NewUserTemplate?rev1=1.3&rev2=1.2 HTTP/1.1" 200 4523|
=> "64.242.88.10 - - [07/Mar/2004:16:06:51 -0800] \"GET /twiki/bin/rdiff/TWiki/NewUserTemplate?rev1=1.3&rev2=1.2 HTTP/1.1\" 200 4523"
irb(main):005:0> p Time.now; 1000000.times{tp.parse(s)}; p Time.now
@komamitsu
komamitsu / client.rb
Last active December 24, 2015 22:09
Dummy Impala Server
require 'impala'
conn = Impala.connect('127.0.0.1', 21000) do |conn|
p conn.query('SELECT zip, income FROM zipcode_incomes ORDER BY income DESC')
end