class Hasta::LocalStorage
The read/write file storage interface to the local representation of the S3 data used by the local map/reduce jobs
Public Instance Methods
write(s3_uri, data_source)
click to toggle source
# File lib/hasta/local_storage.rb, line 14 def write(s3_uri, data_source) contents = StringIO.new data_source.each_line do |line| contents << line end write_to( s3_uri.file? ? s3_uri : s3_uri.append('part-00000'), contents.string ) end
Private Instance Methods
fog_files(s3_bucket, s3_uri)
click to toggle source
# File lib/hasta/local_storage.rb, line 35 def fog_files(s3_bucket, s3_uri) s3_bucket.files.select { |file| file.key.start_with?(s3_uri.path) && file_s3_uri(file).parent == s3_uri } end
write_to(s3_uri, contents)
click to toggle source
# File lib/hasta/local_storage.rb, line 28 def write_to(s3_uri, contents) write_bucket = bucket(s3_uri) || create_bucket(s3_uri.bucket) file = create_file(write_bucket, s3_uri.path, contents) s3_uri end