View Full Document

14 views

Unformatted text preview:

Data Intensive Information Processing Applications Session 12 Bigtable Hive and Pig Jimmy Lin University of Maryland Tuesday April 27 2010 This work is licensed under a Creative Commons Attribution Noncommercial Share Alike 3 0 United States See http creativecommons org licenses by nc sa 3 0 us for details Source Wikipedia Japanese rock garden Today s Agenda Bigtable Hive Pig Bigtable Data Model A table in Bigtable is a sparse distributed persistent multidimensional sorted map Map indexed by a row key column key and a timestamp row string column string time int64 uninterpreted byte array Supports lookups inserts deletes Single row transactions only Image Source Chang et al OSDI 2006 Rows and Columns Rows maintained in sorted lexicographic order Applications can exploit this property for efficient row scans Row ranges dynamically partitioned into tablets Columns grouped into column families Column key family qualifier Column families provide locality hints Unbounded number of columns Bigtable Building Blocks GFS Chubby SSTable SSTable Basic building block of Bigtable Persistent ordered immutable map from keys to values Sequence of blocks on disk plus an index for block lookup Stored in GFS Can be completely mapped into memory Supported operations Look up value associated with key Iterate key value pairs within a key range 64K block 64K block 64K block SSTable Index Source Graphic from slides by Erik Paulson Tablet Dynamically partitioned range of rows Built from multiple SSTables Tablet 64K block Start aardvark 64K block 64K block End apple SSTable Index Source Graphic from slides by Erik Paulson 64K block 64K block 64K block SSTable Index Table Multiple tablets make up the table SSTables can be shared Tablet aardvark Tablet apple SSTable SSTable Source Graphic from slides by Erik Paulson apple two E SSTable SSTable boat Architecture Client library Single master server Tablet servers Bigtable Master Assigns tablets to tablet servers Detects addition and expiration of tablet servers Balances tablet server load Handles garbage collection Handles schema changes Bigtable Tablet Servers Each tablet server manages a set of tablets Typically between ten to a thousand tablets Each 100 200 MB by default Handles read and write requests to the tablets Splits tablets that have grown too large Tablet Location Upon discovery clients cache tablet locations Image Source Chang et al OSDI 2006 Tablet Assignment Master keeps track of Each tablet is assigned to one tablet server at a time Set of live tablet servers Assignment of tablets to tablet servers Unassigned tablets Tablet server maintains an exclusive lock on a file in Chubby Master monitors tablet servers and handles assignment Changes to tablet structure Table creation deletion master initiated Tablet merging master initiated Tablet splitting tablet server initiated Tablet Serving Log Structured Merge Trees Image Source Chang et al OSDI 2006 Compactions Minor compaction Merging compaction Converts the memtable into an SSTable Reduces memory usage and log traffic on restart Reads the contents of a few SSTables and the memtable and writes out a new SSTable Reduces number of SSTables Major compaction Merging compaction that results in only one SSTable No deletion records only live data Bigtable Applications Data source and data sink for MapReduce Google s web crawl Google Earth Google Analytics Lessons Learned Fault tolerance is hard Don t add functionality before understanding its use Single row transactions appear to be sufficient Keep it simple HBase Open source clone of Bigtable Implementation hampered by lack of file append in HDFS Image Source http www larsgeorge com 2009 10 hbase architecture 101 storage html Hive and Pig Need for High Level Languages Hadoop is great for large data processing But writing Java programs for everything is verbose and slow Not everyone wants to or can write Java code Solution develop higher level data processing languages Hive HQL is like SQL Pig Pig Latin is a bit like Perl Hive and Pig Hive data warehousing application in Hadoop Pig large scale data processing system Query language is HQL variant of SQL Tables stored on HDFS as flat files Developed by Facebook now open source Scripts are written in Pig Latin a dataflow language Developed by Yahoo now open source Roughly 1 3 of all Yahoo internal jobs Common idea Provide higher level language to facilitate large data processing Higher level language compiles down to Hadoop jobs Hive Background Started at Facebook Data was collected by nightly cron jobs into Oracle DB ETL via hand coded python Grew from 10s of GBs 2006 to 1 TB day new data 2007 now 10x that Source cc licensed slide by Cloudera Hive Components Shell allows interactive queries Driver session handles fetch execute Compiler parse plan optimize Execution engine DAG of stages MR HDFS metadata Metastore schema location in HDFS SerDe Source cc licensed slide by Cloudera Data Model Tables Partitions Typed columns int float string boolean Also list map for JSON like data For example range partition tables by date Buckets Hash partitions within ranges useful for sampling join optimization Source cc licensed slide by Cloudera Metastore Database namespace containing a set of tables Holds table definitions column types physical layout Holds partitioning information Can be stored in Derby MySQL and many other relational databases Source cc licensed slide by Cloudera Physical Layout Warehouse directory in HDFS Tables stored in subdirectories of warehouse E g user hive warehouse Partitions form subdirectories of tables Actual data stored in flat files Control char delimited text or SequenceFiles With custom SerDe can use arbitrary format Source cc licensed slide by Cloudera Hive Example Hive looks similar to an SQL database Relational join on two tables Table of word counts from Shakespeare collection Table of word counts from the bible SELECT s word s freq k freq FROM shakespeare s JOIN bible k ON s word k word WHERE s freq 1 AND k freq 1 ORDER BY s freq DESC LIMIT 10 the I and to of a you my in is 25848 62394 23031 8854 19671 38985 18038 13526 16700 34654 14170 8057 12702 2720 11297 4135 10797 12445 88826884 Source Material drawn from Cloudera training VM Hive Behind the Scenes SELECT s word s freq k freq FROM shakespeare s JOIN bible k ON s word k word WHERE s freq 1 AND k freq 1 ORDER BY s freq DESC LIMIT 10 Abstract Syntax Tree TOK QUERY TOK FROM TOK JOIN TOK TABREF shakespeare s TOK TABREF bible k


Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Bigtable, Hive, and Pig and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Bigtable, Hive, and Pig and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?