当前位置: 首页 > news >正文

MIT6.824(6.5840) Lab1笔记+源码

文章目录

  • 其他人的内容,笔记写的更好,思路可以去看他们的
  • MapReduce
    • worker
      • map
      • reduce
    • coordinator
    • rpc
    • 纠错
  • 源码
    • worker.go
    • coordinator.go
    • rpc.go

原本有可借鉴的部分
mrsequential.go,多看几遍源码

其他人的内容,笔记写的更好,思路可以去看他们的

MIT - 6.824 全课程 + Lab 博客总览-CSDN博客

MapReuce 详解与复现, 完成 MIT 6.824(6.5840) Lab1 - 掘金 (juejin.cn)

mit 6.824 lab1 笔记 - 掘金 (juejin.cn)

MapReduce

每个 worker 进程需完成以下工作:
向 master 进程请求 task,从若干文件中读取输入数据,执行 task,并将 task 的输出写入到若干文件中。

master 进程除了为 worker 进程分配 task 外,还需要检查在一定时间内(本实验中为 10 秒)每个 worker 进程是否完成了相应的 task,如果未完成的话则将该 task 转交给其他 worker 进程。

worker

worker函数包含map和redicef两个功能
需要知道自己执行哪个功能

worker 请求获取任务 GetTask

任务设置为结构体,其中一个字段为任务类型

type Task struct{Type:0 1 }0为map,1为reduce const枚举

一个为编号

如何获取任务?

GetTask请求coordinator的assignTask方法,传入为自己的信息(???),获得任务信息

自己当前的状态 空闲 忙碌

call(rpcname,args,reply)bool的rpcname对应coordinator.go中coordinator的相关方法

???没理解这个什么用
GetTask中调用call来从coordinator获取任务信息?

那么rpc.go来干什么

使用ihash(key) % NReduce为Map发出的每个KeyValue选择reduce任务号。随机选择序号
n个文件,生成m个不同文件 n X m个 文件??

保存多少个文件

map得到

对结果ohashkey,写入到文件序号1-10

根据序号分配reduce任务

将结果写入到同一文件

map

mapf func(filename string, content string) []KeyValue

filename是传入的文件名
content为传入的文件的内容——传入前需读取内容

传出intermediate[] 产生文件名 mr-x-y

reduce

reducef func(key string, values []string) string)

这里的key对应ihash生成的任务号??

coordinator

分配任务
需要创建几个map worker—根据几个文件
几个 reduce worker—根据设置,这里为10

coordinator函数用来生成唯一id

Coordinator 结构体定义

用来在不同rpc之间通信,所以其内容是公用的?

type Coordinator struct{files   []stringnReduce int
当前处在什么阶段? state}type dic struct{
status 0or1or2
id       
}

map[file string]

如何解决并发问题??

怎么查询worker的状态??

worker主动向coordinator发送信息

rpc

args 请求参数怎么定义

type args struct{

自己的身份信息

自己的状态信息

}

纠错

  1. 6.5840/mr.writeKVs({0xc000e90000, 0x1462a, 0x16800?}, 0xc00007d100, {0xc39d00, 0x0, 0x0?})
    /home/wang2/6.5840/src/mr/worker.go:109 +0x285

  2. *** Starting wc test.
    panic: runtime error: index out of range [1141634764] with length 0

    ihash取余

  3. runtime error: integer divide by zero

reply.NReduce = c.nReduce // 设置 NReduce

  1. cat: ‘mr-out*’: No such file or directory
    — saw 0 workers rather than 2
    — map parallelism test: FAIL
    cat: ‘mr-out*’: No such file or directory
    — map workers did not run in parallel
    — map parallelism test: FAIL

    cat: ‘mr-out*’: No such file or directory
    — too few parallel reduces.
    — reduce parallelism test: FAIL
    文件句柄问题

  2. sort: cannot read: ‘mr-out*’: No such file or directory
    cmp: EOF on mr-wc-all which is empty
    2024/07/19 11:15:10 dialing:dial unix /var/tmp/5840-mr-1000: connect: connection refused
    2024/07/19 11:15:10 dialing:dial unix /var/tmp/5840-mr-1000: connect: connection refused
    2024/07/19 11:15:10 dialing:dial unix /var/tmp/5840-mr-1000: connect: connection refused

  3. coordinator结构体的并发读取问题
    dialing:dial-http unix /var/tmp/5840-mr-1000: read unix @->/var/tmp/5840-mr-1000: read: connection reset by peer

源码

由于笔记等提示跟没有没区别,这里将源码放上,等大家实在没办法再看吧,
github仓库地址
注意lab1中的提示很重要

博主初期也迷茫过,检查bug也痛苦过,祝福大家。
在这里插入图片描述

有的时候也会出错,但是不想搞了–

在这里插入图片描述

worker.go

package mrimport ("encoding/json""fmt""io""os""sort""strings""time"
)
import "log"
import "net/rpc"
import "hash/fnv"// for sorting by key.
type ByKey []KeyValue// for sorting by key.
func (a ByKey) Len() int           { return len(a) }
func (a ByKey) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByKey) Less(i, j int) bool { return a[i].Key < a[j].Key }const (Map = iotaReduceOver
)
const (Idle = iotaBusyFinish
)// Map functions return a slice of KeyValue.type KeyValue struct {Key   stringValue string
}// use ihash(key) % NReduce to choose the reduce
// task number for each KeyValue emitted by Map.func ihash(key string) int {h := fnv.New32a()h.Write([]byte(key))return int(h.Sum32() & 0x7fffffff)
}// main/mrworker.go calls this function.func Worker(mapf func(string, string) []KeyValue, reducef func(string, []string) string) {// Your worker implementation here.Ch := make(chan bool)for {var Res = &Args{State: Idle} //初始化为idle状态var TaskInformation = &TaskInfo{}GetTask(Res, TaskInformation)//主任务结束后不再请求if TaskInformation.TaskType == Over {break}//fmt.Println("do it!")go DoTask(TaskInformation, mapf, reducef, Ch)sign := <-Ch//fmt.Println("sign:", sign)if sign == true {//fmt.Println("Finish one,ID:", TaskInformation.TaskId)Done(Res, TaskInformation)} else {//TaskInformation.Status = Idle//fmt.Println("err one,ID:", TaskInformation.TaskId)call("Coordinator.Err", Res, TaskInformation)Res = &Args{State: Idle}}time.Sleep(time.Second)}// uncomment to send the Example RPC to the coordinator.//CallExample()}func GetTask(Args *Args, TaskInformation *TaskInfo) {// 调用coordinator获取任务for {call("Coordinator.AssignTask", Args, TaskInformation)//fmt.Println(TaskInformation)if TaskInformation.Status != Idle {Args.State = BusyArgs.Tasktype = TaskInformation.TaskTypeArgs.TaskId = TaskInformation.TaskId//fmt.Println("TaskInfo:", TaskInformation)//fmt.Println("Args:", Args)call("Coordinator.Verify", Args, TaskInformation)break}time.Sleep(time.Second)}//fmt.Printf("Type:%v,Id:%v\n", TaskInformation.TaskType, TaskInformation.TaskId)
}func writeKVs(KVs []KeyValue, info *TaskInfo, fConts []*os.File) {//fConts := make([]io.Writer, info.NReduce)KVset := make([][]KeyValue, info.NReduce)//fmt.Println("start write")//for j := 1; j <= info.NReduce; j++ {////	fileName := fmt.Sprintf("mr-%v-%v", info.TaskId, j)//	os.Create(fileName)////	f, _ := os.Open(fileName)//	fConts[j-1] = f////	defer f.Close()//}var Order intfor _, v := range KVs {Order = ihash(v.Key) % info.NReduceKVset[Order] = append(KVset[Order], v)}//fmt.Println("kvset:", KVset)for i, v := range KVset {for _, value := range v {data, _ := json.Marshal(value)_, err := fConts[i].Write(data)//fmt.Println("data: ", data)//fmt.Println("numbers:", write)if err != nil {return}}}//fmt.Println("finish write")
}func read(filename string) []byte {//fmt.Println("read", filename)file, err := os.Open(filename)defer file.Close()if err != nil {log.Fatalf("cannot open %v", filename)fmt.Println(err)}content, err := io.ReadAll(file)if err != nil {log.Fatalf("cannot read %v", filename)}return content
}// DoTask 执行mapf或者reducef任务func DoTask(info *TaskInfo, mapf func(string, string) []KeyValue, reducef func(string, []string) string, Ch chan bool) {//fConts := make([]io.Writer, info.NReduce)//fmt.Println("start", info.TaskId)//go AssignAnother(Ch)switch info.TaskType {case Map:info.FileContent = string(read(info.FileName))//fmt.Println(info.FileContent)KVs := mapf(info.FileName, info.FileContent.(string))//fmt.Println("map:", KVs)//将其排序sort.Sort(ByKey(KVs))var fConts []*os.File // 修改为 *os.File 类型//0-9for j := 0; j < info.NReduce; j++ {//暂时名,完成后重命名fileName := fmt.Sprintf("mr-%v-%v-test", info.TaskId, j)//_, err := os.Create(fileName)//if err != nil {//	fmt.Println(err)//	return//}////f, _ := os.Open(fileName)//fConts[j-1] = f////defer f.Close()f, err := os.Create(fileName) // 直接使用 Create 函数if err != nil {fmt.Println(err)return}//fmt.Println("creatfile:  ", fileName)//fConts[j] = ffConts = append(fConts, f)defer os.Rename(fileName, strings.TrimSuffix(fileName, "-test"))defer f.Close()}writeKVs(KVs, info, fConts)case Reduce:fileName := fmt.Sprintf("testmr-out-%v", info.TaskId)fileOS, err := os.Create(fileName)//fmt.Println("create success")if err != nil {fmt.Println("Error creating file:", err)return}defer os.Rename(fileName, strings.TrimPrefix(fileName, "test"))defer fileOS.Close()var KVs []KeyValue//读取文件for i := 0; i < info.Nmap; i++ {fileName := fmt.Sprintf("mr-%v-%v", i, info.TaskId)//fmt.Println(fileName)file, err := os.Open(fileName)defer file.Close()if err != nil {fmt.Println(err)}dec := json.NewDecoder(file)for {var kv KeyValueif err := dec.Decode(&kv); err != nil {break}//fmt.Println(kv)KVs = append(KVs, kv)}}//var KVsRes []KeyValuesort.Sort(ByKey(KVs))//整理并传输内容给reducei := 0for i < len(KVs) {j := i + 1for j < len(KVs) && KVs[j].Key == KVs[i].Key {j++}values := []string{}for k := i; k < j; k++ {values = append(values, KVs[k].Value)}// this is the correct format for each line of Reduce output.output := reducef(KVs[i].Key, values)//每个key对应的计数//KVsRes = append(KVsRes, KeyValue{KVs[i].Key, output})fmt.Fprintf(fileOS, "%v %v\n", KVs[i].Key, output)i = j}}Ch <- true}func Done(Arg *Args, Info *TaskInfo) {//Info.Status = Idlecall("Coordinator.WorkerDone", Arg, Info)//arg重新清空Arg = &Args{State: Idle}
}func AssignAnother(Ch chan bool) {time.Sleep(2 * time.Second)Ch <- false
}// example function to show how to make an RPC call to the coordinator.
//
// the RPC argument and reply types are defined in rpc.go.
func CallExample() {// declare an argument structure.args := ExampleArgs{}// fill in the argument(s).args.X = 99// declare a reply structure.reply := ExampleReply{}// send the RPC request, wait for the reply.// the "Coordinator.Example" tells the// receiving server that we'd like to call// the Example() method of struct Coordinator.ok := call("Coordinator.Example", &args, &reply)if ok {// reply.Y should be 100.fmt.Printf("reply.Y %v\n", reply.Y)} else {fmt.Printf("call failed!\n")}
}// send an RPC request to the coordinator, wait for the response.
// usually returns true.
// returns false if something goes wrong.func call(rpcname string, args interface{}, reply interface{}) bool {// c, err := rpc.DialHTTP("tcp", "127.0.0.1"+":1234")sockname := coordinatorSock()//fmt.Println("Worker is dialing", sockname)c, err := rpc.DialHTTP("unix", sockname)if err != nil {//log.Fatal("dialing:", err)return false}defer c.Close()err = c.Call(rpcname, args, reply)if err != nil {//fmt.Println(err)return false}return true
}

coordinator.go

package mrimport ("log""sync""time"
)
import "net"
import "os"
import "net/rpc"
import "net/http"type Coordinator struct {// Your definitions here.files      []stringnReduce    intMapTask    map[int]*TaskReduceTask []intOK         boolLock       sync.Mutex
}type Task struct {fileName stringstate    int
}var TaskMapR map[int]*Taskfunc (c *Coordinator) Verify(Arg *Args, Reply *TaskInfo) error {switch Arg.Tasktype {case Map:time.Sleep(3 * time.Second)if c.MapTask[Arg.TaskId].state != Finish {c.MapTask[Arg.TaskId].state = IdleReply = &TaskInfo{}}case Reduce:time.Sleep(3 * time.Second)if c.ReduceTask[Arg.TaskId] != Finish {c.ReduceTask[Arg.TaskId] = IdleReply = &TaskInfo{}}}return nil
}// Your code here -- RPC handlers for the worker to call.
func (c *Coordinator) AssignTask(Arg *Args, Reply *TaskInfo) error {c.Lock.Lock()defer c.Lock.Unlock()//如果请求为空闲if Arg.State == Idle {//Args.State = Busy//首先分配Mapfor i, task := range c.MapTask {//fmt.Println(*task, "Id:", i)if task.state == Idle {//Arg.Tasktype = Map//Arg.TaskId = i + 1Reply.TaskType = MapReply.FileName = task.fileName//fmt.Println(task.fileName)Reply.TaskId = i          //range从0开始Reply.NReduce = c.nReduce // 设置 NReduceReply.Status = Busytask.state = Busy//fmt.Println("map,Id:", i)return nil}}//Map完成后再Reducefor _, task := range c.MapTask {if task.state != Finish {//fmt.Println("等待Map完成")return nil}}//fmt.Println("MapDone")//分配Reducefor i, v := range c.ReduceTask {//fmt.Println(c.ReduceTask)if v == Idle {Arg.Tasktype = ReduceArg.TaskId = iReply.TaskType = ReduceReply.TaskId = iReply.NReduce = c.nReduce // 设置 NReduceReply.Status = BusyReply.Nmap = len(c.files)c.ReduceTask[i] = Busy//fmt.Println(c.ReduceTask[i])//fmt.Println("reduce", i)return nil}}//Reduce都结束则成功for _, v := range c.ReduceTask {if v == Finish {} else {return nil}}Reply.TaskType = Overc.OK = true}return nil
}func (c *Coordinator) WorkerDone(args *Args, reply *TaskInfo) error {//c.Lock.Lock()//defer c.Lock.Unlock()//reply清空reply = &TaskInfo{}//args.State = Finishid := args.TaskId//fmt.Println("id", id)switch args.Tasktype {case Map:c.MapTask[id].state = Finish//fmt.Println(*c.MapTask[id])case Reduce:c.ReduceTask[id] = Finish//fmt.Println(c.ReduceTask)}return nil
}func (c *Coordinator) Err(args *Args, reply *TaskInfo) error {//c.Lock.Lock()//defer c.Lock.Unlock()reply = &TaskInfo{}id := args.TaskIdswitch args.Tasktype {case Map:if c.MapTask[id].state != Finish {c.MapTask[id].state = Idle}case Reduce:if c.ReduceTask[id] != Finish {c.ReduceTask[id] = Idle}}return nil
}// an example RPC handler.
//
// the RPC argument and reply types are defined in rpc.go.func (c *Coordinator) Example(args *ExampleArgs, reply *ExampleReply) error {reply.Y = args.X + 1return nil
}// start a thread that listens for RPCs from worker.gofunc (c *Coordinator) server() {rpc.Register(c)rpc.HandleHTTP()sockname := coordinatorSock()os.Remove(sockname)l, e := net.Listen("unix", sockname)if e != nil {log.Fatal("listen error:", e)}//fmt.Println("Coordinator is listening on", sockname)go http.Serve(l, nil)
}// main/mrcoordinator.go calls Done() periodically to find out
// if the entire job has finished.func (c *Coordinator) Done() bool {//c.Lock.Lock()//defer c.Lock.Unlock()ret := falseif c.OK == true {ret = true}// Your code here.return ret
}// create a Coordinator.
// main/mrcoordinator.go calls this function.
// nReduce is the number of reduce tasks to use.
func MakeCoordinator(files []string, nReduce int) *Coordinator {//fmt.Println(files)TaskMapR = make(map[int]*Task, len(files))for i, file := range files {TaskMapR[i] = &Task{fileName: file,state:    Idle,}}ReduceMap := make([]int, nReduce)c := Coordinator{files:      files,nReduce:    nReduce,MapTask:    TaskMapR,ReduceTask: ReduceMap,OK:         false,}// Your code here.c.server()return &c
}

rpc.go

package mr//
// RPC definitions.
//
// remember to capitalize all names.
//import "os"
import "strconv"//
// example to show how to declare the arguments
// and reply for an RPC.
//type ExampleArgs struct {X int
}type ExampleReply struct {Y int
}// Add your RPC definitions here.type Args struct {State    intTasktype intTaskId   int
}type TaskInfo struct {Status intTaskType int //任务基本信息TaskId   intNReduce intNmap    intFileName    stringFileContent any//Key    string //reduce所需信息//Values []string
}// Cook up a unique-ish UNIX-domain socket name
// in /var/tmp, for the coordinator.
// Can't use the current directory since
// Athena AFS doesn't support UNIX-domain sockets.func coordinatorSock() string {s := "/var/tmp/5840-mr-"s += strconv.Itoa(os.Getuid())return s
}

相关文章:

MIT6.824(6.5840) Lab1笔记+源码

文章目录 其他人的内容&#xff0c;笔记写的更好&#xff0c;思路可以去看他们的MapReduceworkermapreduce coordinatorrpc纠错 源码worker.gocoordinator.gorpc.go 原本有可借鉴的部分 mrsequential.go&#xff0c;多看几遍源码 其他人的内容&#xff0c;笔记写的更好&#xf…...

【目录】8051汇编与C语言系列教程

8051汇编与C语言系列教程 作者将狼才鲸创建日期2024-07-23 CSDN文章地址&#xff1a;【目录】8051汇编与C语言系列教程本Gitee仓库原始地址&#xff1a;才鲸嵌入式/8051_c51_单片机从汇编到C_从Boot到应用实践教程 一、本教程目录 序号教程名称简述教程链接1点亮LCD灯通过IO…...

群管机器人官网源码

一款非常好看的群管机器人html官网源码 搭建教程&#xff1a; 域名解析绑定 源码文件上传解压 访问域名即可 演示图片&#xff1a; 群管机器人官网源码下载&#xff1a;客户端下载 - 红客网络编程与渗透技术 原文链接&#xff1a; 群管机器人官网源码...

整合EasyExcel实现灵活的导入导出java

引入pom依赖 <dependency><groupId>com.alibaba</groupId><artifactId>easyexcel</artifactId></dependency>实现功能 结合Vue前端&#xff0c;实现浏览器页面直接导出日志文件实现文件的灵活导入文件导出 3. 实体类 实体类里有自定义转…...

springSecurity学习之springSecurity web如何取得用户信息

web如何取得用户信息 之前说过SecurityContextHolder默认使用的是ThreadLocal来进行存储的&#xff0c;而且每次都会清除&#xff0c;但是web每次请求都会验证用户权限&#xff0c;这是如何做到的呢&#xff1f; 这是通过SecurityContextPersistenceFilter来实现的&#xff0…...

eclipse中的classbean导入外部class文件,clean项目后删除问题

最近被eclipse搞得头疼&#xff0c;下午终于解决 eclipse创建的java项目中&#xff0c;类的输出目录是classbean。由于项目需要&#xff0c;classbean目录下已经导入了外部的类&#xff0c;但每次clean项目时&#xff0c;会把class删掉。 广泛查询&#xff0c;eclipse不清空c…...

OBD诊断(ISO15031) 0A服务

文章目录 功能简介ISO 15765-4的诊断服务定义1、请求具有永久状态的排放相关故障诊断码2、请求具有永久状态的排放相关故障诊断码3、示例报文 功能简介 0A服务&#xff0c;即 Request emission-related diagnostic trouble code with permanent status&#xff08;请求排放相关…...

ForCloud全栈安全体验,一站式云安全托管试用 开启全能高效攻防

对于正处于业务快速发展阶段的企业&#xff0c;特别是大型央国企而言&#xff0c;日常的安全部署和运营管理往往横跨多家子公司&#xff0c;所面临的挑战不言而喻。尤其是在面对当前常态化的大型攻防演练任务时&#xff0c;难度更是呈“几何级数”上升&#xff1a; 合规难 众…...

Java——————接口(interface) <详解>

1.1 接口的概念 在现实生活中&#xff0c;接口的例子比比皆是&#xff0c;比如&#xff1a;笔记本电脑上的USB接口&#xff0c;电源插座等。 电脑的USB口上&#xff0c;可以插&#xff1a;U盘、鼠标、键盘...所有符合USB协议的设备 电源插座插孔上&#xff0c;可以插&#xff…...

【C++】【继承】【子对象】【构造函数】含子对象的派生类的构造函数写法

&#xff08;1&#xff09;子对象的概念&#xff1a;若派生类A1的数据成员中包含基类A的对象a&#xff0c;则a为派生类A1的子对象 &#xff08;2&#xff09;含子对象的派生类的构造函数的执行顺序是&#xff1a; ①调用基类构造函数&#xff0c;对基类数据成员初始化 ②调用子…...

golang语言 .go文件版本条件编译,xxx.go文件指定go的编译版本必须大于等于xxx才生效的方法, 同一个项目多个go版本文件共存方法

在go语言中&#xff0c;我们不关是可以在编译时指定版本&#xff0c; 在我们的xxx.go文件中也可以指定go的运行版本&#xff0c;即 忽略go.mod中的版本&#xff0c;而是当当前的go运行版本达到指定条件后才生效的xxx.go文件。 方法如下&#xff1a; 我们通过在xxx.go文件的头部…...

深入浅出mediasoup—通信框架

libuv 是一个跨平台的异步事件驱动库&#xff0c;用于构建高性能和可扩展的网络应用程序。mediasoup 基于 libuv 构建了包括管道、信号和 socket 在内的一整套通信框架&#xff0c;具有单线程、事件驱动和异步的典型特征&#xff0c;是构建高性能 WebRTC 流媒体服务器的重要基础…...

每日一题 LeetCode03 无重复字符的最长字串

1.题目描述 给定一个字符串 s &#xff0c;请你找出其中不含有重复字符的最长字串的长度。 2 思路 可以用两个指针, 滑动窗口的思想来做这道题,即定义两个指针.一个left和一个right 并且用一个set容器,一个length , 一个maxlength来记录, 让right往右走,并且用一个set容器来…...

栈和队列(C语言)

栈的定义 栈&#xff1a;一种特殊的线性表&#xff0c;其只允许在固定的一端进行插入和删除元素操作。进行数据插入和删除操作的一端称为栈顶&#xff0c;另一端称为栈底。栈中的数据元素遵守后进先出LIFO&#xff08;Last In First Out&#xff09;的原则。 压栈&#xff1a;…...

swagger-ui.html报错404

问题1&#xff1a;权限受限无法访问 由于采用的Shiro安全框架&#xff0c;需要在配置类ShiroConfig下的Shiro 的过滤器链放行该页面&#xff1a;【添加&#xff1a;filterChainDefinitionMap.put("/swagger-ui.html", "anon");】 public ShiroFilterFact…...

Milvus 核心组件(3)--- MinIO详解

目录 背景 MinIO 安装 docker desktop 安装 Ubuntu UI 在 docker 中的安装 Minio 下载及安装 启动minio docker image 保存 启动 minio web 网页 下一次启动 MinIO基本概念 基本概述 主要特性 应用场景 MinIO 使用 连接server 创建bucket 查询bucket 上传文件…...

[数据集][目标检测]婴儿车检测数据集VOC+YOLO格式1073张5类别

数据集格式&#xff1a;Pascal VOC格式YOLO格式(不包含分割路径的txt文件&#xff0c;仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件) 图片数量(jpg文件个数)&#xff1a;1073 标注数量(xml文件个数)&#xff1a;1073 标注数量(txt文件个数)&#xff1a;1073 标注…...

JAVASE进阶day14(网络编程续TCP,日志)

TCP 三次握手 四次挥手 package com.lu.day14.tcp;import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket;public class Client {public static void main(String[] args) {try(Socket socket new Socket("192.…...

机器学习(五) -- 无监督学习(1) --聚类1

系列文章目录及链接 上篇&#xff1a;机器学习&#xff08;五&#xff09; -- 监督学习&#xff08;7&#xff09; --SVM2 下篇&#xff1a;机器学习&#xff08;五&#xff09; -- 无监督学习&#xff08;1&#xff09; --聚类2 前言 tips&#xff1a;标题前有“***”的内容…...

leetcode 116. 填充每个节点的下一个右侧节点指针

leetcode 116. 填充每个节点的下一个右侧节点指针 题目 给定一个 完美二叉树 &#xff0c;其所有叶子节点都在同一层&#xff0c;每个父节点都有两个子节点。二叉树定义如下&#xff1a; struct Node { int val; Node *left; Node *right; Node *next; } 填充它的每个 next …...

生成xcframework

打包 XCFramework 的方法 XCFramework 是苹果推出的一种多平台二进制分发格式&#xff0c;可以包含多个架构和平台的代码。打包 XCFramework 通常用于分发库或框架。 使用 Xcode 命令行工具打包 通过 xcodebuild 命令可以打包 XCFramework。确保项目已经配置好需要支持的平台…...

《Playwright:微软的自动化测试工具详解》

Playwright 简介:声明内容来自网络&#xff0c;将内容拼接整理出来的文档 Playwright 是微软开发的自动化测试工具&#xff0c;支持 Chrome、Firefox、Safari 等主流浏览器&#xff0c;提供多语言 API&#xff08;Python、JavaScript、Java、.NET&#xff09;。它的特点包括&a…...

LeetCode - 394. 字符串解码

题目 394. 字符串解码 - 力扣&#xff08;LeetCode&#xff09; 思路 使用两个栈&#xff1a;一个存储重复次数&#xff0c;一个存储字符串 遍历输入字符串&#xff1a; 数字处理&#xff1a;遇到数字时&#xff0c;累积计算重复次数左括号处理&#xff1a;保存当前状态&a…...

大语言模型如何处理长文本?常用文本分割技术详解

为什么需要文本分割? 引言:为什么需要文本分割?一、基础文本分割方法1. 按段落分割(Paragraph Splitting)2. 按句子分割(Sentence Splitting)二、高级文本分割策略3. 重叠分割(Sliding Window)4. 递归分割(Recursive Splitting)三、生产级工具推荐5. 使用LangChain的…...

1.3 VSCode安装与环境配置

进入网址Visual Studio Code - Code Editing. Redefined下载.deb文件&#xff0c;然后打开终端&#xff0c;进入下载文件夹&#xff0c;键入命令 sudo dpkg -i code_1.100.3-1748872405_amd64.deb 在终端键入命令code即启动vscode 需要安装插件列表 1.Chinese简化 2.ros …...

Android Bitmap治理全解析:从加载优化到泄漏防控的全生命周期管理

引言 Bitmap&#xff08;位图&#xff09;是Android应用内存占用的“头号杀手”。一张1080P&#xff08;1920x1080&#xff09;的图片以ARGB_8888格式加载时&#xff0c;内存占用高达8MB&#xff08;192010804字节&#xff09;。据统计&#xff0c;超过60%的应用OOM崩溃与Bitm…...

华硕a豆14 Air香氛版,美学与科技的馨香融合

在快节奏的现代生活中&#xff0c;我们渴望一个能激发创想、愉悦感官的工作与生活伙伴&#xff0c;它不仅是冰冷的科技工具&#xff0c;更能触动我们内心深处的细腻情感。正是在这样的期许下&#xff0c;华硕a豆14 Air香氛版翩然而至&#xff0c;它以一种前所未有的方式&#x…...

Python ROS2【机器人中间件框架】 简介

销量过万TEEIS德国护膝夏天用薄款 优惠券冠生园 百花蜂蜜428g 挤压瓶纯蜂蜜巨奇严选 鞋子除臭剂360ml 多芬身体磨砂膏280g健70%-75%酒精消毒棉片湿巾1418cm 80片/袋3袋大包清洁食品用消毒 优惠券AIMORNY52朵红玫瑰永生香皂花同城配送非鲜花七夕情人节生日礼物送女友 热卖妙洁棉…...

Java编程之桥接模式

定义 桥接模式&#xff08;Bridge Pattern&#xff09;属于结构型设计模式&#xff0c;它的核心意图是将抽象部分与实现部分分离&#xff0c;使它们可以独立地变化。这种模式通过组合关系来替代继承关系&#xff0c;从而降低了抽象和实现这两个可变维度之间的耦合度。 用例子…...

[大语言模型]在个人电脑上部署ollama 并进行管理,最后配置AI程序开发助手.

ollama官网: 下载 https://ollama.com/ 安装 查看可以使用的模型 https://ollama.com/search 例如 https://ollama.com/library/deepseek-r1/tags # deepseek-r1:7bollama pull deepseek-r1:7b改token数量为409622 16384 ollama命令说明 ollama serve #&#xff1a…...