2. 발표자
조현구
군산대 컴퓨터정보공학과 석사과정 수료
MCALab. (Mobile Convergence and Application Lab.)
빅데이터, 공간 정보 분석, …
3.
4. 발표 순서
Spatial Tajo 소개
개발하게 된 동기
왜 Apache Tajo인가?
구현 계획
현재 상황; 구현/미구현 부분
경험 공유
참고 자료
5. Spatial Tajo란 무엇인가?
Spatial queries를 위한 플러그인
분산 데이터 웨어하우스 시스템에 저장한
데이터에 대해 공간 관계 질의, 공간 분석
질의를 제공하고 수행할 수 있도록 하는
플러그인
◦ 공간 질의를 위한 공간 함수들
◦ 데이터 타입 지원
◦ 공간 데이터에 대한 인덱스 지원
◦ 래스터 데이터 지원
GitHub Spatial-Tajo Repository
Overall Architecture of Apache Tajo
Tajo Worker
Local
File-
System
HDFS
Amazon
S3
QueryMaster
Local Query Engine
StorageManager Spatial Tajo
Tajo MasterCatalogStore
Allocate
a query
Manage
metadata
Client
JDBC SQL Shell Web UI
6. 개발하게 된 동기
접한 시기 : 2014. 12~
Hadoop → HBase → … … … → Tajo
분석하려는 공간 데이터의 양이 빅 데이터에 근접하는데, 이를 SQL를 이용해서
분석하고 싶다.
배치 작업없이 작동하는 시스템을 이용하고 싶다.
소프트웨어나 솔루션을 자유롭게 사용하고 싶다.
(물론 커뮤니티에 경험 등을 기여한다는 가정하에)
7. 분석하려고 했던 데이터?
인터넷, 모바일 환경의 발전에 따라 작성하는 데이터는 변화
마이크로블로그 데이터의 구성
Related Paper
8. 개발하게 된 동기
물론 기존에 나와있는 솔루션 중에도 괜찮은 게 있다. 하지만…
◦ Relational Database and DBMS
◦ Oracle Spatial and Graph (Oracle Database+Plug-in)
◦ MySQL DBMS
◦ PostGIS with PostgreSQL
◦ NoSQL
◦ Document-oriented database: MongoDB, CouchDB (Plug-in), RethinkDB
◦ HBase, Hive
◦ Cluster and Cloud
◦ GeoMesa, ESRI GIS Tools for Hadoop, SpatialHadoop (http://spatialhadoop.cs.umn.edu) (on Hadoop)
◦ CartoDB (on top of PostgreSQL, PostGIS and SaaS)
결론 : FOSS(Free and Open-Source Software) + Spatial → Apache Tajo + Spatial Plug-in!
9. 왜 Apache Tajo를 선택했나?
Apache Tajo
◦ A robust big data relational and distributed data warehouse system for Apache Hadoop
◦ Designed for low-latency and scalable ad-hoc queries, online aggregation, and ETL on large
-data sets stored on HDFS and other data sources.
특징
◦ 데이터를 분산 저장하는 동작들을 Hadoop이나 Amazon S3 등에 위임함
◦ 데이터의 삽입은 지원하나, 업데이트는 지원하지 않음.
◦ 호환성 : ANSI/ISO SQL로 질의 가능
◦ MapReduce를 이용한 처리보다 더 빠르고, 내고장성 보장
◦ 구축 및 운용에서의 쉬움과 편리함
◦ 필요하면 직접 구현해서 붙이는 것이 가능(Plug-in)
10. 구현 계획
Spatial functions for spatial queries
◦ DE-9IM (Dimensionally Extended nine-Intersection Model)
◦ Binary Predicates : Equals, Disjoints, Intersects and Touches, Crosses, Within, Contains, Overlaps
◦ Spatial Analysis Methods : ConvexHull, Intersection, Union, Difference, SymDifference
◦ Transforming Spatial Type : like ‘asPoint, asPolygon, toPoint, toPolygon, …’
◦ Etc Spatial Functions : Distances, Lengths, Areas and Centroids, …
Adding spatial data types
Supporting an index for spatial data
◦ R-tree, Quad-tree and KD-tree, etc.
Enabling to run kNN queries
11.
12.
13.
14. 현재 상황; 구현된 부분
공간 관련 함수들
◦ JTS를 이용하여 대부분의 함수 구현
◦ DE-9IM : Distances, Equals, Disjoints, Intersects, Touches, Crosses, Overlaps and Contains
kNN 질의 실행
◦ 구현된 공간 함수들을 이용하여 질의가 가능
공간 데이터에 대한 인덱싱
◦ STR(Sort-Tile-Recursive)를 이용한 R-tree 인덱싱
Local indexes
Global
Index
인덱스를 이용해
데이터를 읽는 과정
1. 글로벌 인덱스에서
검색할 키들을 찾음
2. 검색할 키들에 대응하는
로컬 인덱스들을 찾는다.
3. 로컬 인덱스들에서
검색할 키들을 찾는다.
4. 해당 키들에 포함된
오프셋을 이용해 읽는다.
Wikipedia: R-tree - STR, SpatialHadoop Paper and Tajo Document
15. 현재 상황; 미구현된 부분
공간 데이터 타입 추가
◦ 공간 관련 함수들의 파라미터가 부정확하고, 사용하기 불편하다.
미구현된 공간 함수들
◦ Binary Predicates를 제외한 대다수의 공간 함수들
구현한 부분(함수, 질의, 인덱스 등)에 대한 최적화
공간 데이터에 대한 인덱싱 → ?
◦ Quad-tree (with GeoHash) and KD-tree
모듈화
◦ Apache Tajo와 분리가 되어있지 않아 별도의 설치가 불가능.
16. 경험 공유
상황에 대처를 할 수 있는 노하우가 적인 문서가 거의 없다
◦ 적용에 대한 질문이 대다수, 기능 구현에 대한 질문은 거의 찾기 힘들었다
◦ UDF 구현
◦ http://stackoverflow.com/questions/27194691/how-to-write-a-udf-in-tajo → 현재의 방식과 다소 차이가 존재
◦ https://groups.google.com/forum/#!topic/tajo-user-kr/GR8SEhxtnSE → 예전 답변
◦ https://groups.google.com/forum/#!topic/tajo-user-kr/XhgGpGEpExs
◦ 데이터 타입 구현
◦ 인덱스 구현
◦ https://groups.google.com/forum/#!topic/tajo-user-kr/496UcPmEo84 → 직접 질문
17. 경험 공유
실제 구현과 디버깅
◦ Apache Tajo Convension 준수
◦ 파일 최상단의 라이선스 구문
◦ GlobalEngine #L176, #L281
◦ Test
◦ TPCH 테이블 데이터 복사
(tajo-cluster-tests/src/test/resources/tpch)
◦ QueryTestCaseBase #L841
(verifyResultText: assertEquals)
◦ 인덱스 구현
◦ 실제로는 쓸만하게 하려면
생각보다 많은 부분을 손봐야했다.
(Protobuf, ANTLR 포함…)
18. 경험 공유
실제 구현과 디버깅
◦ 명심해야 하는 “것들”
◦ 경계
◦ 인터페이스
◦ 지원되지 않는 것이 버그는 아니다.
(하지만 구현이 필요한 경우가…)
◦ 이미 구현된 것을 한 번 볼 것
◦ 이미 구현된 것을 두 번 볼 것
◦ 이미 구현된 것을 세 번 볼 것
◦ ……
19. 참고 자료
Apache Tajo
◦ Official Website, Source codes, User documentation
◦ Efficient In-situ processing of various storage types on Apache Tajo
◦ Apache Tajo Enters the SQL-on-Hadoop Space
◦ SQL-on-Hadoop: What does “100 times faster than Hive” actually mean?
◦ Setting up an Apache Tajo Cluster on Amazon EMR
PostgreSQL and PostGIS Document
SpatialHadoop
◦ Official Website, Source codes
◦ A demonstration of SpatialHadoop: an efficient mapreduce framework for spatial data
◦ Spatialhadoop: towards flexible and scalable spatial processing using MapReduce
20. Reference
Spatial Databases: With Application to GIS
Indexing
◦ STR: A simple and efficient algorithm for R-tree packing
◦ Spatialhadoop: towards flexible and scalable spatial processing using mapreduce
◦ Tajo: A distributed data warehouse system on large clusters
◦ Apache Tajo Documents: Index types
Wikipedia
◦ Spatial Database
◦ Spatial Query
◦ R-tree
Parts that are not yet implemented include spatial data types, spatial functions, kNN query, spatial data index and modularization. Spatial data types are currently not implemented, so there is an inconvenience that spatial functions have to use primitive types. I am going to resolve the inconvenience of spatial functions, once spatial data types are implemented.
First, as for spatial functions, I am going to implement the functions as lengths, areas, centroids that are not implemented and then, optimize each of the spatial functions and kNN queries.
Next, as for the indexing of spatial data, I am going to implement Quad-tree or KD-Tree using GeoHash as well as R-tree.
Lastly, I am going to modularize the plug-in. Currently, it is combined since it is difficult to separate it from Tajo, but after going through the final modularization in the plug-in, it will be distributed in the form of a plug-in.
For today’s presentation, I mainly referred to the documents and source codes of Tajo, SpatialHadoop and PostGIS and etc., and there are books or websites for information about the contents, as well.
For today’s presentation, I mainly referred to the documents and source codes of Tajo, SpatialHadoop and PostGIS and etc., and there are books or websites for information about the contents, as well.
For Q&A, please e-mail your questions to the e-mail address stated here, and I will answer them in detail. Thank you for listening to my presentation.