<commit_before><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Database objects created used for knowledgebrowser (see eu.planets_project.pp.plato.bean.KBrowser). 
 Attention: This code only works for MySQL-DBMS -->
<hibernate-mapping>
    <!-- stored procedure used to calculate the relative weight of a treenode. -->
    <database-object>
        <create>
            CREATE PROCEDURE calculateTotalWeight(IN tnId INTEGER, OUT relWeight DOUBLE)
            BEGIN
                DECLARE wght DOUBLE;
                DECLARE parentRelWeight DOUBLE;
                DECLARE parent INTEGER;
                
                SELECT weight, parent_fk INTO wght, parent FROM TreeNode WHERE id=tnId;
                
                IF parent IS NULL THEN
                    SET relWeight = wght;
                ELSE 
                    CALL calculateRelativeWeight(parent, parentRelWeight);
                    SET relWeight = wght * parentRelWeight;
                END IF;
            END;
        </create>
        <drop>
            DROP PROCEDURE IF EXISTS calculateTotalWeight;
        </drop>    
    </database-object>
    
    <!-- stored function used as a wrapper for calculateRelativeWeight(), to be used in SELECT statements. -->
    <database-object>
        <create>
            CREATE FUNCTION totalWeight(tnId INTEGER)
            RETURNS DOUBLE
            BEGIN
                DECLARE relWeight DOUBLE;
                
                CALL calculateRelativeWeight(tnId, relWeight);
                
                RETURN relWeight;
            END;
        </create>
        <drop>
            DROP FUNCTION IF EXISTS totalWeight;
        </drop>    
    </database-object>
    
    <!-- stored procedure used to get the root-node for a given treenode. -->
    <database-object>
        <create>
            CREATE PROCEDURE calculateRootNode(IN tnId INTEGER, OUT rootId INTEGER)
            BEGIN
                DECLARE parent INTEGER;
                DECLARE parentRoot INTEGER;
                
                SELECT parent_fk INTO parent FROM TreeNode WHERE id=tnId;
                
                IF parent IS NULL THEN<commit_msg>Fixed auxiliaryDbObjects to sync with kbrowser.sql<commit_after><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Database objects created used for knowledgebrowser (see eu.planets_project.pp.plato.bean.KBrowser). 
 Attention: This code only works for MySQL-DBMS -->
<hibernate-mapping>
    <!-- stored procedure used to calculate the relative weight of a treenode. -->
    <database-object>
        <create>
            CREATE PROCEDURE calculateTotalWeight(IN tnId INTEGER, OUT relWeight DOUBLE)
            BEGIN
                DECLARE wght DOUBLE;
                DECLARE parentRelWeight DOUBLE;
                DECLARE parent INTEGER;
                
                SELECT weight, parent_fk INTO wght, parent FROM TreeNode WHERE id=tnId;
                
                IF parent IS NULL THEN
                    SET relWeight = wght;
                ELSE 
                    CALL calculateTotalWeight(parent, parentRelWeight);
                    SET relWeight = wght * parentRelWeight;
                END IF;
            END;
        </create>
        <drop>
            DROP PROCEDURE IF EXISTS calculateTotalWeight;
        </drop>    
    </database-object>
    
    <!-- stored function used as a wrapper for calculateTotalWeight(), to be used in SELECT statements. -->
    <database-object>
        <create>
            CREATE FUNCTION totalWeight(tnId INTEGER)
            RETURNS DOUBLE
            BEGIN
                DECLARE relWeight DOUBLE;
                
                CALL calculateTotalWeight(tnId, relWeight);
                
                RETURN relWeight;
            END;
        </create>
        <drop>
            DROP FUNCTION IF EXISTS totalWeight;
        </drop>    
    </database-object>
    
    <!-- stored procedure used to get the root-node for a given treenode. -->
    <database-object>
        <create>
            CREATE PROCEDURE calculateRootNode(IN tnId INTEGER, OUT rootId INTEGER)
            BEGIN
                DECLARE parent INTEGER;
                DECLARE parentRoot INTEGER;
                
                SELECT parent_fk INTO parent FROM TreeNode WHERE id=tnId;
                
                IF parent IS NULL THEN
{'fraction_non_alphanumeric': 0.07145904436860068, 'fraction_numerical': 0.0029863481228668944, 'mean_word_length': 1.5250403877221326, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 2, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3405063', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1106, 'n_words': 360}