ruby-hdfs-cdh4 0.0.7 → 0.0.8
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.
- data/ext/hdfs/hdfs.c +13 -5
- metadata +3 -3
data/ext/hdfs/hdfs.c
CHANGED
@@ -763,9 +763,15 @@ VALUE HDFS_File_System_open(int argc, VALUE* argv, VALUE self) {
|
|
763
763
|
* returning the bytes read as a String. If this fails, raises a
|
764
764
|
* FileError.
|
765
765
|
*/
|
766
|
-
VALUE HDFS_File_read(VALUE
|
766
|
+
VALUE HDFS_File_read(int argc, VALUE* argv, VALUE self) {
|
767
|
+
VALUE length;
|
768
|
+
rb_scan_args(argc, argv, "01", &length);
|
769
|
+
unsigned int hdfsLength = HDFS_DEFAULT_BUFFER_SIZE;
|
770
|
+
if (!NIL_P(length)) {
|
771
|
+
hdfsLength = NUM2UINT(length);
|
772
|
+
}
|
767
773
|
// Checks whether we're reading more data than HDFS client can support.
|
768
|
-
if (
|
774
|
+
if (hdfsLength > HDFS_DEFAULT_BUFFER_SIZE) {
|
769
775
|
rb_raise(e_file_error, "Can only read a max of %u bytes from HDFS",
|
770
776
|
HDFS_DEFAULT_BUFFER_SIZE);
|
771
777
|
return Qnil;
|
@@ -775,11 +781,13 @@ VALUE HDFS_File_read(VALUE self, VALUE length) {
|
|
775
781
|
ensure_file_open(data);
|
776
782
|
char* buffer = ALLOC_N(char, length);
|
777
783
|
MEMZERO(buffer, char, length);
|
778
|
-
tSize bytes_read = hdfsRead(data->fs, data->file, buffer,
|
784
|
+
tSize bytes_read = hdfsRead(data->fs, data->file, buffer, hdfsLength);
|
779
785
|
if (bytes_read == -1) {
|
780
786
|
rb_raise(e_file_error, "Failed to read data");
|
781
787
|
}
|
782
|
-
|
788
|
+
VALUE string_output = rb_tainted_str_new(buffer, bytes_read);
|
789
|
+
xfree(buffer);
|
790
|
+
return string_output;
|
783
791
|
}
|
784
792
|
|
785
793
|
/**
|
@@ -1138,7 +1146,7 @@ void Init_hdfs() {
|
|
1138
1146
|
rb_define_method(c_file_system, "utime", HDFS_File_System_utime, -1);
|
1139
1147
|
|
1140
1148
|
c_file = rb_define_class_under(m_dfs, "File", rb_cObject);
|
1141
|
-
rb_define_method(c_file, "read", HDFS_File_read, 1);
|
1149
|
+
rb_define_method(c_file, "read", HDFS_File_read, -1);
|
1142
1150
|
rb_define_method(c_file, "write", HDFS_File_write, 1);
|
1143
1151
|
rb_define_method(c_file, "<<", HDFS_File_write, 1);
|
1144
1152
|
rb_define_method(c_file, "seek", HDFS_File_seek, 1);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-hdfs-cdh4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-06-
|
14
|
+
date: 2013-06-21 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: ruby hadoop libhdfs client with support for cdh4
|
17
17
|
email:
|
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
48
|
version: 1.8.10
|
49
49
|
requirements: []
|
50
50
|
rubyforge_project:
|
51
|
-
rubygems_version: 1.8.
|
51
|
+
rubygems_version: 1.8.23
|
52
52
|
signing_key:
|
53
53
|
specification_version: 3
|
54
54
|
summary: ruby hadoop libhdfs client with support for cdh4
|