Skip to content

Instantly share code, notes, and snippets.

View moaikids's full-sized avatar

moaikids moaikids

  • moaikids
  • moaikids
View GitHub Profile
@moaikids
moaikids / gist:2965358
Created June 21, 2012 11:55
EventExecutor
import java.util.Queue;
import java.util.concurrent.PriorityBlockingQueue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class EventExecutor {
private static Log log = LogFactory.getLog(EventExecutor.class);
private final Queue<Event> queues;
private Thread running;
import lombok.Getter;
public class Event implements Comparable<Event> {
@Getter
private volatile Runnable runnable;
@Getter
private final long time;
@Getter
private boolean canceled = false;
@Getter
@moaikids
moaikids / gist:3695543
Created September 11, 2012 02:39
org.apache.hadoop.hdfs.DFSClient.java (line:3456-3468)
// receive ack for connect
pipelineStatus = blockReplyStream.readShort();
firstBadLink = Text.readString(blockReplyStream);
if (pipelineStatus != DataTransferProtocol.OP_STATUS_SUCCESS) {
if (pipelineStatus == DataTransferProtocol.OP_STATUS_ERROR_ACCESS_TOKEN) {
throw new InvalidBlockTokenException(
"Got access token error for connect ack with firstBadLink as "
+ firstBadLink);
} else {
throw new IOException("Bad connect ack with firstBadLink as "
@moaikids
moaikids / gist:3695577
Created September 11, 2012 02:48
org.apache.hadoop.hdfs.DFSClient.java (line:3360)
int count = conf.getInt("dfs.client.block.write.retries", 3);
@moaikids
moaikids / gist:4221663
Created December 6, 2012 03:57
udf_initialize.py
#!/usr/bin/env python
# encoding: utf-8
import sys
from optparse import OptionParser
sys.path.append('/usr/local/hive/lib/py')
from hive_service import ThriftHive
from hive_service.ttypes import HiveServerException
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
$ diff {HIVE_0.10.0_HOME}/lib/py/hive_service/ThriftHive.py {HIVE_0.9.0_HOME}/lib/py/hive_service/ThriftHive.py
2c2
< # Autogenerated by Thrift Compiler (0.9.0)
---
> # Autogenerated by Thrift Compiler (0.7.0)
6,7d5
< # options string: py
< #
9c7
< from thrift.Thrift import TType, TMessageType, TException, TApplicationException
//https://github.com/fluent/fluentd/blob/master/lib/fluent/command/fluentd.rb
//line 81-91
op.on('-v', '--verbose', "increase verbose level (-v: debug, -vv: trace)", TrueClass) {|b|
if b
opts[:log_level] = [opts[:log_level] - 1, Fluent::Log::LEVEL_TRACE].max
end
}
op.on('-q', '--quiet', "decrease verbose level (-q: warn, -qq: error)", TrueClass) {|b|

explain

explain select * from user limit 10;

explain select * from (select * from user) u sort by user_id limit 10 ;

local mode

select count(*) from user;

set mapred.job.tracker = local;