You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@madlib.apache.org by GitBox <gi...@apache.org> on 2019/09/17 20:42:51 UTC

[GitHub] [madlib] orhankislal commented on a change in pull request #441: Kmeans: simplified silhouette per point for k-means

orhankislal commented on a change in pull request #441: Kmeans: simplified silhouette per point for k-means
URL: https://github.com/apache/madlib/pull/441#discussion_r325376247
 
 

 ##########
 File path: src/modules/linalg/metric.cpp
 ##########
 @@ -368,28 +368,33 @@ closest_column::run(AnyType& args) {
  */
 AnyType
 closest_columns::run(AnyType& args) {
-    MappedMatrix M = args[0].getAs<MappedMatrix>();
-    MappedColumnVector x = args[1].getAs<MappedColumnVector>();
-    uint32_t num = args[2].getAs<uint32_t>();
-    FunctionHandle dist = args[3].getAs<FunctionHandle>()
-        .unsetFunctionCallOptions(FunctionHandle::GarbageCollectionAfterCall);
-    string dist_fname = args[4].getAs<char *>();
-
-    std::string fname = dist_fn_name(dist_fname);
-
-    std::vector<std::tuple<Index, double> > result(num);
-    closestColumnsAndDistancesShortcut(M, x, dist, fname, result.begin(),
-        result.end());
-
-    MutableArrayHandle<int32_t> indices = allocateArray<int32_t,
-        dbal::FunctionContext, dbal::DoNotZero, dbal::ThrowBadAlloc>(num);
-    MutableArrayHandle<double> distances = allocateArray<double,
-        dbal::FunctionContext, dbal::DoNotZero, dbal::ThrowBadAlloc>(num);
-    for (uint32_t i = 0; i < num; ++i)
-        std::tie(indices[i], distances[i]) = result[i];
-
-    AnyType tuple;
-    return tuple << indices << distances;
+
+    try{
 
 Review comment:
   If the dataset has a null value in there, we want to return nothing for that particular row (because we cannot calculate the distance) instead of failing

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services