hdfs_sys/
hdfs_2_2.rs

1//! hdfs 2.2.0 is the first stable release of hadoop 2.
2//!
3//! We take this release as the baseline of hdfs-sys.
4
5use std::os::raw::*;
6
7#[repr(C)]
8#[derive(Debug, Copy, Clone)]
9pub struct hdfsBuilder {
10    _unused: [u8; 0],
11}
12
13pub type tObjectKind = c_uint;
14pub const tObjectKind_kObjectKindFile: tObjectKind = 70;
15pub const tObjectKind_kObjectKindDirectory: tObjectKind = 68;
16
17#[repr(C)]
18#[derive(Debug, Copy, Clone)]
19pub struct hdfs_internal {
20    _unused: [u8; 0],
21}
22pub type hdfsFS = *mut hdfs_internal;
23
24#[repr(C)]
25#[derive(Debug, Copy, Clone)]
26pub struct hdfsFile_internal {
27    _unused: [u8; 0],
28}
29
30pub type hdfsFile = *mut hdfsFile_internal;
31
32#[repr(C)]
33#[derive(Debug, Copy, Clone)]
34pub struct hdfsReadStatistics {
35    pub totalBytesRead: u64,
36    pub totalLocalBytesRead: u64,
37    pub totalShortCircuitBytesRead: u64,
38    #[cfg(feature = "hdfs_2_3")]
39    pub totalZeroCopyBytesRead: u64,
40}
41
42#[repr(C)]
43#[derive(Debug, Copy, Clone)]
44pub struct hdfsFileInfo {
45    pub mKind: tObjectKind,
46    pub mName: *mut c_char,
47    pub mLastMod: c_long,
48    pub mSize: i64,
49    pub mReplication: c_short,
50    pub mBlockSize: i64,
51    pub mOwner: *mut c_char,
52    pub mGroup: *mut c_char,
53    pub mPermissions: c_short,
54    pub mLastAccess: c_long,
55}
56
57extern "C" {
58    pub fn hdfsFileIsOpenForRead(file: hdfsFile) -> c_int;
59    pub fn hdfsFileIsOpenForWrite(file: hdfsFile) -> c_int;
60    pub fn hdfsFileGetReadStatistics(file: hdfsFile, stats: *mut *mut hdfsReadStatistics) -> c_int;
61    pub fn hdfsReadStatisticsGetRemoteBytesRead(stats: *const hdfsReadStatistics) -> i64;
62    pub fn hdfsFileFreeReadStatistics(stats: *mut hdfsReadStatistics);
63    pub fn hdfsConnectAsUser(nn: *const c_char, port: u16, user: *const c_char) -> hdfsFS;
64    pub fn hdfsConnect(nn: *const c_char, port: u16) -> hdfsFS;
65    pub fn hdfsConnectAsUserNewInstance(
66        nn: *const c_char,
67        port: u16,
68        user: *const c_char,
69    ) -> hdfsFS;
70    pub fn hdfsConnectNewInstance(nn: *const c_char, port: u16) -> hdfsFS;
71    pub fn hdfsBuilderConnect(bld: *mut hdfsBuilder) -> hdfsFS;
72    pub fn hdfsNewBuilder() -> *mut hdfsBuilder;
73    pub fn hdfsBuilderSetForceNewInstance(bld: *mut hdfsBuilder);
74    pub fn hdfsBuilderSetNameNode(bld: *mut hdfsBuilder, nn: *const c_char);
75    pub fn hdfsBuilderSetNameNodePort(bld: *mut hdfsBuilder, port: u16);
76    pub fn hdfsBuilderSetUserName(bld: *mut hdfsBuilder, userName: *const c_char);
77    pub fn hdfsBuilderSetKerbTicketCachePath(
78        bld: *mut hdfsBuilder,
79        kerbTicketCachePath: *const c_char,
80    );
81    pub fn hdfsFreeBuilder(bld: *mut hdfsBuilder);
82    pub fn hdfsBuilderConfSetStr(
83        bld: *mut hdfsBuilder,
84        key: *const c_char,
85        val: *const c_char,
86    ) -> c_int;
87    pub fn hdfsConfGetStr(key: *const c_char, val: *mut *mut c_char) -> c_int;
88    pub fn hdfsConfGetInt(key: *const c_char, val: *mut i32) -> c_int;
89    pub fn hdfsConfStrFree(val: *mut c_char);
90    pub fn hdfsDisconnect(fs: hdfsFS) -> c_int;
91    pub fn hdfsOpenFile(
92        fs: hdfsFS,
93        path: *const c_char,
94        flags: c_int,
95        bufferSize: c_int,
96        replication: c_short,
97        blocksize: i32,
98    ) -> hdfsFile;
99
100    pub fn hdfsCloseFile(fs: hdfsFS, file: hdfsFile) -> c_int;
101    pub fn hdfsExists(fs: hdfsFS, path: *const c_char) -> c_int;
102    pub fn hdfsSeek(fs: hdfsFS, file: hdfsFile, desiredPos: i64) -> c_int;
103    pub fn hdfsTell(fs: hdfsFS, file: hdfsFile) -> i64;
104    pub fn hdfsRead(fs: hdfsFS, file: hdfsFile, buffer: *mut c_void, length: i32) -> i32;
105    pub fn hdfsPread(
106        fs: hdfsFS,
107        file: hdfsFile,
108        position: i64,
109        buffer: *mut c_void,
110        length: i32,
111    ) -> i32;
112    pub fn hdfsWrite(fs: hdfsFS, file: hdfsFile, buffer: *const c_void, length: i32) -> i32;
113    pub fn hdfsFlush(fs: hdfsFS, file: hdfsFile) -> c_int;
114    pub fn hdfsHFlush(fs: hdfsFS, file: hdfsFile) -> c_int;
115    pub fn hdfsHSync(fs: hdfsFS, file: hdfsFile) -> c_int;
116    pub fn hdfsAvailable(fs: hdfsFS, file: hdfsFile) -> c_int;
117    pub fn hdfsCopy(srcFS: hdfsFS, src: *const c_char, dstFS: hdfsFS, dst: *const c_char) -> c_int;
118    pub fn hdfsMove(srcFS: hdfsFS, src: *const c_char, dstFS: hdfsFS, dst: *const c_char) -> c_int;
119    pub fn hdfsDelete(fs: hdfsFS, path: *const c_char, recursive: c_int) -> c_int;
120    pub fn hdfsRename(fs: hdfsFS, oldPath: *const c_char, newPath: *const c_char) -> c_int;
121    pub fn hdfsGetWorkingDirectory(
122        fs: hdfsFS,
123        buffer: *mut c_char,
124        bufferSize: c_ulong,
125    ) -> *mut c_char;
126    pub fn hdfsSetWorkingDirectory(fs: hdfsFS, path: *const c_char) -> c_int;
127    pub fn hdfsCreateDirectory(fs: hdfsFS, path: *const c_char) -> c_int;
128    pub fn hdfsSetReplication(fs: hdfsFS, path: *const c_char, replication: i16) -> c_int;
129    pub fn hdfsListDirectory(
130        fs: hdfsFS,
131        path: *const c_char,
132        numEntries: *mut c_int,
133    ) -> *mut hdfsFileInfo;
134    pub fn hdfsGetPathInfo(fs: hdfsFS, path: *const c_char) -> *mut hdfsFileInfo;
135    pub fn hdfsFreeFileInfo(hdfsFileInfo: *mut hdfsFileInfo, numEntries: c_int);
136    pub fn hdfsGetHosts(
137        fs: hdfsFS,
138        path: *const c_char,
139        start: i64,
140        length: i64,
141    ) -> *mut *mut *mut c_char;
142    pub fn hdfsFreeHosts(blockHosts: *mut *mut *mut c_char);
143    pub fn hdfsGetDefaultBlockSize(fs: hdfsFS) -> i64;
144    pub fn hdfsGetDefaultBlockSizeAtPath(fs: hdfsFS, path: *const c_char) -> i64;
145    pub fn hdfsGetCapacity(fs: hdfsFS) -> i64;
146    pub fn hdfsGetUsed(fs: hdfsFS) -> i64;
147    pub fn hdfsChown(
148        fs: hdfsFS,
149        path: *const c_char,
150        owner: *const c_char,
151        group: *const c_char,
152    ) -> c_int;
153    pub fn hdfsChmod(fs: hdfsFS, path: *const c_char, mode: c_short) -> c_int;
154    pub fn hdfsUtime(fs: hdfsFS, path: *const c_char, mtime: c_long, atime: c_long) -> c_int;
155}