activefacts-compositions 1.9.17 → 1.9.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/activefacts-compositions.gemspec +2 -2
- data/lib/activefacts/compositions/binary.rb +1 -1
- data/lib/activefacts/compositions/compositor.rb +16 -12
- data/lib/activefacts/compositions/datavault.rb +110 -115
- data/lib/activefacts/compositions/relational.rb +137 -94
- data/lib/activefacts/compositions/staging.rb +89 -27
- data/lib/activefacts/compositions/traits/datavault.rb +116 -49
- data/lib/activefacts/compositions/traits/rails.rb +2 -2
- data/lib/activefacts/compositions/version.rb +1 -1
- data/lib/activefacts/generator/doc/cwm.rb +6 -18
- data/lib/activefacts/generator/doc/ldm.rb +1 -1
- data/lib/activefacts/generator/etl/unidex.rb +341 -0
- data/lib/activefacts/generator/oo.rb +31 -14
- data/lib/activefacts/generator/rails/models.rb +6 -5
- data/lib/activefacts/generator/rails/schema.rb +5 -9
- data/lib/activefacts/generator/ruby.rb +2 -2
- data/lib/activefacts/generator/sql/mysql.rb +3 -184
- data/lib/activefacts/generator/sql/oracle.rb +3 -152
- data/lib/activefacts/generator/sql/postgres.rb +3 -145
- data/lib/activefacts/generator/sql/server.rb +3 -126
- data/lib/activefacts/generator/sql.rb +54 -422
- data/lib/activefacts/generator/summary.rb +15 -6
- data/lib/activefacts/generator/traits/expr.rb +41 -0
- data/lib/activefacts/generator/traits/sql/mysql.rb +280 -0
- data/lib/activefacts/generator/traits/sql/oracle.rb +265 -0
- data/lib/activefacts/generator/traits/sql/postgres.rb +287 -0
- data/lib/activefacts/generator/traits/sql/server.rb +262 -0
- data/lib/activefacts/generator/traits/sql.rb +538 -0
- metadata +13 -8
- data/lib/activefacts/compositions/docgraph.rb +0 -798
- data/lib/activefacts/compositions/staging/persistent.rb +0 -107
@@ -1,107 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# ActiveFacts Compositions, Staging Compositor.
|
3
|
-
#
|
4
|
-
# Computes a Persistent Staging schema for Data Vault.
|
5
|
-
#
|
6
|
-
# Copyright (c) 2017 Clifford Heath. Read the LICENSE file.
|
7
|
-
#
|
8
|
-
# This style of staging area contains a table for every source table,
|
9
|
-
# with injected foreign keys to a LoadBatch table, as for transient
|
10
|
-
# staging.
|
11
|
-
#
|
12
|
-
# Where it differs is that all unique constraints are disabled, and
|
13
|
-
# replaced by a primary key that is the source schema's PK appended
|
14
|
-
# with the LoadBatchID. Each record also has a ValidUntil timestamp,
|
15
|
-
# which is NULL for the most recent record. This allows a load batch
|
16
|
-
# to load a new version of any record, and the key value will be
|
17
|
-
# adjacent to the previous versions of that record.
|
18
|
-
#
|
19
|
-
# After a batch is complete, any updated record keys will address
|
20
|
-
# more than one record with a NULL ValidUntil timestamp, and this
|
21
|
-
# allows delta detection. As a delta is processed, the older record
|
22
|
-
# can be marked as valid only until the current LoadBatch time, or
|
23
|
-
# it can be deleted. If retained, a purge process can remove records
|
24
|
-
# that have exceeded their useful lifetime.
|
25
|
-
#
|
26
|
-
# Note that this approach doesn't directly detect deleted records.
|
27
|
-
# If the source system uses soft deletion, this generator can be
|
28
|
-
# configured with the name and value of the deleted flag field(s).
|
29
|
-
# This approach also works to manage CDC systems, which provide a
|
30
|
-
# record-deleted flag.
|
31
|
-
#
|
32
|
-
|
33
|
-
require "activefacts/compositions/staging"
|
34
|
-
|
35
|
-
module ActiveFacts
|
36
|
-
module Compositions
|
37
|
-
class Staging
|
38
|
-
class Persistent < Staging
|
39
|
-
public
|
40
|
-
def self.options
|
41
|
-
super.
|
42
|
-
merge({
|
43
|
-
}).
|
44
|
-
merge(Relational.options).
|
45
|
-
reject{|k,v| [:surrogates].include?(k) }
|
46
|
-
end
|
47
|
-
|
48
|
-
def initialize constellation, name, options = {}
|
49
|
-
# Extract recognised options:
|
50
|
-
super(constellation, name, {"loadbatch"=>true}.merge(options))
|
51
|
-
|
52
|
-
raise "--staging/persistent requires the loadbatch option (you can't disable it)" unless @option_loadbatch
|
53
|
-
end
|
54
|
-
|
55
|
-
def complete_foreign_keys
|
56
|
-
super
|
57
|
-
|
58
|
-
remake_primary_keys
|
59
|
-
end
|
60
|
-
|
61
|
-
def remake_primary_keys
|
62
|
-
trace :relational_paths, "Remaking primary keys" do
|
63
|
-
@composition.all_composite.each do |composite|
|
64
|
-
next if composite.mapping.object_type == @loadbatch_entity_type
|
65
|
-
composite.all_access_path.each do |path|
|
66
|
-
# Ignore foreign keys:
|
67
|
-
next unless MM::Index === path
|
68
|
-
|
69
|
-
# Don't meddle with the LoadBatch table:
|
70
|
-
next if composite.mapping.object_type == @loadbatch_entity_type
|
71
|
-
if composite.natural_index == path
|
72
|
-
# Add LoadBatchID to the natural index:
|
73
|
-
trace :relational_paths, "Appending LoadBatch to primary key #{path.inspect}" do
|
74
|
-
load_batch_role =
|
75
|
-
composite.mapping.object_type.all_role.detect do |role|
|
76
|
-
c = role.counterpart and c.object_type == @loadbatch_entity_type
|
77
|
-
end
|
78
|
-
trace :relational_paths, "Found LoadBatch role in #{load_batch_role.fact_type.default_reading}" if load_batch_role
|
79
|
-
# There can only be one absorption of LoadBatch, because we added it,
|
80
|
-
# but if you have separate subtypes, we need to select the one for the right composite:
|
81
|
-
absorptions = load_batch_role.
|
82
|
-
counterpart.
|
83
|
-
all_absorption_as_child_role.
|
84
|
-
select{|a| a.root == composite}
|
85
|
-
# There should now always be exactly one.
|
86
|
-
raise "Missing or ambiguous FK to LoadBatch from #{composite.inspect}" if absorptions.size != 1
|
87
|
-
absorption = absorptions[0]
|
88
|
-
absorption.all_leaf.each do |leaf|
|
89
|
-
@constellation.IndexField(access_path: path, ordinal: path.all_index_field.size, component: leaf)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
elsif path.is_unique
|
93
|
-
# Retract other unique keys:
|
94
|
-
trace :relational_paths, "Retracting unique secondary index #{path.inspect}" do
|
95
|
-
# REVISIT: Or just make it non-unique?
|
96
|
-
path.retract
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end # Persistent
|
104
|
-
end # Staging
|
105
|
-
publish_compositor(Staging::Persistent)
|
106
|
-
end
|
107
|
-
end
|