webhdfs 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/VERSION +1 -1
- data/lib/webhdfs/client_v1.rb +12 -1
- data/lib/webhdfs/fileutils.rb +25 -0
- data/test/webhdfs/fileutils.rb +5 -0
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 079a9de419dc30c5280876fdb45dc4e6a3844fc1
         | 
| 4 | 
            +
              data.tar.gz: 915c3c102e9ae29a729d6498d2280b2fc94077f3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 514504c4024a57b80d81347634c33fa061c82ab28f6f55ff47f9dc5c3dde2efdca053161a912479bb64f2e8e6fef137af1f639848dbe5b1d506b349ac8f6045b
         | 
| 7 | 
            +
              data.tar.gz: 6135ce124d4619ed25a5f1aa790e9cbb7f9cc5a56085256d6bd386f9a9eb0c9fc3a9537b7e8ef72f8a7d19a95afc3f42098c2e3ce5874fcd7526dcb469903a25
         | 
    
        data/README.md
    CHANGED
    
    | @@ -21,7 +21,10 @@ To create/append/read files: | |
| 21 21 |  | 
| 22 22 | 
             
                client.create('/path/to/file', data)
         | 
| 23 23 | 
             
                client.create('/path/to/file', data, :overwrite => false, :blocksize => 268435456, :replication => 5, :permission => 0666)
         | 
| 24 | 
            -
             | 
| 24 | 
            +
             | 
| 25 | 
            +
                #This does not require whole data in memory, and it can be read chunk by chunk, ex: File data
         | 
| 26 | 
            +
                client.create('/path/to/file', file_IO_handle, :overwrite => false, :permission => 0666)
         | 
| 27 | 
            +
             | 
| 25 28 | 
             
                client.append('/path/to/existing/file', data)
         | 
| 26 29 |  | 
| 27 30 | 
             
                client.read('/path/to/target') #=> data
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.5. | 
| 1 | 
            +
            0.5.5
         | 
    
        data/lib/webhdfs/client_v1.rb
    CHANGED
    
    | @@ -268,7 +268,18 @@ module WebHDFS | |
| 268 268 | 
             
                                   path
         | 
| 269 269 | 
             
                                 end
         | 
| 270 270 |  | 
| 271 | 
            -
                  res =  | 
| 271 | 
            +
                  res = nil
         | 
| 272 | 
            +
                  if !payload.nil? and payload.is_a?(IO)
         | 
| 273 | 
            +
                    req = Net::HTTPGenericRequest.new(method,(payload ? true : false),true,request_path,header)
         | 
| 274 | 
            +
                    raise WebHDFS::IOError, 'Error reading given IO data source' unless payload.respond_to? :read and payload.respond_to? :size
         | 
| 275 | 
            +
                    raise WebHDFS::ClientError, 'Error accepting given IO resource as data payload, Not valid in methods other than PUT and POST' unless (method == 'PUT' or method == 'POST')
         | 
| 276 | 
            +
             | 
| 277 | 
            +
                    req.body_stream = payload
         | 
| 278 | 
            +
                    req.content_length = payload.size
         | 
| 279 | 
            +
                    res = conn.request(req)
         | 
| 280 | 
            +
                  else
         | 
| 281 | 
            +
                    res = conn.send_request(method, request_path, payload, header)
         | 
| 282 | 
            +
                  end
         | 
| 272 283 |  | 
| 273 284 | 
             
                  case res
         | 
| 274 285 | 
             
                  when Net::HTTPSuccess
         | 
    
        data/lib/webhdfs/fileutils.rb
    CHANGED
    
    | @@ -70,6 +70,31 @@ module WebHDFS | |
| 70 70 | 
             
                end
         | 
| 71 71 | 
             
                module_function :copy_from_local
         | 
| 72 72 |  | 
| 73 | 
            +
                # Public: Copy local file into HDFS with IOStream
         | 
| 74 | 
            +
                #
         | 
| 75 | 
            +
                # file - local file IO handle
         | 
| 76 | 
            +
                # path - HDFS file path
         | 
| 77 | 
            +
                # options - :overwrite, :blocksize, :replication, :mode, :buffersize, :verbose
         | 
| 78 | 
            +
                #
         | 
| 79 | 
            +
                # Examples
         | 
| 80 | 
            +
                #
         | 
| 81 | 
            +
                #   FileUtils.copy_from_local_via_stream 'local_file_IO_handle', 'remote_file'
         | 
| 82 | 
            +
                #
         | 
| 83 | 
            +
                def copy_from_local_via_stream(file, path, options={})
         | 
| 84 | 
            +
                  opts = options.dup
         | 
| 85 | 
            +
                  fu_log "copy_from_local_via_stream local=#{file} hdfs=#{path}" if opts.delete(:verbose)
         | 
| 86 | 
            +
                  if mode = opts.delete(:mode)
         | 
| 87 | 
            +
                    mode = ('%03o' % mode) if mode.is_a? Integer
         | 
| 88 | 
            +
                  else
         | 
| 89 | 
            +
                    mode = '644'
         | 
| 90 | 
            +
                  end
         | 
| 91 | 
            +
                  opts[:permission] = mode
         | 
| 92 | 
            +
                  opts[:overwrite] ||= true
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                  client.create(path, File.new(file, 'rb'), opts)
         | 
| 95 | 
            +
                end
         | 
| 96 | 
            +
                module_function :copy_from_local_via_stream
         | 
| 97 | 
            +
             | 
| 73 98 | 
             
                # Public: Copy remote HDFS file into local
         | 
| 74 99 | 
             
                #
         | 
| 75 100 | 
             
                # path - HDFS file path
         | 
    
        data/test/webhdfs/fileutils.rb
    CHANGED
    
    | @@ -13,6 +13,11 @@ class FileUtilsTest < Test::Unit::TestCase | |
| 13 13 | 
             
                WebHDFS::FileUtils.rm('VERSION', :verbose => true)
         | 
| 14 14 | 
             
              end
         | 
| 15 15 |  | 
| 16 | 
            +
              def test_copy_from_local_via_stream
         | 
| 17 | 
            +
                WebHDFS::FileUtils.copy_from_local_via_stream('VERSION', '/user/jay/VERSION', :verbose => true)
         | 
| 18 | 
            +
                WebHDFS::FileUtils.rm('VERSION', :verbose => true)
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 16 21 | 
             
              def test_rm
         | 
| 17 22 | 
             
                WebHDFS::FileUtils.mkdir('foo', :mode => 0777, :verbose => true)
         | 
| 18 23 | 
             
                WebHDFS::FileUtils.rm('foo', :verbose => true)
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: webhdfs
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.5. | 
| 4 | 
            +
              version: 0.5.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Kazuki Ohta
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2013- | 
| 11 | 
            +
            date: 2013-10-04 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rake
         | 
| @@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 107 107 | 
             
                  version: '0'
         | 
| 108 108 | 
             
            requirements: []
         | 
| 109 109 | 
             
            rubyforge_project: 
         | 
| 110 | 
            -
            rubygems_version: 2.0. | 
| 110 | 
            +
            rubygems_version: 2.0.3
         | 
| 111 111 | 
             
            signing_key: 
         | 
| 112 112 | 
             
            specification_version: 4
         | 
| 113 113 | 
             
            summary: Ruby WebHDFS/HttpFs client
         |