<commit_before>package chredis

import(
  "fmt"
  "github.com/mediocregopher/radix.v2/redis"
)

type Rreader interface {
  Cmd(cmd string, args ...interface{}) *redis.Resp
  ReadRhash(key string) (map[string]string, error)
  Close() error
}

// Read a redis hash from the redis server.
func (rc *Rclient) ReadRhash(key string) (map[string]string, error) {
  m, err := rc.Cmd("HGETALL", key).Map()
  fmt.Println(m)
  return m, err
}<commit_msg>Now Rreeader returns a Rhash struct instead of a plain map.<commit_after>package chredis

import(
  "fmt"
  "github.com/mediocregopher/radix.v2/redis"
)

type Rreader interface {
  Cmd(cmd string, args ...interface{}) *redis.Resp
  ReadRhash(key string) (Rhash, error)
  Close() error
}

// Read a redis hash from the redis server.
func (rc *Rclient) readHash(key string) (map[string]string, error) {
  m, err := rc.Cmd("HGETALL", key).Map()
  return m, err
}

// Given a key, read a hash, returning a Rhash struct.
func (rc *Rclient) ReadRhash(key string) (Rhash, error) {
  m, err := rc.readHash(key)
  if err != nil {
    // Just propagate err upstream for handling.
    return Rhash{}, err
  }
  fmt.Println("")
  return Rhash{key, m}, nil
}

// TODO: Goroutine that retrieves a stream of keys, reads hashes, and shoves Rhash'es into ch --> 2nd ch just prints the hashes (as a demo implementation).

{'fraction_non_alphanumeric': 0.1337295690936107, 'fraction_numerical': 0.002228826151560178, 'mean_word_length': 3.8453237410071943, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '6130803', 'n_tokens_mistral': 484, 'n_tokens_neox': 476, 'n_words': 155}