final void setupSharedInstance(Context context) throws IOException { if (SHARED_INSTANCE == null) { SHARED_INSTANCE = createSharedInstance(context); } }
SharingMapper.reset();
@Override public void run(Context ctx) throws IOException, InterruptedException { Class<Mapper<K1, V1, K2, V2>> mapperClass = MultithreadedSharingMapper.getMapperClass((JobContext) ctx); Preconditions.checkNotNull(mapperClass, "Could not find Multithreaded Mapper class."); Configuration conf = ctx.getConfiguration(); // instantiate the mapper Mapper<K1, V1, K2, V2> mapper1 = ReflectionUtils.newInstance(mapperClass, conf); SharingMapper<K1, V1, K2, V2, ?> mapper = null; if (mapper1 instanceof SharingMapper) { mapper = (SharingMapper<K1, V1, K2, V2, ?>) mapper1; } Preconditions.checkNotNull(mapper, "Could not instantiate SharingMapper. Class was: %s", mapper1.getClass().getName()); // single threaded call to setup the sharing mapper mapper.setupSharedInstance(ctx); // multithreaded execution super.run(ctx); } }
SharingMapper.reset();
@Override public void run(Context ctx) throws IOException, InterruptedException { Class<Mapper<K1, V1, K2, V2>> mapperClass = MultithreadedSharingMapper.getMapperClass((JobContext) ctx); Preconditions.checkNotNull(mapperClass, "Could not find Multithreaded Mapper class."); Configuration conf = ctx.getConfiguration(); // instantiate the mapper Mapper<K1, V1, K2, V2> mapper1 = ReflectionUtils.newInstance(mapperClass, conf); SharingMapper<K1, V1, K2, V2, ?> mapper = null; if (mapper1 instanceof SharingMapper) { mapper = (SharingMapper<K1, V1, K2, V2, ?>) mapper1; } Preconditions.checkNotNull(mapper, "Could not instantiate SharingMapper. Class was: %s", mapper1.getClass().getName()); // single threaded call to setup the sharing mapper mapper.setupSharedInstance(ctx); // multithreaded execution super.run(ctx); } }
SharingMapper.reset();
final void setupSharedInstance(Context context) throws IOException { if (SHARED_INSTANCE == null) { SHARED_INSTANCE = createSharedInstance(context); } }
@Override public void run(Context ctx) throws IOException, InterruptedException { Class<Mapper<K1, V1, K2, V2>> mapperClass = MultithreadedSharingMapper.getMapperClass((JobContext) ctx); Preconditions.checkNotNull(mapperClass, "Could not find Multithreaded Mapper class."); Configuration conf = ctx.getConfiguration(); // instantiate the mapper Mapper<K1, V1, K2, V2> mapper1 = ReflectionUtils.newInstance(mapperClass, conf); SharingMapper<K1, V1, K2, V2, ?> mapper = null; if (mapper1 instanceof SharingMapper) { mapper = (SharingMapper<K1, V1, K2, V2, ?>) mapper1; } Preconditions.checkNotNull(mapper, "Could not instantiate SharingMapper. Class was: %s", mapper1.getClass().getName()); // single threaded call to setup the sharing mapper mapper.setupSharedInstance(ctx); // multithreaded execution super.run(ctx); } }
SharingMapper.reset();
final void setupSharedInstance(Context context) throws IOException { if (SHARED_INSTANCE == null) { SHARED_INSTANCE = createSharedInstance(context); } }
@Before @Override public void setUp() throws Exception { super.setUp(); inputFile = getTestTempFile("prefs.txt"); intermediateDir = getTestTempDir("intermediate"); intermediateDir.delete(); outputDir = getTestTempDir("output"); outputDir.delete(); tmpDir = getTestTempDir("tmp"); conf = getConfiguration(); // reset as we run all tests in the same JVM SharingMapper.reset(); }