46 |
|
|
47 |
Name of the directory to use for the load files, WITHOUT a trailing slash. |
Name of the directory to use for the load files, WITHOUT a trailing slash. |
48 |
|
|
49 |
=item estimatedRows (optional) |
=item loadOnly |
50 |
|
|
51 |
Estimated maximum number of table rows. If omitted, the table will be created in |
TRUE if the data is to be loaded from an existing file, FALSE if a file is |
52 |
a format that permits an essentially unlimited number of rows. |
to be created. |
53 |
|
|
54 |
=back |
=back |
55 |
|
|
57 |
|
|
58 |
sub new { |
sub new { |
59 |
# Get the parameters. |
# Get the parameters. |
60 |
my ($class, $erdb, $relationName, $directory, $estimatedRows) = @_; |
my ($class, $erdb, $relationName, $directory, $loadOnly) = @_; |
61 |
# Validate the directory name. |
# Validate the directory name. |
62 |
if (! -d $directory) { |
if (! -d $directory) { |
63 |
Confess("Load directory \"$directory\" not found."); |
Confess("Load directory \"$directory\" not found."); |
64 |
} |
} |
65 |
# Determine the name for this relation's load file. |
# Determine the name for this relation's load file. |
66 |
my $fileName = "$directory/$relationName.dtx"; |
my $fileName = "$directory/$relationName.dtx"; |
67 |
|
# Declare the file handle variable. |
68 |
|
my $fileHandle; |
69 |
|
# Determine whether or not this is a primary relation. |
70 |
|
my $primary = ($erdb->_IsPrimary($relationName) ? 1 : 0); |
71 |
|
# Check to see if this is a load-only or a generate-and-load. |
72 |
|
if ($loadOnly) { |
73 |
|
Trace("Relation $relationName will be loaded from $fileName.") if T(2); |
74 |
|
$fileHandle = ""; |
75 |
|
} else { |
76 |
# If this is a primary entity relation, sort the output to remove |
# If this is a primary entity relation, sort the output to remove |
77 |
# duplicate keys. |
# duplicate keys. |
78 |
my $fileString = ($erdb->IsEntity($relationName) ? |
my $fileString = ($erdb->IsEntity($relationName) ? |
79 |
"| sort +0 -1 -u -t \"\t\" >$fileName" : |
"| sort +0 -1 -u -t \"\t\" >$fileName" : |
80 |
">$fileName"); |
">$fileName"); |
81 |
# Open the output file and remember its handle. |
# Open the output file and remember its handle. |
82 |
my $fileHandle = Open(undef, $fileString); |
$fileHandle = Open(undef, $fileString); |
83 |
|
Trace("Relation $relationName load file created with primary flag $primary.") if T(2); |
84 |
|
} |
85 |
# Create the $erload object. |
# Create the $erload object. |
86 |
my $retVal = { |
my $retVal = { |
87 |
dbh => $erdb, |
dbh => $erdb, |
91 |
fileSize => 0, |
fileSize => 0, |
92 |
lineCount => 0, |
lineCount => 0, |
93 |
stats => Stats->new(), |
stats => Stats->new(), |
94 |
primary => ($erdb->_IsPrimary($relationName) ? 1 : 0), |
primary => $primary |
95 |
}; |
}; |
|
Trace("Relation $relationName load file created with primary flag " . $retVal->{primary} . ".") |
|
|
if T(2); |
|
96 |
# Bless and return it. |
# Bless and return it. |
97 |
bless $retVal, $class; |
bless $retVal, $class; |
98 |
return $retVal; |
return $retVal; |