📄 jobconf.java
字号:
} public InputFormat getInputFormat() { return (InputFormat)ReflectionUtils.newInstance(getClass("mapred.input.format.class", TextInputFormat.class, InputFormat.class), this); } public void setInputFormat(Class theClass) { setClass("mapred.input.format.class", theClass, InputFormat.class); } public OutputFormat getOutputFormat() { return (OutputFormat)ReflectionUtils.newInstance(getClass("mapred.output.format.class", TextOutputFormat.class, OutputFormat.class), this); } public void setOutputFormat(Class theClass) { setClass("mapred.output.format.class", theClass, OutputFormat.class); } /** @deprecated Call {@link RecordReader#createKey()}. */ public Class getInputKeyClass() { return getClass("mapred.input.key.class", LongWritable.class, WritableComparable.class); } /** @deprecated Not used */ public void setInputKeyClass(Class theClass) { setClass("mapred.input.key.class", theClass, WritableComparable.class); } /** @deprecated Call {@link RecordReader#createValue()}. */ public Class getInputValueClass() { return getClass("mapred.input.value.class", Text.class, Writable.class); } /** @deprecated Not used */ public void setInputValueClass(Class theClass) { setClass("mapred.input.value.class", theClass, Writable.class); } /** * Should the map outputs be compressed before transfer? * Uses the SequenceFile compression. */ public void setCompressMapOutput(boolean compress) { setBoolean("mapred.compress.map.output", compress); } /** * Are the outputs of the maps be compressed? * @return are they compressed? */ public boolean getCompressMapOutput() { return getBoolean("mapred.compress.map.output", false); } /** * Set the given class as the compression codec for the map outputs. * @param codecClass the CompressionCodec class that will compress the * map outputs */ public void setMapOutputCompressorClass(Class codecClass) { setCompressMapOutput(true); setClass("mapred.output.compression.codec", codecClass, CompressionCodec.class); } /** * Get the codec for compressing the map outputs * @param defaultValue the value to return if it is not set * @return the CompressionCodec class that should be used to compress the * map outputs * @throws IllegalArgumentException if the class was specified, but not found */ public Class getMapOutputCompressorClass(Class defaultValue) { String name = get("mapred.output.compression.codec"); if (name == null) { return defaultValue; } else { try { return getClassByName(name); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Compression codec " + name + " was not found.", e); } } } /** * Get the key class for the map output data. If it is not set, use the * (final) output ket class This allows the map output key class to be * different than the final output key class * * @return map output key class */ public Class getMapOutputKeyClass() { Class retv = getClass("mapred.mapoutput.key.class", null, WritableComparable.class); if (retv == null) { retv = getOutputKeyClass(); } return retv; } /** * Set the key class for the map output data. This allows the user to * specify the map output key class to be different than the final output * value class */ public void setMapOutputKeyClass(Class theClass) { setClass("mapred.mapoutput.key.class", theClass, WritableComparable.class); } /** * Get the value class for the map output data. If it is not set, use the * (final) output value class This allows the map output value class to be * different than the final output value class * * @return map output value class */ public Class getMapOutputValueClass() { Class retv = getClass("mapred.mapoutput.value.class", null, Writable.class); if (retv == null) { retv = getOutputValueClass(); } return retv; } /** * Set the value class for the map output data. This allows the user to * specify the map output value class to be different than the final output * value class */ public void setMapOutputValueClass(Class theClass) { setClass("mapred.mapoutput.value.class", theClass, Writable.class); } public Class getOutputKeyClass() { return getClass("mapred.output.key.class", LongWritable.class, WritableComparable.class); } public void setOutputKeyClass(Class theClass) { setClass("mapred.output.key.class", theClass, WritableComparable.class); } public WritableComparator getOutputKeyComparator() { Class theClass = getClass("mapred.output.key.comparator.class", null, WritableComparator.class); if (theClass != null) return (WritableComparator)ReflectionUtils.newInstance(theClass, this); return WritableComparator.get(getMapOutputKeyClass()); } public void setOutputKeyComparatorClass(Class theClass) { setClass("mapred.output.key.comparator.class", theClass, WritableComparator.class); } public Class getOutputValueClass() { return getClass("mapred.output.value.class", Text.class, Writable.class); } public void setOutputValueClass(Class theClass) { setClass("mapred.output.value.class", theClass, Writable.class); } public Class getMapperClass() { return getClass("mapred.mapper.class", IdentityMapper.class, Mapper.class); } public void setMapperClass(Class theClass) { setClass("mapred.mapper.class", theClass, Mapper.class); } public Class getMapRunnerClass() { return getClass("mapred.map.runner.class", MapRunner.class, MapRunnable.class); } public void setMapRunnerClass(Class theClass) { setClass("mapred.map.runner.class", theClass, MapRunnable.class); } public Class getPartitionerClass() { return getClass("mapred.partitioner.class", HashPartitioner.class, Partitioner.class); } public void setPartitionerClass(Class theClass) { setClass("mapred.partitioner.class", theClass, Partitioner.class); } public Class getReducerClass() { return getClass("mapred.reducer.class", IdentityReducer.class, Reducer.class); } public void setReducerClass(Class theClass) { setClass("mapred.reducer.class", theClass, Reducer.class); } public Class getCombinerClass() { return getClass("mapred.combiner.class", null, Reducer.class); } public void setCombinerClass(Class theClass) { setClass("mapred.combiner.class", theClass, Reducer.class); } /** * Should speculative execution be used for this job? * @return Defaults to true */ public boolean getSpeculativeExecution() { return getBoolean("mapred.speculative.execution", true); } /** * Turn on or off speculative execution for this job. * In general, it should be turned off for map jobs that have side effects. */ public void setSpeculativeExecution(boolean new_val) { setBoolean("mapred.speculative.execution", new_val); } public int getNumMapTasks() { return getInt("mapred.map.tasks", 1); } public void setNumMapTasks(int n) { setInt("mapred.map.tasks", n); } public int getNumReduceTasks() { return getInt("mapred.reduce.tasks", 1); } public void setNumReduceTasks(int n) { setInt("mapred.reduce.tasks", n); } /** * Get the user-specified job name. This is only used to identify the * job to the user. * @return the job's name, defaulting to "" */ public String getJobName() { return get("mapred.job.name", ""); } /** * Set the user-specified job name. * @param name the job's new name */ public void setJobName(String name) { set("mapred.job.name", name); } /** Find a jar that contains a class of the same name, if any. * It will return a jar file, even if that is not the first thing * on the class path that has a class with the same name. * @author Owen O'Malley * @param my_class the class to find * @return a jar file that contains the class, or null * @throws IOException */ private static String findContainingJar(Class my_class) { ClassLoader loader = my_class.getClassLoader(); String class_file = my_class.getName().replaceAll("\\.", "/") + ".class"; try { for(Enumeration itr = loader.getResources(class_file); itr.hasMoreElements();) { URL url = (URL) itr.nextElement(); if ("jar".equals(url.getProtocol())) { String toReturn = url.getPath(); if (toReturn.startsWith("file:")) { toReturn = toReturn.substring("file:".length()); } toReturn = URLDecoder.decode(toReturn, "UTF-8"); return toReturn.replaceAll("!.*$", ""); } } } catch (IOException e) { throw new RuntimeException(e); } return null; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -