Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom tokenizer in bulk loader #2820

Merged
merged 3 commits into from
Dec 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions dgraph/cmd/bulk/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,22 @@ import (
)

type options struct {
RDFDir string
SchemaFile string
DgraphsDir string
TmpDir string
NumGoroutines int
MapBufSize int64
ExpandEdges bool
SkipMapPhase bool
CleanupTmp bool
NumShufflers int
Version bool
StoreXids bool
ZeroAddr string
HttpAddr string
IgnoreErrors bool
RDFDir string
SchemaFile string
DgraphsDir string
TmpDir string
NumGoroutines int
MapBufSize int64
ExpandEdges bool
SkipMapPhase bool
CleanupTmp bool
NumShufflers int
Version bool
StoreXids bool
ZeroAddr string
HttpAddr string
IgnoreErrors bool
CustomTokenizers string

MapShards int
ReduceShards int
Expand Down
44 changes: 27 additions & 17 deletions dgraph/cmd/bulk/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import (
"path/filepath"
"runtime"
"strconv"
"strings"

"github.com/dgraph-io/dgraph/tok"
"github.com/dgraph-io/dgraph/x"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -84,27 +86,30 @@ func init() {
"Number of reduce shards. This determines the number of dgraph instances in the final "+
"cluster. Increasing this potentially decreases the reduce stage runtime by using "+
"more parallelism, but increases memory usage.")
flag.String("custom_tokenizers", "",
"Comma separated list of tokenizer plugins")
}

func run() {
opt := options{
RDFDir: Bulk.Conf.GetString("rdfs"),
SchemaFile: Bulk.Conf.GetString("schema_file"),
DgraphsDir: Bulk.Conf.GetString("out"),
TmpDir: Bulk.Conf.GetString("tmp"),
NumGoroutines: Bulk.Conf.GetInt("num_go_routines"),
MapBufSize: int64(Bulk.Conf.GetInt("mapoutput_mb")),
ExpandEdges: Bulk.Conf.GetBool("expand_edges"),
SkipMapPhase: Bulk.Conf.GetBool("skip_map_phase"),
CleanupTmp: Bulk.Conf.GetBool("cleanup_tmp"),
NumShufflers: Bulk.Conf.GetInt("shufflers"),
Version: Bulk.Conf.GetBool("version"),
StoreXids: Bulk.Conf.GetBool("store_xids"),
ZeroAddr: Bulk.Conf.GetString("zero"),
HttpAddr: Bulk.Conf.GetString("http"),
IgnoreErrors: Bulk.Conf.GetBool("ignore_errors"),
MapShards: Bulk.Conf.GetInt("map_shards"),
ReduceShards: Bulk.Conf.GetInt("reduce_shards"),
RDFDir: Bulk.Conf.GetString("rdfs"),
SchemaFile: Bulk.Conf.GetString("schema_file"),
DgraphsDir: Bulk.Conf.GetString("out"),
TmpDir: Bulk.Conf.GetString("tmp"),
NumGoroutines: Bulk.Conf.GetInt("num_go_routines"),
MapBufSize: int64(Bulk.Conf.GetInt("mapoutput_mb")),
ExpandEdges: Bulk.Conf.GetBool("expand_edges"),
SkipMapPhase: Bulk.Conf.GetBool("skip_map_phase"),
CleanupTmp: Bulk.Conf.GetBool("cleanup_tmp"),
NumShufflers: Bulk.Conf.GetInt("shufflers"),
Version: Bulk.Conf.GetBool("version"),
StoreXids: Bulk.Conf.GetBool("store_xids"),
ZeroAddr: Bulk.Conf.GetString("zero"),
HttpAddr: Bulk.Conf.GetString("http"),
IgnoreErrors: Bulk.Conf.GetBool("ignore_errors"),
MapShards: Bulk.Conf.GetInt("map_shards"),
ReduceShards: Bulk.Conf.GetInt("reduce_shards"),
CustomTokenizers: Bulk.Conf.GetString("custom_tokenizers"),
}

x.PrintVersion()
Expand All @@ -125,6 +130,11 @@ func run() {
opt.NumShufflers, opt.ReduceShards)
os.Exit(1)
}
if opt.CustomTokenizers != "" {
for _, soFile := range strings.Split(opt.CustomTokenizers, ",") {
tok.LoadCustomTokenizer(soFile)
}
}

opt.MapBufSize <<= 20 // Convert from MB to B.

Expand Down