1. 程式人生 > >Apache Drill原始碼分析和編譯

Apache Drill原始碼分析和編譯

此前瞭解過Apache Drill的設計原理,借鑑與Google的Dremel的一個開源實現;而cloudera貌似在此基礎上構造了impala.

最近從apache官網上看到Drill原始碼可以下載了,分析一下。

http://www.apache.org/dyn/closer.cgi/incubator/drill/drill-1.0.0-m1-incubating/

程式碼結構:

包括:src,sqlparser,exec,distribution,contrib,common,sample-data.

檢視INSTALL.cd要求如下:

Java 7+

protoc 2.5.x compiler 【google的Protobuffer compiler 2.5.x】

Maven 3.0+

原始碼可以直接下載;然後通過mvn clean install來進行安裝。

將drill-1.0.0xxx.tar.gz解壓縮到/drill/目錄下

直接執行./sqlline,開始下載所需的包

最後開始報錯

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
cat: .classpath: 沒有那個檔案或目錄
Exception in thread "main" java.lang.NoClassDefFoundError: sqlline/SqlLine
Caused by: java.lang.ClassNotFoundException: sqlline.SqlLine

 看來還算需要根據規定一步步來處理。

執行命令

mvn install [開始下載依賴的版本]

檢測Java版本不行,升級或者安裝Java 7

[[email protected] jdk1.7]# pwd
/drill/jdk1.7
修改/etc/profile

[[email protected] jdk1.7]# vi /etc/profile
[[email protected] jdk1.7]# source /etc/profile
[[email protected] jdk1.7]# 

然後執行mvn install

發現錯誤缺少profobuf的complier

根據Drill的Install.md中依賴內容為protoc 2.5.x complier


接下來準備:

安裝protobuf,下載http://code.google.com/p/protobuf/

http://code.google.com/p/protobuf/downloads/detail?name=protobuf-2.5.0.tar.gz

對應的protobuf-2.5.0.tar.gz

tar zxvf protobuf-2.5.0.tar.gz
cd protobuf-2.5.0
./configure
make
make check
make install
安裝結束。
驗證:
檢視是否安裝成功:protoc --version

[[email protected] protobuf-2.5.0]# protoc --version
libprotoc 2.5.0
[[email protected] protobuf-2.5.0]# 

接下來繼續:

mvn install

最後存在錯誤如下:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test (default-test) on project common: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
[ERROR] Command was/bin/sh -c cd /drill/drill/common && /drill/jdk1.7/jre/bin/java -XX:MaxDirectMemorySize=4096M org.apache.maven.surefire.booter.ForkedBooter /drill/drill/common/target/surefire/surefire5854881226327277986tmp /drill/drill/common/target/surefire/surefire_02131510559628541214tmp
[ERROR] -> [Help 1]

測試通過

 git clone https://github.com/apache/incubator-drill.git
下載原始碼

[[email protected] incubator-drill]# pwd
/drill/incubator-drill
[[email protected] incubator-drill]# ls
common   distribution  header      KEYS     NOTICE   protocol   sample-data  sqlline    src     tools
contrib  exec          INSTALL.md  LICENSE  pom.xml  README.md  sandbox      sqlparser  target
[[email protected] incubator-drill]# 
執行測試:

    cd incubator-drill
    mvn clean install

編譯失敗存在錯誤:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Invalid maximum direct memory size: -XX:MaxDirectMemorySize=4096M
The specified size exceeds the maximum representable size.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

分析pom.xml檔案中

<plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.15</version>
          <configuration>
            <argLine>-XX:MaxDirectMemorySize=4096M </argLine>
          </configuration>
        </plugin>

分配給CentOS6.3的記憶體只有1128M

嘗試修改-XX:MaxDirectMemorySize=896M

重新進行mvn install,原來的錯誤已經不存從

執行到後面錯誤包括:

[INFO] exec/Java Execution Engine ........................ FAILURE [10:23.114s]
[INFO] SQL Parser ........................................ SKIPPED
[INFO] contrib/sqlline ................................... SKIPPED
[INFO] Packaging and Distribution Assembly ............... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13:31.608s
[INFO] Finished at: Sat Nov 30 23:58:45 CST 2013
[INFO] Final Memory: 41M/146M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test (default-test) on project java-exec: There are test failures.
[ERROR] 
[ERROR] Please refer to /drill/drill/exec/java-exec/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :java-exec
[[email protected] drill]# 

存在test failures

Tests in error: 
  TestSimpleFunctions.testSubstring:122 » OutOfMemory Direct buffer memory
  TestSimpleFunctions.testIsNull:68 » OutOfMemory Direct buffer memory
  TestComparisonFunctions.testIntNullable:126->runTest:66 » OutOfMemory Direct b...
  TestComparisonFunctions.testInt:82->runTest:66 » OutOfMemory Direct buffer mem...
  TestComparisonFunctions.testBigIntNullable:136->runTest:66 » OutOfMemory Direc...
  TestComparisonFunctions.testBigInt:93->runTest:66 » OutOfMemory Direct buffer ...
  TestComparisonFunctions.testFloat4:104->runTest:66 » OutOfMemory Direct buffer...
  TestComparisonFunctions.testFloat8:115->runTest:66 » OutOfMemory Direct buffer...
  TestAgg.twoKeyAgg:92->doTest:63 » OutOfMemory Direct buffer memory
  TestAgg.oneKeyAgg:69->doTest:63 » OutOfMemory Direct buffer memory
  TestDistributedFragmentRun.oneBitOneExchangeOneEntryRun:50 »  test timed out a...
  TestDistributedFragmentRun.twoBitOneExchangeTwoEntryRun:106 »  test timed out ...
  TestDistributedFragmentRun.oneBitOneExchangeTwoEntryRun:69 »  test timed out a...
  TestDistributedFragmentRun.oneBitOneExchangeTwoEntryRunLogical:87 »  test time...
  TestMergeJoin.orderedEqualityLeftJoin:124 » NullPointer
  TestMergeJoin.orderedEqualityInnerJoin:180 » OutOfMemory Direct buffer memory
  TestMergeJoin.orderedEqualityMultiBatchJoin:232 » OutOfMemory Direct buffer me...
  TestMergeJoin.simpleEqualityJoin:72 » OutOfMemory Direct buffer memory
  TestEndianess.testLittleEndian:33 » OutOfMemory Direct buffer memory

相關例項:

testLittleEndian(org.apache.drill.exec.memory.TestEndianess)  Time elapsed: 0.735 sec  <<< ERROR!
java.lang.OutOfMemoryError: Direct buffer memory
    at java.nio.Bits.reserveMemory(Bits.java:658)
    at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123)
    at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:306)
    at io.netty.buffer.PoolArenaL$DirectArena.newChunk(PoolArenaL.java:381)
    at io.netty.buffer.PoolArenaL.allocateNormal(PoolArenaL.java:144)
    at io.netty.buffer.PoolArenaL.allocate(PoolArenaL.java:133)
    at io.netty.buffer.PoolArenaL.allocate(PoolArenaL.java:95)
    at io.netty.buffer.PooledByteBufAllocatorL.newDirectBuffer(PooledByteBufAllocatorL.java:236)
    at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:132)
    at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:123)
    at org.apache.drill.exec.memory.DirectBufferAllocator.buffer(DirectBufferAllocator.java:35)
    at org.apache.drill.exec.memory.TestEndianess.testLittleEndian(TestEndianess.java:33)

-------------------

在Cloudera的CDH4.3的虛擬機器下,安裝jdk1.7.0_45和protoc-2.5.0

然後嘗試多次

mvn e install最終完成安裝編譯

測試執行;

./sqlline -u jdbc:drill:schema=parquet-local -n admin -p admin

首先掃描是否有更新,如果沒有更新,啟動命令列

測試命令

SELECT 
      _MAP['R_REGIONKEY'] AS region_key, 
      _MAP['R_NAME'] AS name, _MAP['R_COMMENT'] AS comment
    FROM "sample-data/region.parquet";

相關推薦

Apache Drill原始碼分析編譯

此前瞭解過Apache Drill的設計原理,借鑑與Google的Dremel的一個開源實現;而cloudera貌似在此基礎上構造了impala. 最近從apache官網上看到Drill原始碼可以下載了,分析一下。 http://www.apache.org/dyn/closer.cgi/incuba

Apache Arrow原始碼分析(一)——簡介框架

背景 列儲存在資料庫領域中早已被提出,列儲存資料結構在分析型事務上表現優異,大資料分析引擎,諸如Spark-SQL,Impala 均採用列儲存作為其中間資料表示形式,那麼Apache Arrow就是這樣一種記憶體列式資料結構。 在眾多分散式系統中,每

java併發之原子操作類(AtomicLong原始碼分析)非阻塞演算法

  背景 近年來,在併發演算法領域的大多數研究都側重於非阻塞演算法,這種演算法用底層的原子機器指令(例如比較併發交換指令)代替鎖來確保資料在併發訪問中的一致性。非阻塞演算法被廣泛的用於在作業系統和JVM中實現執行緒/程序排程機制、垃圾回收機制以及鎖和其他併發資料結構。 與基於鎖

Mybatis的處理引數原始碼分析方法傳參取參分析

一、Mybatis中解析引數傳遞的原始碼分析 首先,當查詢資料庫語句mapper.getEmpByIdAndLastName(1, "tom");執行時,會呼叫Mybatis包中MapperProxy.invoke()方法,然後按照順序執行; 流程: 注:先進入Mybatis包中Mapp

SpringFramework3 原始碼下載編譯教程

Spring已經將原始碼從svn遷移到了git。所以,首先需要安裝git環境。我使用的是Windows下的TortoiseGit,帶圖形介面,比較直觀。 下載後,進入下載到的資料夾,裡面有個README.md的說明檔案,如果E文可以,可以按

Hibernate4.0原始碼下載編譯教程

廢話不多說,直接進入主題。首先是下載原始碼,跟spring一樣,hibernate也採用git管理。 git://github.com/hibernate/hibernate-orm.git 下載後,hiberante同樣也是採用了g

ButterKnife原始碼分析手寫

大學剛出來實習那會,自己寫了一個執行時的 ViewById 和 OnClick 註解,用來解決 findViewById 和 setOnClickListener 。其實也是參考 xUtils 的原始碼,後來加了很多的功能擴充套件,如網路檢測等等。關鍵是那時 x

ButterKnife手原始碼分析手寫

參考butterknife原始碼進行手寫,首先分model:butterknife,compiler和annomation 首先butterknife原始碼分析:使用butterknife之後會自動生成這個類 package com.peakma

資源排程原始碼分析任務排程原始碼分析

1.資源排程原始碼分析 資源請求簡單圖 資源排程Master路徑: 路徑:spark-1.6.0/core/src/main/scala/org.apache.spark/deploy/Master/Master.scala 提交應用程式,submit的路徑: 路徑:spark-1.6

jQuery選擇器原始碼分析easyui核心分析

寫在選擇器原始碼分析之前      這裡指對1.7.2版本的原始碼分析,更高版本添加了更多程式碼。      整個jQuery的程式碼是寫在一個(function(window, undefined){})(window);這樣一個閉包裡。請思考,為什麼要這樣做?      將其寫在一個閉包函式

JAVA隨筆篇一(Timer原始碼分析scheduleAtFixedRate的使用)

寫完了基礎篇,想了很久要不要去寫進階篇,去寫JSP等等的使用方法,最後決定先不去寫,因為自己並不是JAVA方面的大牛,目前也在邊做邊學,所以決定先將自己不懂的拿出來學並記下來。 Timer是Java自帶的java.util.Timer類,通過排程一個java.util.Ti

VLC for Android原始碼下載編譯 (包含其他開源專案,很全面!!!!)

Project Hosting on 點選開啟連結  from:http://dingran.iteye.com/blog/1717711 1.vlc for android  已經發布了,開源的地址是: http://wiki.videolan.or

Zebra-VTYSH原始碼分析改造(三):新增定製命令

  一 檢視介紹 由上面幾篇文章分析可見,所有的命令都是包含在node中的,根據Cisco或者H3常見路由器或者交換機的CLI格式可見,一個node就對應著一個檢視(View)。常用的檢視包括:普通檢視,管理檢視,檔案系統檢視,配置檢視,以及介面配置檢視和VLAN檢視等。

linux sock_raw原始套接字程式設計 (轉)Linux下Libpcap原始碼分析包過濾機制

sock_raw原始套接字程式設計可以接收到本機網絡卡上的資料幀或者資料包,對與監聽網路的流量和分析是很有作用的.一共可以有3種方式建立這種 socket 1.socket(AF_INET, SOCK_RAW, IPPROTO_TCP|IPPROTO_UDP|IPPROT

Java資料結構----棧(Stack)原始碼分析個人簡單實現

一、Stack原始碼分析 1.繼承結構  棧是資料結構中一種很重要的資料結構型別,因為棧的後進先出功能是實際的開發中有很多的應用場景。Java API中提供了棧(Stacck)的實現。   Stack類繼承了Vector類,而Vector類繼承了AbstractList抽象

apache kafka原始碼分析工程搭建(IDEA)

[2014-05-24 23:45:31,965] INFO Verifying properties (kafka.utils.VerifiableProperties) [2014-05-24 23:45:32,009] INFO Property broker.id is overridden to

linux原始碼下載編譯 問題

Linux 核心原始碼下載地址 https://www.kernel.org/pub/linux/kernel/ 1.下載完成之後,把它放在/usr/src 下 2.解壓 3. 正常情況下, 在/lib/modules/{uname -v}下,我的版本是/lib/

6.原始碼分析---dubbo相比SOFARPC是如何實現負載均衡的?

官方目前建議使用的負載均衡包括以下幾種: random(隨機演算法) localPref(本地優先演算法) roundRobin(輪詢演算法) consistentHash(一致性hash演算法) 所以我們接下來分析以下以上四種負載均衡的原始碼是怎樣的。 隨機演算法 我們先看一下SOFARPC的原始碼實現

mysql複製那點事(2)-binlog組提交原始碼分析實現

目錄 mysql複製那點事(2)-binlog組提交原始碼分析和實現 0. 參考文獻 1. innodb和binlog的兩階段提交 2. 組提交原理 3. 組提交實現 3.1

Harmony OS 開發避坑指南——原始碼下載編譯

# Harmony OS 開發避坑指南——原始碼下載和編譯 本文介紹瞭如何下載鴻蒙系統原始碼,如何一次性配置可以編譯三個目標平臺(`Hi3516`,`Hi3518`和`Hi3861`)的編譯環境,以及如何將原始碼編譯為三個目標平臺的二進位制檔案。 **坑點總結**: 1. 下載原始碼基本上沒有太多坑,可