hutch-xamplr 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +13 -0
- data/VERSION.yml +1 -1
- data/examples/random-people/people.rb +2 -2
- data/examples/random-people/query.rb +16 -11
- data/examples/random-people-shared-addresses/Makefile +16 -0
- data/examples/random-people-shared-addresses/batch-load-users.rb +86 -0
- data/examples/random-people-shared-addresses/find-mentions.rb +50 -0
- data/examples/random-people-shared-addresses/find-people-by-address.rb +110 -0
- data/examples/random-people-shared-addresses/optimise.rb +19 -0
- data/examples/random-people-shared-addresses/people.rb +50 -0
- data/examples/random-people-shared-addresses/query.rb +78 -0
- data/examples/random-people-shared-addresses/query2.rb +76 -0
- data/examples/random-people-shared-addresses/random-names.csv +10000 -0
- data/examples/random-people-shared-addresses/what-to-query-on.rb +82 -0
- data/examples/random-people-shared-addresses/xampl-gen.rb +36 -0
- data/examples/random-people-shared-addresses/xml/people.xml +14 -0
- data/lib/xamplr/TODO +1 -3
- data/lib/xamplr/{persister → obsolete}/fsdb.rb +0 -0
- data/lib/xamplr/persistence.rb +7 -3
- data/lib/xamplr/persister/tokyo-cabinet.rb +70 -7
- data/lib/xamplr/templates/element_data.template +29 -21
- data/lib/xamplr/templates/element_empty.template +29 -22
- data/lib/xamplr/templates/element_mixed.template +31 -24
- data/lib/xamplr/templates/element_simple.template +29 -22
- data/lib/xamplr/{Makefile → test-support/Makefile} +0 -0
- data/lib/xamplr/{bench-cache.rb → test-support/bench-cache.rb} +1 -1
- data/lib/xamplr/{bench-script.rb → test-support/bench-script.rb} +0 -0
- data/lib/xamplr/{bench.rb → test-support/bench.rb} +0 -0
- data/lib/xamplr/{bench2.rb → test-support/bench2.rb} +9 -9
- data/lib/xamplr/{test-cache.rb → test-support/test-cache.rb} +0 -0
- data/lib/xamplr/{test-data → test-support/test-data}/binding.xml +0 -0
- data/lib/xamplr/{test-data → test-support/test-data}/example.xml +0 -0
- data/lib/xamplr/{test-data → test-support/test-data}/internationalization-utf8.txt +0 -0
- data/lib/xamplr/{test-data → test-support/test-data}/labels.xml +0 -0
- data/lib/xamplr/{test-data → test-support/test-data}/labels001.xml +0 -0
- data/lib/xamplr/{test-deep-change.rb → test-support/test-deep-change.rb} +0 -0
- data/lib/xamplr/{test-elements.rb → test-support/test-elements.rb} +0 -0
- data/lib/xamplr/{test-indexed-array.rb → test-support/test-indexed-array.rb} +0 -0
- data/lib/xamplr/{test-misc.rb → test-support/test-misc.rb} +0 -0
- data/lib/xamplr/{test-names.rb → test-support/test-names.rb} +0 -0
- data/lib/xamplr/{test-rollback.rb → test-support/test-rollback.rb} +0 -0
- data/lib/xamplr/{test.rb → test-support/test.rb} +74 -74
- data/lib/xamplr/to-ruby.rb +19 -15
- data/lib/xamplr/to-xml.rb +5 -4
- data/lib/xamplr/visitor.rb +6 -2
- data/lib/xamplr/xampl-object.rb +4 -9
- metadata +43 -25
- data/lib/xamplr/BUGS +0 -3
- data/lib/xamplr/CHANGES +0 -16
- data/lib/xamplr/REQUIREMENTS +0 -2
- data/lib/xamplr/sqlite/sqlite-play.rb +0 -14
data/CHANGES.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
2009-04-16 (version 1.0.2)
|
3
|
+
|
4
|
+
-- if tag starts with a number, prefix it with an 'x' (e.g. 0abc --> x0abc).
|
5
|
+
The problem arose if a tag like <0abc> was used in an xml file
|
6
|
+
used to generate xampl code. In that case, the 'attribute
|
7
|
+
names' associated with the tag would be based on '_abc'. The
|
8
|
+
change makes the attribute names be based on x0abc. The choice
|
9
|
+
of 'x' is arbitrary, but we can't have a leading digit, and
|
10
|
+
the '_' could fail to distinguish certain elements (e.g. 0abc
|
11
|
+
and 1abc would both be based on '_abc').
|
12
|
+
|
13
|
+
|
data/VERSION.yml
CHANGED
@@ -2,8 +2,8 @@ $LOAD_PATH.unshift("xampl_generated_code")
|
|
2
2
|
|
3
3
|
require 'RandomPeople'
|
4
4
|
|
5
|
-
Xampl.set_default_persister_kind(:tokyo_cabinet)
|
6
|
-
Xampl.set_default_persister_format(:xml_format)
|
5
|
+
#Xampl.set_default_persister_kind(:tokyo_cabinet)
|
6
|
+
#Xampl.set_default_persister_format(:xml_format)
|
7
7
|
|
8
8
|
module RandomPeople
|
9
9
|
|
@@ -28,14 +28,16 @@ module RandomPeople
|
|
28
28
|
found3 = []
|
29
29
|
|
30
30
|
start_query_at = Time.now
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# q.
|
37
|
-
|
38
|
-
|
31
|
+
found1 = Xampl.transaction("random-people") do
|
32
|
+
Xampl.query do | q |
|
33
|
+
q.add_condition('city', :equals, 'TORONTO')
|
34
|
+
q.add_condition('email', :ends_with, 'dodgit.com')
|
35
|
+
|
36
|
+
# q.setlimit(10, 10)
|
37
|
+
|
38
|
+
q.order_by('surname', :strasc)
|
39
|
+
end
|
40
|
+
end
|
39
41
|
|
40
42
|
start_find_at = Time.now
|
41
43
|
found2 = Xampl.transaction("random-people") do
|
@@ -54,7 +56,7 @@ module RandomPeople
|
|
54
56
|
found3 = Xampl.transaction("random-people") do
|
55
57
|
Xampl.find_pids do | q |
|
56
58
|
q.add_condition('city', :equals, 'TORONTO')
|
57
|
-
|
59
|
+
q.add_condition('email', :ends_with, 'dodgit.com')
|
58
60
|
|
59
61
|
# q.setlimit(10, 10)
|
60
62
|
|
@@ -66,7 +68,10 @@ module RandomPeople
|
|
66
68
|
# found1.each do | person_meta |
|
67
69
|
# puts "surname: #{ person_meta['surname']}, given: #{ person_meta['xampl'].given_name }"
|
68
70
|
# end
|
69
|
-
|
70
|
-
puts
|
71
|
+
|
72
|
+
puts
|
73
|
+
puts "query :: found: #{ found1.size }, in: #{ start_find_at - start_query_at }"
|
74
|
+
puts "find :: found: #{ found2.size }, in: #{ start_find_pids_at - start_find_at }"
|
75
|
+
puts "find pids:: found: #{ found3.size }, in: #{ done - start_find_pids_at}"
|
71
76
|
end
|
72
77
|
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
|
2
|
+
require 'fastercsv'
|
3
|
+
require 'xampl_generated_code/RandomPeople'
|
4
|
+
require 'people'
|
5
|
+
|
6
|
+
Xampl.set_default_persister_kind(:tokyo_cabinet)
|
7
|
+
#Xampl.set_default_persister_format(:xml_format)
|
8
|
+
Xampl.set_default_persister_format(:ruby_format)
|
9
|
+
|
10
|
+
module RandomPeople
|
11
|
+
|
12
|
+
start_at = Time.now
|
13
|
+
|
14
|
+
arr_of_arrs = FasterCSV.read("random-names.csv")
|
15
|
+
|
16
|
+
parsed_at = Time.now
|
17
|
+
|
18
|
+
#GivenName,Surname,StreetAddress,City,State,ZipCode,EmailAddress,TelephoneNumber
|
19
|
+
|
20
|
+
#<people pid=''
|
21
|
+
# xmlns="http://xampl.com/people">
|
22
|
+
# <person pid=''
|
23
|
+
# given-name=''
|
24
|
+
# surname=''
|
25
|
+
# email=''
|
26
|
+
# phone=''>
|
27
|
+
# <address pid=''
|
28
|
+
# street-address=''
|
29
|
+
# city=''
|
30
|
+
# state=''
|
31
|
+
# postal-code=''/>
|
32
|
+
# </person>
|
33
|
+
#</people>
|
34
|
+
|
35
|
+
base = 0
|
36
|
+
|
37
|
+
created_addresses = 0
|
38
|
+
shared_addresses = 0
|
39
|
+
|
40
|
+
10.times do | iter |
|
41
|
+
inner_start = Time.now
|
42
|
+
Xampl.transaction("random-people") do
|
43
|
+
|
44
|
+
base += arr_of_arrs.size
|
45
|
+
|
46
|
+
arr_of_arrs.each_with_index do | row, i |
|
47
|
+
person_pid = "person-#{ base + i }"
|
48
|
+
person = Person.new(person_pid)
|
49
|
+
|
50
|
+
person.given_name = row[0]
|
51
|
+
person.surname = row[1]
|
52
|
+
person.email = row[6]
|
53
|
+
person.phone = row[7]
|
54
|
+
|
55
|
+
addresses = Xampl.find_xampl do | q |
|
56
|
+
q.add_condition('class', :equals, Address.name)
|
57
|
+
|
58
|
+
q.add_condition('street-address', :equals, row[2])
|
59
|
+
q.add_condition('postal-code', :equals, row[5])
|
60
|
+
end
|
61
|
+
|
62
|
+
address = addresses.first
|
63
|
+
if address then
|
64
|
+
person << address
|
65
|
+
shared_addresses += 1
|
66
|
+
else
|
67
|
+
address = person.new_address("address-#{ person_pid }")
|
68
|
+
address.street_address = row[2]
|
69
|
+
address.city = row[3]
|
70
|
+
address.state = row[4]
|
71
|
+
address.postal_code = row[5]
|
72
|
+
created_addresses += 1
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
puts "transaction ending..."
|
77
|
+
end
|
78
|
+
puts "iter: #{ iter } in #{ Time.now - inner_start }"
|
79
|
+
end
|
80
|
+
|
81
|
+
processed_at = Time.now
|
82
|
+
|
83
|
+
p "parsed in #{ parsed_at - start_at }, processed in: #{ processed_at - parsed_at }"
|
84
|
+
puts " created addresses: #{ created_addresses }, shared: #{ shared_addresses }"
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
require 'xampl_generated_code/RandomPeople'
|
3
|
+
require 'people'
|
4
|
+
|
5
|
+
Xampl.set_default_persister_kind(:tokyo_cabinet)
|
6
|
+
#Xampl.set_default_persister_format(:xml_format)
|
7
|
+
Xampl.set_default_persister_format(:ruby_format)
|
8
|
+
|
9
|
+
module RandomPeople
|
10
|
+
|
11
|
+
#<people pid=''
|
12
|
+
# xmlns="http://xampl.com/people">
|
13
|
+
# <person pid=''
|
14
|
+
# given-name=''
|
15
|
+
# surname=''
|
16
|
+
# email=''
|
17
|
+
# phone=''>
|
18
|
+
# <address pid=''
|
19
|
+
# street-address=''
|
20
|
+
# city=''
|
21
|
+
# state=''
|
22
|
+
# postal-code=''/>
|
23
|
+
# </person>
|
24
|
+
#</people>
|
25
|
+
|
26
|
+
10.times do
|
27
|
+
|
28
|
+
people = Xampl.transaction("random-people") do
|
29
|
+
Person.find_by_query do | q |
|
30
|
+
q.add_condition('city', :equals, 'TORONTO')
|
31
|
+
q.add_condition('email', :ends_with, 'dodgit.com')
|
32
|
+
|
33
|
+
q.order_by('surname', :strasc)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
first_person = people.first
|
38
|
+
address = first_person.address.first
|
39
|
+
|
40
|
+
start_at = Time.now
|
41
|
+
|
42
|
+
people_at_address = Xampl.transaction("random-people") do
|
43
|
+
Xampl.find_mentions_of(address)
|
44
|
+
end
|
45
|
+
|
46
|
+
done = Time.now
|
47
|
+
puts "found #{ people_at_address.size } people at that address in: #{ done - start_at }, #{ people_at_address.size / (done - start_at) }/s"
|
48
|
+
# people_at_address.each { | person | puts person.pp_xml }
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
|
2
|
+
require 'xampl_generated_code/RandomPeople'
|
3
|
+
require 'people'
|
4
|
+
|
5
|
+
Xampl.set_default_persister_kind(:tokyo_cabinet)
|
6
|
+
#Xampl.set_default_persister_format(:xml_format)
|
7
|
+
Xampl.set_default_persister_format(:ruby_format)
|
8
|
+
|
9
|
+
module RandomPeople
|
10
|
+
|
11
|
+
#<people pid=''
|
12
|
+
# xmlns="http://xampl.com/people">
|
13
|
+
# <person pid=''
|
14
|
+
# given-name=''
|
15
|
+
# surname=''
|
16
|
+
# email=''
|
17
|
+
# phone=''>
|
18
|
+
# <address pid=''
|
19
|
+
# street-address=''
|
20
|
+
# city=''
|
21
|
+
# state=''
|
22
|
+
# postal-code=''/>
|
23
|
+
# </person>
|
24
|
+
#</people>
|
25
|
+
|
26
|
+
times = [0, 0]
|
27
|
+
counts = [0, 0]
|
28
|
+
|
29
|
+
10.times do | trial |
|
30
|
+
found1 = []
|
31
|
+
found2 = []
|
32
|
+
found3 = []
|
33
|
+
|
34
|
+
#<p:person email='Edelmira.K.Abshire@dodgit.com'
|
35
|
+
# given-name='Edelmira'
|
36
|
+
# phone='416-279-8804'
|
37
|
+
# pid='person-29944'
|
38
|
+
# surname='Abshire'
|
39
|
+
# xmlns:p='http://xampl.com/people'>
|
40
|
+
# <p:address city='TORONTO'
|
41
|
+
# pid='person-19944'
|
42
|
+
# postal_code='M1P 4W2'
|
43
|
+
# state='ON'
|
44
|
+
# street_address='4194 Borough Drive'/></p:person>
|
45
|
+
|
46
|
+
|
47
|
+
all_people = nil
|
48
|
+
people_inspected = 0
|
49
|
+
start_at = Time.now
|
50
|
+
|
51
|
+
people = Xampl.transaction("random-people") do
|
52
|
+
addresses = Address.find_by_query do | q |
|
53
|
+
q.add_condition('street-address', :equals, '4194 Borough Drive')
|
54
|
+
q.add_condition('postal-code', :equals, 'M1P 4W2')
|
55
|
+
end
|
56
|
+
|
57
|
+
all_people = Set.new
|
58
|
+
people_inspected = 0
|
59
|
+
|
60
|
+
addresses.each do | address |
|
61
|
+
people = Person.find_by_query do | q |
|
62
|
+
# TODO -- want to be able to find people by the address directly, e.g. address.find_by_citation/find_by_mention & find_by_reference
|
63
|
+
q.add_condition('city', :equals, address.city)
|
64
|
+
q.add_condition('state', :equals, address.state)
|
65
|
+
end
|
66
|
+
|
67
|
+
people_inspected += people.size
|
68
|
+
|
69
|
+
people.each do | person |
|
70
|
+
all_people << person if person.address.first == address
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
done_at = Time.now
|
76
|
+
puts "done in: #{ done_at - start_at }, #{ people_inspected } people inspected, #{ all_people.size } identified"
|
77
|
+
times[0] += (done_at - start_at) if 0 < trial
|
78
|
+
counts[0] += 1 if 0 < trial
|
79
|
+
|
80
|
+
start_at = Time.now
|
81
|
+
|
82
|
+
people = Xampl.transaction("random-people") do
|
83
|
+
addresses = Address.find_by_query do | q |
|
84
|
+
q.add_condition('street-address', :equals, '4194 Borough Drive')
|
85
|
+
q.add_condition('postal-code', :equals, 'M1P 4W2')
|
86
|
+
end
|
87
|
+
|
88
|
+
all_people = Set.new
|
89
|
+
people_inspected = 0
|
90
|
+
|
91
|
+
addresses.each do | address |
|
92
|
+
people = Xampl.find_mentions_of(address)
|
93
|
+
|
94
|
+
people_inspected += people.size
|
95
|
+
|
96
|
+
people.each do | person |
|
97
|
+
all_people << person if person.address.first == address
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
done_at = Time.now
|
103
|
+
puts "done in: #{ done_at - start_at }, #{ people_inspected } people inspected, #{ all_people.size } identified"
|
104
|
+
times[1] += (done_at - start_at) if 0 < trial
|
105
|
+
counts[1] += 1 if 0 < trial
|
106
|
+
end
|
107
|
+
|
108
|
+
puts "0) total time: #{ times[0] }, count: #{ counts[0] }, average/s: #{ counts[0]/times[0]}"
|
109
|
+
puts "1) total time: #{ times[1] }, count: #{ counts[1] }, average/s: #{ counts[1]/times[1]}"
|
110
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
$LOAD_PATH.unshift("xampl_generated_code")
|
2
|
+
|
3
|
+
require 'RandomPeople'
|
4
|
+
require 'people'
|
5
|
+
|
6
|
+
Xampl.set_default_persister_kind(:tokyo_cabinet)
|
7
|
+
#Xampl.set_default_persister_format(:xml_format)
|
8
|
+
Xampl.set_default_persister_format(:ruby_format)
|
9
|
+
|
10
|
+
module RandomPeople
|
11
|
+
|
12
|
+
start_opt = Time.now
|
13
|
+
Xampl.transaction("random-people") do
|
14
|
+
Xampl.optimise(:indexes_only => true)
|
15
|
+
# Xampl.optimise
|
16
|
+
end
|
17
|
+
puts "optimised in #{ Time.now - start_opt}"
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
require 'xampl_generated_code/RandomPeople'
|
3
|
+
|
4
|
+
module RandomPeople
|
5
|
+
|
6
|
+
#<people pid=''
|
7
|
+
# xmlns="http://xampl.com/people">
|
8
|
+
# <person pid=''
|
9
|
+
# given-name=''
|
10
|
+
# surname=''
|
11
|
+
# email=''
|
12
|
+
# phone=''>
|
13
|
+
# <address pid=''
|
14
|
+
# street-address=''
|
15
|
+
# city=''
|
16
|
+
# state=''
|
17
|
+
# postal-code=''/>
|
18
|
+
# </person>
|
19
|
+
#</people>
|
20
|
+
|
21
|
+
class Person
|
22
|
+
|
23
|
+
Xampl::TokyoCabinetPersister.add_lexical_indexs(%w{ surname city state email })
|
24
|
+
|
25
|
+
def describe_yourself
|
26
|
+
{
|
27
|
+
'surname' => self.surname,
|
28
|
+
'city' => self.address.first.city,
|
29
|
+
'state' => self.address.first.state,
|
30
|
+
'email' => self.email
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class Address
|
36
|
+
|
37
|
+
Xampl::TokyoCabinetPersister.add_lexical_indexs(%w{ street-address postal-code city state })
|
38
|
+
|
39
|
+
def describe_yourself
|
40
|
+
{
|
41
|
+
'street-address' => self.street_address,
|
42
|
+
'postal-code' => self.postal_code,
|
43
|
+
'city' => self.city,
|
44
|
+
'state' => self.state
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,78 @@
|
|
1
|
+
|
2
|
+
require 'xampl_generated_code/RandomPeople'
|
3
|
+
require 'people'
|
4
|
+
|
5
|
+
Xampl.set_default_persister_kind(:tokyo_cabinet)
|
6
|
+
#Xampl.set_default_persister_format(:xml_format)
|
7
|
+
Xampl.set_default_persister_format(:ruby_format)
|
8
|
+
|
9
|
+
module RandomPeople
|
10
|
+
|
11
|
+
#<people pid=''
|
12
|
+
# xmlns="http://xampl.com/people">
|
13
|
+
# <person pid=''
|
14
|
+
# given-name=''
|
15
|
+
# surname=''
|
16
|
+
# email=''
|
17
|
+
# phone=''>
|
18
|
+
# <address pid=''
|
19
|
+
# street-address=''
|
20
|
+
# city=''
|
21
|
+
# state=''
|
22
|
+
# postal-code=''/>
|
23
|
+
# </person>
|
24
|
+
#</people>
|
25
|
+
|
26
|
+
5.times do
|
27
|
+
found1 = []
|
28
|
+
found2 = []
|
29
|
+
found3 = []
|
30
|
+
|
31
|
+
start_query_at = Time.now
|
32
|
+
found1 = Xampl.transaction("random-people") do
|
33
|
+
Xampl.query do | q |
|
34
|
+
q.add_condition('city', :equals, 'TORONTO')
|
35
|
+
q.add_condition('email', :ends_with, 'dodgit.com')
|
36
|
+
|
37
|
+
# q.setlimit(10, 10)
|
38
|
+
|
39
|
+
q.order_by('surname', :strasc)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
start_find_at = Time.now
|
44
|
+
found2 = Xampl.transaction("random-people") do
|
45
|
+
Person.find_by_query do | q |
|
46
|
+
q.add_condition('city', :equals, 'TORONTO')
|
47
|
+
q.add_condition('email', :ends_with, 'dodgit.com')
|
48
|
+
|
49
|
+
# q.setlimit(10, 10)
|
50
|
+
|
51
|
+
q.order_by('surname', :strasc)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
start_find_pids_at = Time.now
|
56
|
+
|
57
|
+
found3 = Xampl.transaction("random-people") do
|
58
|
+
Xampl.find_pids do | q |
|
59
|
+
q.add_condition('city', :equals, 'TORONTO')
|
60
|
+
q.add_condition('email', :ends_with, 'dodgit.com')
|
61
|
+
|
62
|
+
# q.setlimit(10, 10)
|
63
|
+
|
64
|
+
q.order_by('surname', :strasc)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
done = Time.now
|
68
|
+
|
69
|
+
# found1.each do | person_meta |
|
70
|
+
# puts "surname: #{ person_meta['surname']}, given: #{ person_meta['xampl'].given_name }"
|
71
|
+
# end
|
72
|
+
|
73
|
+
puts
|
74
|
+
puts "query :: found: #{ found1.size }, in: #{ start_find_at - start_query_at }"
|
75
|
+
puts "find :: found: #{ found2.size }, in: #{ start_find_pids_at - start_find_at }"
|
76
|
+
puts "find pids:: found: #{ found3.size }, in: #{ done - start_find_pids_at}"
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
$LOAD_PATH.unshift("xampl_generated_code")
|
2
|
+
|
3
|
+
require 'RandomPeople'
|
4
|
+
require 'people'
|
5
|
+
|
6
|
+
Xampl.set_default_persister_kind(:tokyo_cabinet)
|
7
|
+
#Xampl.set_default_persister_format(:xml_format)
|
8
|
+
Xampl.set_default_persister_format(:ruby_format)
|
9
|
+
|
10
|
+
module RandomPeople
|
11
|
+
|
12
|
+
#GivenName,Surname,StreetAddress,City,State,ZipCode,EmailAddress,TelephoneNumber
|
13
|
+
#<people pid='' xmlns="http://xampl.com/people">
|
14
|
+
# <person pid=''
|
15
|
+
# given-name=''
|
16
|
+
# surname=''
|
17
|
+
# street-address=''
|
18
|
+
# city=''
|
19
|
+
# state=''
|
20
|
+
# postal-code=''
|
21
|
+
# email=''
|
22
|
+
# phone=''/>
|
23
|
+
#</people>
|
24
|
+
|
25
|
+
1.times do
|
26
|
+
found1 = []
|
27
|
+
found2 = []
|
28
|
+
found3 = []
|
29
|
+
|
30
|
+
start = Time.now
|
31
|
+
|
32
|
+
Xampl.transaction("random-people") do
|
33
|
+
found1 = Xampl.find_pids do | q |
|
34
|
+
q.add_condition('city', :equals, 'TORONTO')
|
35
|
+
q.add_condition('surname', :equals, 'Smith')
|
36
|
+
end
|
37
|
+
|
38
|
+
found2 = Xampl.find_pids do | q |
|
39
|
+
q.add_condition('city', :equals, 'LONDON')
|
40
|
+
q.add_condition('surname', :equals, 'Smith')
|
41
|
+
end
|
42
|
+
|
43
|
+
found3 = Xampl.find_pids do | q |
|
44
|
+
q.add_condition('city', :stror, 'TORONTO,LONDON')
|
45
|
+
q.add_condition('surname', :equals, 'Smith')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
done = Time.now
|
50
|
+
|
51
|
+
puts "INDEXED found(#{ done - start }):: TORONTO #{ found1.size }, LONDON: #{ found2.size }, TORONTO,LONDON: #{ found3.size }/#{ found1.size + found2.size }"
|
52
|
+
|
53
|
+
start = Time.now
|
54
|
+
|
55
|
+
Xampl.transaction("random-people") do
|
56
|
+
found1 = Xampl.find_pids do | q |
|
57
|
+
q.add_condition('city', :equals, 'TORONTO', true, true)
|
58
|
+
q.add_condition('surname', :equals, 'Smith', true, true)
|
59
|
+
end
|
60
|
+
|
61
|
+
found2 = Xampl.find_pids do | q |
|
62
|
+
q.add_condition('city', :equals, 'LONDON', true, true)
|
63
|
+
q.add_condition('surname', :equals, 'Smith', true, true)
|
64
|
+
end
|
65
|
+
|
66
|
+
found3 = Xampl.find_pids do | q |
|
67
|
+
q.add_condition('city', :stror, 'TORONTO,LONDON', true, true)
|
68
|
+
q.add_condition('surname', :equals, 'Smith', true, true)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
done = Time.now
|
73
|
+
|
74
|
+
puts "NOT INDEXED found(#{ done - start }):: TORONTO #{ found1.size }, LONDON: #{ found2.size }, TORONTO,LONDON: #{ found3.size }/#{ found1.size + found2.size }"
|
75
|
+
end
|
76
|
+
end
|