Fix overflow in decimal divide. Added warning if overflow happened.

Change-Id: I2e9167dbec83b3d1c2cf0e52fae4e09d6b5a38ce
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3141
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins
Perf improvements for the in-memory sort

The changes in this patch are:
 i) Remove the use of GetTuple(index) in the core loop of the sorter
    and move to a more iterator-like access pattern.
ii) Change TupleRowComparator to use a vector<uint8_t> instead of
    vector<bool> for is_asc_ and nulls_first_.

On "Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz",
with 1 impalad, tpch_parquet, scale factor 1GB, disable_outermost_topn = 1,
all sorts in memory.

select l_orderkey from lineitem order by l_orderkey desc limit 1 : ~2.1 s
select l_comment from lineitem order by l_comment desc limit 1 : ~6.96 s
select * from lineitem order by l_comment desc limit 1 : ~11.7 s
select * from lineitem order by l_orderkey desc limit 1 : ~4.8 s

Change-Id: I4f82534d54e05552df972e464159e680bff6bcb4
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3094
Reviewed-by: Srinath Shankar <sshankar@cloudera.com>
Tested-by: jenkins
IMPALA-1055: Compute stats query statements don't quote DB and table names

The compute stats statement was not quoting the DB and table names. If those names
were aliasing with keywords, then the compute stats would not execute due to a syntax
error.

Change-Id: Ie08421246bb54a63a44eaf19d0d835da780b7033
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3170
Reviewed-by: Ippokratis Pandis <ipandis@cloudera.com>
Tested-by: jenkins
Change memory allocation in buffered block manager and sorter

The sorter and block manager currently allocate all of their memory
up-front. This patch changes that so that memory is allocated as a run
is built. Only the minimum number of blocks required are allocated
up-front.
Added a non-blocking TryExpand() call to the buffered block manager to
allocate a new buffer and assign it to a block. The only place where this
is invoked is when the sorter tries to extend a run.
While there are other ways of doing this, this seemed like a minimally
invasive change to make at this point.
In the merge phase, the sorter does not try to allocate more buffers,
but instead works with the buffers allocated up to that point. This is
something that is pretty easy to change.
Other changes include:
a) There is no longer a max_available_buffers() in the block manager.
   Replaced by a combination of available_allocated_buffers() and
   TryExpand().
b) In WriteUnpinnedBlocks(), unallocated memory is taken into account
   to determine if blocks should be written out.
c) The sorter uses a block to copy out sorted var-len data when
   unpinning the blocks in a run. This block is now allocated up-front.

Change-Id: Ifbb2ffd679a882afe8895f4785ec6d7c49c30b98
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3148
Reviewed-by: Srinath Shankar <sshankar@cloudera.com>
Tested-by: jenkins
IMPALA-1040: Reading a decimal partitioned column with invalid values

This commit fixes IMPALA-1040 in which when an invalid value is inserted
to a decimal partitioned column through hive it results in a non
informative error message and in some cases in the associated table to
disappear from Impala's catalog. The fix results in a more informative
error message to always be thrown by Impala to indicate the insertion of
an invalid partition key value.

Change-Id: I2855ea69944e269fb7e02b3825f44e64352151e7
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3062
Reviewed-by: Dimitris Tsirogiannis <dtsirogiannis@cloudera.com>
Tested-by: jenkins