<commit_before># ABSTRACT: Ballerina backend.

use strict;
use warnings;
package Ballerina::Runtime;

use YAML::Tiny;

sub new {
	my $class = shift;
	my $self = { schema => YAML::Tiny->read("database.yml")->[0] };
	return bless $self, $class;
}

sub table_info {
	my ($self, $table) = @_;
	return +{
		name     => $table,
		label    => $self->table_label($table),
	    columns  => $self->table_columns($table),
	    coltypes => $self->table_coltypes($table),
	    keys     => $self->table_keys($table),
	};
}

sub table_coltypes {
	my ($self, $table) = @_;
	die "Unknown table $table" unless exists $self->{schema}{$table};

	return $self->{schema}{$table}{columns}
}

sub table_label {
	my ($self, $table) = @_;
	die "Unknown table $table" unless exists $self->{schema}{$table};

	return $self->{schema}{$table}{label} || $table;
}

sub table_columns {
	my ($self, $table) = @_;
	die "Unknown table $table" unless exists $self->{schema}{$table};

	return [ sort {
	    $self->{schema}{$table}{columns}{$a}{order}
	    <=>
	    $self->{schema}{$table}{columns}{$b}{order}
	} keys %{$self->{schema}{$table}{columns}} ];
}

sub table_keys {
	my ($self, $table) = @_;
	die "Unknown table $table" unless exists $self->{schema}{$table};

	[ grep {
    	exists($self->{schema}{$table}{columns}{$_}{primary_key})
	} keys %{$self->{schema}{$table}{columns}} ];
}


1;
<commit_msg>is_primary_key instead of just primary_key<commit_after># ABSTRACT: Ballerina backend.

use strict;
use warnings;
package Ballerina::Runtime;

use YAML::Tiny;

sub new {
	my $class = shift;
	my $self = { schema => YAML::Tiny->read("database.yml")->[0] };
	return bless $self, $class;
}

sub table_info {
	my ($self, $table) = @_;
	return +{
		name     => $table,
		label    => $self->table_label($table),
	    columns  => $self->table_columns($table),
	    coltypes => $self->table_coltypes($table),
	    keys     => $self->table_keys($table),
	};
}

sub table_coltypes {
	my ($self, $table) = @_;
	die "Unknown table $table" unless exists $self->{schema}{$table};

	return $self->{schema}{$table}{columns}
}

sub table_label {
	my ($self, $table) = @_;
	die "Unknown table $table" unless exists $self->{schema}{$table};

	return $self->{schema}{$table}{label} || $table;
}

sub table_columns {
	my ($self, $table) = @_;
	die "Unknown table $table" unless exists $self->{schema}{$table};

	return [ sort {
	    $self->{schema}{$table}{columns}{$a}{order}
	    <=>
	    $self->{schema}{$table}{columns}{$b}{order}
	} keys %{$self->{schema}{$table}{columns}} ];
}

sub table_keys {
	my ($self, $table) = @_;
	die "Unknown table $table" unless exists $self->{schema}{$table};

	[ grep {
    	exists($self->{schema}{$table}{columns}{$_}{is_primary_key})
	} keys %{$self->{schema}{$table}{columns}} ];
}


1;

{'fraction_non_alphanumeric': 0.2132564841498559, 'fraction_numerical': 0.001440922190201729, 'mean_word_length': 4.4344422700587085, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '965017', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1006, 'n_words': 214}