2.3. Catalog_Exercise 2

机器学习生产化:从模型部署到系统级可靠性实战 机器学习模型上线并非终点,而是系统级可靠性的真正起点。在金融、风控等高后果场景中,模型的数学正确性远不足以保障业务连续性;关键在于构建具备熔断、降级、可观测性与契约治理能力的ML系统。本文围绕模型服务的稳定性设计、特征与决策漂移监控、面向失败的工程实践(如超时/重试/熔断)、审计就绪的治理框架(Model Registry、Data Contract、Decision Log)等核心问题展开,深度融合MLOps工程方法与真实故障复盘经验,为数据科学家、SRE及技术负责人提供可落地的生产级ML系统建设路径。 阅读详情

The catalog (class Catalog in SimpleDB) consists of a list of the tables and schemas of the tables that are currently in the database. You will need to support the ability to add a new table, as well as getting information about a particular table. Associated with each table is a TupleDesc object that allows operators to determine the types and number of fields in a table.
The global catalog is a single instance of Catalog that is allocated for the entire SimpleDB process. The global catalog can be retrieved via the method Database.getCatalog(), and the same goes for the global buffer pool (using Database.getBufferPool()).

Exercise 2. Implement the skeleton methods in:
src/java/simpledb/Catalog.java
At this point, your code should pass the unit tests in CatalogTest.

这会是写好目录,这个类里头有所有的表和表的数据。代码如下

package simpledb;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;

/**
 * The Catalog keeps track of all available tables in the database and their
 * associated schemas.
 * For now, this is a stub catalog that must be populated with tables by a
 * user program before it can be used -- eventually, this should be converted
 * to a catalog that reads a catalog table from disk.
 */

public class Catalog {

    /**
     * Constructor.
     * Creates a new, empty catalog.
     */
    private List<table> tables ;
    static class table{
        public DbFile dbFile;
        public String name;
        public String pkeyField;
        public int tableId;

    }
    public Catalog() {
        // some code goes here
        tables = new ArrayList<>();
    }

    /**
     * Add a new table to the catalog.
     * This table's contents are stored in the specified DbFile.
     * @param file the contents of the table to add;  file.getId() is the identfier of
     *    this file/tupledesc param for the calls getTupleDesc and getFile
     * @param name the name of the table -- may be an empty string.  May not be null.  If a name
     * @param pkeyField the name of the primary key field
     * conflict exists, use the last table to be added as the table for a given name.
     */
    public void addTable(DbFile file, String name, String pkeyField) {
        // some code goes here
        table newtable = new table();
        newtable.dbFile = file;
        newtable.name = name;
        newtable.pkeyField = pkeyField;
        newtable.tableId = file.getId();
        for (int i=0;i<tables.size();i++){
            table t = tables.get(i);
            if (t.name==name){
                newtable.tableId = t.tableId;
                tables.set(i,newtable);
                return;
            }
        }
        this.tables.add(newtable);
        System.out.println(newtable);
    }

    public void addTable(DbFile file, String name) {
        addTable(file, name, "");
    }

    /**
     * Add a new table to the catalog.
     * This table has tuples formatted using the specified TupleDesc and its
     * contents are stored in the specified DbFile.
     * @param file the contents of the table to add;  file.getId() is the identfier of
     *    this file/tupledesc param for the calls getTupleDesc and getFile
     */
    public void addTable(DbFile file) {
        addTable(file, (UUID.randomUUID()).toString());
    }

    /**
     * Return the id of the table with a specified name,
     * @throws NoSuchElementException if the table doesn't exist
     */
    public int getTableId(String name) throws NoSuchElementException {
        // some code goes here
        for (table t:tables){
            if (t.name==name){
                return t.tableId;
            }
        }
        throw new NoSuchElementException();
    }

    /**
     * Returns the tuple descriptor (schema) of the specified table
     * @param tableid The id of the table, as specified by the DbFile.getId()
     *     function passed to addTable
     * @throws NoSuchElementException if the table doesn't exist
     */
    public TupleDesc getTupleDesc(int tableid) throws NoSuchElementException {
        // some code goes here
        for (table t :tables){
            if (t.tableId==tableid){
                return t.dbFile.getTupleDesc();
            }
        }
        return null;
    }

    /**
     * Returns the DbFile that can be used to read the contents of the
     * specified table.
     * @param tableid The id of the table, as specified by the DbFile.getId()
     *     function passed to addTable
     */
    public DbFile getDbFile(int tableid) throws NoSuchElementException {
        // some code goes here
        for (table t :tables){
            if (t.tableId==tableid){
                return t.dbFile;
            }
        }
        return null;
    }

    public String getPrimaryKey(int tableid) {
        // some code goes here
        for (table t :tables){
            if (t.tableId==tableid){
                return t.pkeyField;
            }
        }
        return null;
    }

    public Iterator<Integer> tableIdIterator() {
        // some code goes here
        return  new Iterator<Integer>() {
            private int index=0;
            @Override
            public boolean hasNext() {
                return index<tables.size();
            }

            @Override
            public Integer next() {
                int count = index;
                index++;
                return tables.get(count).tableId;
            }
        };
    }

    public String getTableName(int id) {
        // some code goes here
        for (table t :tables){
            if (t.tableId==id){
                return t.name;
            }
        }
        return null;
    }

    /** Delete all tables from the catalog */
    public void clear() {
        // some code goes here
        tables = new ArrayList<>();
    }

    /**
     * Reads the schema from a file and creates the appropriate tables in the database.
     * @param catalogFile
     */
    public void loadSchema(String catalogFile) {
        String line = "";
        String baseFolder=new File(catalogFile).getParent();
        try {
            BufferedReader br = new BufferedReader(new FileReader(new File(catalogFile)));

            while ((line = br.readLine()) != null) {
                //assume line is of the format name (field type, field type, ...)
                String name = line.substring(0, line.indexOf("(")).trim();
                //System.out.println("TABLE NAME: " + name);
                String fields = line.substring(line.indexOf("(") + 1, line.indexOf(")")).trim();
                String[] els = fields.split(",");
                ArrayList<String> names = new ArrayList<String>();
                ArrayList<Type> types = new ArrayList<Type>();
                String primaryKey = "";
                for (String e : els) {
                    String[] els2 = e.trim().split(" ");
                    names.add(els2[0].trim());
                    if (els2[1].trim().toLowerCase().equals("int"))
                        types.add(Type.INT_TYPE);
                    else if (els2[1].trim().toLowerCase().equals("string"))
                        types.add(Type.STRING_TYPE);
                    else {
                        System.out.println("Unknown type " + els2[1]);
                        System.exit(0);
                    }
                    if (els2.length == 3) {
                        if (els2[2].trim().equals("pk"))
                            primaryKey = els2[0].trim();
                        else {
                            System.out.println("Unknown annotation " + els2[2]);
                            System.exit(0);
                        }
                    }
                }
                Type[] typeAr = types.toArray(new Type[0]);
                String[] namesAr = names.toArray(new String[0]);
                TupleDesc t = new TupleDesc(typeAr, namesAr);
                HeapFile tabHf = new HeapFile(new File(baseFolder+"/"+name + ".dat"), t);
                addTable(tabHf,name,primaryKey);
                System.out.println("Added table : " + name + " with schema " + t);
            }
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (IndexOutOfBoundsException e) {
            System.out.println ("Invalid catalog entry : " + line);
            System.exit(0);
        }
    }
}

这个可以还是不可以通过测试,因为我前面的TupleDesc出了点问题,导致第一个test过不了,就是equals方法出了个问题,得补上TDItem的equals方法

public static class TDItem implements Serializable {

        private static final long serialVersionUID = 1L;

        /**
         * The type of the field
         */
        Type fieldType;

        /**
         * The name of the field
         */
        String fieldName;

        public TDItem(Type t, String n) {
            this.fieldName = n;
            this.fieldType = t;
        }

        public String toString() {
            return fieldName + "(" + fieldType + ")";
        }

        @Override
        public boolean equals(Object obj) {
            if(obj==null)return false;
            if (obj==this)return true;
            if (getClass() !=obj.getClass()){
                return false;
            }
            TDItem tdItem = (TDItem) obj;

            return tdItem.fieldName.equals(this.fieldName)&&tdItem.fieldType.equals(this.fieldType);
        }
    }

这样三个测试都可以过了。

6.830 Lab 1: SimpleDB Intro 在6.830中,实现一个基础的数据管理系统SimpleDB。Lab1主要是实现对硬盘上存储数据的访问,之后的Lab会实现其他query processing operators,包括transactions,locking,concurrent queries。 1. Getting started SimpleDB使用Ant build tool来编译代码和运行测试... 阅读详情

相关推荐

同花顺API实战指南:从零搭建股票数据自动化采集系统

本文提供了一份详尽的同花顺API实战指南,手把手教你从零开始搭建股票数据自动化采集系统。内容涵盖API权限申请、Python环境配置、数据采集与存储脚本编写、自动化定时任务实现以及数据清洗等核心环节,旨在帮助量化交易与数据分析爱好者构建稳定可靠的数据源,解放双手,提升研究效率。

weixin_29200741的博客 2408

java 获取泛型对象实体类的表名

说明: 获取实体对象表名,主要是为了获取表名做特殊的业务,但是获取表名不一定要这样获取,但是这是为了统一而实现的功能,其实是在这里面实现的,https://blog.csdn.net/qq_38428623/article/details/105234896 1、实体类型 import javax.persistence.Table; @Data @Table(name...

比嗨皮兔 2917

动态对抗Zygisk-IL2CppDumper:Unity游戏安全新策略

本文深入探讨了对抗Zygisk-IL2CppDumper攻击的Unity游戏安全新策略。通过实时内存监控、动态混淆技术和异常行为检测体系,有效防止关键代码被动态提取。文章详细介绍了内存指纹系统、运行时混淆方案和五维特征模型等实用防御手段,帮助开发者提升游戏安全性。

weixin_29325955的博客 306

Mit6.830-SimpleDB-Lab1-学习笔记

Lab1 SimpleDB包括 - 表示字段、元组和元组模式的类; - 将谓词和条件应用于元组的类; - 一种或多种访问方法(例如堆文件),用于在磁盘上存储关系,并提供一种方法来迭代这些关系的元组; - 处理元组的运算符类的集合(例如,select、join、insert、delete等); - 缓冲池,用于在内存中缓存活动元组和页面,并处理并发控制和事务(在本实验室中,您无需担心这两个问题); - 存储有关可用表及其模式的信息的目录。 不包括 - (Lab1中不包括)一种SQL前端或解析器,

weixin_43414605的博客 3028

告别安装烦恼!Orange3 3.38.0 Windows绿色版下载即用,附保姆级汉化与组件配置指南

本文详细介绍了Orange3 3.38.0 Windows绿色版的下载与使用,包括中文汉化、组件配置及高效管理技巧。这款无需安装的数据科学工具特别适合快速验证想法的研究人员和移动办公用户,支持多种数据源和可视化工具,大幅提升工作效率。

weixin_30897233的博客 602

ESP-CSI:使用ESP32进行CSI(信道状态信息)采集

使用esp32进行csi(信道状态信息)采集和处理

capsize的博客 8280

6.830 lab1

lab地址 大佬博客地址 exercise 1 exercise 2 exercise 3 exercise 4 exercise 5 exercise 6 总结 Exercise 1 lab1实现元组Tuple和其模式TupleDesc 1.TupleDesc可以理解成表头 我们每次在数据库中创建一张表时, 首先便要指定 1>每个列的列名 2>列的类型(domain) TupleDesc中 以TDItem内部类来表示列 TDItem内 Type field

m0_62706061的博客 343

SMARTFORMS实战:用Template+Loop实现复杂表格布局(附避坑指南)

本文深入解析了SMARTFORMS中Template与Loop组合实现复杂表格布局的实战技巧,突破传统TABLE组件的限制。通过多级表头、单元格合并等案例演示,提供从基础架构搭建到动态数据绑定的完整解决方案,并分享性能优化与异常处理的最佳实践,助力开发者高效应对企业级报表设计挑战。

numpy6sculptor的博客 805

Windows驱动程序之cat文件介绍

目录 一、cat文件简介 二、cat文件应用场景 三、cat文件的生成 四、cat文件与数字签名 1、测试签名 2、微软签名 五、参考文档 一、cat文件简介 cat即目录英文单词catalog的简写形式,.cat文件为数字签名的目录文件。.cat数字签名的目录文件可以用作任意文件集合的数字签名。目录文件包含加密哈希或指纹的集合,目录文件的每个指纹对应于驱动程序包安装的文件。Windows通过使用这些哈希或者指纹来验证驱动程序包在发布后是否未被更改。 一般双...

VinWqx的博客 1万+

FPGA 学习系列(2):Verilog 语法基础

Verilog 由门级建模数据流建模行为建模门级建模(Gate Level Modeling):使用基本逻辑门描述电路,接近硬件物理结构。数据流建模(Data Flow Modeling):使用assign语句进行组合逻辑建模,类似数学方程式。行为建模(Behavioral Modeling):使用always代码块和if-elsecase等控制语句建模,抽象程度较高。Verilog 代码一般由模块(module)组成,每个模块描述一个独立的硬件功能。

Azperk的博客 988

Python爬虫实战教程:如何高效爬取税务局通知通告

税务局发布的通知通告包含政策法规、办税指南、公告信息等,是纳税人、企业合规经营的重要参考。官网发布频率高,手动查看不便,自动爬取并保存,方便信息及时掌握及历史数据归档。本文以合法合规的方式示范,建议实际应用前确认目标网站允许爬取的范围和方式。建议使用pandas进行数据清洗,如去重、空值处理等。对于研究税务政策、进行大数据分析、搭建行业信息平台,爬取税务局通知通告信息尤为关键。公告列表以分页形式展现,包含标题、发布时间和详情页链接。进行政策趋势图、发布频率统计等可视化。爬取公开数据时,务必遵守网站的。

2201_76125261的博客 1781

Windows驱动之INF文件

这只是简单的一个inf文件编写过程,还有一些更为复杂的本文没有写上,需要的可自行查找资料。

TakakiTohno的博客 4909

Manus创始人深度复盘:AI Agent产品的技术架构与战略转型

成本对比:同样任务处理,中国区单位成本是亚太区的2.3倍。付费转化率:中国区1.2% vs 全球平均4.7%微信/支付宝等超级App的适配代码占比达17%Zstandard:压缩比38%,耗时12ms。每季度需要投入3名高级工程师专职维护兼容性。国际版API平均延迟:180-220ms。中国版特殊部署延迟:480-720ms。信息保持准确率:93%(7天跨度测试)自研算法:压缩比39%,耗时5ms。存储效率:相比纯文本节省68%空间。:本地化部署导致的延迟与费用差异。LZ4:压缩比42%,耗时8ms。

m0_75253143的博客 7146

SimpleDB数据库 Lab1实现

SimpleDB的lab1实现数据库基本的存储逻辑结构。

qq_62617798的博客 361

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Exercise 5

这次感觉比前几次都难,尤其卡在了iterator上,需要反复阅读上面的说明,说明在DbfileIterator上,。详细代码如下HeapFile.java 在文本编译器上删的sout测试语句,可能会带来一些错误,欢迎指正public class HeapFile implements DbFile { /** * Constructs a heap file backed by t

github_31804537的博客 689

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

MIT6.830 lab2/exercise2/Catelog

1. 预计用时:1h 2. 难度:easy 3. 搞清楚什么是Catelog The catalog (classCatalogin SimpleDB) consists of a list of the tables and schemas of the tables that are currently in the database. You will need to support the ability to add a new table, as well as getting in...

wwxy1995的博客 335

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

[MIT 6.830 SimpleDB] Lab1 Exercise 1-3

MIT 6.830 SimpleDB Lab1 Exercise 1-3,立足于初学者得详细解法!

JacinLee的博客 1010

Exercise 2

Background This assignment asks you to model a coffee store application. Description Gourmet Coffee is a store that sells coffee from countries around the globe. It also sells coffee brewing ...

Hyvi的专栏 428

架构一套在线教育系统:从最初时需求到最后成型

一个大型在线教育系统的架构的建立,不是一开始就有的,最开始可能只是实现它的基础需求,然后开始慢慢优化,最后成型,需求长时间的适应和打磨

xgl905289698的博客 385

机器学习生产化:跨越Notebook到系统的鸿沟

机器学习模型部署不是算法落地的终点,而是系统工程的起点。从特征服务超时、批流时间语义错位,到服务网格隐式依赖和灰度决策不一致,真实生产环境中的瓶颈90%不在模型本身,而在集成边界、基础设施适配与可观测性设计。本文聚焦ML系统化落地的核心挑战——如何将模型转化为具备容错性、可审计性、合规性与业务契约保障的数字基础设施。结合风控、支付等高敏场景实践,深入解析延迟预算驱动的‘一模多态’部署、Arrow零拷贝序列化优化、KS检验驱动的数据漂移响应,以及基于Feature Flag与决策网关的灰度治理。关键词:ML系

weixin_33829657的博客 379

机器学习生产化实战:从Notebook到稳定运行的六大控制点

机器学习模型上线并非终点,而是进入真实业务场景后稳定性、可观测性与可维护性的起点。本文围绕ML Ops核心挑战——数据契约断裂、特征漂移、服务语义级健康缺失、预测结果衰减等关键问题,系统阐述如何构建分层熔断架构、定义稳定性权重(SW)评估体系,并落地输入Schema强校验、特征可复现保障、业务语义健康探针、实时漂移检测、反馈闭环归因及预置降级策略六大生产控制点。内容聚焦工程可实施性,覆盖Airflow+Triton技术栈选型逻辑、影子模式到全量上线七步法,以及21个月线上验证的轻量级运维检查清单,助力算法与

a304096740的博客 327

生产级机器学习系统设计:从Notebook到高可靠决策服务

机器学习模型部署不是训练完成的终点,而是系统工程的起点。在真实业务场景中,模型需面对数据漂移、特征缺失、延迟抖动与合规审计等多重挑战,其核心已从‘预测准确’转向‘决策可信’。本文围绕输入契约、韧性设计、可观测性、业务语义化输出及多维监控等关键技术,解析如何构建具备可预测性、可解释性、可兜底和可追溯能力的生产级ML系统。特别聚焦银行风控、实时反欺诈等高SLA场景,融合ONNX推理优化、特征平台SLA保障、决策溯源图谱等落地实践,为MLOps工程师提供面向真实世界的系统化生存指南。

weixin_33937778的博客 318

Codex 桌面版接入本地LLMapi网关指南

改config.toml 改成新的模型ID,改models.json 追加新模型的描述,可以参考Deepseek-V4-Flash的json。模型目录文件 需要包含前面文件提到的模型 注意大小写要一致。若不支持这个协议,可找一些工具进行协议转换。auth.json 文件内容。作用:指定用apikey登录。不需要,直接替换配置文件就行。1.是否需要codex账号。定义使用的模型和模型地址。2.其他模型ID怎么接入。

gsls200808的专栏 546

MIT6.830-lab2-SimpleDB Operators(数据库的操作算子Filter、Join、Aggregates、Insertion and Deletion,以及页LRU淘汰策略)

在6.830的Project2中,我们要实现常见的SQL语句所需要的数据库操作,在Project1中,我们已经实现了一种顺序扫描的操作SeqScan,它的实现方式是利用SimpleDB的Heap File类提供的迭代器来遍历整个数据表文件中的所有元组信息。Filter:按条件筛选符合的元组;Join:将两个表中符合条件的元组进行join操作;Aggregate:按照一定的目标对表中的元组进行聚合运算;Insert和Delete:插入、删除元组。

迷雾总会解 1452

MIT6.830 Lab 1 实验笔记 底层存储相关单元

Lab1 底层存储相关单元 Exercise 1 TupleDesc 和 Tuple TupleDesc 代表的是数据库中表头的一行的具体类型 包括了一张表中的数据类型和名称。然后TupleDesc.java中就有个数组 TDItem[ ]代表了这张表里面的表头,数据类型就是在里面定义的静态的内部类。 public static class TDItem implements Serializable { private static final long serialVersion

Fitzzzz的博客 963

6.830/6.814 Lab 1: SimpleDB 解析

写一个项目最重要的是什么,是知道你要干什么,然后怎么去做。编程语言并不特别重要,用到的时候去查。 In the lab assignments in 6.830 you will write a basic database management system called SimpleDB. For this lab, you will focus on implementing the core modules required to access stored data on disk; in.

wwxy1995的博客 1140
上一篇: CS186 Project 1: SimpleDB Exercise 1
下一篇: 114. Flatten Binary Tree to Linked List
王Clever
博客等级 码龄11年 9粉丝 83原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值