docs:README
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
# AGENTS.md
|
||||
|
||||
`spark_project` — Spark(Scala + Java 双实现)学习项目,含三套分层练习与 MySQL 写入示例表。
|
||||
|
||||
## Setup commands
|
||||
|
||||
- 拉依赖:`mvn -DskipTests dependency:resolve`
|
||||
- 编译:`mvn compile`(同时编译 `src/main/java` 与 `src/main/scala`)
|
||||
- 打包:`mvn package`(产出 `target/spark_project-1.0-SNAPSHOT-jar-with-dependencies.jar`)
|
||||
- 跑测试:`mvn test`(当前 `src/test/` 为空,等价空跑)
|
||||
- 清理:`mvn clean`
|
||||
- 单文件运行入口:IDE 里把目标 `object ExercisesX` / `class Xxx` 作为 `main` 直接 run,或:
|
||||
`java -cp target/spark_project-1.0-SNAPSHOT-jar-with-dependencies.jar org.example.App`
|
||||
|
||||
## Project layout
|
||||
|
||||
- `pom.xml` — Maven 配置,启用 `scala-maven-plugin` 与 `maven-assembly-plugin`,强制 JDK 8 / Scala 2.11
|
||||
- `src/main/java/org/example/core/` — Java 版 4 个核心 Demo(`GroupByKeyDemo` / `MyPartitioner` / `RddCreateDemo` / `RepartitionVsCoalesce`)
|
||||
- `src/main/scala/org/example/App.scala` — Scala 入口(`local[2]` 模式跑 `word.txt` WordCount)
|
||||
- `src/main/scala/org/example/core/` — 与 Java 同名的 Scala 版 4 个 Demo
|
||||
- `src/main/scala/org/exercises/exercises1/exercises/` — 第 1 课练习(Spark 入门)
|
||||
- `src/main/scala/org/exercises/exercises2/exercises/` — 第 2 课练习(RDD 算子:map / filter / flatMap / reduce / foreach)
|
||||
- `src/main/scala/org/exercises/exercises3/exercises/` — 第 3 课练习(PairRDD / reduceByKey / WordCount)
|
||||
- `src/main/scala/org/exercises/exercisesN/demo/` — 上述练习对应的演示实现
|
||||
- `src/main/resources/` — `log4j.properties` / `word.txt` / MySQL 建表 SQL `create_table.sql`
|
||||
- `src/test/java/` — 测试目录(JUnit 3.8.1 已声明但当前为空)
|
||||
|
||||
## Code style
|
||||
|
||||
- Java 8(`maven.compiler.source/target=8`)与 Scala 2.11.12 共存;新文件优先 Scala,统一参考现有 demo 的写法
|
||||
- Spark Master 全部固定为 `local` / `local[2]`,本机调试无需集群
|
||||
- 中文注释和**中文 commit message** 是项目常态(参考最近 6 个 commit),不要切换成英文
|
||||
|
||||
## Testing instructions
|
||||
|
||||
- 当前 `src/test/` 没有任何用例,跑测试等价于空跑
|
||||
- 加测试用 `src/test/java/`,包路径跟随被测包(`org.example` / `org.exercises.xxx`),JUnit 3.8.1(继承 `TestCase`,方法名 `testXxx`)
|
||||
- 所有测试通过后再提 PR
|
||||
|
||||
## PR & commit conventions
|
||||
|
||||
- 默认分支:`main`,从 `main` 拉 feature 分支,**禁止直接 push 到 `main`**
|
||||
- Commit 风格:参考现有 `feat:ChatGPT 第 X 课:主题` 形式,保持**简体中文 + 一句话主题**
|
||||
- 单节课 / 单道练习的提交保持原子;本仓库暂无 CI(`.github/workflows/` 未配置),提 PR 前请本地跑通 `mvn test`
|
||||
|
||||
## Security
|
||||
|
||||
- `.gitignore` 已忽略 `target/`、`.idea/`、`*.iml`、`.classpath` 等构建 / IDE 产物
|
||||
- MySQL / Hadoop 凭据**不要**写进 `src/main/resources/`,需要外部化(环境变量或 `*.local.properties`,并加入 `.gitignore`)
|
||||
- 不要把含个人 token 的 fat jar 提交到仓库
|
||||
Reference in New Issue
Block a user