本文整理汇总了Golang中github.com/janelia-flyem/dvid/datastore.TypeServiceByName函数的典型用法代码示例。如果您正苦于以下问题:Golang TypeServiceByName函数的具体用法?Golang TypeServiceByName怎么用?Golang TypeServiceByName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TypeServiceByName函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: repoNewDataHandler
func repoNewDataHandler(c web.C, w http.ResponseWriter, r *http.Request) {
uuid := c.Env["uuid"].(dvid.UUID)
config := dvid.NewConfig()
if err := config.SetByJSON(r.Body); err != nil {
BadRequest(w, r, fmt.Sprintf("Error decoding POSTed JSON config for 'new': %v", err))
return
}
// Make sure that the passed configuration has data type and instance name.
typename, found, err := config.GetString("typename")
if !found || err != nil {
BadRequest(w, r, "POST on repo endpoint requires specification of valid 'typename'")
return
}
dataname, found, err := config.GetString("dataname")
if !found || err != nil {
BadRequest(w, r, "POST on repo endpoint requires specification of valid 'dataname'")
return
}
typeservice, err := datastore.TypeServiceByName(dvid.TypeString(typename))
if err != nil {
BadRequest(w, r, err)
return
}
_, err = datastore.NewData(uuid, typeservice, dvid.InstanceName(dataname), config)
if err != nil {
BadRequest(w, r, err)
return
}
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, "{%q: 'Added %s [%s] to node %s'}", "result", dataname, typename, uuid)
}
开发者ID:jwohlwend,项目名称:dvid,代码行数:32,代码来源:web.go
示例2: initTestRepo
// Sets package-level testRepo and TestVersionID
func initTestRepo() (dvid.UUID, dvid.VersionID) {
testMu.Lock()
defer testMu.Unlock()
if mstype == nil {
var err error
mstype, err = datastore.TypeServiceByName(TypeName)
if err != nil {
log.Fatalf("Can't get imagetile type: %s\n", err)
}
grayscaleT, err = datastore.TypeServiceByName("uint8blk")
if err != nil {
log.Fatalf("Can't get grayscale type: %s\n", err)
}
}
return datastore.NewTestRepo()
}
开发者ID:jmptrader,项目名称:dvid,代码行数:17,代码来源:imagetile_test.go
示例3: initTestRepo
// Sets package-level testRepo and TestVersionID
func initTestRepo() (dvid.UUID, dvid.VersionID) {
testMu.Lock()
defer testMu.Unlock()
if labelsT == nil {
var err error
labelsT, err = datastore.TypeServiceByName("labelblk")
if err != nil {
log.Fatalf("Can't get labelblk type: %s\n", err)
}
rgbaT, err = datastore.TypeServiceByName("rgba8blk")
if err != nil {
log.Fatalf("Can't get rgba8blk type: %s\n", err)
}
}
return tests.NewRepo()
}
开发者ID:hanslovsky,项目名称:dvid,代码行数:17,代码来源:labelblk_test.go
示例4: typehelpHandler
func typehelpHandler(c web.C, w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
typename := dvid.TypeString(c.URLParams["typename"])
typeservice, err := datastore.TypeServiceByName(typename)
if err != nil {
BadRequest(w, r, err)
return
}
fmt.Fprintf(w, typeservice.Help())
}
开发者ID:jwohlwend,项目名称:dvid,代码行数:10,代码来源:web.go
示例5: initTestRepo
// Sets package-level testRepo and TestVersionID
func initTestRepo() (dvid.UUID, dvid.VersionID) {
if dtype == nil {
var err error
dtype, err = datastore.TypeServiceByName(TypeName)
if err != nil {
log.Fatalf("Can't get labelgraph type: %v\n", err)
}
}
return datastore.NewTestRepo()
}
开发者ID:tartavull,项目名称:dvid,代码行数:11,代码来源:labelgraph_test.go
示例6: initTestRepo
// Sets package-level testRepo and TestVersionID
func initTestRepo() (dvid.UUID, dvid.VersionID) {
testMu.Lock()
defer testMu.Unlock()
if grayscaleT == nil {
var err error
grayscaleT, err = datastore.TypeServiceByName("uint8blk")
if err != nil {
log.Fatalf("Can't get uint8blk type: %s\n", err)
}
rgbaT, err = datastore.TypeServiceByName("rgba8blk")
if err != nil {
log.Fatalf("Can't get rgba8blk type: %s\n", err)
}
roiT, err = datastore.TypeServiceByName("roi")
if err != nil {
log.Fatalf("Can't get ROI type: %s\n", err)
}
}
return datastore.NewTestRepo()
}
开发者ID:jmptrader,项目名称:dvid,代码行数:21,代码来源:uint8_test.go
示例7: initTestRepo
// Sets package-level testRepo and TestVersionID
func initTestRepo() (dvid.UUID, dvid.VersionID) {
testMu.Lock()
defer testMu.Unlock()
if roitype == nil {
var err error
roitype, err = datastore.TypeServiceByName(TypeName)
if err != nil {
log.Fatalf("Can't get ROI type: %v\n", err)
}
}
return datastore.NewTestRepo()
}
开发者ID:jmptrader,项目名称:dvid,代码行数:13,代码来源:roi_test.go
示例8: initTestRepo
// Sets package-level testRepo and TestVersionID
func initTestRepo() (dvid.UUID, dvid.VersionID) {
testMu.Lock()
defer testMu.Unlock()
if dtype == nil {
var err error
dtype, err = datastore.TypeServiceByName(TypeName)
if err != nil {
log.Fatalf("Can't get multichan16 type: %v\n", err)
}
}
return tests.NewRepo()
}
开发者ID:hanslovsky,项目名称:dvid,代码行数:13,代码来源:multichan16_test.go
示例9: ForegroundROI
// ForegroundROI creates a new ROI by determining all non-background blocks.
func (d *Data) ForegroundROI(req datastore.Request, reply *datastore.Response) error {
if d.Values.BytesPerElement() != 1 {
return fmt.Errorf("Foreground ROI command only implemented for 1 byte/voxel data!")
}
// Parse the request
var uuidStr, dataName, cmdStr, destName, backgroundStr string
req.CommandArgs(1, &uuidStr, &dataName, &cmdStr, &destName, &backgroundStr)
// Get the version and repo
uuid, versionID, err := datastore.MatchingUUID(uuidStr)
if err != nil {
return err
}
if err = datastore.AddToNodeLog(uuid, []string{req.Command.String()}); err != nil {
return err
}
// Use existing destination data or a new ROI data.
var dest *roi.Data
dest, err = roi.GetByUUID(uuid, dvid.InstanceName(destName))
if err != nil {
config := dvid.NewConfig()
typeservice, err := datastore.TypeServiceByName("roi")
if err != nil {
return err
}
dataservice, err := datastore.NewData(uuid, typeservice, dvid.InstanceName(destName), config)
if err != nil {
return err
}
var ok bool
dest, ok = dataservice.(*roi.Data)
if !ok {
return fmt.Errorf("Could not create ROI data instance")
}
}
// Asynchronously process the voxels.
background, err := dvid.StringToPointNd(backgroundStr, ",")
if err != nil {
return err
}
go d.foregroundROI(versionID, dest, background)
return nil
}
开发者ID:hanslovsky,项目名称:dvid,代码行数:48,代码来源:imageblk.go
示例10: CreateComposite
// CreateComposite creates a new rgba8 image by combining hash of labels + the grayscale
func (d *Data) CreateComposite(request datastore.Request, reply *datastore.Response) error {
timedLog := dvid.NewTimeLog()
// Parse the request
var uuidStr, dataName, cmdStr, grayscaleName, destName string
request.CommandArgs(1, &uuidStr, &dataName, &cmdStr, &grayscaleName, &destName)
// Get the version
uuid, v, err := datastore.MatchingUUID(uuidStr)
if err != nil {
return err
}
// Log request
if err = datastore.AddToNodeLog(uuid, []string{request.Command.String()}); err != nil {
return err
}
// Get the grayscale data.
dataservice, err := datastore.GetDataByUUIDName(uuid, dvid.InstanceName(grayscaleName))
if err != nil {
return err
}
grayscale, ok := dataservice.(*imageblk.Data)
if !ok {
return fmt.Errorf("%s is not the name of uint8 data", grayscaleName)
}
// Create a new rgba8blk data.
var compservice datastore.DataService
compservice, err = datastore.GetDataByUUIDName(uuid, dvid.InstanceName(destName))
if err == nil {
return fmt.Errorf("Data instance with name %q already exists", destName)
}
typeService, err := datastore.TypeServiceByName("rgba8blk")
if err != nil {
return fmt.Errorf("Could not get rgba8 type service from DVID")
}
config := dvid.NewConfig()
compservice, err = datastore.NewData(uuid, typeService, dvid.InstanceName(destName), config)
if err != nil {
return err
}
composite, ok := compservice.(*imageblk.Data)
if !ok {
return fmt.Errorf("Error: %s was unable to be set to rgba8 data", destName)
}
// Iterate through all labels and grayscale chunks incrementally in Z, a layer at a time.
wg := new(sync.WaitGroup)
op := &compositeOp{grayscale, composite, v}
chunkOp := &storage.ChunkOp{op, wg}
store, err := d.GetOrderedKeyValueDB()
if err != nil {
return err
}
ctx := datastore.NewVersionedCtx(d, v)
extents := d.Extents()
blockBeg := imageblk.NewTKey(extents.MinIndex)
blockEnd := imageblk.NewTKey(extents.MaxIndex)
err = store.ProcessRange(ctx, blockBeg, blockEnd, chunkOp, storage.ChunkFunc(d.CreateCompositeChunk))
wg.Wait()
// Set new mapped data to same extents.
composite.Properties.Extents = grayscale.Properties.Extents
if err := datastore.SaveDataByUUID(uuid, composite); err != nil {
dvid.Infof("Could not save new data '%s': %v\n", destName, err)
}
timedLog.Infof("Created composite of %s and %s", grayscaleName, destName)
return nil
}
开发者ID:tartavull,项目名称:dvid,代码行数:74,代码来源:composite.go
示例11: Do
// Do acts as a switchboard for remote command execution
func (c *RPCConnection) Do(cmd datastore.Request, reply *datastore.Response) error {
if reply == nil {
dvid.Debugf("reply is nil coming in!\n")
return nil
}
if cmd.Name() == "" {
return fmt.Errorf("Server error: got empty command!")
}
switch cmd.Name() {
case "help":
reply.Text = fmt.Sprintf(RPCHelpMessage, config.RPCAddress(), config.HTTPAddress())
case "shutdown":
Shutdown()
// Make this process shutdown in a second to allow time for RPC to finish.
// TODO -- Better way to do this?
log.Printf("DVID server halted due to 'shutdown' command.")
reply.Text = fmt.Sprintf("DVID server at %s has been halted.\n", config.RPCAddress())
go func() {
time.Sleep(1 * time.Second)
os.Exit(0)
}()
case "types":
if len(cmd.Command) == 1 {
text := "\nData Types within this DVID Server\n"
text += "----------------------------------\n"
mapTypes, err := datastore.Types()
if err != nil {
return fmt.Errorf("Error trying to retrieve data types within this DVID server!")
}
for url, typeservice := range mapTypes {
text += fmt.Sprintf("%-20s %s\n", typeservice.GetTypeName(), url)
}
reply.Text = text
} else {
if len(cmd.Command) != 3 || cmd.Command[2] != "help" {
return fmt.Errorf("Unknown types command: %q", cmd.Command)
}
var typename string
cmd.CommandArgs(1, &typename)
typeservice, err := datastore.TypeServiceByName(dvid.TypeString(typename))
if err != nil {
return err
}
reply.Text = typeservice.Help()
}
case "repos":
var subcommand, alias, description, uuidStr string
cmd.CommandArgs(1, &subcommand, &alias, &description, &uuidStr)
switch subcommand {
case "new":
var assign *dvid.UUID
if uuidStr == "" {
assign = nil
} else {
u := dvid.UUID(uuidStr)
assign = &u
}
root, err := datastore.NewRepo(alias, description, assign)
if err != nil {
return err
}
if err := datastore.SetRepoAlias(root, alias); err != nil {
return err
}
if err := datastore.SetRepoDescription(root, description); err != nil {
return err
}
reply.Text = fmt.Sprintf("New repo %q created with head node %s\n", alias, root)
default:
return fmt.Errorf("Unknown repos command: %q", subcommand)
}
case "repo":
var uuidStr, subcommand string
cmd.CommandArgs(1, &uuidStr, &subcommand)
uuid, _, err := datastore.MatchingUUID(uuidStr)
if err != nil {
return err
}
switch subcommand {
case "new":
var typename, dataname string
cmd.CommandArgs(3, &typename, &dataname)
// Get TypeService
typeservice, err := datastore.TypeServiceByName(dvid.TypeString(typename))
if err != nil {
return err
}
// Create new data
config := cmd.Settings()
_, err = datastore.NewData(uuid, typeservice, dvid.InstanceName(dataname), config)
//.........这里部分代码省略.........
开发者ID:hanslovsky,项目名称:dvid,代码行数:101,代码来源:rpc.go
示例12: handleCommand
// switchboard for remote command execution
func handleCommand(cmd *datastore.Request) (reply *datastore.Response, err error) {
if cmd.Name() == "" {
err = fmt.Errorf("Server error: got empty command!")
return
}
reply = new(datastore.Response)
switch cmd.Name() {
case "help":
reply.Text = fmt.Sprintf(RPCHelpMessage, config.RPCAddress(), config.HTTPAddress())
case "shutdown":
dvid.Infof("DVID server halting due to 'shutdown' command.")
reply.Text = fmt.Sprintf("DVID server at %s is being shutdown...\n", config.RPCAddress())
// launch goroutine shutdown so we can concurrently return shutdown message to client.
go Shutdown()
case "types":
if len(cmd.Command) == 1 {
text := "\nData Types within this DVID Server\n"
text += "----------------------------------\n"
var mapTypes map[dvid.URLString]datastore.TypeService
if mapTypes, err = datastore.Types(); err != nil {
err = fmt.Errorf("Error trying to retrieve data types within this DVID server!")
return
}
for url, typeservice := range mapTypes {
text += fmt.Sprintf("%-20s %s\n", typeservice.GetTypeName(), url)
}
reply.Text = text
} else {
if len(cmd.Command) != 3 || cmd.Command[2] != "help" {
err = fmt.Errorf("Unknown types command: %q", cmd.Command)
return
}
var typename string
var typeservice datastore.TypeService
cmd.CommandArgs(1, &typename)
if typeservice, err = datastore.TypeServiceByName(dvid.TypeString(typename)); err != nil {
return
}
reply.Text = typeservice.Help()
}
case "repos":
var subcommand string
cmd.CommandArgs(1, &subcommand)
switch subcommand {
case "new":
var alias, description string
cmd.CommandArgs(2, &alias, &description)
config := cmd.Settings()
var uuidStr, passcode string
var found bool
if uuidStr, found, err = config.GetString("uuid"); err != nil {
return
}
var assign *dvid.UUID
if !found {
assign = nil
} else {
uuid := dvid.UUID(uuidStr)
assign = &uuid
}
if passcode, found, err = config.GetString("passcode"); err != nil {
return
}
var root dvid.UUID
root, err = datastore.NewRepo(alias, description, assign, passcode)
if err != nil {
return
}
if err = datastore.SetRepoAlias(root, alias); err != nil {
return
}
if err = datastore.SetRepoDescription(root, description); err != nil {
return
}
reply.Text = fmt.Sprintf("New repo %q created with head node %s\n", alias, root)
case "delete":
var uuidStr, passcode string
cmd.CommandArgs(2, &uuidStr, &passcode)
var uuid dvid.UUID
if uuid, _, err = datastore.MatchingUUID(uuidStr); err != nil {
return
}
if err = datastore.DeleteRepo(uuid, passcode); err != nil {
return
}
reply.Text = fmt.Sprintf("Started deletion of repo %s.\n", uuid)
default:
err = fmt.Errorf("Unknown repos command: %q", subcommand)
return
//.........这里部分代码省略.........
开发者ID:tartavull,项目名称:dvid,代码行数:101,代码来源:rpc.go
注:本文中的github.com/janelia-flyem/dvid/datastore.TypeServiceByName函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论