<commit_before>package main

import (
	"bufio"
	"errors"
	"fmt"
	// "os"
	"io"
	"os/exec"
	// "time"
	// "runtime"
	// "sync"
)

var check func(string, error) = func(what string, e error) {
	if e != nil {
		fmt.Println("Error", what+":", e.Error())
		/*os.Exit(1000)*/
		panic(e)
	}
}

type DuplexTerm struct {
	Writer *bufio.Writer
	Reader *bufio.Reader
	Cmd    *exec.Cmd
	Stdin  io.WriteCloser
	Stdout io.ReadCloser
}

func (d *DuplexTerm) SendInput(input string) (result string, e error) {
	iwrite, ewrite := d.Writer.WriteString(input + "\n")
	check("write", ewrite)
	if iwrite == 0 {
		check("write", errors.New("Writing only 0 byte"))
	} else {
		err := d.Writer.Flush()
		check("Flush", err)
	}

	/*for {
		bread, eread := d.Reader.ReadString('\n')
		if eread != nil && eread.Error() == "EOF" {
			break
		}
		check("read", eread)
		fmt.Println(bread)
	}*/

	return
}

func (d *DuplexTerm) Open() (err error) {
	d.Cmd = exec.Command("sh", "-c", "beeline --outputFormat=csv2 -u jdbc:hive2://192.168.0.223:10000/default -n developer -d org.apache.hive.jdbc.HiveDriver")

	d.Stdin, err = d.Cmd.StdinPipe()
	// check("stdin", err)

	d.Stdout, err = d.Cmd.StdoutPipe()
	// check("stdout", err)

	d.Writer = bufio.NewWriter(d.Stdin)
	d.Reader = bufio.NewReader(d.Stdout)

	err = d.Cmd.Start()
	// check("Start", err)
	return
}

func (d *DuplexTerm) Close() {
	d.Cmd.Wait()
	d.Stdin.Close()
	d.Stdout.Close()
}

func main() {
	dup := DuplexTerm{}
	err := dup.Open()
	result, err := dup.SendInput("select * from sample_07 limit 5;")
	fmt.Printf("error: %v\n", err)
	result, err = dup.SendInput("!quit")
	fmt.Printf("error: %v\n", err)
	_ = result
	_ = err

	for {
		bread, eread := dup.Reader.ReadString('\n')
		if eread != nil && eread.Error() == "EOF" {
			break
		}
		check("read", eread)
		fmt.Println(bread)
	}

	defer dup.Close()
	fmt.Println("Done")
}
<commit_msg>testing<commit_after>package main

import (
	"bufio"
	"errors"
	"fmt"
	// "os"
	"io"
	"os/exec"
	"strings"
	// "time"
	// "runtime"
	// "sync"
)

var check func(string, error) = func(what string, e error) {
	if e != nil {
		fmt.Println("Error", what+":", e.Error())
		/*os.Exit(1000)*/
		panic(e)
	}
}

type DuplexTerm struct {
	Writer *bufio.Writer
	Reader *bufio.Reader
	Cmd    *exec.Cmd
	Stdin  io.WriteCloser
	Stdout io.ReadCloser
}

func (d *DuplexTerm) SendInput(input string) (result string, e error) {
	iwrite, ewrite := d.Writer.WriteString(input + "\n")
	check("write", ewrite)
	if iwrite == 0 {
		check("write", errors.New("Writing only 0 byte"))
	} else {
		err := d.Writer.Flush()
		check("Flush", err)
	}

	/*for {
		bread, eread := d.Reader.ReadString('\n')
		if eread != nil && eread.Error() == "EOF" {
			break
		}
		check("read", eread)
		fmt.Println(bread)
	}*/

	return
}

func (d *DuplexTerm) Open() (err error) {
	d.Cmd = exec.Command("sh", "-c", "beeline --outputFormat=csv2 -u jdbc:hive2://192.168.0.223:10000/default -n developer -d org.apache.hive.jdbc.HiveDriver")

	d.Stdin, err = d.Cmd.StdinPipe()
	// check("stdin", err)

	d.Stdout, err = d.Cmd.StdoutPipe()
	// check("stdout", err)

	d.Writer = bufio.NewWriter(d.Stdin)
	d.Reader = bufio.NewReader(d.Stdout)

	err = d.Cmd.Start()
	// check("Start", err)
	return
}

func (d *DuplexTerm) Close() {
	d.Cmd.Wait()
	d.Stdin.Close()
	d.Stdout.Close()
}

func main() {
	dup := DuplexTerm{}
	err := dup.Open()

	result, err := dup.SendInput("select * from sample_07 limit 5;")
	fmt.Printf("error: %v\n", err)

	result, err = dup.SendInput("!quit")
	fmt.Printf("error: %v\n", err)

	_ = result
	_ = err

	for {
		bread, eread := dup.Reader.ReadString('\n')
		if eread != nil && eread.Error() == "EOF" {
			break
		}
		check("read", eread)
		fmt.Println(strings.TrimRight(bread, "\n"))
	}

	defer dup.Close()
	fmt.Println("Done")
}

{'fraction_non_alphanumeric': 0.20010601643254705, 'fraction_numerical': 0.013782136231115823, 'mean_word_length': 3.3832752613240418, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2436235', 'n_tokens_mistral': 1676, 'n_tokens_neox': 1579, 'n_words': 334}