org.apache.hadoop.io.ObjectWritable Java Examples

The following examples show how to use org.apache.hadoop.io.ObjectWritable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConvexHullMapReduce.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Override
protected void mapNativeValue(
    final GeoWaveInputKey key,
    final Object value,
    final org.apache.hadoop.mapreduce.Mapper<GeoWaveInputKey, ObjectWritable, GeoWaveInputKey, ObjectWritable>.Context context)
    throws IOException, InterruptedException {

  @SuppressWarnings("unchecked")
  final AnalyticItemWrapper<T> wrapper = itemWrapperFactory.create((T) value);
  outputKey.setInternalAdapterId(key.getInternalAdapterId());
  outputKey.setDataId(
      new ByteArray(
          StringUtils.stringToBinary(nestedGroupCentroidAssigner.getGroupForLevel(wrapper))));
  outputKey.setGeoWaveKey(key.getGeoWaveKey());
  context.write(outputKey, currentValue);
}
 
Example #2
Source File: GeoWaveDedupeJobRunner.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure(final Job job) throws Exception {

  job.setJobName("GeoWave Dedupe (" + dataStoreOptions.getGeoWaveNamespace() + ")");

  job.setMapperClass(GeoWaveDedupeMapper.class);
  job.setCombinerClass(GeoWaveDedupeCombiner.class);
  job.setReducerClass(getReducer());
  job.setMapOutputKeyClass(GeoWaveInputKey.class);
  job.setMapOutputValueClass(ObjectWritable.class);
  job.setOutputKeyClass(GeoWaveInputKey.class);
  job.setOutputValueClass(ObjectWritable.class);

  job.setInputFormatClass(GeoWaveInputFormat.class);
  job.setOutputFormatClass(getOutputFormatClass());
  job.setNumReduceTasks(getNumReduceTasks());

  job.setSpeculativeExecution(false);

  try (final FileSystem fs = FileSystem.get(job.getConfiguration())) {
    final Path outputPath = getHdfsOutputPath();
    fs.delete(outputPath, true);
    FileOutputFormat.setOutputPath(job, outputPath);
  }
}
 
Example #3
Source File: InputToOutputKeyReducer.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Override
protected void setup(
    final Reducer<GeoWaveInputKey, ObjectWritable, GeoWaveOutputKey, Object>.Context context)
    throws IOException, InterruptedException {
  super.setup(context);
  internalAdapterStore = GeoWaveOutputFormat.getJobContextInternalAdapterStore(context);
  final ScopedJobConfiguration config =
      new ScopedJobConfiguration(
          context.getConfiguration(),
          InputToOutputKeyReducer.class,
          LOGGER);
  outputKey =
      new GeoWaveOutputKey(
          "na",
          new String[] {config.getString(OutputParameters.Output.INDEX_ID, "na")});
}
 
Example #4
Source File: SimpleFeatureOutputReducer.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Override
protected void reduceNativeValues(
    final GeoWaveInputKey key,
    final Iterable<Object> values,
    final ReduceContext<GeoWaveInputKey, ObjectWritable, GeoWaveInputKey, Object> context)
    throws IOException, InterruptedException {
  final Iterator<Object> valIt = values.iterator();
  if (valIt.hasNext()) {
    key.setInternalAdapterId( // TODO this is a bit of a hack, but the
        // adapter is seemingly completely
        // transient and never actually
        // persisted - it seems unlikely that
        // the value for internal adapter ID
        // even matters, but if it does this is
        // the best effort
        InternalAdapterStoreImpl.getLazyInitialAdapterId(outputAdapter.getTypeName()));
    final SimpleFeature feature = getSimpleFeature(key, valIt.next());
    context.write(key, feature);
  }
}
 
Example #5
Source File: TestNiFiRecordSerDe.java    From nifi with Apache License 2.0 6 votes vote down vote up
public void testSimpleArray(String typeName, DataType elementDataType, Object[] values, Object[] expected) throws SerDeException {
    NiFiRecordSerDe serDe = createSerDe("listc",
            "array<" + typeName + ">"
    );

    RecordSchema schema = new SimpleRecordSchema(Collections.singletonList(
            new RecordField("listc", RecordFieldType.ARRAY.getArrayDataType(elementDataType))
    ));

    Object deserialized = serDe.deserialize(new ObjectWritable(new MapRecord(schema, new HashMap<String, Object>() {{
        put("listc", values);
    }})));

    List<Object> fields = (List<Object>)deserialized;
    assertEquals(1, fields.size());
    List<Object> nested = (List<Object>) fields.get(0);

    for(int i=0; i<expected.length; i++){
        assertEquals(expected[i], nested.get(i));
    }
}
 
Example #6
Source File: KSamplerMapReduce.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Override
protected void reduceNativeValues(
    final GeoWaveInputKey key,
    final Iterable<Object> values,
    final Reducer<GeoWaveInputKey, ObjectWritable, GeoWaveOutputKey, T>.Context context)
    throws IOException, InterruptedException {

  final String groupID = KeyManager.getGroupAsString(key.getDataId().getBytes());

  for (final Object value : values) {
    final AnalyticItemWrapper<T> sampleItem = itemWrapperFactory.create((T) value);
    Integer outputCount = outputCounts.get(groupID);
    outputCount = outputCount == null ? Integer.valueOf(0) : outputCount;
    if ((outputCount == null) || (outputCount < maxCount)) {

      final AnalyticItemWrapper<T> centroid = createCentroid(groupID, sampleItem);
      if (centroid != null) {
        context.write(
            new GeoWaveOutputKey(sampleDataTypeName, indexNames),
            centroid.getWrappedItem());
        outputCount++;
        outputCounts.put(groupID, outputCount);
      }
    }
  }
}
 
Example #7
Source File: GeoWaveDedupeReducer.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
protected void reduce(
    final GeoWaveInputKey key,
    final Iterable<ObjectWritable> values,
    final Reducer<GeoWaveInputKey, ObjectWritable, GeoWaveInputKey, ObjectWritable>.Context context)
    throws IOException, InterruptedException {
  final Iterator<ObjectWritable> objects = values.iterator();
  if (objects.hasNext()) {
    context.write(key, objects.next());
  }
}
 
Example #8
Source File: GeoWaveWritableOutputReducer.java    From geowave with Apache License 2.0 5 votes vote down vote up
protected void reduceWritableValues(
    final KEYIN key,
    final Iterable<VALUEIN> values,
    final Reducer<KEYIN, VALUEIN, GeoWaveInputKey, ObjectWritable>.Context context)
    throws IOException, InterruptedException {
  reduceNativeValues(key, values, new NativeReduceContext(context, serializationTool));
}
 
Example #9
Source File: GeoWaveDedupeCombiner.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
protected void reduce(
    final GeoWaveInputKey key,
    final Iterable<ObjectWritable> values,
    final Reducer<GeoWaveInputKey, ObjectWritable, GeoWaveInputKey, ObjectWritable>.Context context)
    throws IOException, InterruptedException {
  final Iterator<ObjectWritable> it = values.iterator();
  while (it.hasNext()) {
    final ObjectWritable next = it.next();
    if (next != null) {
      context.write(key, next);
      return;
    }
  }
}
 
Example #10
Source File: GeoWaveWritableInputMapper.java    From geowave with Apache License 2.0 5 votes vote down vote up
protected void mapWritableValue(
    final GeoWaveInputKey key,
    final ObjectWritable value,
    final Mapper<GeoWaveInputKey, ObjectWritable, KEYOUT, VALUEOUT>.Context context)
    throws IOException, InterruptedException {
  mapNativeValue(key, serializationTool.fromWritable(key.getInternalAdapterId(), value), context);
}
 
Example #11
Source File: LinkRank.java    From nutch-htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Runs the link analysis job. The link analysis job applies the link rank
 * formula to create a score per url and stores that score in the NodeDb.
 * 
 * Typically the link analysis job is run a number of times to allow the link
 * rank scores to converge.
 * 
 * @param nodeDb The node database from which we are getting previous link
 * rank scores.
 * @param inverted The inverted inlinks
 * @param output The link analysis output.
 * @param iteration The current iteration number.
 * @param numIterations The total number of link analysis iterations
 * 
 * @throws IOException If an error occurs during link analysis.
 */
private void runAnalysis(Path nodeDb, Path inverted, Path output,
  int iteration, int numIterations, float rankOne)
  throws IOException {

  JobConf analyzer = new NutchJob(getConf());
  analyzer.set("link.analyze.iteration", String.valueOf(iteration + 1));
  analyzer.setJobName("LinkAnalysis Analyzer, iteration " + (iteration + 1)
    + " of " + numIterations);
  FileInputFormat.addInputPath(analyzer, nodeDb);
  FileInputFormat.addInputPath(analyzer, inverted);
  FileOutputFormat.setOutputPath(analyzer, output);
  analyzer.set("link.analyze.rank.one", String.valueOf(rankOne));
  analyzer.setMapOutputKeyClass(Text.class);
  analyzer.setMapOutputValueClass(ObjectWritable.class);
  analyzer.setInputFormat(SequenceFileInputFormat.class);
  analyzer.setMapperClass(Analyzer.class);
  analyzer.setReducerClass(Analyzer.class);
  analyzer.setOutputKeyClass(Text.class);
  analyzer.setOutputValueClass(Node.class);
  analyzer.setOutputFormat(MapFileOutputFormat.class);
  analyzer.setBoolean("mapreduce.fileoutputcommitter.marksuccessfuljobs", false);

  LOG.info("Starting analysis job");
  try {
    JobClient.runJob(analyzer);
  }
  catch (IOException e) {
    LOG.error(StringUtils.stringifyException(e));
    throw e;
  }
  LOG.info("Finished analysis job.");
}
 
Example #12
Source File: GeoWaveMapper.java    From geowave with Apache License 2.0 5 votes vote down vote up
protected void mapWritableValue(
    final GeoWaveInputKey key,
    final ObjectWritable value,
    final Mapper<GeoWaveInputKey, ObjectWritable, GeoWaveInputKey, ObjectWritable>.Context context)
    throws IOException, InterruptedException {
  mapNativeValue(
      key,
      serializationTool.fromWritable(key.getInternalAdapterId(), value),
      new NativeMapContext<>(context, serializationTool));
}
 
Example #13
Source File: GeoWaveMapper.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
protected void map(
    final GeoWaveInputKey key,
    final ObjectWritable value,
    final Mapper<GeoWaveInputKey, ObjectWritable, GeoWaveInputKey, ObjectWritable>.Context context)
    throws IOException, InterruptedException {
  mapWritableValue(key, value, context);
}
 
Example #14
Source File: Loops.java    From nutch-htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Takes any node that has inlinks and sets up a route for all of its
 * outlinks. These routes will then be followed to a maximum depth inside of
 * the Looper job.
 */
public void reduce(Text key, Iterator<ObjectWritable> values,
  OutputCollector<Text, Route> output, Reporter reporter)
  throws IOException {

  String url = key.toString();
  Node node = null;
  List<LinkDatum> outlinkList = new ArrayList<LinkDatum>();

  // collect all outlinks and assign node
  while (values.hasNext()) {
    ObjectWritable objWrite = values.next();
    Object obj = objWrite.get();
    if (obj instanceof LinkDatum) {
      outlinkList.add((LinkDatum)obj);
    }
    else if (obj instanceof Node) {
      node = (Node)obj;
    }
  }

  // has to have inlinks otherwise cycle not possible
  if (node != null) {

    int numInlinks = node.getNumInlinks();
    if (numInlinks > 0) {

      // initialize and collect a route for every outlink
      for (LinkDatum datum : outlinkList) {
        String outlinkUrl = datum.getUrl();
        Route route = new Route();
        route.setFound(false);
        route.setLookingFor(url);
        route.setOutlinkUrl(outlinkUrl);
        output.collect(new Text(outlinkUrl), route);
      }
    }
  }
}
 
Example #15
Source File: GroupAssigmentJobRunner.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(final Job job) throws Exception {
  job.setMapperClass(GroupAssignmentMapReduce.GroupAssignmentMapper.class);
  job.setMapOutputKeyClass(GeoWaveInputKey.class);
  job.setMapOutputValueClass(ObjectWritable.class);
  job.setReducerClass(Reducer.class);
  job.setOutputKeyClass(GeoWaveInputKey.class);
  job.setOutputValueClass(ObjectWritable.class);
}
 
Example #16
Source File: LinkRank.java    From nutch-htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Runs the inverter job. The inverter job flips outlinks to inlinks to be
 * passed into the analysis job.
 * 
 * The inverter job takes a link loops database if it exists. It is an
 * optional componenet of link analysis due to its extreme computational and
 * space requirements but it can be very useful is weeding out and eliminating
 * link farms and other spam pages.
 * 
 * @param nodeDb The node database to use.
 * @param outlinkDb The outlink database to use.
 * @param loopDb The loop database to use if it exists.
 * @param output The output directory.
 * 
 * @throws IOException If an error occurs while running the inverter job.
 */
private void runInverter(Path nodeDb, Path outlinkDb, Path loopDb, Path output)
  throws IOException {

  // configure the inverter
  JobConf inverter = new NutchJob(getConf());
  inverter.setJobName("LinkAnalysis Inverter");
  FileInputFormat.addInputPath(inverter, nodeDb);
  FileInputFormat.addInputPath(inverter, outlinkDb);

  // add the loop database if it exists, isn't null
  if (loopDb != null) {
    FileInputFormat.addInputPath(inverter, loopDb);
  }
  FileOutputFormat.setOutputPath(inverter, output);
  inverter.setInputFormat(SequenceFileInputFormat.class);
  inverter.setMapperClass(Inverter.class);
  inverter.setReducerClass(Inverter.class);
  inverter.setMapOutputKeyClass(Text.class);
  inverter.setMapOutputValueClass(ObjectWritable.class);
  inverter.setOutputKeyClass(Text.class);
  inverter.setOutputValueClass(LinkDatum.class);
  inverter.setOutputFormat(SequenceFileOutputFormat.class);
  inverter.setBoolean("mapreduce.fileoutputcommitter.marksuccessfuljobs", false);

  // run the inverter job
  LOG.info("Starting inverter job");
  try {
    JobClient.runJob(inverter);
  }
  catch (IOException e) {
    LOG.error(StringUtils.stringifyException(e));
    throw e;
  }
  LOG.info("Finished inverter job.");
}
 
Example #17
Source File: KSamplerMapReduceTest.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Test
public void testMapperWithZeroRank() throws IOException {
  capturedObjects.clear();
  mapDriver.getConfiguration().setClass(
      GeoWaveConfiguratorBase.enumToConfKey(
          KSamplerMapReduce.class,
          SampleParameters.Sample.SAMPLE_RANK_FUNCTION),
      TestSamplingNoRankFunction.class,
      SamplingRankFunction.class);

  final GeoWaveInputKey inputKey = new GeoWaveInputKey();
  inputKey.setInternalAdapterId(internalAdapterId);
  inputKey.setDataId(new ByteArray("abc".getBytes()));

  final ObjectWritable ow = new ObjectWritable();
  ow.set(new TestObjectWritable(new TestObject(new Coordinate(25.4, 25.6), "abc")));

  final GeoWaveInputKey outputKey = new GeoWaveInputKey();
  outputKey.setInternalAdapterId(internalAdapterId);

  final ByteBuffer keyBuf = ByteBuffer.allocate(64);
  keyBuf.putDouble(0.0);
  keyBuf.putInt(3);
  keyBuf.put(inputKey.getDataId().getBytes());
  outputKey.setDataId(new ByteArray(keyBuf.array()));

  mapDriver.withInput(inputKey, ow);

  final List<Pair<GeoWaveInputKey, ObjectWritable>> results = mapDriver.run();

  assertEquals(0, results.size());

  // results from sample rank function to make sure it was provided the
  // correct object
  assertEquals(1, capturedObjects.size());
  assertEquals("abc", ((TestObject) capturedObjects.get(0)).id);
}
 
Example #18
Source File: KMeansDistortionMapReduceTest.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Test
public void testMapper() throws IOException {

  final GeoWaveInputKey inputKey = new GeoWaveInputKey();
  inputKey.setInternalAdapterId(adapterId);
  inputKey.setDataId(new ByteArray("abc".getBytes()));

  final ObjectWritable ow = new ObjectWritable();
  ow.set(
      new FeatureWritable(
          ftype,
          AnalyticFeature.createGeometryFeature(
              ftype,
              batchId,
              "123",
              "fred",
              grp1,
              20.30203,
              factory.createPoint(new Coordinate(02.33, 0.23)),
              new String[] {"extra1"},
              new double[] {0.022},
              1,
              1,
              0)));

  mapDriver.withInput(inputKey, ow);

  final List<Pair<Text, CountofDoubleWritable>> results = mapDriver.run();
  // output key has the dataID adjusted to contain the rank
  assertEquals(results.get(0).getFirst().toString(), grp1);
  // output value is the same as input value
  assertEquals(results.get(0).getSecond().getValue(), 0.0, 0.0001);
}
 
Example #19
Source File: StoreCopyReducer.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
protected void setup(
    final Reducer<GeoWaveInputKey, ObjectWritable, GeoWaveOutputKey, Object>.Context context)
    throws IOException, InterruptedException {
  super.setup(context);
  store = GeoWaveOutputFormat.getJobContextAdapterIndexMappingStore(context);
  internalAdapterStore = GeoWaveOutputFormat.getJobContextInternalAdapterStore(context);
}
 
Example #20
Source File: GeoWaveReducer.java    From geowave with Apache License 2.0 5 votes vote down vote up
protected void reduceWritableValues(
    final GeoWaveInputKey key,
    final Iterable<ObjectWritable> values,
    final Reducer<GeoWaveInputKey, ObjectWritable, GeoWaveInputKey, ObjectWritable>.Context context)
    throws IOException, InterruptedException {
  final HadoopWritableSerializer<?, Writable> serializer =
      serializationTool.getHadoopWritableSerializerForAdapter(key.getInternalAdapterId());
  final Iterable<Object> transformedValues = Iterables.transform(values, writable -> {
    final Object innerObj = writable.get();
    return innerObj instanceof Writable ? serializer.fromWritable((Writable) innerObj) : innerObj;
  });

  reduceNativeValues(key, transformedValues, new NativeReduceContext(context, serializationTool));
}
 
Example #21
Source File: DBScanMapReduceTest.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Test
public void test8With4() throws IOException {

  final Random r = new Random(3434);
  for (int i = 0; i < 8; i++) {
    final SimpleFeature feature =
        createTestFeature(
            "f" + i,
            new Coordinate(
                round(30.0 + (r.nextGaussian() * 0.00001)),
                round(30.0 + (r.nextGaussian() * 0.00001))));
    mapDriver.addInput(new GeoWaveInputKey(adapterId, new ByteArray(feature.getID())), feature);
  }

  final List<Pair<PartitionDataWritable, AdapterWithObjectWritable>> mapperResults =
      mapDriver.run();

  final List<Pair<PartitionDataWritable, List<AdapterWithObjectWritable>>> partitions =
      getReducerDataFromMapperInput(mapperResults);

  reduceDriver.addAll(partitions);

  reduceDriver.getConfiguration().setInt(
      GeoWaveConfiguratorBase.enumToConfKey(
          NNMapReduce.class,
          ClusteringParameters.Clustering.MINIMUM_SIZE),
      4);

  final List<Pair<GeoWaveInputKey, ObjectWritable>> reduceResults = reduceDriver.run();
  assertEquals(1, reduceResults.size());
}
 
Example #22
Source File: Loops.java    From nutch-htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Wraps values in ObjectWritable.
 */
public void map(Text key, Writable value,
  OutputCollector<Text, ObjectWritable> output, Reporter reporter)
  throws IOException {

  ObjectWritable objWrite = new ObjectWritable();
  objWrite.set(value);
  output.collect(key, objWrite);
}
 
Example #23
Source File: KSamplerMapReduce.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public int getPartition(
    final GeoWaveInputKey key,
    final ObjectWritable val,
    final int numPartitions) {
  final byte[] grpIDInBytes = KeyManager.getGroup(key.getDataId().getBytes());
  final int partition = hash(grpIDInBytes) % numPartitions;
  return partition;
}
 
Example #24
Source File: ScoreUpdater.java    From nutch-htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Changes input into ObjectWritables.
 */
public void map(Text key, Writable value,
  OutputCollector<Text, ObjectWritable> output, Reporter reporter)
  throws IOException {

  ObjectWritable objWrite = new ObjectWritable();
  objWrite.set(value);
  output.collect(key, objWrite);
}
 
Example #25
Source File: TestNiFiRecordSerDe.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testStructField() throws SerDeException{
    NiFiRecordSerDe serDe = createSerDe("structc",
            "struct<age:int,name:string>"
    );
    RecordSchema innerSchema = new SimpleRecordSchema(Arrays.asList(
            new RecordField("age", RecordFieldType.INT.getDataType()),
            new RecordField("name", RecordFieldType.STRING.getDataType())
    ));
    RecordSchema schema = new SimpleRecordSchema(Collections.singletonList(
            new RecordField("structc", RecordFieldType.RECORD.getRecordDataType(innerSchema))
    ));

    HashMap<String, Object> value = new HashMap<String, Object>() {{
        put("structc", new MapRecord(innerSchema, new HashMap<String, Object>() {{
            put("age", 15);
            put("name", "gideon");
        }}));
    }};

    List<Object> expected = Collections.singletonList(
            Arrays.asList(15, "gideon")
    );

    Object deserialized = serDe.deserialize(new ObjectWritable(new MapRecord(schema, value)));

    assertEquals(expected, deserialized);
}
 
Example #26
Source File: GeoWaveWritableInputReducer.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
protected void reduce(
    final GeoWaveInputKey key,
    final Iterable<ObjectWritable> values,
    final Reducer<GeoWaveInputKey, ObjectWritable, KEYOUT, VALUEOUT>.Context context)
    throws IOException, InterruptedException {
  reduceWritableValues(key, values, context);
}
 
Example #27
Source File: GeoWaveInputLoadJobRunner.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(final Job job) throws Exception {

  job.setMapperClass(Mapper.class);
  job.setReducerClass(InputToOutputKeyReducer.class);
  job.setMapOutputKeyClass(GeoWaveInputKey.class);
  job.setMapOutputValueClass(ObjectWritable.class);
  job.setOutputKeyClass(GeoWaveOutputKey.class);
  job.setOutputValueClass(Object.class);
  job.setSpeculativeExecution(false);

  job.setJobName("GeoWave Input to Output");
  job.setReduceSpeculativeExecution(false);
}
 
Example #28
Source File: ConvexHullJobRunner.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(final Job job) throws Exception {
  job.setMapperClass(ConvexHullMapReduce.ConvexHullMap.class);
  job.setMapOutputKeyClass(GeoWaveInputKey.class);
  job.setMapOutputValueClass(ObjectWritable.class);
  job.setReducerClass(ConvexHullMapReduce.ConvexHullReducer.class);
  job.setReduceSpeculativeExecution(false);
  job.setOutputKeyClass(GeoWaveOutputKey.class);
  job.setOutputValueClass(Object.class);
}
 
Example #29
Source File: InputToOutputKeyReducer.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
protected void reduceNativeValues(
    final GeoWaveInputKey key,
    final Iterable<Object> values,
    final Reducer<GeoWaveInputKey, ObjectWritable, GeoWaveOutputKey, Object>.Context context)
    throws IOException, InterruptedException {
  outputKey.setTypeName(internalAdapterStore.getTypeName(key.getInternalAdapterId()));
  for (final Object value : values) {
    context.write(outputKey, value);
  }
}
 
Example #30
Source File: HiveRecordWriter.java    From nifi with Apache License 2.0 5 votes vote down vote up
public Object encode(Record record) throws SerializationError {
    try {
        ObjectWritable blob = new ObjectWritable(record);
        return serde.deserialize(blob);
    } catch (SerDeException e) {
        throw new SerializationError("Unable to convert Record into Object", e);
    }
}