本文整理匯總了Golang中github.com/eaigner/hood.Hood.FindSql方法的典型用法代碼示例。如果您正苦於以下問題:Golang Hood.FindSql方法的具體用法?Golang Hood.FindSql怎麽用?Golang Hood.FindSql使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/eaigner/hood.Hood
的用法示例。
在下文中一共展示了Hood.FindSql方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetNumAliveWorkers
func GetNumAliveWorkers(tx *hood.Hood) int {
var results []IntStruct
err := tx.FindSql(&results,
`select count(*) as value
from worker
where status=$1`, WORKER_ALIVE)
if err != nil {
panic(err)
}
return results[0].Value
}
示例2: GetNumSegmentsComplete
func (rdd *Rdd) GetNumSegmentsComplete(tx *hood.Hood, include *Segment) int {
var results []IntStruct
err := tx.FindSql(&results,
`select count(*) as value
from segment
where (rdd_id = $1 and status=$3)
or id = $2`, rdd.Id, include.Id, SEGMENT_COMPLETE)
if err != nil {
panic(err)
}
return results[0].Value
}
示例3: GetRandomAliveWorker
func GetRandomAliveWorker(tx *hood.Hood) *Worker {
var results []Worker
err := tx.FindSql(&results,
`select *
from worker
where status=$1
order by random()
limit 1`, WORKER_ALIVE)
if err != nil {
panic(err)
}
if len(results) == 0 {
return nil
} else {
return &results[0]
}
}
示例4: GetPendingRdds
func GetPendingRdds(tx *hood.Hood) []*Rdd {
var results []Rdd
err := tx.FindSql(&results,
`select rdd.*
from rdd
where rdd.state = $1`, RDD_PENDING)
if err != nil {
panic(err)
}
// Should return pointers to the result objects so that
// they can be mutated
pointerResults := make([]*Rdd, len(results))
for i := range results {
pointerResults[i] = &results[i]
}
return pointerResults
}
示例5: GetRddByStartTime
func GetRddByStartTime(tx *hood.Hood, protojobId int64, startTime int64) *Rdd {
var results []Rdd
err := tx.FindSql(&results,
`select rdd.*
from rdd
inner join workflow_batch
on rdd.workflow_batch_id = workflow_batch.id
where rdd.protojob_id = $1
and workflow_batch.start_time = $2`, protojobId, startTime)
if err != nil {
panic(err)
}
if len(results) == 0 {
return nil
} else {
return &results[0]
}
}
示例6: GetRddEdges
// Get all Rdd edges whose dest Rdd is in the given workflow batch. Note that
// the source and dest Rdds may be produced in different batches.
func (workflowBatch *WorkflowBatch) GetRddEdges(tx *hood.Hood) []*RddEdge {
var results []RddEdge
err := tx.FindSql(&results,
`select rdd_edge.*
from rdd_edge
inner join rdd dest_rdd
on rdd_edge.dest_rdd_id = dest_rdd.id
where dest_rdd.workflow_batch_id = $1`, workflowBatch.Id)
if err != nil {
panic(err)
}
// Should return pointers to the result objects so that
// they can be mutated
pointerResults := make([]*RddEdge, len(results))
for i := range results {
pointerResults[i] = &results[i]
}
return pointerResults
}
示例7: GetDestRdds
func (rdd *Rdd) GetDestRdds(tx *hood.Hood) []*Rdd {
var results []Rdd
err := tx.FindSql(&results,
`select dest_rdd.*
from rdd_edge
inner join rdd dest_rdd
on rdd_edge.dest_rdd_id = dest_rdd.id
where rdd_edge.source_rdd_id = $1`, rdd.Id)
if err != nil {
panic(err)
}
// Should return pointers to the result objects so that
// they can be mutated
pointerResults := make([]*Rdd, len(results))
for i := range results {
pointerResults[i] = &results[i]
}
return pointerResults
}
示例8: GetWorkflowEdges
// Select all workflow edges whose dest_protojob is in the given
// workflow (this also imlies that the source_protojob is in the workflow)
func (workflow *Workflow) GetWorkflowEdges(tx *hood.Hood) []*WorkflowEdge {
var results []WorkflowEdge
err := tx.FindSql(&results,
`select workflow_edge.*
from workflow_edge
inner join protojob dest_job
on workflow_edge.dest_job_id = dest_job.id
where dest_job.workflow_id = $1`, workflow.Id)
if err != nil {
panic(err)
}
// Should return pointers to the result objects so that
// they can be mutated
pointerResults := make([]*WorkflowEdge, len(results))
for i := range results {
pointerResults[i] = &results[i]
}
return pointerResults
}
示例9: GetSourceProtojobs
func (protojob *Protojob) GetSourceProtojobs(tx *hood.Hood) []*Protojob {
var results []Protojob
err := tx.FindSql(&results,
`select source_job.*
from workflow_edge
inner join protojob source_job
on workflow_edge.source_job_id = source_job.id
where workflow_edge.dest_job_id = $1`, protojob.Id)
if err != nil {
panic(err)
}
// Should return pointers to the result objects so that
// they can be mutated
pointerResults := make([]*Protojob, len(results))
for i := range results {
pointerResults[i] = &results[i]
}
return pointerResults
}
示例10: GetSegmentCopies
func (rdd *Rdd) GetSegmentCopies(tx *hood.Hood) []*SegmentCopy {
var results []SegmentCopy
err := tx.FindSql(&results,
`select segment_copy.*
from segment_copy
inner join segment
on segment_copy.segment_id = segment.id
where segment.rdd_id = $1`, rdd.Id)
if err != nil {
panic(err)
}
// Should return pointers to the result objects so that
// they can be mutated
pointerResults := make([]*SegmentCopy, len(results))
for i := range results {
pointerResults[i] = &results[i]
}
return pointerResults
}