{"id":24881917,"url":"https://github.com/janrockdev/p2p-rust","last_synced_at":"2025-03-27T07:16:02.990Z","repository":{"id":273782368,"uuid":"920866308","full_name":"janrockdev/p2p-rust","owner":"janrockdev","description":"Peer-2-Peer Network with Apache Arrow in Rust","archived":false,"fork":false,"pushed_at":"2025-02-11T13:22:01.000Z","size":89,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T14:27:39.482Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","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/janrockdev.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}},"created_at":"2025-01-22T22:48:33.000Z","updated_at":"2025-02-11T13:22:05.000Z","dependencies_parsed_at":"2025-02-11T14:26:35.988Z","dependency_job_id":"93f8c487-3a06-4880-9e65-5d58c76a55d0","html_url":"https://github.com/janrockdev/p2p-rust","commit_stats":null,"previous_names":["janrockdev/p2p-rust"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janrockdev%2Fp2p-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janrockdev%2Fp2p-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janrockdev%2Fp2p-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janrockdev%2Fp2p-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janrockdev","download_url":"https://codeload.github.com/janrockdev/p2p-rust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245798353,"owners_count":20673902,"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","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":[],"created_at":"2025-02-01T12:14:25.855Z","updated_at":"2025-03-27T07:16:02.782Z","avatar_url":"https://github.com/janrockdev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Peer-2-Peer Network with Apache Arrow in Rust\n\nThis project is built to test the Rust peer-to-peer library `libp2p`. It demonstrates how to create a simple peer-to-peer network where multiple nodes can communicate with each other using shared in-memory cache. The project includes examples of setting up nodes, connecting them, and running benchmarks to measure performance.\n\nEach node has in-memory cache and Apache Arrow persistent cache.\n\n### Run\n```shell\n# open terminal #1 (node)\nmake run\n# open terminal #2 (node)\nmake run\n# ...\n# open terminal #3 (benchmark) /write/read/both\ncargo run --bin client 127.0.0.1:8080 127.0.0.1:8081 node_8080_cache.arrow write 1000\ncargo run --bin client 127.0.0.1:8080 127.0.0.1:8081 node_8080_cache.arrow read 1000\n```\n\n### Socket\n```shell\nnc 127.0.0.1 8080\n# use\nGET key731 # get value for key\nSET key1001=value1001 # sen new pair\nGET_LEN # cache size\nGET_ALL # print all\n```\n\n### Output\n```shell\nWrite Benchmark Complete: 1000 requests, Total Time: 705.879621ms, Avg Time per Request: 705.879µs\n```\n\n### Python\n```shell\npython3 -m venv venv\nsource venv/bin/activate\npython3 -m pip install pyarrow\npython3 -m pip install pandas\npython3 arrow.py\ndeactivate\n```\n\n### Arrow IPC to Parquet\n```rust\nuse std::fs::File;\nuse std::sync::Arc;\n\nuse arrow::ipc::reader::FileReader as ArrowIPCReader;\nuse arrow::record_batch::RecordBatch;\nuse parquet::arrow::ArrowWriter;\nuse parquet::file::properties::WriterProperties;\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    // Step 1: Read Arrow IPC file\n    let ipc_file = File::open(\"data.arrow\")?;\n    let mut ipc_reader = ArrowIPCReader::try_new(ipc_file)?;\n    \n    // Collect all RecordBatches from the IPC file\n    let mut record_batches = vec![];\n    while let Some(batch) = ipc_reader.next()? {\n        record_batches.push(batch);\n    }\n\n    // Ensure at least one RecordBatch is available\n    if record_batches.is_empty() {\n        return Err(\"No data found in the Arrow IPC file.\".into());\n    }\n\n    // Combine RecordBatches into a single schema if needed\n    let schema = record_batches[0].schema();\n\n    // Step 2: Write to Parquet\n    let parquet_file = File::create(\"output.parquet\")?;\n    let writer_properties = WriterProperties::builder().build();\n    let mut parquet_writer = ArrowWriter::try_new(parquet_file, schema, Some(writer_properties))?;\n\n    // Write each RecordBatch to the Parquet file\n    for batch in record_batches {\n        parquet_writer.write(\u0026batch)?;\n    }\n\n    // Close the writer to flush data to disk\n    parquet_writer.close()?;\n\n    println!(\"Converted Arrow IPC to Parquet successfully.\");\n    Ok(())\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanrockdev%2Fp2p-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanrockdev%2Fp2p-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanrockdev%2Fp2p-rust/lists"}