Hive Tez AM split computation based on the input format

Published Aug 03 2021 12:54 AM 1,214 Views
Microsoft

Introduction:

 

The performance of the query depend on the size and type of data each of Tez container processes. Split computation plays a major role when deciding on the number of containers required to run a specific query. This affects the cluster resource utilization, performance of the specific query and the performance & running of concurrent queries.

 

Problem often encounters:

 

With text based formats like Parquet, TextFormat for the data under Hive, the input splits is straight forward. It is calculated based on:

             

 

No. of data files = No. of splits

 

 

These data files could be combined with Tez grouping algorithm based on the data locality and rack awareness. This is affected by several factors. If TEZ_GROUPING_SPLIT_COUNT is set, the value will be used as initial count. Otherwise, the one passed in parameter will be used. Then the initial count will be corrected according to TEZ_GROUPING_SPLIT_MIN_SIZE and TEZ_GROUPING_SPLIT_MAX_SIZE: if the initial count causes a too small grouped split size, it will be overridden as total input size/TEZ_GROUPING_SPLIT_MIN_SIZE; if initial count causes too large grouped split size, it will be override as total input size/TEZ_GROUPING_SPLIT_MAX_SIZE.

 

// HiveSplitGenerator   

 

2017-02-16 15:56:48,862 [INFO] [InputInitializer {Map 1} #0] |tez.HiveSplitGenerator|: Number of input splits: 5. 3 available slots, 1.7 waves. Input format is: org.apache.hadoop.hive.ql.io.HiveInputFormat

 

 

// then grouping logic get called in HiveSplitGenerator

 

 

2017-02-16 15:56:48,891 [DEBUG] [InputInitializer {Map 1} #0] |tez.SplitGrouper|: Adding split hdfs://azure/apps/hive/warehouse/managed/hivesample01/sample1.csv to src new group? true

2017-02-16 15:56:48,891 [DEBUG] [InputInitializer {Map 1} #0] |tez.SplitGrouper|: Adding split hdfs://azure/apps/hive/warehouse/managed/hivesample01/sample1.csv to src new group? false

2017-02-16 15:56:48,891 [DEBUG] [InputInitializer {Map 1} #0] |tez.SplitGrouper|: Adding split hdfs://azure/apps/hive/warehouse/managed/hivesample01/sample1.csv to src new group? false

2017-02-16 15:56:48,891 [DEBUG] [InputInitializer {Map 1} #0] |tez.SplitGrouper|: Adding split hdfs://azure/apps/hive/warehouse/managed/hivesample01/sample1.csv to src new group? false

2017-02-16 15:56:48,892 [DEBUG] [InputInitializer {Map 1} #0] |tez.SplitGrouper|: Adding split hdfs://azure/apps/hive/warehouse/managed/hivesample01/sample1.csv to src new group? false

2017-02-16 15:56:48,892 [INFO] [InputInitializer {Map 1} #0] |tez.SplitGrouper|: # Src groups for split generation: 2

2017-02-16 15:56:48,893 [INFO] [InputInitializer {Map 1} #0] |tez.SplitGrouper|: Estimated number of tasks: 5 for bucket 1

 

 

org.apache.hadoop.mapred.split.TezMapredSplitsGrouper#getGroupedSplits(org.apache.hadoop.conf.Configuration, org.apache.hadoop.mapred.InputSplit[], int, java.lang.String, org.apache.hadoop.mapred.split.SplitSizeEstimator) based on tez.grouping.split-count

 

 

2017-02-16 15:56:48,894 [INFO] [InputInitializer {Map 1} #0] |split.TezMapredSplitsGrouper|: Grouping splits in Tez

2017-02-16 15:56:48,894 [INFO] [InputInitializer {Map 1} #0] |split.TezMapredSplitsGrouper|: Using original number of splits: 5 desired splits: 5

2017-02-16 15:56:48,897 [INFO] [InputInitializer {Map 1} #0] |tez.SplitGrouper|: Original split size is 5 grouped split size is 5, for bucket: 1

2017-02-16 15:56:48,899 [INFO] [InputInitializer {Map 1} #0] |tez.HiveSplitGenerator|: Number of grouped splits: 5

 

 

This could be addressed from the Hive end as well with hive.input.format=org.apache.hadoop.hive.ql.io.CombineHiveInputFormat.

 

If we set this parameter in hive-site.xml, it will be the default Hive InputFormat provided not setting 'hive.input.format' explicitly before the HQL.

The InputFormat in this scenario serves different function in comparison to the former one. Firstly, let's take a glance at 'org.apache.hadoop.mapred.FileInputFormat', which is the base class for all file-based InputFormat. There are three essential methods in this class:

 

 

boolean isSplitable(FileSystem fs, Path filename)
InputSplit[] getSplits(JobConf job, int numSplits)
RecordReader<K, V> getRecordReader(InputSplit split, JobConf job, Reporter reporter)

 

 

'isSplitable' is self-explaining: it will return whether the given filename is splitable. This method is valid when working around MapReduce program, when it comes to Hive-related one, we could set 'mapreduce.input.fileinputformat.split.minsize' in hive-site.xml to a very big value to achieve the same effect alternatively.

'getSplits' will return an array of InputSplit objects, whose size is corresponding to the number of mappers for this HQL task. Every InputSplit contains one or more file chunks in current file system, the details will be discussed later.

'getRecordReader' will return a 'org.apache.hadoop.mapred.RecordReader' object, whose function is to read data record by record from underlying file system. The main methods are as follows:

 

K createKey()
V createValue()
boolean next(K key, V value)
float getProgress()

 

 

'createKey', 'createValue' and 'getProgress' is well self-explaining. 'next' will evaluate the key and value parameters from current read position provided it returns true; when being at EOF, false is returned.

In the former case as mentioned above, only 'getRecordReader' method will be used; Whereas in the latter case, only 'getSplits' method will be used.

 

Suppose you have a file for the 200M, press the top HiveInputFormatof the split algorithm:

  1. The total file size is 200M, goalSize = 200M/2 = 100M, minSize = 1, splitSize = max {1, min {100M, 128M}} = 100M
  2. 200M/100M> 1.1, so the size of the first block is 100M
  3. The remaining file size is 100M, less than 128M, so the second block size is 100M.

Whereas, CombineHiveInputFormat of the split algorithm:

  1. 128M <200M <128M X 2, so the size of the first block is 128M
  2. The remaining file size is 200M-128M = 72M, 72M <128M, so the second block size is 72M

 

What happens when it’s a ORC table and why ORC:

 

Split Computation and Grouping by OrcInputFormat:

 

Firstly, OrcInputFormat reads all stripes from all input ORC files, and creates one split per stripe unless the stripe size is lower than mapreduce.input.fileinputformat.split.minsize value.

If the stripe is smaller than mapreduce.input.fileinputformat.split.minsize then OrcInputFormat combines multiple stripes into a single input split.

 

Split Grouping by Tez:

 

In addition to OrcInputFormat, the Tez engine can further group the input splits.

Initially Tez asks the YARN Resource Manager about the number of available containers, multiplies this number by tez.grouping.split-waves (1.7 by default; for more information about split ways, read Tez Internals #1 – Number of Map Tasks) and gets the desired number of input splits (and tasks).

From the Tez Application Master log you can see:

 

[INFO] [InputInitializer {Map 1} #0] |tez.HiveSplitGenerator|: Number of input splits: 1084. 337 available slots, 1.7 waves.
[INFO] [InputInitializer {Map 1} #0] |tez.SplitGrouper|: Estimated number of tasks: 572

 

1084 is the total number of stripes in all input ORC files, 337 is the total number of available containers, and 337 * 1.7 gives 572 tasks.

 

Tez knows that it wants to run 572 tasks, so it defines the average data size per task:

 

[INFO] [InputInitializer {Map 1} #0] |grouper.TezSplitGrouper|: Grouping splits in Tez
[INFO] [InputInitializer {Map 1} #0] |grouper.TezSplitGrouper|: Desired numSplits: 572 lengthPerGroup: 822989185 numLocations: 1 numSplitsPerLocation: 1084 numSplitsInGroup: 1 totalLength: 470749813876 numOriginalSplits: 1084 . Grouping by length: true count: false nodeLocalOnly: false

 

Tez calculates totalLength that is the total volume of input data to process. Note that Tez uses the column statistics from ORC files, not from Hive Metastore (!) to get the estimated uncompressed data size. That’s why totalLength is 470 GB while the total size of input ORC files is just 143 GB.

 

Knowing the total data size and the desired number of tasks, Tez gets lengthPerGroup, the desired size of input split: 470749813876/572 = 822989185. So the desired input split is 822 MB (!), and again it is the uncompressed data size.

 

Similar to OrcInputFormat, Tez also goes through all ORC stripes (actually input splits created by OrcInputFormat), but now it deals with the uncompressed data sizes.

If the input split is smaller than tez.grouping.min-size then it is combined with another split trying to create input splits having the lengthPerGroup size.

 

It is hard to get this exact size, since Tez has to operate with full ORC stripes, it cannot split a single stripe into multiple input splits.

 

ORC Split strategy:

 

There are three available options HYBRID, ETL and BI:

 

HYBRID: Reads the footers for all files if there are fewer files than expected mapper count, switching over to generating 1 split per file if the average file sizes are smaller than the default HDFS blocksize.

BI: Per file split. It will be faster when the number of files is less

ETL: Reads the File Footer and then decides the number of splits. There is a searchArg passed to the reader which can eliminate orc stripes/splits based on the filter condition provided in the query. This is used when you can allow ORC split to spend time on calculating the Splits and is used when the Query is large.

 

Accelerate the ORC split computation:

 

Tuning the default value of hive.orc.compute.splits.num.threads=10, set the value of this parameter to match the number of available processors. This parameter controls the number of parallel threads involved in computing splits. For Parquet computing splits is still single-threaded, so split computations can take longer with Parquet and Cloud Object Stores.

 

With hive.exec.orc.split.strateg=ETL, set hive.orc.splits.include.file.footer=true – This ensure Hive and Tez AM is aware of the split payload from the footer information.

 

References:

https://www.slideshare.net/Hadoop_Summit/orc-file-optimizing-your-big-data

https://community.hortonworks.com/articles/68631/optimizing-hive-queries-for-orc-formatted-tables.ht...

%3CLINGO-SUB%20id%3D%22lingo-sub-2602852%22%20slang%3D%22en-US%22%3EHive%20Tez%20AM%20split%20computation%20based%20on%20the%20input%20format%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2602852%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3EIntroduction%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThe%20performance%20of%20the%20query%20depend%20on%20the%20size%20and%20type%20of%20data%20each%20of%20Tez%20container%20processes.%20Split%20computation%20plays%20a%20major%20role%20when%20deciding%20on%20the%20number%20of%20containers%20required%20to%20run%20a%20specific%20query.%20This%20affects%20the%20cluster%20resource%20utilization%2C%20performance%20of%20the%20specific%20query%20and%20the%20performance%20%26amp%3B%20running%20of%20concurrent%20queries.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EProblem%20often%20encounters%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20text%20based%20formats%20like%20Parquet%2C%20TextFormat%20for%20the%20data%20under%20Hive%2C%20the%20input%20splits%20is%20straight%20forward.%20It%20is%20calculated%20based%20on%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3ENo.%20of%20data%20files%20%3D%20No.%20of%20splits%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThese%20data%20files%20could%20be%20combined%20with%20Tez%20grouping%20algorithm%20based%20on%20the%20data%20locality%20and%20rack%20awareness.%20This%20is%20affected%20by%20several%20factors.%20If%20TEZ_GROUPING_SPLIT_COUNT%20is%20set%2C%20the%20value%20will%20be%20used%20as%20initial%20count.%20Otherwise%2C%20the%20one%20passed%20in%20parameter%20will%20be%20used.%20Then%20the%20initial%20count%20will%20be%20corrected%20according%20to%20TEZ_GROUPING_SPLIT_MIN_SIZE%20and%20TEZ_GROUPING_SPLIT_MAX_SIZE%3A%20if%20the%20initial%20count%20causes%20a%20too%20small%20grouped%20split%20size%2C%20it%20will%20be%20overridden%20as%20total%20input%20size%2FTEZ_GROUPING_SPLIT_MIN_SIZE%3B%20if%20initial%20count%20causes%20too%20large%20grouped%20split%20size%2C%20it%20will%20be%20override%20as%20total%20input%20size%2FTEZ_GROUPING_SPLIT_MAX_SIZE.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%2F%2F%20HiveSplitGenerator%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E2017-02-16%2015%3A56%3A48%2C862%20%5BINFO%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Ctez.HiveSplitGenerator%7C%3A%20Number%20of%20input%20splits%3A%205.%203%20available%20slots%2C%201.7%20waves.%20Input%20format%20is%3A%20org.apache.hadoop.hive.ql.io.HiveInputFormat%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%2F%2F%20then%20grouping%20logic%20get%20called%20in%20HiveSplitGenerator%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E2017-02-16%2015%3A56%3A48%2C891%20%5BDEBUG%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Ctez.SplitGrouper%7C%3A%20Adding%20split%20hdfs%3A%2F%2Fazure%2Fapps%2Fhive%2Fwarehouse%2Fmanaged%2Fhivesample01%2Fsample1.csv%20to%20src%20new%20group%3F%20true%0A%0A2017-02-16%2015%3A56%3A48%2C891%20%5BDEBUG%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Ctez.SplitGrouper%7C%3A%20Adding%20split%20hdfs%3A%2F%2Fazure%2Fapps%2Fhive%2Fwarehouse%2Fmanaged%2Fhivesample01%2Fsample1.csv%20to%20src%20new%20group%3F%20false%0A%0A2017-02-16%2015%3A56%3A48%2C891%20%5BDEBUG%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Ctez.SplitGrouper%7C%3A%20Adding%20split%20hdfs%3A%2F%2Fazure%2Fapps%2Fhive%2Fwarehouse%2Fmanaged%2Fhivesample01%2Fsample1.csv%20to%20src%20new%20group%3F%20false%0A%0A2017-02-16%2015%3A56%3A48%2C891%20%5BDEBUG%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Ctez.SplitGrouper%7C%3A%20Adding%20split%20hdfs%3A%2F%2Fazure%2Fapps%2Fhive%2Fwarehouse%2Fmanaged%2Fhivesample01%2Fsample1.csv%20to%20src%20new%20group%3F%20false%0A%0A2017-02-16%2015%3A56%3A48%2C892%20%5BDEBUG%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Ctez.SplitGrouper%7C%3A%20Adding%20split%20hdfs%3A%2F%2Fazure%2Fapps%2Fhive%2Fwarehouse%2Fmanaged%2Fhivesample01%2Fsample1.csv%20to%20src%20new%20group%3F%20false%0A%0A2017-02-16%2015%3A56%3A48%2C892%20%5BINFO%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Ctez.SplitGrouper%7C%3A%20%23%20Src%20groups%20for%20split%20generation%3A%202%0A%0A2017-02-16%2015%3A56%3A48%2C893%20%5BINFO%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Ctez.SplitGrouper%7C%3A%20Estimated%20number%20of%20tasks%3A%205%20for%20bucket%201%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-left%22%3Eorg.apache.hadoop.mapred.split.TezMapredSplitsGrouper%23getGroupedSplits(org.apache.hadoop.conf.Configuration%2C%20org.apache.hadoop.mapred.InputSplit%5B%5D%2C%20int%2C%20java.lang.String%2C%20org.apache.hadoop.mapred.split.SplitSizeEstimator)%20based%20on%20tez.grouping.split-count%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-basic%22%3E%3CCODE%3E2017-02-16%2015%3A56%3A48%2C894%20%5BINFO%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Csplit.TezMapredSplitsGrouper%7C%3A%20Grouping%20splits%20in%20Tez%0A%0A2017-02-16%2015%3A56%3A48%2C894%20%5BINFO%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Csplit.TezMapredSplitsGrouper%7C%3A%20Using%20original%20number%20of%20splits%3A%205%20desired%20splits%3A%205%0A%0A2017-02-16%2015%3A56%3A48%2C897%20%5BINFO%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Ctez.SplitGrouper%7C%3A%20Original%20split%20size%20is%205%20grouped%20split%20size%20is%205%2C%20for%20bucket%3A%201%0A%0A2017-02-16%2015%3A56%3A48%2C899%20%5BINFO%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Ctez.HiveSplitGenerator%7C%3A%20Number%20of%20grouped%20splits%3A%205%0A%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EThis%20could%20be%20addressed%20from%20the%20Hive%20end%20as%20well%20with%20hive.input.format%3Dorg.apache.hadoop.hive.ql.io.CombineHiveInputFormat.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EIf%20we%20set%20this%20parameter%20in%20hive-site.xml%2C%20it%20will%20be%20the%20default%20Hive%20InputFormat%20provided%20not%20setting%20'hive.input.format'%20explicitly%20before%20the%20HQL.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThe%20InputFormat%20in%20this%20scenario%20serves%20different%20function%20in%20comparison%20to%20the%20former%20one.%20Firstly%2C%20let's%20take%20a%20glance%20at%20'org.apache.hadoop.mapred.FileInputFormat'%2C%20which%20is%20the%20base%20class%20for%20all%20file-based%20InputFormat.%20There%20are%20three%20essential%20methods%20in%20this%20class%3A%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3Eboolean%20isSplitable(FileSystem%20fs%2C%20Path%20filename)%0AInputSplit%5B%5D%20getSplits(JobConf%20job%2C%20int%20numSplits)%0ARecordReader%3CK%3E%20getRecordReader(InputSplit%20split%2C%20JobConf%20job%2C%20Reporter%20reporter)%3C%2FK%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E'isSplitable'%20is%20self-explaining%3A%20it%20will%20return%20whether%20the%20given%20filename%20is%20splitable.%20This%20method%20is%20valid%20when%20working%20around%20MapReduce%20program%2C%20when%20it%20comes%20to%20Hive-related%20one%2C%20we%20could%20set%20'mapreduce.input.fileinputformat.split.minsize'%20in%20hive-site.xml%20to%20a%20very%20big%20value%20to%20achieve%20the%20same%20effect%20alternatively.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E'getSplits'%20will%20return%20an%20array%20of%20InputSplit%20objects%2C%20whose%20size%20is%20corresponding%20to%20the%20number%20of%20mappers%20for%20this%20HQL%20task.%20Every%20InputSplit%20contains%20one%20or%20more%20file%20chunks%20in%20current%20file%20system%2C%20the%20details%20will%20be%20discussed%20later.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E'getRecordReader'%20will%20return%20a%20'org.apache.hadoop.mapred.RecordReader'%20object%2C%20whose%20function%20is%20to%20read%20data%20record%20by%20record%20from%20underlying%20file%20system.%20The%20main%20methods%20are%20as%20follows%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EK%20createKey()%0AV%20createValue()%0Aboolean%20next(K%20key%2C%20V%20value)%0Afloat%20getProgress()%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E'createKey'%2C%20'createValue'%20and%20'getProgress'%20is%20well%20self-explaining.%20'next'%20will%20evaluate%20the%20key%20and%20value%20parameters%20from%20current%20read%20position%20provided%20it%20returns%20true%3B%20when%20being%20at%20EOF%2C%20false%20is%20returned.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EIn%20the%20former%20case%20as%20mentioned%20above%2C%20only%20'getRecordReader'%20method%20will%20be%20used%3B%20Whereas%20in%20the%20latter%20case%2C%20only%20'getSplits'%20method%20will%20be%20used.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3ESuppose%20you%20have%20a%20file%20for%20the%20200M%2C%20press%20the%20top%20HiveInputFormatof%20the%20split%20algorithm%3A%3C%2FP%3E%0A%3COL%20class%3D%22lia-align-justify%22%3E%0A%3CLI%3EThe%20total%20file%20size%20is%20200M%2C%20goalSize%20%3D%20200M%2F2%20%3D%20100M%2C%20minSize%20%3D%201%2C%20splitSize%20%3D%20max%20%7B1%2C%20min%20%7B100M%2C%20128M%7D%7D%20%3D%20100M%3C%2FLI%3E%0A%3CLI%3E200M%2F100M%26gt%3B%201.1%2C%20so%20the%20size%20of%20the%20first%20block%20is%20100M%3C%2FLI%3E%0A%3CLI%3EThe%20remaining%20file%20size%20is%20100M%2C%20less%20than%20128M%2C%20so%20the%20second%20block%20size%20is%20100M.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EWhereas%2C%20CombineHiveInputFormat%20of%20the%20split%20algorithm%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%20class%3D%22lia-align-justify%22%3E128M%20%26lt%3B200M%20%26lt%3B128M%20X%202%2C%20so%20the%20size%20of%20the%20first%20block%20is%20128M%3C%2FLI%3E%0A%3CLI%20class%3D%22lia-align-justify%22%3EThe%20remaining%20file%20size%20is%20200M-128M%20%3D%2072M%2C%2072M%20%26lt%3B128M%2C%20so%20the%20second%20block%20size%20is%2072M%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWhat%20happens%20when%20it%E2%80%99s%20a%20ORC%20table%20and%20why%20ORC%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3ESplit%20Computation%20and%20Grouping%20by%20OrcInputFormat%3A%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EFirstly%2C%20OrcInputFormat%20reads%20all%20stripes%20from%20all%20input%20ORC%20files%2C%20and%20creates%20one%20split%20per%20stripe%20unless%20the%20stripe%20size%20is%20lower%20than%20mapreduce.input.fileinputformat.split.minsize%20value.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EIf%20the%20stripe%20is%20smaller%20than%20mapreduce.input.fileinputformat.split.minsize%20then%20OrcInputFormat%20combines%20multiple%20stripes%20into%20a%20single%20input%20split.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3ESplit%20Grouping%20by%20Tez%3A%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EIn%20addition%20to%20OrcInputFormat%2C%20the%20Tez%20engine%20can%20further%20group%20the%20input%20splits.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EInitially%20Tez%20asks%20the%20YARN%20Resource%20Manager%20about%20the%20number%20of%20available%20containers%2C%20multiplies%20this%20number%20by%20tez.grouping.split-waves%20(1.7%20by%20default%3B%20for%20more%20information%20about%20split%20ways%2C%20read%20Tez%20Internals%20%231%20%E2%80%93%20Number%20of%20Map%20Tasks)%20and%20gets%20the%20desired%20number%20of%20input%20splits%20(and%20tasks).%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EFrom%20the%20Tez%20Application%20Master%20log%20you%20can%20see%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%5BINFO%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Ctez.HiveSplitGenerator%7C%3A%20Number%20of%20input%20splits%3A%201084.%20337%20available%20slots%2C%201.7%20waves.%0A%5BINFO%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Ctez.SplitGrouper%7C%3A%20Estimated%20number%20of%20tasks%3A%20572%0A%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E1084%20is%20the%20total%20number%20of%20stripes%20in%20all%20input%20ORC%20files%2C%20337%20is%20the%20total%20number%20of%20available%20containers%2C%20and%20337%20*%201.7%20gives%20572%20tasks.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3ETez%20knows%20that%20it%20wants%20to%20run%20572%20tasks%2C%20so%20it%20defines%20the%20average%20data%20size%20per%20task%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%5BINFO%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Cgrouper.TezSplitGrouper%7C%3A%20Grouping%20splits%20in%20Tez%0A%5BINFO%5D%20%5BInputInitializer%20%7BMap%201%7D%20%230%5D%20%7Cgrouper.TezSplitGrouper%7C%3A%20Desired%20numSplits%3A%20572%20lengthPerGroup%3A%20822989185%20numLocations%3A%201%20numSplitsPerLocation%3A%201084%20numSplitsInGroup%3A%201%20totalLength%3A%20470749813876%20numOriginalSplits%3A%201084%20.%20Grouping%20by%20length%3A%20true%20count%3A%20false%20nodeLocalOnly%3A%20false%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3ETez%20calculates%20totalLength%20that%20is%20the%20total%20volume%20of%20input%20data%20to%20process.%20Note%20that%20Tez%20uses%20the%20column%20statistics%20from%20ORC%20files%2C%20not%20from%20Hive%20Metastore%20(!)%20to%20get%20the%20estimated%20uncompressed%20data%20size.%20That%E2%80%99s%20why%20totalLength%20is%20470%20GB%20while%20the%20total%20size%20of%20input%20ORC%20files%20is%20just%20143%20GB.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EKnowing%20the%20total%20data%20size%20and%20the%20desired%20number%20of%20tasks%2C%20Tez%20gets%20lengthPerGroup%2C%20the%20desired%20size%20of%20input%20split%3A%20470749813876%2F572%20%3D%20822989185.%20So%20the%20desired%20input%20split%20is%20822%20MB%20(!)%2C%20and%20again%20it%20is%20the%20uncompressed%20data%20size.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3ESimilar%20to%20OrcInputFormat%2C%20Tez%20also%20goes%20through%20all%20ORC%20stripes%20(actually%20input%20splits%20created%20by%20OrcInputFormat)%2C%20but%20now%20it%20deals%20with%20the%20uncompressed%20data%20sizes.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EIf%20the%20input%20split%20is%20smaller%20than%20tez.grouping.min-size%20then%20it%20is%20combined%20with%20another%20split%20trying%20to%20create%20input%20splits%20having%20the%20lengthPerGroup%20size.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EIt%20is%20hard%20to%20get%20this%20exact%20size%2C%20since%20Tez%20has%20to%20operate%20with%20full%20ORC%20stripes%2C%20it%20cannot%20split%20a%20single%20stripe%20into%20multiple%20input%20splits.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EORC%20Split%20strategy%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EThere%20are%20three%20available%20options%20HYBRID%2C%20ETL%20and%20BI%3A%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%3CSTRONG%3EHYBRID%3A%3C%2FSTRONG%3E%20Reads%20the%20footers%20for%20all%20files%20if%20there%20are%20fewer%20files%20than%20expected%20mapper%20count%2C%20switching%20over%20to%20generating%201%20split%20per%20file%20if%20the%20average%20file%20sizes%20are%20smaller%20than%20the%20default%20HDFS%20blocksize.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%3CSTRONG%3EBI%3A%3C%2FSTRONG%3E%20Per%20file%20split.%20It%20will%20be%20faster%20when%20the%20number%20of%20files%20is%20less%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%3CSTRONG%3EETL%3A%3C%2FSTRONG%3E%20Reads%20the%20File%20Footer%20and%20then%20decides%20the%20number%20of%20splits.%20There%20is%20a%20searchArg%20passed%20to%20the%20reader%20which%20can%20eliminate%20orc%20stripes%2Fsplits%20based%20on%20the%20filter%20condition%20provided%20in%20the%20query.%20This%20is%20used%20when%20you%20can%20allow%20ORC%20split%20to%20spend%20time%20on%20calculating%20the%20Splits%20and%20is%20used%20when%20the%20Query%20is%20large.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAccelerate%20the%20ORC%20split%20computation%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3ETuning%20the%20default%20value%20of%20hive.orc.compute.splits.num.threads%3D10%2C%20set%20the%20value%20of%20this%20parameter%20to%20match%20the%20number%20of%20available%20processors.%20This%20parameter%20controls%20the%20number%20of%20parallel%20threads%20involved%20in%20computing%20splits.%20%3CSTRONG%3EFor%20Parquet%20computing%20splits%20is%20still%20single-threaded%2C%20so%20split%20computations%20can%20take%20longer%20with%20Parquet%20and%20Cloud%20Object%20Stores.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3EWith%20hive.exec.orc.split.strateg%3DETL%2C%20set%20hive.orc.splits.include.file.footer%3Dtrue%20%E2%80%93%20This%20ensure%20Hive%20and%20Tez%20AM%20is%20aware%20of%20the%20split%20payload%20from%20the%20footer%20information.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-justify%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EReferences%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.slideshare.net%2FHadoop_Summit%2Forc-file-optimizing-your-big-data%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fwww.slideshare.net%2FHadoop_Summit%2Forc-file-optimizing-your-big-data%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.hortonworks.com%2Farticles%2F68631%2Foptimizing-hive-queries-for-orc-formatted-tables.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fcommunity.hortonworks.com%2Farticles%2F68631%2Foptimizing-hive-queries-for-orc-formatted-tables.html%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2602852%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22inputfile.png%22%20style%3D%22width%3A%20555px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F300092i0406A3EF813B942A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22inputfile.png%22%20alt%3D%22Hive%20Input%20Split%20and%20effect%20on%20the%20number%20of%20Tez%20tasks%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EHive%20Input%20Split%20and%20effect%20on%20the%20number%20of%20Tez%20tasks%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2602852%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EHDInsight%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Aug 03 2021 12:54 AM
Updated by: