xamplr 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +13 -0
- data/LICENSE +3 -0
- data/README.rdoc +26 -0
- data/README.rdoc.orig +118 -0
- data/Rakefile +85 -0
- data/VERSION.yml +4 -0
- data/examples/random-people-shared-addresses/Makefile +16 -0
- data/examples/random-people-shared-addresses/batch-load-users.rb +83 -0
- data/examples/random-people-shared-addresses/find-mentions.rb +47 -0
- data/examples/random-people-shared-addresses/find-people-by-address.rb +104 -0
- data/examples/random-people-shared-addresses/optimise.rb +16 -0
- data/examples/random-people-shared-addresses/people.rb +35 -0
- data/examples/random-people-shared-addresses/query.rb +75 -0
- data/examples/random-people-shared-addresses/query2.rb +73 -0
- data/examples/random-people-shared-addresses/random-names.csv +10000 -0
- data/examples/random-people-shared-addresses/settings.rb +3 -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/examples/random-people/Makefile +16 -0
- data/examples/random-people/batch-load-users.rb +61 -0
- data/examples/random-people/optimise.rb +16 -0
- data/examples/random-people/people.rb +22 -0
- data/examples/random-people/query.rb +73 -0
- data/examples/random-people/query2.rb +73 -0
- data/examples/random-people/random-names.csv +10000 -0
- data/examples/random-people/rawtc.rb +91 -0
- data/examples/random-people/settings.rb +3 -0
- data/examples/random-people/what-to-query-on.rb +80 -0
- data/examples/random-people/xampl-gen.rb +36 -0
- data/examples/random-people/xml/people.xml +11 -0
- data/examples/read-testing/Makefile +10 -0
- data/examples/read-testing/load.rb +65 -0
- data/examples/read-testing/read.rb +51 -0
- data/examples/read-testing/rrr.rb +87 -0
- data/examples/read-testing/settings.rb +2 -0
- data/examples/read-testing/xampl-gen.rb +36 -0
- data/examples/read-testing/xml/text.xml +8 -0
- data/examples/tokyo-cabinet-experimental/expt-query.rb +42 -0
- data/examples/tokyo-cabinet-experimental/expt-query2.rb +42 -0
- data/examples/tokyo-cabinet-experimental/expt-query3.rb +41 -0
- data/examples/tokyo-cabinet-experimental/expt-reader.rb +32 -0
- data/examples/tokyo-cabinet-experimental/expt.rb +61 -0
- data/examples/tokyo-cabinet-experimental/xampl-gen.rb +36 -0
- data/examples/tokyo-cabinet-experimental/xml/tcx.xml +6 -0
- data/lib/xampl-generator.rb +3 -0
- data/lib/xampl.rb +3 -0
- data/lib/xamplr-generator.rb +10 -0
- data/lib/xamplr.rb +37 -0
- data/lib/xamplr/README-POSSIBLE-PROBLEMS +5 -0
- data/lib/xamplr/TODO +1 -0
- data/lib/xamplr/exceptions.rb +97 -0
- data/lib/xamplr/from-xml-orig.rb +350 -0
- data/lib/xamplr/from-xml.rb +439 -0
- data/lib/xamplr/gen-elements.xml +6230 -0
- data/lib/xamplr/gen.elements.xml +108 -0
- data/lib/xamplr/generate-elements.rb +15 -0
- data/lib/xamplr/generator.rb +5 -0
- data/lib/xamplr/graphml-out.rb +470 -0
- data/lib/xamplr/handwritten/example.rb +698 -0
- data/lib/xamplr/handwritten/hand-example.rb +533 -0
- data/lib/xamplr/handwritten/test-handwritten.rb +873 -0
- data/lib/xamplr/indexed-array.rb +115 -0
- data/lib/xamplr/mixins.rb +397 -0
- data/lib/xamplr/my.gen.elements.xml +461 -0
- data/lib/xamplr/notifications.rb +57 -0
- data/lib/xamplr/obsolete/fsdb.rb +62 -0
- data/lib/xamplr/persist-to-xml.rb +249 -0
- data/lib/xamplr/persistence.rb +522 -0
- data/lib/xamplr/persistence.rb.more_thread_safe +771 -0
- data/lib/xamplr/persistence.rb.partially_thread_safe +763 -0
- data/lib/xamplr/persister.rb +310 -0
- data/lib/xamplr/persisters/caches.rb +186 -0
- data/lib/xamplr/persisters/caching.rb +172 -0
- data/lib/xamplr/persisters/filesystem.rb +60 -0
- data/lib/xamplr/persisters/in-memory.rb +180 -0
- data/lib/xamplr/persisters/simple.rb +59 -0
- data/lib/xamplr/persisters/tokyo-cabinet.rb +641 -0
- data/lib/xamplr/simpleTemplate/danger.rx +4 -0
- data/lib/xamplr/simpleTemplate/obsolete/input-c.r4 +35 -0
- data/lib/xamplr/simpleTemplate/obsolete/play.r6.txt +12 -0
- data/lib/xamplr/simpleTemplate/obsolete/play_more.r6.txt +20 -0
- data/lib/xamplr/simpleTemplate/obsolete/test001.r5 +8 -0
- data/lib/xamplr/simpleTemplate/obsolete/test002.r5 +13 -0
- data/lib/xamplr/simpleTemplate/obsolete/test003.r5 +37 -0
- data/lib/xamplr/simpleTemplate/old/r6.000.rb +122 -0
- data/lib/xamplr/simpleTemplate/old/r6.001.rb +145 -0
- data/lib/xamplr/simpleTemplate/play.r6 +12 -0
- data/lib/xamplr/simpleTemplate/play_more.r6 +20 -0
- data/lib/xamplr/simpleTemplate/play_noblanks.r6 +21 -0
- data/lib/xamplr/simpleTemplate/playq.r6 +16 -0
- data/lib/xamplr/simpleTemplate/r6.rb +87 -0
- data/lib/xamplr/simpleTemplate/simple-template.rb +75 -0
- data/lib/xamplr/templates/child.template +47 -0
- data/lib/xamplr/templates/child_indexed.template +89 -0
- data/lib/xamplr/templates/child_modules.template +5 -0
- data/lib/xamplr/templates/element_classes.template +11 -0
- data/lib/xamplr/templates/element_data.template +282 -0
- data/lib/xamplr/templates/element_empty.template +285 -0
- data/lib/xamplr/templates/element_mixed.template +277 -0
- data/lib/xamplr/templates/element_simple.template +276 -0
- data/lib/xamplr/templates/package.template +26 -0
- data/lib/xamplr/test-support/Makefile +47 -0
- data/lib/xamplr/test-support/bench-cache.rb +80 -0
- data/lib/xamplr/test-support/bench-script.rb +21 -0
- data/lib/xamplr/test-support/bench.rb +116 -0
- data/lib/xamplr/test-support/bench2.rb +132 -0
- data/lib/xamplr/test-support/test-cache.rb +147 -0
- data/lib/xamplr/test-support/test-data/binding.xml +7 -0
- data/lib/xamplr/test-support/test-data/example.xml +14 -0
- data/lib/xamplr/test-support/test-data/internationalization-utf8.txt +1 -0
- data/lib/xamplr/test-support/test-data/labels.xml +37 -0
- data/lib/xamplr/test-support/test-data/labels001.xml +38 -0
- data/lib/xamplr/test-support/test-deep-change.rb +135 -0
- data/lib/xamplr/test-support/test-elements.rb +109 -0
- data/lib/xamplr/test-support/test-indexed-array.rb +169 -0
- data/lib/xamplr/test-support/test-misc.rb +73 -0
- data/lib/xamplr/test-support/test-names.rb +67 -0
- data/lib/xamplr/test-support/test-rollback.rb +106 -0
- data/lib/xamplr/test-support/test.rb +1504 -0
- data/lib/xamplr/to-ruby.rb +220 -0
- data/lib/xamplr/to-xml.rb +158 -0
- data/lib/xamplr/version.rb +67 -0
- data/lib/xamplr/visitor.rb +140 -0
- data/lib/xamplr/visitors.rb +573 -0
- data/lib/xamplr/xampl-generator.rb +533 -0
- data/lib/xamplr/xampl-hand-generated.rb +1535 -0
- data/lib/xamplr/xampl-module.rb +36 -0
- data/lib/xamplr/xampl-object-internals.rb +6 -0
- data/lib/xamplr/xampl-object.rb +202 -0
- data/lib/xamplr/xampl-persisted-object.rb +122 -0
- data/lib/xamplr/xml-text.rb +117 -0
- data/lib/xamplr/xml/document.xml +7 -0
- data/lib/xamplr/xml/elements.xml +101 -0
- data/lib/xamplr/xml/elements000.xml +73 -0
- data/lib/xamplr/xml/example.xml +23 -0
- data/lib/xamplr/xml/options.xml +12 -0
- data/lib/xamplr/xml/uche.xml +38 -0
- data/lib/xamplr/yEd-sample.graphml +300 -0
- data/test/test_helper.rb +10 -0
- data/test/xamplr_test.rb +7 -0
- metadata +245 -0
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/LICENSE
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
= xamplr
|
2
|
+
|
3
|
+
xamplr is a set of software tools that supports development of ruby applications.
|
4
|
+
|
5
|
+
Features:
|
6
|
+
- supports Domain Driven Design in Ruby
|
7
|
+
- persistence ignornace
|
8
|
+
- clusters, entities, 'regular' objects, and repositories (corresponding approximately to DDD's aggregates, entities, value objects, and repositories)
|
9
|
+
- different peristence techniques including filesystem (XML format) and Tokyo Cabinet
|
10
|
+
- transaction support
|
11
|
+
- querying
|
12
|
+
- fast development, fast execution
|
13
|
+
- has been in use in commercial software since 2004, a Java version has been in use since 1998.
|
14
|
+
|
15
|
+
Anti-Features:
|
16
|
+
- absymal lack of documentation. If you are brave and willing to wade through (old) blog entries, you might try looking at:
|
17
|
+
|
18
|
+
http://recursive.ca/hutch/category/software/tools-i-use/xampl/
|
19
|
+
|
20
|
+
License: For the moment it is AGPLv3 (see COPYING). An alternative license
|
21
|
+
may be negotiated, contact me. In the near future this license will be
|
22
|
+
relaxed.
|
23
|
+
|
24
|
+
== Copyright
|
25
|
+
|
26
|
+
Copyright (c) 2009 Bob Hutchison. See LICENSE and COPYING for details.
|
data/README.rdoc.orig
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
= xamplr
|
2
|
+
|
3
|
+
xamplr is a tool for developing Ruby programs, the ruby implementation
|
4
|
+
of xampl. It facilitates the 'M' part of an MVC architecture. It
|
5
|
+
is meant to be very easy to use, supportive of idiomatic Ruby usage,
|
6
|
+
and mostly invisible.
|
7
|
+
|
8
|
+
With it's current lack of documentation it will be hard to get going
|
9
|
+
with xampl. I am working on documentation that will be appearing
|
10
|
+
over the next little while, in the meantime if you are willing to
|
11
|
+
wade through a blog, you might try looking at:
|
12
|
+
|
13
|
+
http://recursive.ca/hutch/category/software/tools-i-use/xampl/
|
14
|
+
|
15
|
+
Features:
|
16
|
+
- pure Ruby, no libraries required except those shipped with Ruby 1.8.2
|
17
|
+
- uses XML to declaratively describe a class structure
|
18
|
+
- uses a collection of example XML documents, no schema are required
|
19
|
+
- supports arbitrary object graphs, not just XML-like trees
|
20
|
+
- Ruby idiomatic facilities to navigate the object structures (e.g. named
|
21
|
+
arrays, hash, iterator support, uses blocks, etc.)
|
22
|
+
- support empty, simple (text content only), data (no or limited text
|
23
|
+
content, but with arbitrary element content), and mixed content (where
|
24
|
+
text and element content can be intermingled)
|
25
|
+
- maintains 'document order' of objects
|
26
|
+
- keeps track of parents
|
27
|
+
- can compare two clusters for equality (limited, but will be improved)
|
28
|
+
- maps XML namespaces to Ruby modules (with handy defaults) and you can
|
29
|
+
suggest preferred namespace prefixes for XML output
|
30
|
+
- converts XML element and attributes names to valid (and predictable)
|
31
|
+
Ruby names
|
32
|
+
- includes an XML pull parser (very fast)
|
33
|
+
- code generation is template driven, so the adventurous can change what
|
34
|
+
is generated
|
35
|
+
- includes a simple but powerful and fast templating engine
|
36
|
+
- includes a simple-minded but effective hash-like class that maintains
|
37
|
+
insertion order (fast insertion, lookup, and iteration, but at the
|
38
|
+
expense of delete)
|
39
|
+
- naming conventions are used when generating code (but these conventions
|
40
|
+
can be changed)
|
41
|
+
- additions to the XML will very rarely break existing code, and so
|
42
|
+
incremental development of functionality is supported
|
43
|
+
- generated code is readable and debuggable
|
44
|
+
- a command line tool to generate the code, or you can generate at runtime
|
45
|
+
- XML binding to the classes (i.e. parsing an XML file will produce an
|
46
|
+
object graph)
|
47
|
+
- can augment existing classes
|
48
|
+
- programmer adds functionality by opening the class or module, no worries
|
49
|
+
about the code generator overwriting your changes
|
50
|
+
- object structures can generate XML output (and there is an XML pretty
|
51
|
+
printer used for emphasising human readable XML output)
|
52
|
+
- easy to use persistence mechanism
|
53
|
+
- persistence is in terms of clusters of objects, the cluster is updated
|
54
|
+
all at once
|
55
|
+
- lazy loading of persisted clusters
|
56
|
+
- LRU cache (of clusters)
|
57
|
+
- the changed clusters are available for inspection
|
58
|
+
- XML, Ruby, and YAML persistence mechanism (purposely no Marshal support)
|
59
|
+
- persist to memory, or hard drive (optional persistence to an FSDB)
|
60
|
+
- sync and rollback (even with memory persistence); this is a weak form
|
61
|
+
of transaction support
|
62
|
+
- 'automatic' and 'manual' modes of persistence ('automatic' means that
|
63
|
+
any xampl cluster created while a persister is active will be
|
64
|
+
automatically managed by that persister, manual means that you have
|
65
|
+
to introduce the xampl cluster to the persister)
|
66
|
+
- fast alternative to persistence that does not support rollback
|
67
|
+
- xampl objects can hold arbitrary attribute values through the
|
68
|
+
persistence 'cycle' if using Ruby or YAML persistence (even xampl
|
69
|
+
object); with XML you won't loose anything but all attributes will
|
70
|
+
be strings after restoration.
|
71
|
+
- multiple persisters, possibly with differing persistence mechanisms,
|
72
|
+
are supported
|
73
|
+
- dead easy single user applications (e.g. desktop apps, CGI), almost as
|
74
|
+
easy for multiple user applications and webapps
|
75
|
+
- you can add your own persister types (and formats for that matter)
|
76
|
+
- general purpose Visitor pattern facility, with pre and post visit methods,
|
77
|
+
cycle and revisit detection and handling
|
78
|
+
- lots of hooks
|
79
|
+
- many unit tests, all execute without warning when run with the -w Ruby flag
|
80
|
+
- there are some examples, and the beginnings of a tutorial in the form of
|
81
|
+
a series of examples that lead you through the core parts of xampl
|
82
|
+
|
83
|
+
Features that are coming soon:
|
84
|
+
- many more hooks
|
85
|
+
- more sophisticated augmentation of existing classes
|
86
|
+
- indexing and querying of the persisted object structures
|
87
|
+
- more persisters (e.g. sqlite)
|
88
|
+
- real transactions
|
89
|
+
- a better comparison function (that deals with cyclic structures at all, and
|
90
|
+
better with non-tree acyclic structures)
|
91
|
+
|
92
|
+
Known Bugs or Potential Problems or Suspected Problems
|
93
|
+
- generated attribute names may conflict with Ruby keywords and this is not
|
94
|
+
a nice thing to witness (this is easy to fix, but I don't want to do this
|
95
|
+
until the next release at the earliest)
|
96
|
+
- I don't know if this will work on Windows -- I tried, but I don't have a
|
97
|
+
windows machine to test this with -- there might be some pathname stuff
|
98
|
+
assuming unix (but I hope not)
|
99
|
+
- some of the code is unnecessarily ugly (e.g. some of the visitor internals)
|
100
|
+
- there are no Ruby docs (but I promise... really)
|
101
|
+
- comparison of cyclic structures will crash
|
102
|
+
|
103
|
+
License: AGPLv3 (see COPYING). An alternative license may be negotiated, contact me.
|
104
|
+
|
105
|
+
While the Ruby version of xampl is brand new it is based on a Java
|
106
|
+
tool that I've been developing since 1998 and in its fifth generation.
|
107
|
+
There are many features in the Java version that are not available in
|
108
|
+
this library, but that is either just a matter of time, or they will
|
109
|
+
never be needed because Ruby programs don't need the help.
|
110
|
+
|
111
|
+
The Java version of the tool has been used to write a number of large
|
112
|
+
webapps, and a few smaller desktop applications, and even an applet.
|
113
|
+
|
114
|
+
There is a Common Lisp/CLOS version coming.
|
115
|
+
|
116
|
+
== Copyright
|
117
|
+
|
118
|
+
Copyright (c) 2009 Bob Hutchison. See LICENSE and COPYING for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "xamplr"
|
8
|
+
gem.summary = %Q{xamplr is the ruby version of xampl}
|
9
|
+
gem.email = "hutch@recursive.ca"
|
10
|
+
gem.homepage = "http://github.com/hutch/xamplr"
|
11
|
+
gem.authors = ["Bob Hutchison"]
|
12
|
+
gem.rubyforge_project = 'xampl'
|
13
|
+
|
14
|
+
gem.add_dependency('hutch-xamplr-pp')
|
15
|
+
gem.add_dependency('libxml-ruby', ">=1.1.3")
|
16
|
+
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
+
end
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
Rake::TestTask.new(:test) do |test|
|
25
|
+
test.libs << 'lib' << 'test'
|
26
|
+
test.pattern = 'test/**/*_test.rb'
|
27
|
+
test.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'rcov/rcovtask'
|
32
|
+
Rcov::RcovTask.new do |test|
|
33
|
+
test.libs << 'test'
|
34
|
+
test.pattern = 'test/**/*_test.rb'
|
35
|
+
test.verbose = true
|
36
|
+
end
|
37
|
+
rescue LoadError
|
38
|
+
task :rcov do
|
39
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
if File.exist?('VERSION.yml')
|
49
|
+
config = YAML.load(File.read('VERSION.yml'))
|
50
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
51
|
+
else
|
52
|
+
version = ""
|
53
|
+
end
|
54
|
+
|
55
|
+
rdoc.rdoc_dir = 'rdoc'
|
56
|
+
rdoc.title = "xamplr #{version}"
|
57
|
+
rdoc.rdoc_files.include('README*')
|
58
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
59
|
+
end
|
60
|
+
|
61
|
+
begin
|
62
|
+
require 'rake/contrib/sshpublisher'
|
63
|
+
namespace :rubyforge do
|
64
|
+
|
65
|
+
desc "Release gem and RDoc documentation to RubyForge"
|
66
|
+
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
67
|
+
|
68
|
+
namespace :release do
|
69
|
+
desc "Publish RDoc to RubyForge."
|
70
|
+
task :docs => [:rdoc] do
|
71
|
+
config = YAML.load(
|
72
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
73
|
+
)
|
74
|
+
|
75
|
+
host = "#{config['username']}@rubyforge.org"
|
76
|
+
remote_dir = "/var/www/gforge-projects/xampl"
|
77
|
+
local_dir = 'rdoc'
|
78
|
+
|
79
|
+
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
rescue LoadError
|
84
|
+
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
85
|
+
end
|
data/VERSION.yml
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'fastercsv'
|
2
|
+
require 'xampl_generated_code/RandomPeople'
|
3
|
+
require 'people'
|
4
|
+
require 'settings'
|
5
|
+
|
6
|
+
module RandomPeople
|
7
|
+
|
8
|
+
start_at = Time.now
|
9
|
+
|
10
|
+
arr_of_arrs = FasterCSV.read("random-names.csv")
|
11
|
+
|
12
|
+
parsed_at = Time.now
|
13
|
+
|
14
|
+
#GivenName,Surname,StreetAddress,City,State,ZipCode,EmailAddress,TelephoneNumber
|
15
|
+
|
16
|
+
#<people pid=''
|
17
|
+
# xmlns="http://xampl.com/people">
|
18
|
+
# <person pid=''
|
19
|
+
# given-name=''
|
20
|
+
# surname=''
|
21
|
+
# email=''
|
22
|
+
# phone=''>
|
23
|
+
# <address pid=''
|
24
|
+
# street-address=''
|
25
|
+
# city=''
|
26
|
+
# state=''
|
27
|
+
# postal-code=''/>
|
28
|
+
# </person>
|
29
|
+
#</people>
|
30
|
+
|
31
|
+
base = 0
|
32
|
+
|
33
|
+
created_addresses = 0
|
34
|
+
shared_addresses = 0
|
35
|
+
|
36
|
+
10.times do | iter |
|
37
|
+
inner_start = Time.now
|
38
|
+
|
39
|
+
Xampl.transaction("random-people") do
|
40
|
+
|
41
|
+
base += arr_of_arrs.size
|
42
|
+
|
43
|
+
arr_of_arrs.each_with_index do | row, i |
|
44
|
+
person_pid = "person-#{ base + i }"
|
45
|
+
person = Person.new(person_pid)
|
46
|
+
|
47
|
+
person.given_name = row[0]
|
48
|
+
person.surname = row[1]
|
49
|
+
person.email = row[6]
|
50
|
+
person.phone = row[7]
|
51
|
+
|
52
|
+
addresses = Xampl.find_xampl do | q |
|
53
|
+
q.add_condition('class', :equals, Address.name)
|
54
|
+
|
55
|
+
q.add_condition('street-address', :equals, row[2])
|
56
|
+
q.add_condition('postal-code', :equals, row[5])
|
57
|
+
end
|
58
|
+
|
59
|
+
address = addresses.first
|
60
|
+
if address then
|
61
|
+
person << address
|
62
|
+
shared_addresses += 1
|
63
|
+
else
|
64
|
+
address = person.new_address("address-#{ person_pid }")
|
65
|
+
address.street_address = row[2]
|
66
|
+
address.city = row[3]
|
67
|
+
address.state = row[4]
|
68
|
+
address.postal_code = row[5]
|
69
|
+
created_addresses += 1
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
puts "transaction ending..."
|
74
|
+
end
|
75
|
+
puts "iter: #{ iter } in #{ Time.now - inner_start }"
|
76
|
+
end
|
77
|
+
|
78
|
+
processed_at = Time.now
|
79
|
+
|
80
|
+
p "parsed in #{ parsed_at - start_at }, processed in: #{ processed_at - parsed_at }"
|
81
|
+
puts " created addresses: #{ created_addresses }, shared: #{ shared_addresses }"
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
require 'xampl_generated_code/RandomPeople'
|
3
|
+
require 'people'
|
4
|
+
require 'settings'
|
5
|
+
|
6
|
+
module RandomPeople
|
7
|
+
|
8
|
+
#<people pid=''
|
9
|
+
# xmlns="http://xampl.com/people">
|
10
|
+
# <person pid=''
|
11
|
+
# given-name=''
|
12
|
+
# surname=''
|
13
|
+
# email=''
|
14
|
+
# phone=''>
|
15
|
+
# <address pid=''
|
16
|
+
# street-address=''
|
17
|
+
# city=''
|
18
|
+
# state=''
|
19
|
+
# postal-code=''/>
|
20
|
+
# </person>
|
21
|
+
#</people>
|
22
|
+
|
23
|
+
10.times do
|
24
|
+
|
25
|
+
people = Xampl.transaction("random-people") do
|
26
|
+
Person.find_by_query do | q |
|
27
|
+
q.add_condition('city', :equals, 'TORONTO')
|
28
|
+
q.add_condition('email', :ends_with, 'dodgit.com')
|
29
|
+
|
30
|
+
q.order_by('surname', :strasc)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
first_person = people.first
|
35
|
+
address = first_person.address.first
|
36
|
+
|
37
|
+
start_at = Time.now
|
38
|
+
|
39
|
+
people_at_address = Xampl.transaction("random-people") do
|
40
|
+
Xampl.find_mentions_of(address)
|
41
|
+
end
|
42
|
+
|
43
|
+
done = Time.now
|
44
|
+
puts "found #{ people_at_address.size } people at that address in: #{ done - start_at }, #{ people_at_address.size / (done - start_at) }/s"
|
45
|
+
# people_at_address.each { | person | puts person.pp_xml }
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
|
2
|
+
require 'xampl_generated_code/RandomPeople'
|
3
|
+
require 'people'
|
4
|
+
require 'settings'
|
5
|
+
|
6
|
+
module RandomPeople
|
7
|
+
|
8
|
+
#<people pid=''
|
9
|
+
# xmlns="http://xampl.com/people">
|
10
|
+
# <person pid=''
|
11
|
+
# given-name=''
|
12
|
+
# surname=''
|
13
|
+
# email=''
|
14
|
+
# phone=''>
|
15
|
+
# <address pid=''
|
16
|
+
# street-address=''
|
17
|
+
# city=''
|
18
|
+
# state=''
|
19
|
+
# postal-code=''/>
|
20
|
+
# </person>
|
21
|
+
#</people>
|
22
|
+
|
23
|
+
times = [0, 0]
|
24
|
+
counts = [0, 0]
|
25
|
+
|
26
|
+
10.times do | trial |
|
27
|
+
found1 = []
|
28
|
+
found2 = []
|
29
|
+
found3 = []
|
30
|
+
|
31
|
+
#<p:person email='Edelmira.K.Abshire@dodgit.com'
|
32
|
+
# given-name='Edelmira'
|
33
|
+
# phone='416-279-8804'
|
34
|
+
# pid='person-29944'
|
35
|
+
# surname='Abshire'
|
36
|
+
# xmlns:p='http://xampl.com/people'>
|
37
|
+
# <p:address city='TORONTO'
|
38
|
+
# pid='person-19944'
|
39
|
+
# postal_code='M1P 4W2'
|
40
|
+
# state='ON'
|
41
|
+
# street_address='4194 Borough Drive'/></p:person>
|
42
|
+
|
43
|
+
|
44
|
+
all_people = nil
|
45
|
+
people_inspected = 0
|
46
|
+
start_at = Time.now
|
47
|
+
|
48
|
+
people = Xampl.transaction("random-people") do
|
49
|
+
addresses = Address.find_by_query do | q |
|
50
|
+
q.add_condition('street-address', :equals, '4194 Borough Drive')
|
51
|
+
q.add_condition('postal-code', :equals, 'M1P 4W2')
|
52
|
+
end
|
53
|
+
|
54
|
+
all_people = Set.new
|
55
|
+
people_inspected = 0
|
56
|
+
|
57
|
+
addresses.each do | address |
|
58
|
+
people = Person.find_by_query do | q |
|
59
|
+
# TODO -- want to be able to find people by the address directly, e.g. address.find_by_citation/find_by_mention & find_by_reference
|
60
|
+
q.add_condition('city', :equals, address.city)
|
61
|
+
q.add_condition('state', :equals, address.state)
|
62
|
+
end
|
63
|
+
|
64
|
+
people_inspected += people.size
|
65
|
+
|
66
|
+
people.each do | person |
|
67
|
+
all_people << person if person.address.first == address
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
done_at = Time.now
|
73
|
+
puts "done in: #{ done_at - start_at }, #{ people_inspected } people inspected, #{ all_people.size } identified"
|
74
|
+
times[0] += (done_at - start_at) if 0 < trial
|
75
|
+
counts[0] += 1 if 0 < trial
|
76
|
+
|
77
|
+
start_at = Time.now
|
78
|
+
|
79
|
+
people = Xampl.transaction("random-people") do
|
80
|
+
addresses = Address.find_by_query do | q |
|
81
|
+
q.add_condition('street-address', :equals, '4194 Borough Drive')
|
82
|
+
q.add_condition('postal-code', :equals, 'M1P 4W2')
|
83
|
+
end
|
84
|
+
|
85
|
+
all_people = Set.new
|
86
|
+
people_inspected = 0
|
87
|
+
|
88
|
+
addresses.each do | address |
|
89
|
+
people = Xampl.find_mentions_of(address)
|
90
|
+
|
91
|
+
people_inspected += people.size
|
92
|
+
all_people.merge(people)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
done_at = Time.now
|
97
|
+
puts "done in: #{ done_at - start_at }, #{ people_inspected } people inspected, #{ all_people.size } identified"
|
98
|
+
times[1] += (done_at - start_at) if 0 < trial
|
99
|
+
counts[1] += 1 if 0 < trial
|
100
|
+
end
|
101
|
+
|
102
|
+
puts "0) total time: #{ times[0] }, count: #{ counts[0] }, average/s: #{ counts[0]/times[0]}"
|
103
|
+
puts "1) total time: #{ times[1] }, count: #{ counts[1] }, average/s: #{ counts[1]/times[1]}"
|
104
|
+
end
|