Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Following up on my comment, the Javadocs for <code>TaggedInputSplit</code> confirms that you are probably wrongly casting the input split to a FileSplit:</p> <pre><code>/** * An {@link InputSplit} that tags another InputSplit with extra data for use * by {@link DelegatingInputFormat}s and {@link DelegatingMapper}s. */ </code></pre> <p>My guess is your setup method looks something like this:</p> <pre><code>@Override protected void setup(Context context) throws IOException, InterruptedException { FileSplit split = (FileSplit) context.getInputSplit(); } </code></pre> <p>Unfortunately <code>TaggedInputSplit</code> is not public visible, so you can't easily do an <code>instanceof</code> style check, followed by a cast and then call to <code>TaggedInputSplit.getInputSplit()</code> to get the actual underlying FileSplit. So either you'll need to update the source yourself and re-compile&amp;deploy, post a JIRA ticket to ask this to be fixed in future version (if it already hasn't been actioned in 2+) or perform some nasty <em>nasty</em> reflection hackery to get to the underlying InputSplit</p> <p>This is completely untested:</p> <pre><code>@Override protected void setup(Context context) throws IOException, InterruptedException { InputSplit split = context.getInputSplit(); Class&lt;? extends InputSplit&gt; splitClass = split.getClass(); FileSplit fileSplit = null; if (splitClass.equals(FileSplit.class)) { fileSplit = (FileSplit) split; } else if (splitClass.getName().equals( "org.apache.hadoop.mapreduce.lib.input.TaggedInputSplit")) { // begin reflection hackery... try { Method getInputSplitMethod = splitClass .getDeclaredMethod("getInputSplit"); getInputSplitMethod.setAccessible(true); fileSplit = (FileSplit) getInputSplitMethod.invoke(split); } catch (Exception e) { // wrap and re-throw error throw new IOException(e); } // end reflection hackery } } </code></pre> <p><strong>Reflection Hackery Explained:</strong></p> <p>With TaggedInputSplit being declared protected scope, it's not visible to classes outside the <code>org.apache.hadoop.mapreduce.lib.input</code> package, and therefore you cannot reference that class in your setup method. To get around this, we perform a number of reflection based operations:</p> <ol> <li><p>Inspecting the class name, we can test for the type TaggedInputSplit using it's fully qualified name</p> <p><code>splitClass.getName().equals("org.apache.hadoop.mapreduce.lib.input.TaggedInputSplit")</code></p></li> <li><p>We know we want to call the <code>TaggedInputSplit.getInputSplit()</code> method to recover the wrapped input split, so we utilize the <code>Class.getMethod(..)</code> reflection method to acquire a reference to the method:</p> <p><code>Method getInputSplitMethod = splitClass.getDeclaredMethod("getInputSplit");</code></p></li> <li><p>The class still isn't public visible so we use the setAccessible(..) method to override this, stopping the security manager from throwing an exception</p> <p><code>getInputSplitMethod.setAccessible(true);</code></p></li> <li><p>Finally we invoke the method on the reference to the input split and cast the result to a FileSplit (optimistically hoping its a instance of this type!):</p> <p><code>fileSplit = (FileSplit) getInputSplitMethod.invoke(split);</code></p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload