druid icon indicating copy to clipboard operation
druid copied to clipboard

Batch indexing spatial dimensions on Hadoop 2.6 fails

Open dclim opened this issue 11 years ago • 5 comments

When trying to index data using a spec that contains a spatial dimension, the following is thrown in Hadoop 2.6:

com.google.common.primitives.Floats.tryParse(Ljava/lang/String;)Ljava/lang/Float;
2015-10-23T19:52:25,699 INFO [task-runner-0] org.apache.hadoop.mapreduce.Job - Task Id : attempt_1444427552702_0021_r_000003_2, Status : FAILED

Cause is the use of Floats.tryParse() in SpatialDimensionRowTransformer, which wasn't introduced until Guava 14 (Hadoop 2.6/2.7.1 still use Guava 11):

  private boolean isSpatialDimValsValid(List<String> dimVals)
  {
    if (dimVals == null || dimVals.isEmpty()) {
      return false;
    }
    for (String dimVal : dimVals) {
      if (Floats.tryParse(dimVal) == null) {
        return false;
      }
    }
    return true;
  }

  private boolean isJoinedSpatialDimValValid(String dimVal)
  {
    if (dimVal == null || dimVal.isEmpty()) {
      return false;
    }
    Iterable<String> dimVals = SPLITTER.split(dimVal);
    for (String val : dimVals) {
      if (Floats.tryParse(val) == null) {
        return false;
      }
    }
    return true;
  }

dclim avatar Oct 26 '15 21:10 dclim

This should be present for all versions of hadoop then, right?

drcrallen avatar Oct 26 '15 21:10 drcrallen

Yeah, pretty sure the issue exists for all Hadoop.

dclim avatar Oct 26 '15 21:10 dclim

We can remove Floats.tryParse and use something else that's available in older versions of Guava.

On Mon, Oct 26, 2015 at 2:33 PM, David Lim [email protected] wrote:

Yeah, pretty sure the issue exists for all Hadoop.

— Reply to this email directly or view it on GitHub https://github.com/druid-io/druid/issues/1866#issuecomment-151291099.

fjy avatar Oct 26 '15 22:10 fjy

We could just use the core Float.parseFloat() and catch the NumberFormatException and return false, as long as we're not concerned about the performance implication of throwing/catching the exception, which is probably not a big deal since this is used at ingestion time and validation failures are the exception rather than the norm.

dclim avatar Oct 26 '15 22:10 dclim

that sounds good

fjy avatar Oct 26 '15 22:10 fjy