<commit_before>package edu.stanford.prpl.junction.api.sample.datalog;

import edu.stanford.prpl.junction.api.object.OutboundObjectStream;
import edu.stanford.prpl.junction.api.query.JunctionProcessedQuery;
import edu.stanford.prpl.junction.api.query.JunctionQuery;
import edu.stanford.prpl.junction.api.query.JunctionQueryHandler;

public class DatalogQueryHandler extends JunctionQueryHandler {

	@Override
	public boolean supportsQuery(JunctionQuery query) {
		return DatalogQuery.supports(query);
	}
	
	
	@Override
	public void handleQuery(JunctionProcessedQuery query, OutboundObjectStream result) {
		// query text:
		/*
		if (!(query instanceof StoredQuery)) {
			results.close(); // todo: set error message
			return;
		}
		*/
		String queryText = query.getQueryText();
		
		// get results
		// when result comes in:
		//results.write(jsonObject.getBytes());<commit_msg>added memo on how to handle obligations query<commit_after>package edu.stanford.prpl.junction.api.sample.datalog;

import edu.stanford.prpl.junction.api.object.OutboundObjectStream;
import edu.stanford.prpl.junction.api.query.JunctionProcessedQuery;
import edu.stanford.prpl.junction.api.query.JunctionQuery;
import edu.stanford.prpl.junction.api.query.JunctionQueryHandler;

public class DatalogQueryHandler extends JunctionQueryHandler {

	@Override
	public boolean supportsQuery(JunctionQuery query) {
		return DatalogQuery.supports(query);
	}
	
	
	@Override
	public void handleQuery(JunctionProcessedQuery query, OutboundObjectStream result) {
		// query text:
		/*
		if (!(query instanceof StoredQuery)) {
			results.close(); // todo: set error message
			return;
		}
		*/
		
		// obligations:
		// if !authenticated {
		//   results = getJunctionManager().query(new ObligationsQuery("AUTHENTICATE")) // or whatever
		//   if (!authenticate(results)) { result.close(); return; }
		// }
		
		String queryText = query.getQueryText();
		
		// get results
		// when result comes in:
		//results.write(jsonObject.getBytes());
{'fraction_non_alphanumeric': 0.11288711288711288, 'fraction_numerical': 0.0, 'mean_word_length': 4.4577656675749315, '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': '1118270', 'n_tokens_mistral': 673, 'n_tokens_neox': 613, 'n_words': 120}