@@ -129,6 +129,48 @@ cdef class HadoopFileSystem:
129129 self ._path_info(path, & info)
130130 return info.kind == ObjectType_FILE
131131
132+ def get_capacity (self ):
133+ """
134+ Get reported total capacity of file system
135+
136+ Returns
137+ -------
138+ capacity : int
139+ """
140+ cdef int64_t capacity = 0
141+ with nogil:
142+ check_status(self .client.get().GetCapacity(& capacity))
143+ return capacity
144+
145+ def get_space_used (self ):
146+ """
147+ Get space used on file system
148+
149+ Returns
150+ -------
151+ space_used : int
152+ """
153+ cdef int64_t space_used = 0
154+ with nogil:
155+ check_status(self .client.get().GetUsed(& space_used))
156+ return space_used
157+
158+ def df (self ):
159+ """
160+ Return free space on disk, like the UNIX df command
161+
162+ Returns
163+ -------
164+ space : int
165+ """
166+ return self .get_capacity() - self .get_space_used()
167+
168+ def rename (self , path , new_path ):
169+ cdef c_string c_path = tobytes(path)
170+ cdef c_string c_new_path = tobytes(new_path)
171+ with nogil:
172+ check_status(self .client.get().Rename(c_path, c_new_path))
173+
132174 def info (self , path ):
133175 """
134176 Return detailed HDFS information for path
@@ -158,6 +200,30 @@ cdef class HadoopFileSystem:
158200 else ' file' )
159201 }
160202
203+ def stat (self , path ):
204+ """
205+ Return basic file system statistics about path
206+
207+ Parameters
208+ ----------
209+ path : string
210+ Path to file or directory
211+
212+ Returns
213+ -------
214+ stat : dict
215+ """
216+ cdef FileStatistics info
217+ cdef c_string c_path = tobytes(path)
218+ with nogil:
219+ check_status(self .client.get()
220+ .Stat(c_path, & info))
221+ return {
222+ ' size' : info.size,
223+ ' kind' : (' directory' if info.kind == ObjectType_DIRECTORY
224+ else ' file' )
225+ }
226+
161227 cdef _path_info(self , path, HdfsPathInfo* info):
162228 cdef c_string c_path = tobytes(path)
163229
@@ -290,9 +356,16 @@ cdef class HadoopFileSystem:
290356 def open (self , path , mode = ' rb' , buffer_size = None , replication = None ,
291357 default_block_size = None ):
292358 """
359+ Open HDFS file for reading or writing
360+
293361 Parameters
294362 ----------
295- mode : string, 'rb', 'wb', 'ab'
363+ mode : string
364+ Must be one of 'rb', 'wb', 'ab'
365+
366+ Returns
367+ -------
368+ handle : HdfsFile
296369 """
297370 self ._ensure_client()
298371
0 commit comments