Algorithm-ConstructDFA2
view release on metacpan or search on metacpan
lib/Algorithm/ConstructDFA2.pm view on Meta::CPAN
JSON->new->canonical(1)->indent(0)->ascii(1)
},
);
sub BUILD {
my ($self) = @_;
###################################################################
# Create dbh
$self->_log->debug("Creating database");
my $dbh = DBI->connect( $self->storage_dsn );
$dbh->{RaiseError} = 1;
# $dbh->{AutoCommit} = 1;
$self->_set_dbh( $dbh );
###################################################################
# Register Extension functions
$self->_log->debug("Register extension functions");
$self->_dbh->sqlite_create_function( '_vertex_matches', 2, sub {
return !! $self->vertex_matches->(@_);
});
$self->_dbh->sqlite_create_function( '_vertex_nullable', 1, sub {
return !! $self->vertex_nullable->(@_);
});
$self->_dbh->sqlite_create_function( '_canonical', 1, sub {
# Since SQLite's json_group_array does not guarantee ordering,
# we sort the items in the list ourselves here.
my @vertices = $self->_vertex_str_to_vertices(@_);
return $self->_vertex_str_from_vertices(@vertices);
});
###################################################################
# Deploy schema
$self->_log->debug("Deploying schema");
$self->_deploy_schema();
###################################################################
# Insert input data
$self->_log->debug("Initialising input");
$self->_init_input;
$self->_log->debug("Initialising vertices");
$self->_init_vertices;
$self->_log->debug("Initialising edges");
$self->_init_edges;
###################################################################
# Insert pre-computed data
$self->_log->debug("Initialising match data");
$self->_init_matches;
$self->_log->debug("Computing epsilon closures");
$self->_init_epsilon_closure;
###################################################################
# Let DB analyze data so far
$self->_log->debug("Updating DB statistics");
$self->_dbh->do('ANALYZE');
# FIXME: strictly speaking, the dead state is a ombination of all
# vertices from which an accepting combination of vertices cannot
# be reached. That might be important. Perhaps when later merging
# dead states, this would be resolved automatically? Probably not.
my $dead_state_id = $self->find_or_create_state_id();
$self->_set_dead_state_id($dead_state_id);
}
( run in 1.191 second using v1.01-cache-2.11-cpan-49f99fa48dc )