<commit_before>import logging

from neo4j_util import Neo4JException
import neo4j_util as db_util

log = logging.getLogger('rhizi')

class DB_Driver_Base():

    def log_committed_queries(self, statement_set):
        for sp_dict in statement_set['statements']:
            if None != sp_dict['parameters']:
                msg = '\tq: {0}\n\tp: {1}'.format(sp_dict['statement'].encode('utf-8'),
                                                  sp_dict['parameters'])
            else:
                msg = '\tq: {0}'.format(sp_dict['statement'])
            log.debug(msg)

class DB_Driver_Embedded(DB_Driver_Base):
    def __init__(self, db_base_url):
        self.tx_base_url = db_base_url + '/db/data/transaction'

        from org.rhizi.db.neo4j.util import EmbeddedNeo4j
        self.edb = EmbeddedNeo4j.createDb()
        self.edb.createDb()

    def begin_tx(self, op):
        pass

    def exec_statement_set(self, op):
        s_set = op.statement_set
        self.edb.executeCypherQury()

    def commit_tx(self, op):
        pass

class DB_Driver_REST(DB_Driver_Base):
    def __init__(self, db_base_url):
        self.tx_base_url = db_base_url + '/db/data/transaction'

    def begin_tx(self, op):
        tx_open_url = self.tx_base_url

        try:
            #
            # [!] neo4j seems picky about receiving an additional empty statement list
            #
            data = db_util.statement_set_to_REST_form([])  # open TX with empty statement_set
            ret = db_util.post_neo4j(tx_open_url, data)
            tx_commit_url = ret['commit']
            op.parse_tx_id(tx_commit_url)

            log.debug('tx-open: id: {0}, commit-url: {1}'.format(op.tx_id, tx_commit_url))
        except Exception as e:
            raise Exception('failed to open transaction: ' + e.message)

    def exec_statement_set(self, op):
<commit_msg>DB_Driver_Embedded: nop unimplemented exec_statement_set()<commit_after>import logging

from neo4j_util import Neo4JException
import neo4j_util as db_util

log = logging.getLogger('rhizi')

class DB_Driver_Base():

    def log_committed_queries(self, statement_set):
        for sp_dict in statement_set['statements']:
            if None != sp_dict['parameters']:
                msg = '\tq: {0}\n\tp: {1}'.format(sp_dict['statement'].encode('utf-8'),
                                                  sp_dict['parameters'])
            else:
                msg = '\tq: {0}'.format(sp_dict['statement'])
            log.debug(msg)

class DB_Driver_Embedded(DB_Driver_Base):
    def __init__(self, db_base_url):
        self.tx_base_url = db_base_url + '/db/data/transaction'

        from org.rhizi.db.neo4j.util import EmbeddedNeo4j
        self.edb = EmbeddedNeo4j.createDb()
        self.edb.createDb()

    def begin_tx(self, op):
        pass

    def exec_statement_set(self, op):
        pass

    def commit_tx(self, op):
        pass

class DB_Driver_REST(DB_Driver_Base):
    def __init__(self, db_base_url):
        self.tx_base_url = db_base_url + '/db/data/transaction'

    def begin_tx(self, op):
        tx_open_url = self.tx_base_url

        try:
            #
            # [!] neo4j seems picky about receiving an additional empty statement list
            #
            data = db_util.statement_set_to_REST_form([])  # open TX with empty statement_set
            ret = db_util.post_neo4j(tx_open_url, data)
            tx_commit_url = ret['commit']
            op.parse_tx_id(tx_commit_url)

            log.debug('tx-open: id: {0}, commit-url: {1}'.format(op.tx_id, tx_commit_url))
        except Exception as e:
            raise Exception('failed to open transaction: ' + e.message)

    def exec_statement_set(self, op):

{'fraction_non_alphanumeric': 0.10802801724137931, 'fraction_numerical': 0.007543103448275862, 'mean_word_length': 2.369328493647913, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5770294', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1192, 'n_words': 239}