<commit_before>from cassandra.query import SimpleStatement
from collections import namedtuple

import json

class AbstractGraphStatement:
    """
    Parent implementation of the Graph specific statements. It encapsulate the necessary work
    to produce a statement recognizable to the DSEQueryHandler.
    Child implementations will contain the graph_options field and will have to call self.configure()
    before being executed. They also need to implement the _configure_and_get_wrapped() method that
    will be called by the GraphSession to transparently execute the wrapped statement.
    """
    _wrapped = None

    """
    The graph specific options that will be included in the execution of the statement.
    The 4 available graph options are : 
        - graph-keyspace : define the keyspace the graph is defined with.
        - graph-source : choose the graph traversal source, configured on the server side.
        - graph-language : the language used in the queries.
        - graph-rebinding : rename the traversal source.
    """
    graph_options = {}

    def __init__(self):
        pass

    def _configure(self, session_graph_options):
        # Handles the general tranformations to apply on the wrapped statement.
        merged_options = session_graph_options.copy()
        merged_options.update(self.graph_options)
        self._wrapped.custom_payload = merged_options

    def _configure_and_get_wrapped(self, graph_options):
        raise NotImplementedError()


class GraphStatement(AbstractGraphStatement):
    """
    A simple, un-prepared graph query.
    """

    """
    The query string used in this statement.
    """
    query_string = None


    def __init__(self, query_string, graph_options=None):
        AbstractGraphStatement.__init__(self)
        self.query_string = query_string

    def _configure_and_get_wrapped(self, session_graph_options):
        self._wrapped = SimpleStatement(self.query_string)
        self._configure(session_graph_options)
        return self._wrapped


class PreparedGraphStatement(object):
    """
    A prepared graph statement returned from the execution of a GraphSession.prepare()
    method. This query corresponding to this statement is supposed to contain Gremlin 
    parameters that will eventually be bound.
    """

    _prepared_statement = None
    _graph_statement = None<commit_msg>Forgot to add the graph options from the GraphStatement constructor to the statement.<commit_after>from cassandra.query import SimpleStatement
from collections import namedtuple

import json

class AbstractGraphStatement:
    """
    Parent implementation of the Graph specific statements. It encapsulate the necessary work
    to produce a statement recognizable to the DSEQueryHandler.
    Child implementations will contain the graph_options field and will have to call self.configure()
    before being executed. They also need to implement the _configure_and_get_wrapped() method that
    will be called by the GraphSession to transparently execute the wrapped statement.
    """
    _wrapped = None

    """
    The graph specific options that will be included in the execution of the statement.
    The 4 available graph options are : 
        - graph-keyspace : define the keyspace the graph is defined with.
        - graph-source : choose the graph traversal source, configured on the server side.
        - graph-language : the language used in the queries.
        - graph-rebinding : rename the traversal source.
    """
    graph_options = {}

    def __init__(self):
        pass

    def _configure(self, session_graph_options):
        # Handles the general tranformations to apply on the wrapped statement.
        merged_options = session_graph_options.copy()
        merged_options.update(self.graph_options)
        self._wrapped.custom_payload = merged_options

    def _configure_and_get_wrapped(self, graph_options):
        raise NotImplementedError()


class GraphStatement(AbstractGraphStatement):
    """
    A simple, un-prepared graph query.
    """

    """
    The query string used in this statement.
    """
    query_string = None


    def __init__(self, query_string, graph_options=None):
        AbstractGraphStatement.__init__(self)
        self.query_string = query_string
        if graph_options:
            self.graph_options = graph_options

    def _configure_and_get_wrapped(self, session_graph_options):
        self._wrapped = SimpleStatement(self.query_string)
        self._configure(session_graph_options)
        return self._wrapped


class PreparedGraphStatement(object):
    """
    A prepared graph statement returned from the execution of a GraphSession.prepare()
    method. This query corresponding to this statement is supposed to contain Gremlin 
    parameters that will eventually be bound.
    """

    _prepared_statement = None
    _graph_statement = None
{'fraction_non_alphanumeric': 0.0559297815880792, 'fraction_numerical': 0.0004082465809348847, 'mean_word_length': 3.3209876543209877, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6219524', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1174, 'n_words': 447}