Skip to content
Snippets Groups Projects
Commit 5798faab authored by ale's avatar ale
Browse files

remove some old useless code

parent 4d52c146
Branches
No related tags found
No related merge requests found
package mapreduce
func MapReduce(mapper func(interface{}, chan interface{}),
reducer func(chan interface{}, chan interface{}),
input chan interface{},
pool_size int) interface{} {
reduce_input := make(chan interface{})
reduce_output := make(chan interface{})
worker_output := make(chan chan interface{}, pool_size)
go reducer(reduce_input, reduce_output)
go func() {
for worker_chan := range worker_output {
reduce_input <- <-worker_chan
}
close(reduce_input)
}()
go func() {
for item := range input {
my_chan := make(chan interface{})
go mapper(item, my_chan)
worker_output <- my_chan
}
close(worker_output)
}()
return <-reduce_output
}
package util
import (
"crypto/rand"
"encoding/hex"
"fmt"
"os"
"path/filepath"
"time"
)
var (
tmpdir = os.TempDir()
)
func TempName(prefix, suffix string) string {
buf := make([]byte, 4)
rand.Read(buf)
return filepath.Join(
tmpdir,
fmt.Sprintf(
"%s%d.%d.%s%s",
prefix,
os.Getpid(),
time.Now().Unix(),
hex.EncodeToString(buf),
suffix))
}
func TempFile(prefix, suffix string) (*os.File, error) {
return os.Create(TempName(prefix, suffix))
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment