<commit_before>package jet

import (
	"fmt"
	"reflect"
	"strconv"
	"strings"
)

type mapper struct {
	conv ColumnConverter
}

func (m *mapper) unpack(keys []string, values []interface{}, out interface{}) error {
	val := reflect.ValueOf(out)
	if val.Kind() != reflect.Ptr {
		return fmt.Errorf("cannot unpack result to non-pointer (%s)", val.Type().String())
	}
	return m.unpackValue(keys, values, val)
}

func (m *mapper) unpackValue(keys []string, values []interface{}, out reflect.Value) error {
	switch out.Kind() {
	case reflect.Ptr:
		if out.IsNil() {
			out.Set(reflect.New(out.Type().Elem()))
		}
		return m.unpackValue(keys, values, reflect.Indirect(out))
	case reflect.Slice:
		if keys == nil {
			return m.unpackSimple(nil, values, out)
		} else {
			return m.unpackSlice(keys, values, out)
		}
	case reflect.Struct:
		return m.unpackStruct(keys, values, out)
	case reflect.Map:
		if keys == nil {
			return m.unpackSimple(nil, values, out)
		} else {
			return m.unpackMap(keys, values, out)
		}
	default:
		return m.unpackSimple(nil, values, out)
	}
	return fmt.Errorf("cannot unpack result to %T (%s)", out, out.Kind())
}

func (m *mapper) unpackSlice(keys []string, values []interface{}, out reflect.Value) error {
	elemTyp := reflect.Indirect(reflect.New(out.Type().Elem()))
	m.unpackValue(keys, values, elemTyp)
	out.Set(reflect.Append(out, elemTyp))
	return nil
}

func (m *mapper) unpackStruct(keys []string, values []interface{}, out reflect.Value) error {
	for i, k := range keys {
		var convKey string
		if m.conv == nil {
			convKey = strings.ToUpper(k[:1]) + k[1:]<commit_msg>fix unpacking of struct fields like time.Time<commit_after>package jet

import (
	"fmt"
	"reflect"
	"strconv"
	"strings"
)

type mapper struct {
	conv ColumnConverter
}

func (m *mapper) unpack(keys []string, values []interface{}, out interface{}) error {
	val := reflect.ValueOf(out)
	if val.Kind() != reflect.Ptr {
		return fmt.Errorf("cannot unpack result to non-pointer (%s)", val.Type().String())
	}
	return m.unpackValue(keys, values, val)
}

func (m *mapper) unpackValue(keys []string, values []interface{}, out reflect.Value) error {
	switch out.Kind() {
	case reflect.Ptr:
		if out.IsNil() {
			out.Set(reflect.New(out.Type().Elem()))
		}
		return m.unpackValue(keys, values, reflect.Indirect(out))
	case reflect.Slice:
		if keys == nil {
			return m.unpackSimple(nil, values, out)
		} else {
			return m.unpackSlice(keys, values, out)
		}
	case reflect.Struct:
		return m.unpackStruct(keys, values, out)
	case reflect.Map:
		if keys == nil {
			return m.unpackSimple(nil, values, out)
		} else {
			return m.unpackMap(keys, values, out)
		}
	default:
		return m.unpackSimple(nil, values, out)
	}
	return fmt.Errorf("cannot unpack result to %T (%s)", out, out.Kind())
}

func (m *mapper) unpackSlice(keys []string, values []interface{}, out reflect.Value) error {
	elemTyp := reflect.Indirect(reflect.New(out.Type().Elem()))
	m.unpackValue(keys, values, elemTyp)
	out.Set(reflect.Append(out, elemTyp))
	return nil
}

func (m *mapper) unpackStruct(keys []string, values []interface{}, out reflect.Value) error {
	// If no keys are passed in it's probably a struct field requiring
	// a simple unpack like a time.Time struct field.
	if len(keys) == 0 {
		return m.unpackSimple(nil, values, out)
	}
	for i, k := range keys {
		var convKey string
		if m.conv == nil {
			convKey = strings.ToUpper(k[:1]) + k[1:]
{'fraction_non_alphanumeric': 0.15373352855051245, 'fraction_numerical': 0.0014641288433382138, 'mean_word_length': 4.2312404287901995, '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': '160402', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1181, 'n_words': 334}