MCPcopy Index your code
hub / github.com/Xuanwo/hdrs

github.com/Xuanwo/hdrs @v0.3.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.2 ↗ · + Follow
87 symbols 291 edges 8 files 37 documented · 43% updated 17mo agov0.3.2 · 2024-03-21★ 428 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

hdrs   Build Status Latest Version

HDFS Native Client in Rust based on hdfs-sys.

Quick Start

use std::io::{Read, Write};

use hdrs::Client;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let fs = Client::connect("hdfs://127.0.0.1:9000")?;

    let mut f = fs.open_file().write(true).create(true).open("/tmp/hello.txt")?;
    let n = f.write("Hello, World!".as_bytes())?;

    let mut f = fs.open_file().read(true).open("/tmp/hello.txt")?;
    let mut buf = vec![0; 1024];
    let n = f.read(&mut buf)?;

    let _ = fs.remove_file("/tmp/hello.txt")?;

    Ok(())
}

Compiletime

hdrs depends on hdfs-sys which links libjvm to work.

Please make sure JAVA_HOME is set correctly:

export JAVA_HOME=/path/to/java
export LD_LIBRARY_PATH=${JAVA_HOME}/lib/server:${LD_LIBRARY_PATH}
  • Enable vendored feature to compile libhdfs and link in static.
  • Specify HDFS_LIB_DIR or HADOOP_HOME to load from specified path instead of compile.
  • Specify HDFS_STATIC=1 to link libhdfs in static.
  • And finally, we will fallback to compile libhdfs and link in static.

Runtime

hdrs depends on hdfs-sys which uses JNI to call functions provided by jars that provided by hadoop releases.

Please also make sure HADOOP_HOME, LD_LIBRARY_PATH, CLASSPATH is set correctly during runtime:

export HADOOP_HOME=/path/to/hadoop
export LD_LIBRARY_PATH=${JAVA_HOME}/lib/server:${LD_LIBRARY_PATH}
export CLASSPATH=$(${HADOOP_HOME}/bin/hadoop classpath --glob)

If libhdfs is configued to link dynamiclly, please also add ${HADOOP_HOME}/lib/native in LD_LIBRARY_PATH to make sure linker can find libhdfs.so:

export LD_LIBRARY_PATH=${JAVA_HOME}/lib/server:${HADOOP_HOME}/lib/native:${LD_LIBRARY_PATH}

Version Requirement

hdrs requires at least hadoop 2.3 to work: hadoop 2.2 doesn't handle FileNotFound correctly.

hdrs requires at least hadoop 2.6 to work: Older version of hadoop doesn't handle errno correctly. In older versions, hadoop will set errno to 3 if input path is an empty dir.

Contributing

Check out the CONTRIBUTING.md guide for more details on getting started with contributing to this project.

Getting help

Submit issues for bug report or asking questions in discussion.

Acknowledgment

This project is highly inspired by clang-sys

License

Licensed under Apache License, Version 2.0.

Core symbols most depended-on inside this repo

open_file
called by 20
src/client.rs
connect
called by 19
src/client.rs
open
called by 17
src/open_options.rs
len
called by 12
src/metadata.rs
metadata
called by 11
src/client.rs
create
called by 10
src/open_options.rs
read
called by 9
src/open_options.rs
write
called by 6
src/open_options.rs

Shape

Method 59
Function 20
Class 8

Languages

Rust100%

Modules by API surface

src/client.rs19 symbols
src/async_file.rs16 symbols
src/metadata.rs14 symbols
src/file.rs13 symbols
src/open_options.rs12 symbols
tests/main.rs8 symbols
src/readdir.rs5 symbols

For agents

$ claude mcp add hdrs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page