13 releases

0.2.0 Jan 10, 2023
0.1.7 Dec 22, 2022
0.1.5 Nov 30, 2022
0.1.4 Jun 3, 2022
0.0.3 Apr 29, 2022

#669 in Command line utilities

Download history 837/week @ 2022-11-30 932/week @ 2022-12-07 572/week @ 2022-12-14 697/week @ 2022-12-21 894/week @ 2022-12-28 996/week @ 2023-01-04 1025/week @ 2023-01-11 802/week @ 2023-01-18 887/week @ 2023-01-25 1378/week @ 2023-02-01 1565/week @ 2023-02-08 1447/week @ 2023-02-15 1135/week @ 2023-02-22 1498/week @ 2023-03-01 1460/week @ 2023-03-08 1281/week @ 2023-03-15

5,546 downloads per month
Used in opendal

Apache-2.0

2MB
50K SLoC

C 49K SLoC // 0.1% comments Rust 1.5K SLoC // 0.0% comments

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}

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 is set correctly during runtime:

export HADOOP_HOME=/path/to/hadoop
export LD_LIBRARY_PATH=${JAVA_HOME}/lib/server:${LD_LIBRARY_PATH}

hdrs will detect CLASSPATH based on HADOOP_HOME, users can override the behavior via setting CLASSPATH manually:

export CLASSPATH=$(find $HADOOP_HOME -iname "*.jar" | xargs echo | tr ' ' ':')

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.

Dependencies