Skip to content

Instantly share code, notes, and snippets.

@coderplay
coderplay / IntArrayIntersection.java
Last active December 11, 2015 21:29
sorted array intersection
import java.util.Arrays;
import java.util.Random;
public class IntArrayIntersection {
/*
* O(N+M)
*/
public static int[] intersectByLiteration(final int[] lhs, final int[] rhs) {
// worst case size for the intersection array
class Lock {}
class Danger {
static {
System.out.println("clinit begin...");
try {Thread.sleep(2000);} catch (Exception e) {}
synchronized (Lock.class) { System.out.println("clinit done!");}
}
}
public class Hang {
public static void main(String[] args) {

SemanticAnalyzer主体流程

  • 新建QueryBlock
  • 预处理(语意分析)
  • 获取MetaData
  • 获取每个源table的相关结构
  • 将视图替换, 重写, 并将其记入view别名
  • 检查inputformat
  • 保存alias->tab 至QB
  • 为子查询获取meta
  • 获取目标的相关结构, 目标有两种:表或本地目录
@coderplay
coderplay / GroupVarInt.java
Last active December 15, 2015 13:39
group variant integer encoding
import java.lang.reflect.Field;
import java.util.Random;
import sun.misc.Unsafe;
public class GroupVarInt {
private final static int UINT24_MAX = ((2<<23) - 1);
private final static int UINT16_MAX = ((2<<15) - 1);
private final static int UINT8_MAX = ((2<<7) -1);
private static final long BYTE_ARRAY_OFFSET;
@coderplay
coderplay / PBQvsThreadPool.java
Created April 8, 2013 08:18
Using PriorityBlockingQueue in thread pool
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.RunnableFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@coderplay
coderplay / thread.c
Created April 18, 2013 07:17
这段代码在2.6.18-164.el5xen会出现cpu 100%的情况
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#define NANOSECS_PER_SEC 1000000000
pthread_mutex_t lock;
@coderplay
coderplay / JavaDU.java
Last active January 31, 2016 16:27
Counting the size of a directory
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.LinkOption;
import java.nio.file.Paths;
import java.util.List;
import java.util.ArrayList;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.RecursiveTask;
import java.io.IOException;
@coderplay
coderplay / ViewDirectByteBuffer.md
Last active December 22, 2015 10:29
Direct ByteBuffer的内存查看

Java应用中经常用ByteBuffer.allocateDirect()或者Unsafe.allocateMemory()分配一段内存。 MAT等内存查看器看不到native的内存, 所以需要借助gdb等工具来查看.

ByteBuffer bb = ByteBuffer.allocateDirect(capacity)
                              .order(ByteOrder.nativeOrder());

这种ByteBuffer可以得到它的起始内存地址

@coderplay
coderplay / giraph.md
Last active December 25, 2015 13:29
Giraph notes

Master start

  1. aggregator handler
  2. start a netty master server - to receive messages from workers
  3. start a netty master client - to send messages to workers
  4. create vertex/edge input splits, write splits to zk in parallel
  5. while () do coordinatesuperstep()

Worker start

  1. partitioner
  2. start a worker server
@coderplay
coderplay / log
Last active December 28, 2015 08:39
tajo> select count(1) from supplier;
Progress: 50%, response time: 1.033 sec
Progress: 100%, response time: 1.481 sec
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/mzhou/tajo/tajo-0.2.0-SNAPSHOT/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/mzhou/hadoop/hadoop-2.0.5-alpha/share/hadoop/common/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
2013-12-05 20:28:33,330 WARN storage.AbstractStorageManager (AbstractStorageManager.java:<init>(85)) - does not support block metadata. ('dfs.datanode.hdfs-blocks-metadata.enabled')
final state: QUERY_SUCCEEDED, init time: 0.135 sec, response time: 1.481 sec
result: hdfs://172.16.19.32:8020/tajo-mzhou/staging/q_1386302792972_0002/RESULT, 1 rows (8 B)