final Path file = new Path(getWorkOutputPath(job), getUniqueName(job, "part") + "." + extension); final int visCacheSize = FileOutputConfigurator.getVisibilityCacheSize(conf);
@Override public int run(String[] args) throws Exception { if (args.length != 2) { throw new IllegalArgumentException( "Usage : " + MRTester.class.getName() + " <table> <outputfile>"); } String table = args[0]; JobConf job = new JobConf(getConf()); job.setJarByClass(this.getClass()); ConfiguratorBase.setVisibilityCacheSize(job, JOB_VISIBILITY_CACHE_SIZE); job.setInputFormat(AccumuloInputFormat.class); AccumuloInputFormat.setZooKeeperInstance(job, getCluster().getClientConfig()); AccumuloInputFormat.setConnectorInfo(job, getAdminPrincipal(), getAdminToken()); AccumuloInputFormat.setInputTableName(job, table); AccumuloFileOutputFormat.setOutputPath(job, new Path(args[1])); AccumuloFileOutputFormat.setSampler(job, SAMPLER_CONFIG); job.setMapperClass(BAD_TABLE.equals(table) ? BadKeyMapper.class : IdentityMapper.class); job.setMapOutputKeyClass(Key.class); job.setMapOutputValueClass(Value.class); job.setOutputFormat(AccumuloFileOutputFormat.class); job.setNumReduceTasks(0); return JobClient.runJob(job).isSuccessful() ? 0 : 1; }
@Override public RecordWriter<Key,Value> getRecordWriter(FileSystem ignored, JobConf job, String name, Progressable progress) throws IOException { // get the path of the temporary output file final Configuration conf = job; final AccumuloConfiguration acuConf = FileOutputConfigurator.getAccumuloConfiguration(CLASS, job); final String extension = acuConf.get(Property.TABLE_FILE_TYPE); final Path file = new Path(getWorkOutputPath(job), getUniqueName(job, "part") + "." + extension); final int visCacheSize = ConfiguratorBase.getVisibilityCacheSize(conf); return new RecordWriter<Key,Value>() { RFileWriter out = null; @Override public void close(Reporter reporter) throws IOException { if (out != null) out.close(); } @Override public void write(Key key, Value value) throws IOException { if (out == null) { out = RFile.newWriter().to(file.toString()).withFileSystem(file.getFileSystem(conf)) .withTableProperties(acuConf).withVisibilityCacheSize(visCacheSize).build(); out.startDefaultLocalityGroup(); } out.append(key, value); } }; }
@Override public RecordWriter<Key,Value> getRecordWriter(FileSystem ignored, JobConf job, String name, Progressable progress) throws IOException { // get the path of the temporary output file final Configuration conf = job; final AccumuloConfiguration acuConf = FileOutputConfigurator.getAccumuloConfiguration(CLASS, job); final String extension = acuConf.get(Property.TABLE_FILE_TYPE); final Path file = new Path(getWorkOutputPath(job), getUniqueName(job, "part") + "." + extension); final int visCacheSize = ConfiguratorBase.getVisibilityCacheSize(conf); return new RecordWriter<Key,Value>() { RFileWriter out = null; @Override public void close(Reporter reporter) throws IOException { if (out != null) out.close(); } @Override public void write(Key key, Value value) throws IOException { if (out == null) { out = RFile.newWriter().to(file.toString()).withFileSystem(file.getFileSystem(conf)) .withTableProperties(acuConf).withVisibilityCacheSize(visCacheSize).build(); out.startDefaultLocalityGroup(); } out.append(key, value); } }; }