コード例 #1
0
    @Override
    protected void setup(
        final Reducer<Text, CountofDoubleWritable, GeoWaveOutputKey, DistortionEntry>.Context
            context)
        throws IOException, InterruptedException {
      super.setup(context);
      final ScopedJobConfiguration config =
          new ScopedJobConfiguration(
              context.getConfiguration(),
              KMeansDistortionMapReduce.class,
              KMeansDistortionMapReduce.LOGGER);

      final int k = config.getInt(JumpParameters.Jump.COUNT_OF_CENTROIDS, -1);
      if (k > 0) {
        expectedK = k;
      }

      try {
        centroidManager =
            new CentroidManagerGeoWave<Object>(
                context, KMeansDistortionMapReduce.class, KMeansDistortionMapReduce.LOGGER);
      } catch (final Exception e) {
        KMeansDistortionMapReduce.LOGGER.warn("Unable to initialize centroid manager", e);
        throw new IOException("Unable to initialize centroid manager", e);
      }

      batchId =
          config.getString(GlobalParameters.Global.PARENT_BATCH_ID, centroidManager.getBatchId());
    }
コード例 #2
0
    @SuppressWarnings("unchecked")
    @Override
    protected void setup(
        final Mapper<GeoWaveInputKey, ObjectWritable, Text, CountofDoubleWritable>.Context context)
        throws IOException, InterruptedException {
      super.setup(context);
      final ScopedJobConfiguration config =
          new ScopedJobConfiguration(
              context.getConfiguration(),
              KMeansDistortionMapReduce.class,
              KMeansDistortionMapReduce.LOGGER);

      try {
        nestedGroupCentroidAssigner =
            new NestedGroupCentroidAssignment<Object>(
                context, KMeansDistortionMapReduce.class, KMeansDistortionMapReduce.LOGGER);
      } catch (final Exception e1) {
        throw new IOException(e1);
      }

      try {
        centroidExtractor =
            config.getInstance(
                CentroidParameters.Centroid.EXTRACTOR_CLASS,
                CentroidExtractor.class,
                SimpleFeatureCentroidExtractor.class);
      } catch (final Exception e1) {
        throw new IOException(e1);
      }

      try {
        itemWrapperFactory =
            config.getInstance(
                CentroidParameters.Centroid.WRAPPER_FACTORY_CLASS,
                AnalyticItemWrapperFactory.class,
                SimpleFeatureItemWrapperFactory.class);
      } catch (final Exception e1) {
        throw new IOException(e1);
      }
    }
コード例 #3
0
 @Override
 public Object getValue(
     final JobContext context, final Class<?> scope, final Object defaultValue) {
   final ScopedJobConfiguration scopedConfig =
       new ScopedJobConfiguration(context.getConfiguration(), scope);
   if (baseClass.isAssignableFrom(Integer.class)) {
     return Integer.valueOf(
         scopedConfig.getInt(parent.self(), ((Integer) defaultValue).intValue()));
   } else if (baseClass.isAssignableFrom(String.class)) {
     return scopedConfig.getString(parent.self(), defaultValue.toString());
   } else if (baseClass.isAssignableFrom(Double.class)) {
     return scopedConfig.getDouble(parent.self(), (Double) defaultValue);
   } else if (baseClass.isAssignableFrom(byte[].class)) {
     return scopedConfig.getBytes(parent.self());
   } else if ((defaultValue == null) || (defaultValue instanceof Class)) {
     try {
       return scopedConfig.getInstance(parent.self(), baseClass, (Class) defaultValue);
     } catch (InstantiationException | IllegalAccessException e) {
       LOGGER.error("Unable to get instance from job context", e);
     }
   }
   return null;
 }