{"id":31287736,"url":"https://github.com/r-siddiq/schemacraft","last_synced_at":"2026-05-19T14:33:06.813Z","repository":{"id":314689241,"uuid":"1056421632","full_name":"r-siddiq/SchemaCraft","owner":"r-siddiq","description":"SchemaCraft is a lightweight Java/Maven toolkit for defining schemas, creating typed tables, storing tuples, and performing relational operations (projection, joins, lookups) with JUnit-tested in-memory models.","archived":false,"fork":false,"pushed_at":"2025-09-14T04:03:48.000Z","size":65,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-14T06:07:16.453Z","etag":null,"topics":["bytebuffer","exception-handling","file-io","junit","lookups","maven","object-oriented-programming","relational-operators","schema","serialization","tables","tuples"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r-siddiq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-14T03:56:26.000Z","updated_at":"2025-09-14T04:03:51.000Z","dependencies_parsed_at":"2025-09-14T06:07:17.738Z","dependency_job_id":"41342a2a-44aa-437f-be32-63d295e9d0c9","html_url":"https://github.com/r-siddiq/SchemaCraft","commit_stats":null,"previous_names":["r-siddiq/schemacraft"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/r-siddiq/SchemaCraft","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-siddiq%2FSchemaCraft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-siddiq%2FSchemaCraft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-siddiq%2FSchemaCraft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-siddiq%2FSchemaCraft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-siddiq","download_url":"https://codeload.github.com/r-siddiq/SchemaCraft/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-siddiq%2FSchemaCraft/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276737524,"owners_count":25695700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-24T02:00:09.776Z","response_time":97,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bytebuffer","exception-handling","file-io","junit","lookups","maven","object-oriented-programming","relational-operators","schema","serialization","tables","tuples"],"created_at":"2025-09-24T11:05:35.792Z","updated_at":"2025-09-24T11:05:38.783Z","avatar_url":"https://github.com/r-siddiq.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SchemaCraft (Java/Maven)\n\nLightweight, in‑memory relational toolkit that lets you **define schemas**, **create typed tables**, **insert tuples/rows**, and perform **lookups, projection, and natural joins**. Types are pluggable via a small `IType` interface; the project ships with `INT` and `VARCHAR(n)` implementations that support fixed‑width binary serialization using `ByteBuffer`.\n\n## At a Glance\n- **Project Name:** `SchemaCraft`\n- **Modules:** single‑module Maven project (root)\n- **Maven:** wrapper present (`mvnw`, `.mvn/wrapper`)\n- **Coordinates:** `schemacraft:schemacraft:1.0-SNAPSHOT`\n- **Java Toolchain:** 17+ (set via `maven.compiler.release` or compatible)\n- **Testing:** JUnit Jupiter **5.11.0**\n- **Entry Point:** `schemacraft.MainApplication` (demo); library API is under `schemacraft.*`\n- **Key Package:** `schemacraft`\n\n## Project Structure\n```\nSchemaCraft/\n├── .mvn/\n│   └── wrapper/\n│       ├── maven-wrapper.jar\n│       ├── maven-wrapper.properties\n│       └── MavenWrapperDownloader.java\n├── src/\n│   ├── main/\n│   │   └── java/\n│   │       └── schemacraft/\n│   │           ├── Constants.java\n│   │           ├── ITable.java\n│   │           ├── IType.java\n│   │           ├── MainApplication.java\n│   │           ├── Schema.java\n│   │           ├── Table.java\n│   │           ├── Tuple.java\n│   │           ├── TypeInt.java\n│   │           └── TypeVarchar.java\n│   └── test/\n│       └── java/\n│           └── schemacraft/\n│               ├── TableTest.java\n│               └── TupleTest.java\n├── .gitignore\n├── mvnw\n├── mvnw.cmd\n├── pom.xml\n└── README.md\n```\n\n## Build \u0026 Test\n\n### Maven (wrapper)\n```bash\n# from the project root (folder containing pom.xml)\n./mvnw -q clean package\n./mvnw -q test\n```\n\nThis produces `target/schemacraft-1.0-SNAPSHOT.jar` (no external runtime deps).\n\n## Features\n\n- **Schemas \u0026 Types**\n  - `Schema` defines an ordered set of columns (optionally a **key** column).\n  - Built‑in types:\n    - `TypeInt` = `INT`\n    - `TypeVarchar(max)` = `VARCHAR(n)` with fixed maximum length and padded binary layout.\n  - Add columns with helpers: `addIntType(name)`, `addVarCharType(name, max)`, and `addKey*` variants.\n  - Utilities: `size()`, `getTupleSizeInBytes()`, `getColumnIndex(name)`, `getType(i)`, `getName(i)`.\n\n- **Tables \u0026 Tuples**\n  - `Table` holds a collection of `Tuple`s for a `Schema`.\n  - Core ops: `insert(Tuple)`, `delete(key)`, `lookup(key)` (by key), `lookup(colName, value)` (by predicate), `iterator()`, `size()`.\n  - `Tuple` gives field‑level accessors: `get(i)`, `get(String)`, `getInt(i)`, `getString(i)`, `set(i, value)`, `getKey()`.\n\n- **Relational Operations**\n  - `Schema.project(String... attrs)` → new projected `Schema`.\n  - `Schema.naturaljoin(Schema other)` → combined `Schema` (no key) for natural join.\n  - `Tuple.project(Schema projected)` and `Tuple.joinTuple(Schema joinSchema, Tuple t1, Tuple t2)` offer row‑wise transforms.\n  - `Table.lookup(col, value)` returns a new `Table` with matching tuples.\n\n- **Binary Serialization**\n  - `IType.readValue(ByteBuffer)` / `writeValue(Object, ByteBuffer)` permit **fixed‑width** row serialization.\n  - `Schema.serialize(ByteBuffer)` and `Tuple.serialize(ByteBuffer)` support compact storage.\n  - `Constants.BLOCK_SIZE = 4096` suggests page/block alignment for future storage engines.\n\n- **Developer Ergonomics**\n  - `Constants.MAX_COLUMN_NAME_LENGTH = 24` and `Constants.DEBUG` flag.\n  - Clean, minimal API — easy to extend with custom `IType` implementations.\n\n## Code Map\n\n### `schemacraft.Schema`\n- **Add columns:** `addIntType`, `addVarCharType`, `addKeyIntType`, `addKeyVarCharType`\n- **Inspect:** `getKey`, `getColumnIndex`, `getType`, `getName`, `getMaxSQLSize`, `size`, `getTupleSizeInBytes`\n- **Algebra:** `project(String[])`, `naturaljoin(Schema)`\n- **IO:** `serialize(ByteBuffer)`\n- **toString():** human‑readable schema listing\n\n### `schemacraft.Table`\n- **Lifecycle:** `Table(Schema)`, `close()`\n- **Mutation:** `insert(Tuple)`, `delete(key)`\n- **Query:** `lookup(key)`, `lookup(colName, value)`, `iterator()`, `size()`\n- **toString():** pretty prints rows\n\n### `schemacraft.Tuple`\n- **Construct:** `Tuple(Schema, Object... values)`; validates arity and types\n- **Access:** `get(int)`, `get(String)`, `getInt(int)`, `getString(int)`, `set(int, Object)`, `getKey()`\n- **Transform:** `project(Schema)`, `joinTuple(Schema, Tuple, Tuple)`\n- **IO:** `serialize(ByteBuffer)`, `deserialize(Schema, ByteBuffer)`\n\n### `schemacraft.IType` (SPI)\n```java\nString getColumnName();\nint getMaxSizeBytes();\nint getMaxSQLLength();\nString getExternalName();\nint getInternalType();\nObject readValue(ByteBuffer buf);\nvoid writeValue(Object value, ByteBuffer buf);\n```\n\n### `schemacraft.TypeInt` / `schemacraft.TypeVarchar`\n- Fixed‑size `ByteBuffer` encoding; `VARCHAR` pads/truncates to `max` bytes.\n\n### `schemacraft.Constants`\n- `BLOCK_SIZE = 4096`, `MAX_COLUMN_NAME_LENGTH = 24`, `DEBUG`\n\n### `schemacraft.MainApplication`\n- Small demo showing schema creation, inserts, and `lookup` by column/key.\n\n## Usage\n\nBelow is a minimal example using the public API:\n\n```java\nimport schemacraft.*;\n\npublic class Demo {\n    public static void main(String[] args) {\n        // 1) Define a schema with a key column and two attributes\n        Schema schema = new Schema();\n        schema.addKeyIntType(\"ID\");\n        schema.addVarCharType(\"dept_name\", 20);\n        schema.addVarCharType(\"building\", 16);\n\n        // 2) Create a table and insert tuples\n        Table table = new Table(schema);\n        table.insert(new Tuple(schema, 19803, \"Comp. Sci.\", \"SIG\"));\n        table.insert(new Tuple(schema, 19901, \"Comp. Sci.\", \"GHC\"));\n        table.insert(new Tuple(schema, 20123, \"Math\",      \"Wean\"));\n\n        // 3) Lookup by key and by non-key column\n        Table row = table.lookup(19803);\n        Table cs  = table.lookup(\"dept_name\", \"Comp. Sci.\");\n\n        // 4) Project columns\n        Schema proj = schema.project(new String[] {\"dept_name\"});\n\n        System.out.println(row);\n        System.out.println(cs);\n        System.out.println(proj);\n    }\n}\n```\n\nCompile \u0026 run your own demo (outside Maven build):\n```bash\n# compile (point to target jar if you also want to reuse build outputs)\njavac -cp target/schemacraft-1.0-SNAPSHOT.jar Demo.java\njava  Demo\n```\n\n## Testing\n\nJUnit 5 tests (e.g., tuple construction \u0026 schema validation):\n```bash\n./mvnw -q test\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-siddiq%2Fschemacraft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-siddiq%2Fschemacraft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-siddiq%2Fschemacraft/lists"}