monetdb 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWJkMDFjNjQyYWY5ZTFiY2IyZmU5YTQwYTUwMjhiZjY0OWRkYTM3Mg==
4
+ MThkM2ZmNjgyZDMwNmMzZmVlYTc3ZTBhYzZmZjhhZGFmOGFlZWFlNg==
5
5
  data.tar.gz: !binary |-
6
- ZTBlNWNjNDA1YTAzN2I2YzYyZGZmZmVkYjEyYWVhMDk3MmI3OWE5OA==
6
+ MjZiNTIxYTNmMzkyOTQzMjBkNGQxZGY3MWJhMGQ0MjI1MGE5NWRiZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWNiM2RmYmM1MTQ0MjE3ZDk4NzVjYWI5ZDYzMDFjMDFmYTg0YmNhZGYwYzIx
10
- ZmE3MDJiNThmZGFhNjM5ZDQxODEwMjU3ZDVkNmM4MTFiZjg1YjE1NzU1NzNh
11
- MjkzZGRkYTI0NjdhMjcwN2RlZGVhODk0NWIzZGMyMjkyMzZjNTI=
9
+ Njg2ZGY4ZjQxZWVhMmFhYjkxNDQ2NWJlYTM4ZmE1NDExZmIxYTJhNTRhYmQw
10
+ ZDUzZDFiY2ViMzRhNTk0MzkxZDI2NmZiOWE3NTM2NWM0ZWEyYTI5MGMxMGRh
11
+ MTc3MjcxNDVjNWY5OWNiYjY2OTEzNzA4ZGNjOWY5Nzg4MmUyYjI=
12
12
  data.tar.gz: !binary |-
13
- ODUzYzExNWY5N2VjOWI0OWFiMmJjNDgzMDIyMDBjMmRlYTU4ZjU2NWM0ZTMy
14
- NjM2MDMwODkzNzMzNTZkM2I2ZGU0YjhjMGU4ZTNkMGViNzU3MWY4YmNhYjhj
15
- ZGEyZTMxY2Y4NzgyYWU2ZWZlMzgwZjcxNWU0ZmJhMGZjZTcxZjk=
13
+ NGU0NDk0MWFkNTMzYjU0MTllZGNiOWFiMmRlZWVkY2EzM2EzMTQwZDM1MDFj
14
+ NTc2NjZmZWExMDU5ODhiZTI5ODVkMGJmNmQ2NjQ5Yjk1NGI1NWZmZTg1NzQy
15
+ MTQ1NzI1ZDllYjExZWU3NzZjNGVlZjY4YTRiY2U4Mzg4MGUwY2E=
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  = MonetDB CHANGELOG
2
2
 
3
+ == Version 0.1.2 (October 6, 2014)
4
+
5
+ * Simplified MonetDB#select_rows gaining performance receiving the query result set
6
+
3
7
  == Version 0.1.1 (August 28, 2014)
4
8
 
5
9
  * Fixed raising several errors
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- monetdb (0.1.1)
4
+ monetdb (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/lib/monetdb.rb CHANGED
@@ -183,29 +183,48 @@ class MonetDB
183
183
  #
184
184
  # Returns an array of arrays with casted values.
185
185
  def select_rows(qry)
186
+ return if @connection.nil?
187
+ data = MonetDB::Data.new @connection
188
+
186
189
  start = Time.now
187
- data = query(qry)
190
+ @connection.send(data.send(:format_query, qry))
191
+ result_set = @connection.receive.split("\n")
188
192
  log :info, "\n SQL (#{((Time.now - start) * 1000).round(1)}ms) #{qry}"
189
- column_types = data.instance_variable_get(:@header)["columns_type"]
190
- types = data.instance_variable_get(:@header)["columns_name"].collect{|x| column_types[x]}
191
- data.fetch_all.collect do |array|
192
- row = []
193
- array.each_with_index do |value, index|
194
- row << begin
195
- unless value == "NULL"
196
- case types[index]
197
- when "bigint", "int"
198
- value.to_i
199
- when "double"
200
- value.to_f
201
- else
202
- value.force_encoding("UTF-8")
193
+
194
+ if (row = result_set[0]).chr == MSG_INFO
195
+ raise QueryError, row
196
+ end
197
+
198
+ record_set = result_set.select{|x| [MSG_SCHEMA_HEADER, MSG_QUERY].include? x[0]}.compact
199
+ data.send :receive_record_set, record_set.join("\n")
200
+
201
+ if data.instance_variable_get(:@action) == Q_TABLE
202
+ header = data.send :parse_header_table, data.instance_variable_get(:@header)
203
+ end
204
+
205
+ column_types = header["columns_type"]
206
+ types = header["columns_name"].collect{|x| column_types[x]}
207
+
208
+ result_set.collect do |x|
209
+ if x[0] == MSG_TUPLE
210
+ row, values = [], x[1..-2].split(",\t")
211
+ values.each_with_index do |value, index|
212
+ row << begin
213
+ unless value.strip == "NULL"
214
+ case types[index]
215
+ when "bigint", "int"
216
+ value.to_i
217
+ when "double"
218
+ value.to_f
219
+ else
220
+ value.strip.gsub(/(^"|"$|\\|\")/, "").force_encoding("UTF-8")
221
+ end
203
222
  end
204
223
  end
205
224
  end
225
+ row
206
226
  end
207
- row
208
- end
227
+ end.compact
209
228
  end
210
229
 
211
230
  # Returns whether a "connection" object exists.
@@ -1,7 +1,7 @@
1
1
  class MonetDB
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- TINY = 1
4
+ TINY = 2
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join(".")
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monetdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Engel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-28 00:00:00.000000000 Z
11
+ date: 2014-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake