AbstractWritableConverter extends WritableStoreCaster<W> implements WritableConverter<W> { @Override public void initialize(Class<? extends W> writableClass) throws IOException { if (writableClass == null) { return; } if (writable != null) { Class<?> existingWritableClass = writable.getClass(); Preconditions.checkArgument(existingWritableClass.isAssignableFrom(writableClass), "Existing Writable implementation '%s' is not assignable from class '%s'", existingWritableClass.getName(), writableClass.getName()); } try { writable = writableClass.newInstance(); } catch (Exception e) { throw new IOException(String.format("Failed to create instance of Writable type '%s'", writableClass.getName()), e); } } AbstractWritableConverter(W writable);  AbstractWritableConverter(); @Override void initialize(Class<? extends W> writableClass); @Override ResourceFieldSchema getLoadSchema(); @Override Object bytesToObject(DataByteArray dataByteArray); @Override @SuppressWarnings("unchecked") Class<W> getWritableClass(); @Override void checkStoreSchema(ResourceFieldSchema schema); @Override @SuppressWarnings("unchecked") W toWritable(Object value);  }
@Test public void readOutsidePig() throws ClassCastException, ParseException, ClassNotFoundException, InstantiationException, IllegalAccessException, IOException, InterruptedException { final SequenceFileLoader<IntWritable, Text> loader = new SequenceFileLoader<IntWritable, Text>(String.format("-c %s", IntWritableConverter.class.getName()), String.format( "-c %s %s", writableConverterClass.getName(), writableConverterArguments)); Job job = new Job(); loader.setUDFContextSignature("12345"); loader.setLocation(tempFilename, job); final RecordReader<DataInputBuffer, DataInputBuffer> reader = new RawSequenceFileRecordReader(); final FileSplit fileSplit = new FileSplit(new Path(tempFilename), 0, new File(tempFilename).length(), new String[] { "localhost" }); final TaskAttemptContext context = HadoopCompat.newTaskAttemptContext(HadoopCompat.getConfiguration(job), new TaskAttemptID()); reader.initialize(fileSplit, context); final InputSplit[] wrappedSplits = new InputSplit[] { fileSplit }; final int inputIndex = 0; final List<OperatorKey> targetOps = Arrays.asList(new OperatorKey("54321", 0)); final int splitIndex = 0; final PigSplit split = new PigSplit(wrappedSplits, inputIndex, targetOps, splitIndex); split.setConf(HadoopCompat.getConfiguration(job)); loader.prepareToRead(reader, split); validate(new LoadFuncTupleIterator(loader)); }