<commit_before>//  Copyright (c) 2015 Couchbase, Inc.

package gson

import "strconv"
import "fmt"
import "encoding/json"

func gson2collate(obj interface{}, code []byte, config *Config) int {
	if obj == nil {
		code[0], code[1] = TypeNull, Terminator
		return 2
	}

	switch value := obj.(type) {
	case bool:
		if value {
			code[0] = TypeTrue
		} else {
			code[0] = TypeFalse
		}
		code[1] = Terminator
		return 2

	case float64:
		n := 0
		code[n] = TypeNumber
		n++
		n += normalizeFloat(obj, code[n:], config.nk)
		code[n] = Terminator
		n++
		return n

	case int64:
		n := 0
		code[n] = TypeNumber
		n++
		n += normalizeFloat(obj, code[n:], config.nk)
		code[n] = Terminator
		n++
		return n

	case int:
		n := 0
		code[n] = TypeNumber
		n++
		n += normalizeFloat(int64(value), code[n:], config.nk)
		code[n] = Terminator
		n++
		return n

	case json.Number:
		n := 0
		code[n] = TypeNumber
		n++
		f, err := strconv.ParseFloat(string(value), 64)
		if err != nil {
			panic(err)
		}
		n += normalizeFloat(f, code[n:], config.nk)
		code[n] = Terminator
		n++
		return n

	case Length:
		n := 0
		code[n] = TypeLength
		n++<commit_msg>bug fix: gson2collate() to support uint64 and float32.<commit_after>//  Copyright (c) 2015 Couchbase, Inc.

package gson

import "strconv"
import "fmt"
import "encoding/json"

func gson2collate(obj interface{}, code []byte, config *Config) int {
	if obj == nil {
		code[0], code[1] = TypeNull, Terminator
		return 2
	}

	switch value := obj.(type) {
	case bool:
		if value {
			code[0] = TypeTrue
		} else {
			code[0] = TypeFalse
		}
		code[1] = Terminator
		return 2

	case float64:
		n := 0
		code[n] = TypeNumber
		n++
		n += normalizeFloat(obj, code[n:], config.nk)
		code[n] = Terminator
		n++
		return n

	case float32:
		n := 0
		code[n] = TypeNumber
		n++
		n += normalizeFloat(float64(value), code[n:], config.nk)
		code[n] = Terminator
		n++
		return n

	case int64:
		n := 0
		code[n] = TypeNumber
		n++
		n += normalizeFloat(obj, code[n:], config.nk)
		code[n] = Terminator
		n++
		return n

	case uint64:
		n := 0
		code[n] = TypeNumber
		n++
		n += normalizeFloat(int64(value), code[n:], config.nk)
		code[n] = Terminator
		n++
		return n

	case int:
		n := 0
		code[n] = TypeNumber
		n++
		n += normalizeFloat(int64(value), code[n:], config.nk)
		code[n] = Terminator
		n++
		return n

	case json.Number:
		n := 0
		code[n] = TypeNumber
		n++
		f, err := strconv.ParseFloat(string(value), 64)
		if err != nil {
			panic(err)
		}
		n += normalizeFloat(f, code[n:], config.nk)
		code[n] = Terminator
		n++
		return n

	case Length:
		n := 0
		code[n] = TypeLength
		n++
{'fraction_non_alphanumeric': 0.15408085430968727, 'fraction_numerical': 0.02479023646071701, 'mean_word_length': 3.054095826893354, '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': '5766703', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1043, 'n_words': 290}