Majid Azimi
Majid Azimi

Reputation: 5745

What are the types of <K,V> in InputSampler<K,V>?

I'm a newbie in Hadoop world. I want to know what are the types of <K,V> in InputSampler<K,V> or InputSampler.Sampler<K,V>? This is equal to key and value coming out from Mapper? The examples on Internet don't use them. For example this link just instantiate it without generics:

InputSampler.Sampler sampler = new InputSampler.RandomSampler(pcnt, numSamples, maxSplits);

Upvotes: 0

Views: 89

Answers (1)

Thomas Jungblut
Thomas Jungblut

Reputation: 20969

Yes, when looking at the code, K denotes the type of the key, V denotes the value type. The real Writable type depends on what kind of input you want to sample, in that sense- yes it is similar to what you would use in a Mapper.

  RecordReader<K,V> reader = inf.createRecordReader(splits.get(i), samplingContext);
  reader.initialize(splits.get(i), samplingContext);
  while (reader.nextKeyValue()) {
    samples.add(ReflectionUtils.copy(job.getConfiguration(),
    reader.getCurrentKey(), null));
  }

Upvotes: 1

Related Questions