hivemeta 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -1
- data/lib/hivemeta/connection.rb +3 -2
- data/lib/hivemeta/record.rb +9 -6
- data/lib/hivemeta/table.rb +4 -3
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
* 2011-05-19 - fsf
|
2
|
-
-
|
2
|
+
- thank you ruby-prof!
|
3
|
+
- perf: 4x+ faster ... now basically on par with manual split into array
|
4
|
+
- perf: create extra hash for column index by name
|
5
|
+
- perf: remove unnecessary string indexed assignment
|
6
|
+
- clean: table.each does each inside rather than each_with_index
|
3
7
|
|
4
8
|
* 2011-05-17 - fsf
|
5
9
|
- bugfix: default unspecified delimiter is ^A rather than TAB
|
data/lib/hivemeta/connection.rb
CHANGED
@@ -77,8 +77,9 @@ module HiveMeta
|
|
77
77
|
col_cmt = rec[2]
|
78
78
|
tbl_loc = rec[3]
|
79
79
|
sd_id = rec[4]
|
80
|
-
table.columns[col_idx]
|
81
|
-
table.
|
80
|
+
table.columns[col_idx] = col_name
|
81
|
+
table.indexes[col_name.to_sym] = col_idx
|
82
|
+
table.comments[col_idx] = col_cmt
|
82
83
|
table.path = tbl_loc
|
83
84
|
end
|
84
85
|
|
data/lib/hivemeta/record.rb
CHANGED
@@ -9,10 +9,11 @@ module HiveMeta
|
|
9
9
|
raise FieldCountError
|
10
10
|
end
|
11
11
|
|
12
|
-
@
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
@table = table
|
13
|
+
#@columns = {}
|
14
|
+
# table.each_col_with_index do |col_name, i|
|
15
|
+
# #@columns[col_name.to_sym] = @fields[i]
|
16
|
+
# end
|
16
17
|
end
|
17
18
|
|
18
19
|
# allow for column access via column name as an index
|
@@ -22,13 +23,15 @@ module HiveMeta
|
|
22
23
|
# example: rec[7]
|
23
24
|
def [] index
|
24
25
|
return "#{@fields[index]}" if index.is_a? Integer
|
25
|
-
"#{@columns[index.to_sym]}"
|
26
|
+
#"#{@columns[index.to_sym]}"
|
27
|
+
"#{@fields[@table.indexes[index.to_sym]]}"
|
26
28
|
end
|
27
29
|
|
28
30
|
# allow for column access via column name as a method
|
29
31
|
# example: rec.col_name
|
30
32
|
def method_missing(id, *args)
|
31
|
-
return @
|
33
|
+
return @fields[@table.indexes[id]] if @fields[@table.indexes[id]]
|
34
|
+
#return @columns[id] if @columns[id]
|
32
35
|
raise NoMethodError
|
33
36
|
end
|
34
37
|
end
|
data/lib/hivemeta/table.rb
CHANGED
@@ -4,12 +4,13 @@ module HiveMeta
|
|
4
4
|
include Comparable
|
5
5
|
include Enumerable
|
6
6
|
|
7
|
-
attr_accessor :path, :columns, :comments, :delimiter
|
7
|
+
attr_accessor :path, :columns, :comments, :delimiter, :indexes
|
8
8
|
|
9
9
|
def initialize(name)
|
10
10
|
@name = name
|
11
11
|
@path = nil
|
12
|
-
@
|
12
|
+
@indexes = {} # column indexes by name
|
13
|
+
@columns = [] # column names by index
|
13
14
|
@comments = []
|
14
15
|
@delimiter = "\001"
|
15
16
|
end
|
@@ -19,7 +20,7 @@ module HiveMeta
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def each
|
22
|
-
@columns.
|
23
|
+
@columns.each do |column_name|
|
23
24
|
yield column_name if column_name
|
24
25
|
end
|
25
26
|
end
|