Association Rules: Rewrite Apriori for performance improvement

Jira: MADLIB-462 MADLIB-475 MADLIB-638

After studying the current implementation of Apriori, we found the following
issues:

1) The result was unstable, since it used the hash key to unique identify a
   svec.  As we know, two svecs may have the same hash key.  Therefore, we
   will not use the hash key.
2) There were a lot cross joins.  Actually, we can use inner join to do the
   same thing as the cross join did.  The cross join was making the process
   anti-scalable.
3) It was changing the sparse vector in many place, which caused the memory
   issues.  Now, we don't change the svec.  We just construct the svec and
   then do some operations(such as minus, multiply, etc) on that.
4) It used PLPGSQL to implement the algorithm, including aggregate function.

Based on the above analysis, we rewrite it. We use PLPYTHON and C++ AL to
address these.

Although we add code in UDF class for SRF, it is still pretty premature.
It has a lot of spaces to redesign for general purpose.
k-means: Check uniqueness of user-provided IDs

Jira: MADLIB-649
Madpack: Add pg_catalog prefix to version() call

Jira: MADLIB-473

Users may have search_path with madlib, public and madpack gets confused
when calling version() function.  Add pg_catalog prefix to make sure it's
the one in the platform.
k-means: Improve performance with array

Jira: MADLIB-454

It seems sparse vector was the bottleneck of the scalability.  We see 10
times faster in some of our use cases by using arrays instead of sparse
vectors.  Although we still have concerns around space efficiency, we
saw the arrays are also packed enough by the compression and toast mechanism.
Let's see by having this fix if our test cases verify the improvement.
 SVM: Limit the number of features in the training table

Jjra: MADLIB-602

If the number of features of a dataset is greater than 102400, then we will
report error.  This is due to the current implementation with array, which
has 1G size limit per datum.  If the table is empty, we will report an error,
too.
Build System: Remove GREENPLUM from m4_ifdef macro

Jira: MADLIB-639
New Method: Add linear-chain conditional random field for NLP

Jira: MADLIB-647

This is the addition of CRF on top of the existing Viterbi module.  The design
document still has some space to be improved, but hope additional work on it
in the future.
Association Rules: Disable in GPDB4.0

Jira: MADLIB-661

Comment out the 'assoc_rule' from src/ports/greenplum/4.0/config/Modules.yml,
as it's now using array_agg() which is not supported in GPDB 4.0.  We hope
to support this again by replacing array_agg() with our implementation in the
near future.
New k-means implementation, rewritten as an iteratively called aggregate function

Jira: MADLIB-522, MADLIB-585

k-Means:
- Complete redesign and rewrite. Main new features: 1) The new implementation is nothing more but an iteratively called aggregate function. No conversion between temporary tables and iteration states takes place. 2) The distance metric is fully pluggable. 3) Clear separation between the seeding algorithm and Lloyd's local search heuristic 4) The new code should be much easier to read and maintain
- Uses C++ AL
- First incarnation of general Python abstraction layer (currently still in kmeans.py, though). Main feature: No data movement between backend and PL/Python.

Utilities:
- Implemented a C function exec_sql_using() that can be used to emulate the EXECUTE ... USING command that is not available before PostgreSQL 8.4. This seems to be the only "guaranteed lossless" way to write function arguments into a table.
k-Means: Modularized recentering

Jira: MADLIB-522, MADLIB-586

Linear Algebra:
- Added the avg_vector UDA that computes the average of a set of vectors

k-means:
- Removed the internal kmeans_step aggregate. Instead, kmeans now asks for an aggregate function that calculates the mean, given a set of vectors.
- Added UDFs for simulating default arguments

Other changes:
- Renamed C file containing code for exec_sql_using()
- Added verbose mode to Python IterationController
k-means: Minor changes in SQL/Python code to reflect changes in design document

Jira: None

Changes:
- In the k-means SQL/Python code, replaced "col_" by "expr_", because users are
  not limited to passing column names but any expression that has the correct
  type.
- Fixed a compiler warning in avg_vector.cpp.
Vector operations: Added "distances" and normalized average

Jira: MADLIB-522, MADLIB-532

List of changes:

Vector operations:
- New functions: "sqaured_angle" and "squared_tanimoto"
- Added a UDA "normalized_avg"
- Changed UDA "avg_vector" to "avg".
- New unit tests

k-Means:
- Parameters "fn_squared_dist" and "agg_mean" now of type TEXT, so that
  specifying overloaded functions is easier and does not require passing a
  regprocedure value any more
k-Means: Verify that function parameters have correct signature

Jira: MADLIB-522
Revert "Temporarily deactivate random-sampling module for gppkg release [...]"

Jira: None

This reverts commit 15bfc3d and activates again the random-sampling module.
k-means: objective_fn in output, random seeding. Primitive unit test.

Jira: MADLIB-522

Changes:
- k-means now reports the value of the objective function (sum of squared
  distances, over all points) in the output.
- Random seeding is now included.
- Replace the old primitive unit test by a new primitive unit tests. The result
  is not checked for sanity.
k-means: Some tuning of the kmeans SQL

Jira: MADLIB-522

Performance tuning:
- It turns out that the inter-iteration state should better be accessed via
subqueries instead of joining the state table and adding a WHERE clause.
If there are multiple subqueries in a subquery, adding an OFFSET 0 can give
PostgreSQL/GP a hint that the outer query should not be flattened.
- Replaced all occurrences of the kmeans module by kmeans_new.
C++ AL: Directly call FunctionHandle without detour through the backend

Jira: MADLIB-672

Performance improvements. However, memory allocation/deallocation for boost any
type and boost function type are still expensive. Probably should resort to just
a pointer, even if it is less elegant and type safe.
k-means: Shortcut for 4 built-in distance functions

Jira: MADLIB-522

Changes:
- Added a kmeans() function that takes the initial centroids from a relation (as
  opposed to an array)
- As part of that, extended the exec_sql_using() function that now supports
  queries that return a single value
- Added a kmeans iteration state that is slightly different from the kmeans
  return type
- Slight refactoring of closest_column function: Now is a generic function that
  works both with UDFs and normal C++ functions. On top of that, implemented
  cheat for the four most used distance functions. In the future, additional
  performance tuning of the FunctionHandle class should make this cheat
  unnecessary
Sampling: Now use modular transition state of weighted sampling

Jira: MADLIB-499, MADLIB-584

Added a function for weighted sampling of vectors (previously only int64 was
supported). The C++ is completely generic.
New k-means: Removed argument point id from argument list

Jira: MADLIB-522

Now that we have a function to sample vectors directly, it is unnecessary to
supply a point id argument to k-means (it was only used for weighted sampling
in k-means++). This should improve performance and usability.

Other changes:
- Added return type to closest_column. On Greenplum, we would otherwise see an
  error of the form "cannot serialize transient record type".
- Adapted k-means unit tests.
- New unit test for kmeans with initial centroids provided in table
- Fixed oversight that squaredDistNorm1 did not return the square of the
  1-norm.
- C++ AL: Fixed bug in NativeArrayToMappedMatrix() and
  NativeArrayToMappedVector()