fuyufjh 最近的时间轴更新
fuyufjh's repos on GitHub
C++ · 203 人关注
GraphicBuffer
Use GraphicBuffer class from Android native code
Rust · 163 人关注
heygpt
A simple command-line interface for ChatGPT API written in Rust ⚡️
TypeScript · 37 人关注
mior
mior - Merge into one RSS
Java · 26 人关注
calculator
A simple calculator to demonstrate code gen technology
JavaScript · 21 人关注
ArkPets-Web
Go · 18 人关注
splunk-hec-go
Splunk HTTP Event Collector (HEC) Golang library
17 人关注
tensorflow-and-deep-learning-chinese
TensorFlow and deep learning without a PhD, translated to Chinese
TypeScript · 10 人关注
ArkPets-Chrome
明日方舟桌宠 Chrome 浏览器插件
Python · 8 人关注
chatgpt-toolbox
ChatGPT Toolbox based on Streamlit
C · 6 人关注
compiler-lab-nju
NJU Compiler Course Lab
2 人关注
go-scratch
Minimal Container Image for Go Binaries
JavaScript · 2 人关注
hexo-migrator-ghost
Ghost migrator for Hexo.
Java · 1 人关注
calcite-demo
1 人关注
galaxysql
PolarDB-X is a cloud native distributed SQL Database designed for high concurrency, massive storage, complex querying scenarios.
1 人关注
go-alpine
Minimal container image for Go binaries based on Alpine Linux
Java · 1 人关注
lynx
JavaScript · 1 人关注
n-blog
Multiuser blog system build with Express & MongoDB
0 人关注
acme.sh
A pure Unix shell script implementing ACME client protocol
CSS · 0 人关注
Affinity
Affinity is a clean, minimal, modern theme that focus on content for Ghost.
Python · 0 人关注
aiomysql
aiomysql is a library for accessing a MySQL database from the asyncio
Java · 0 人关注
aliyun-emapreduce-sdk
Hadoop/Spark on Aliyun, supporting interactions with Aliyun's base services.
Java · 0 人关注
aliyun-oss-java-sdk
Aliyun OSS SDK for Java
JavaScript · 0 人关注
automatically-set-milestone-to-issue
Java · 0 人关注
BrainControl
Python · 0 人关注
Brainwave_control_system
C++ · 0 人关注
BtQt
A simple Qt based BitTorrent client!
Python · 0 人关注
computer_use_ootb
An out-of-the-box (OOTB) version of Anthropic Claude Computer Use for Windows and macOS
TypeScript · 0 人关注
contextual-qa-checklist-action
Github action for filename-based QA checklists in PRs
Java · 0 人关注
CounselorAssistant
自动将NJU教务系统导出表格整理为学分表
Python · 0 人关注
dimensions
read the width, height, and rotation of images.
JavaScript · 0 人关注
dockerfiles
:whale: Dockerfiles
Python · 0 人关注
dotfiles
Backup my config
CSS · 0 人关注
DreamOnWeb
0 人关注
druid
阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
Go · 0 人关注
fasthttp
Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
Java · 0 人关注
flink
Flink code for TPC-DS competition,forked from Apache Flink,and cherry pick some new feature.
JavaScript · 0 人关注
fuyufjh.github.io
Go · 0 人关注
go-aws-mon
put basic linux metrics to AWS CloudWatch with GoLang, fit for coreos and other small AMI Instance on AWS It is easy to kick up with cloud-init as system basic monitoring working with EC2 CloudWatch.
JavaScript · 0 人关注
hexo-renderer-marked
Markdown renderer for Hexo
0 人关注
juicefs
JuiceFS is a distributed POSIX file system built on top of Redis and S3.
C# · 0 人关注
Light-Switch
Easily switch from light to dark theme, or the other way around, in Windows 10/11.
Python · 0 人关注
loki_logging_handler
A logging handler that sends log messages to Loki with buffer
Python · 0 人关注
md2zhihu
convert markdown to zhihu compatible format.
Java · 0 人关注
meow-album
0 人关注
mintty-color-schemes
Some color schemes for MinTTY
C · 0 人关注
NanoOS
Simple UNIX running on X86
Java · 0 人关注
nju-data-mining-lab2
0 人关注
openraft
rust raft with improvements
Java · 0 人关注
pgjdbc
Postgresql JDBC Driver
0 人关注
PolarDB-for-PostgreSQL
A cloud-native database based on PostgreSQL developed by Alibaba Cloud.
0 人关注
risingwave
RisingWave: the next-generation streaming database in the cloud.
Java · 0 人关注
rocketmq-externals
Mirror of Apache RocketMQ (Incubating)
Scala · 0 人关注
scala-impatient
My solutions for "Scala for the Impatient" exercises
TypeScript · 0 人关注
schema-registry-webui
Go · 0 人关注
shadowsocks-go
go port of shadowsocks
Racket · 0 人关注
sicp-exercises
JavaScript · 0 人关注
simple-gallery
Simple Gallery based on blueimp/Gallery
Scala · 0 人关注
spark
Mirror of Apache Spark
VimL · 0 人关注
spf13-vim
The ultimate vim distribution
Go · 0 人关注
splunk
Splunk Libraries in golang
Java · 0 人关注
splunk-sdk-java
Splunk Software Development Kit for Java
0 人关注
sqllogictest-rs
Sqllogictest (dialect with extensions) parser and runner in Rust.
CSS · 0 人关注
stackedit-css-chinese
CSS · 0 人关注
StayPuft
A fork of Casper, the default theme for Ghost
HCL · 0 人关注
tack
Terraform module for creating Kubernetes cluster running on CoreOS in an AWS VPC
Go · 0 人关注
tidb
TiDB is a distributed HTAP database compatible with the MySQL protocol
0 人关注
tiny-llm
A course of learning LLM inference serving on Apple Silicon for systems engineers: build a tiny vLLM + Qwen.
0 人关注
TokenBucket
Lock-free implementation of the token bucket algorithm in C++
0 人关注
type-exercise-in-rust
Learn Rust black magics by implementing basic types in database systems
Rust · 0 人关注
typos
Source code spell checker
Go · 0 人关注
vultr
:penguin: Vultr CLI and API client library
fuyufjh

fuyufjh

🏢  Dev
V2EX 第 96093 号会员,加入于 2015-02-06 16:50:28 +08:00
根据 fuyufjh 的设置,主题列表被隐藏
二手交易 相关的信息,包括已关闭的交易,不会被隐藏
fuyufjh 最近回复了
2025 年 9 月 14 日
回复了 YanSeven 创建的主题 云计算 “云数据库”和“云原生数据库”的区别是什么
这俩都是给 IDC 自建用户设计的…… “云数据库”至少也应该是 RDS / Aurora / PolarDB / Neon 这样的线上服务吧
2024 年 9 月 22 日
回复了 zhuyancarina 创建的主题 互联网 科研访谈对象招募 | 女程序员身份建构与文化认同
搞艺术的想象力都很丰富吧?但凡认识一个女程序员都不会写下这么小众的文字
2024 年 6 月 1 日
回复了 EVJohn 创建的主题 iPhone 看 15/15pro 的价格很心动啊,买 15 还是等 16
16 (非 Pro ) 会上 8GB 内存,比 15 多了 2GB
2024 年 4 月 17 日
回复了 utop1a 创建的主题 程序员 请教一个数据库或代码的唯一性设计问题
忍不住直接丢给 GPT-4 了,以下是它的回答:

你的需求是实现一个层级配置功能,其中层级关系由三个字段( a, b, c )定义,并且需要确保配置的数据项在同一层级上不重复。根据你的描述,这里是一个典型的树形结构,其中 a 是第一层,b 是第二层,c 是第三层。

为了解决你目前面临的问题,可以考虑以下几个设计思路:

### 1. 使用路径枚举模型( Materialized Path )

在这种模型中,你可以为每个节点存储一个路径字符串,该字符串反映了从根到该节点的完整路径。例如:

- "1" -> "1/"
- "1,2" -> "1/2/"
- "1,2,3" -> "1/2/3/"

在查询时,你可以使用路径来检查是否存在重复的层级配置。例如,要检查是否存在与"1/2/3/"相同或更高层级的配置,只需要查询路径以"1/2/3/"开头的记录。

### 2. 使用左右值模型( Nested Set )

这种模型适用于存储层级数据,每个节点都有一个左值和一个右值,通过这两个值可以快速查询节点的子节点和父节点。但是,这种模型在插入和删除操作时需要更新大量记录,可能不适合频繁变动的配置。

### 3. 使用 Adjacency List 模型并增加唯一性约束

这是最简单的层级数据模型,每个节点都有一个指向父节点的外键。在你的情况下,可以在表中添加唯一性约束来确保同一层级的配置不会重复。

例如,你可以在数据库表中创建一个唯一索引:

```sql
CREATE UNIQUE INDEX idx_unique_config ON t(a, b, c);
```

这样,数据库将自动保证不会插入重复的层级配置。

### 4. 使用闭包表模型( Closure Table )

闭包表存储每个节点与其每个祖先之间的关系。这种模型查询快速,但是需要维护一个额外的表来存储关系。

### 5. 使用触发器或应用层逻辑

你可以在数据库层使用触发器来阻止违反层级规则的数据插入,或者在应用层实现逻辑来确保数据的一致性。

### 结合你的需求

你的需求似乎最适合使用路径枚举模型,因为它可以很容易地通过字符串比较来检查层级关系。你可以这样设计:

1. 在表中添加一个额外的字段,比如 `path`。
2. 当插入新记录时,根据 a, b, c 的值生成路径字符串。
3. 使用这个路径字符串来检查是否有重复的层级配置。

例如:

```sql
-- 假设你要插入新记录
SET @new_a = '1';
SET @new_b = '2';
SET @new_c = NULL;

-- 生成路径字符串
SET @new_path = CONCAT_WS('/', @new_a, IFNULL(@new_b, ''), IFNULL(@new_c, ''));

-- 检查是否存在重复的层级配置
SELECT COUNT(*)
FROM t
WHERE path = @new_path OR path LIKE CONCAT(@new_path, '/%');

-- 如果计数为 0 ,则可以插入新记录
```

这种方法可以避免你当前面临的问题,并且可以很容易地扩展到更多层级。
2024 年 4 月 16 日
回复了 OliverDD 创建的主题 程序员 对数据库感兴趣,但完全接受不了 cpp
看看大数据,Spark 、Hive 、Trino 这些,语言以 JVM 系的为主,查询路径上的知识差不多太多,存储、事务之类的被大幅简化了
2023 年 11 月 27 日
回复了 V2asker 创建的主题 浏览器 下面哪款浏览器更安全?
chrome 套皮能列出 100 个 😄
2023 年 11 月 8 日
回复了 Alucns 创建的主题 MySQL MYSQL8 正式环境有必要关闭性能架构 performance_schema=OFF
fyi. 阿里云 RDS ,8GB 及以上内存的实例默认 on ,否则 off
2023 年 10 月 2 日
回复了 xieyuheng 创建的主题 程序员 [连载] 用文件系统做数据库 之一 设计文档
你需要的是 kv store

虽然文件系统也可以看作是一个面向大 value 、没有 ACID 事务的 kv store ,但显然不推荐这么用
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1898 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 23ms · UTC 14:51 · PVG 22:51 · LAX 06:51 · JFK 09:51
♥ Do have faith in what you're doing.