mapreduce笔记

一、 inputSplit

   InputSplit是指分片,在MapReduce当中作业中,作为map task最小输入单位。分片是基于文件基础上出来的而来的概念,通俗的理解一个文件可以切分为多少个片段,每个片段包括了<文件名,开始位置,长度,位于哪些主机>等信息。在MapTask拿到这些分片后,会知道从哪开始读取数据。


二、处理阶段

input->map->partitions->sort->combine(到这里是属于map task)->shuffle->reduce->output(这部分属于reduce task)

  

三、排序 [first,second]

package mr;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class SortTest {
	private static class MyNewKey implements WritableComparable<MyNewKey> {
		long firstNum;
		long secondNum;
		
		public MyNewKey() {
        }

		public MyNewKey(long firstNum, long secondNum) {
			super();
			this.firstNum = firstNum;
			this.secondNum = secondNum;
		}

		@Override
		public void write(DataOutput out) throws IOException {
			out.writeLong(firstNum);
			out.writeLong(secondNum);
		}

		@Override
		public void readFields(DataInput in) throws IOException {
			firstNum = in.readLong();
			secondNum = in.readLong();
		}

		/*
		 * 当key进行排序时会调用以下这个compreTo方法
		 */
		@Override
		public int compareTo(MyNewKey anotherKey) {
			System.out.println();
			System.out.println("sorting!!!");
			System.out.println("thisone:"+firstNum+","+secondNum+"anotherone:"+anotherKey.firstNum+","+anotherKey.secondNum);
			long min = firstNum - anotherKey.firstNum;
			if (min != 0) {
				// 说明第一列不相等,则返回两数之间小的数
				return (int) min;
			} else {
				return (int) (secondNum - anotherKey.secondNum);
			}
		}
	}

	public static class MyMapper extends Mapper<LongWritable, Text, MyNewKey, LongWritable> {

		protected void map(LongWritable key, Text value,
				Context context)
				throws java.io.IOException, InterruptedException {

			String[] spilted = value.toString().split(",");
			long firstNum = Long.parseLong(spilted[0]);
			long secondNum = Long.parseLong(spilted[1]);
			// 使用新的类型作为key参与排序
			MyNewKey newKey = new MyNewKey(firstNum, secondNum);
			context.write(newKey, new LongWritable(secondNum));
			System.out.println("mapping~");
		}
	}

	public static class MyReducer extends Reducer<MyNewKey, LongWritable, LongWritable, LongWritable> {

		protected void reduce(MyNewKey key, java.lang.Iterable<LongWritable> values,
				Context context)
				throws java.io.IOException, InterruptedException {

			context.write(new LongWritable(key.firstNum), new LongWritable(key.secondNum));
			System.out.println("reducing~");
		}
	}

	private static String INPUT_PATH = "hdfs://master:9000/input/cp.txt";
	private static String OUTPUT_PATH = "hdfs://master:9000/output/c";

	public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {

		Configuration conf = new Configuration();
		try {
			FileSystem  fs=FileSystem.get(new URI(OUTPUT_PATH),conf);
			if(fs.exists(new Path(OUTPUT_PATH)))
				fs.delete(new Path(OUTPUT_PATH));
		} catch (URISyntaxException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Job job = new Job(conf, "myjob");
		job.setJarByClass(SortTest.class);
		job.setMapperClass(MyMapper.class);
		job.setReducerClass(MyReducer.class);
		//job.setCombinerClass(MyReducer.class);

		job.setOutputKeyClass(LongWritable.class);
		job.setOutputValueClass(LongWritable.class);
		
		job.setMapOutputKeyClass(MyNewKey.class);
		job.setMapOutputValueClass(LongWritable.class);

		FileInputFormat.addInputPath(job, new Path(INPUT_PATH));
		FileOutputFormat.setOutputPath(job, new Path(OUTPUT_PATH));

		job.waitForCompletion(true);
	}
}


内容概要:该论文聚焦于T2WI核磁共振图像超分辨率问题,提出了一种利用T1WI模态作为辅助信息的跨模态解决方案。其主要贡献包括:提出基于高频信息约束的网络框架,通过主干特征提取分支和高频结构先验建模分支结合Transformer模块和注意力机制有效重建高频细节;设计渐进式特征匹配融合框架,采用多阶段相似特征匹配算法提高匹配鲁棒性;引入模型量化技术降低推理资源需求。实验结果表明,该方法不仅提高了超分辨率性能,还保持了图像质量。 适合人群:从事医学图像处理、计算机视觉领域的研究人员和工程师,尤其是对核磁共振图像超分辨率感兴趣的学者和技术开发者。 使用场景及目标:①适用于需要提升T2WI核磁共振图像分辨率的应用场景;②目标是通过跨模态信息融合提高图像质量,解决传统单模态方法难以克服的高频细节丢失问题;③为临床诊断提供更高质量的影像资料,帮助医生更准确地识别病灶。 其他说明:论文不仅提供了详细的网络架构设计与实现代码,还深入探讨了跨模态噪声的本质、高频信息约束的实现方式以及渐进式特征匹配的具体过程。此外,作者还对模型进行了量化处理,使得该方法可以在资源受限环境下高效运行。阅读时应重点关注论文中提到的技术创新点及其背后的原理,理解如何通过跨模态信息融合提升图像重建效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值