<commit_before>package backend

import (
	"fmt"
	"strconv"
	"strings"

	"log"

	"github.com/garyburd/redigo/redis"
	gosocketio "github.com/graarh/golang-socketio"
)

func scan(conn *gosocketio.Channel, c redis.Conn, key, field string, t scanType, iterate int64, maxScanLimits int) (int64, []string) {

	var method, cmd string
	var ret []interface{}
	var keys, tmp []string
	var err error
	switch t {
	case keyScan:
		method = "scan"
	case setScan:
		method = "sscan"
	case hashScan:
		method = "hscan"
	case zsetScan:
		method = "zscan"
	default:
		log.Println("type not exists!")
		return 0, nil
	}

	for {

		if t == keyScan {
			if !strings.ContainsAny(key, "*") {
				key = key + "*"
			}
			cmd = fmt.Sprintf("%s %d MATCH %s COUNT %d", method, iterate, key, _globalConfigs.System.KeyScanLimits)
			ret, err = redis.Values(c.Do(method, iterate, "MATCH", key, "COUNT", _globalConfigs.System.KeyScanLimits))

		} else {
			if key == "" {
				sendCmdError(conn, "key can't not be empty")
				return 0, nil
			}
			if !strings.ContainsAny(key, "*") {
				field = field + "*"
			}
			cmd = fmt.Sprintf("%s %s %d MATCH %s COUNT %d", method, key, iterate, field, _globalConfigs.System.KeyScanLimits)
			ret, err = redis.Values(c.Do(method, key, iterate, "MATCH", field, "COUNT", _globalConfigs.System.KeyScanLimits))
		}

		sendCmd(conn, cmd)
		if err != nil {
			sendCmdError(conn, "redis error: "+err.Error())
			return 0, nil
		}
		sendCmdReceive(conn, ret)
		tmp, err = redis.Strings(ret[1], nil)
		if err != nil {
			sendCmdError(conn, "redis error: "+err.Error())
			return 0, nil
		}
		keys = append(keys, tmp...)
		iterate, err = redis.Int64(ret[0], nil)<commit_msg>fix bug<commit_after>package backend

import (
	"fmt"
	"strconv"
	"strings"

	"log"

	"github.com/garyburd/redigo/redis"
	gosocketio "github.com/graarh/golang-socketio"
)

func scan(conn *gosocketio.Channel, c redis.Conn, key, field string, t scanType, iterate int64, maxScanLimits int) (int64, []string) {

	var method, cmd string
	var ret []interface{}
	var keys, tmp []string
	var err error
	switch t {
	case keyScan:
		method = "scan"
	case setScan:
		method = "sscan"
	case hashScan:
		method = "hscan"
	case zsetScan:
		method = "zscan"
	default:
		log.Println("type not exists!")
		return 0, nil
	}

	for {

		if t == keyScan {
			if !strings.ContainsAny(key, "*") {
				key = key + "*"
			}
			cmd = fmt.Sprintf("%s %d MATCH %s COUNT %d", method, iterate, key, _globalConfigs.System.KeyScanLimits)
			ret, err = redis.Values(c.Do(method, iterate, "MATCH", key, "COUNT", _globalConfigs.System.KeyScanLimits))

		} else {
			if key == "" {
				sendCmdError(conn, "key can't not be empty")
				return 0, nil
			}
			if !strings.ContainsAny(field, "*") {
				field = field + "*"
			}
			cmd = fmt.Sprintf("%s %s %d MATCH %s COUNT %d", method, key, iterate, field, _globalConfigs.System.KeyScanLimits)
			ret, err = redis.Values(c.Do(method, key, iterate, "MATCH", field, "COUNT", _globalConfigs.System.KeyScanLimits))
		}

		sendCmd(conn, cmd)
		if err != nil {
			sendCmdError(conn, "redis error: "+err.Error())
			return 0, nil
		}
		sendCmdReceive(conn, ret)
		tmp, err = redis.Strings(ret[1], nil)
		if err != nil {
			sendCmdError(conn, "redis error: "+err.Error())
			return 0, nil
		}
		keys = append(keys, tmp...)
		iterate, err = redis.Int64(ret[0], nil)
{'fraction_non_alphanumeric': 0.15458358298382266, 'fraction_numerical': 0.007189934092270821, 'mean_word_length': 3.5865384615384617, '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': '1146363', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1248, 'n_words': 330}