Option to remove size calls
Fix permutations of optimization intersections Return empty string as per bolt fix case sensitivity and memstore panic
This commit is contained in:
parent
aedd0401e2
commit
fab8cd64b3
4 changed files with 34 additions and 3 deletions
|
|
@ -249,6 +249,9 @@ func (qs *QuadStore) ValueOf(name string) graph.Value {
|
|||
}
|
||||
|
||||
func (qs *QuadStore) NameOf(id graph.Value) string {
|
||||
if id == nil {
|
||||
return ""
|
||||
}
|
||||
return qs.revIDMap[id.(int64)]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,16 @@ func intersect(a sqlIterator, b sqlIterator, qs *QuadStore) (*SQLIterator, error
|
|||
if bnew, ok := b.(*SQLNodeIterator); ok {
|
||||
return intersectNode(anew, bnew, qs)
|
||||
}
|
||||
if bnew, ok := b.(*SQLNodeIntersection); ok {
|
||||
return appendNodeIntersection(bnew, anew, qs)
|
||||
}
|
||||
} else if anew, ok := a.(*SQLNodeIntersection); ok {
|
||||
if bnew, ok := b.(*SQLNodeIterator); ok {
|
||||
return appendNodeIntersection(anew, bnew, qs)
|
||||
}
|
||||
if bnew, ok := b.(*SQLNodeIntersection); ok {
|
||||
return combineNodeIntersection(anew, bnew, qs)
|
||||
}
|
||||
} else if anew, ok := a.(*SQLLinkIterator); ok {
|
||||
if bnew, ok := b.(*SQLLinkIterator); ok {
|
||||
return intersectLink(anew, bnew, qs)
|
||||
|
|
@ -65,6 +71,17 @@ func appendNodeIntersection(a *SQLNodeIntersection, b *SQLNodeIterator, qs *Quad
|
|||
return it, nil
|
||||
}
|
||||
|
||||
func combineNodeIntersection(a *SQLNodeIntersection, b *SQLNodeIntersection, qs *QuadStore) (*SQLIterator, error) {
|
||||
m := &SQLNodeIntersection{
|
||||
tableName: newTableName(),
|
||||
nodeIts: append(a.nodeIts, b.nodeIts...),
|
||||
}
|
||||
m.Tagger().CopyFromTagger(a.Tagger())
|
||||
m.Tagger().CopyFromTagger(b.Tagger())
|
||||
it := NewSQLIterator(qs, m)
|
||||
return it, nil
|
||||
}
|
||||
|
||||
func intersectLink(a *SQLLinkIterator, b *SQLLinkIterator, qs *QuadStore) (*SQLIterator, error) {
|
||||
m := &SQLLinkIterator{
|
||||
tableName: newTableName(),
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ type QuadStore struct {
|
|||
sqlFlavor string
|
||||
size int64
|
||||
lru *cache
|
||||
noSizes bool
|
||||
}
|
||||
|
||||
func connectSQLTables(addr string, _ graph.Options) (*sql.DB, error) {
|
||||
|
|
@ -257,6 +258,10 @@ func (qs *QuadStore) ValueOf(s string) graph.Value {
|
|||
}
|
||||
|
||||
func (qs *QuadStore) NameOf(v graph.Value) string {
|
||||
if v == nil {
|
||||
glog.V(2).Info("NameOf was nil")
|
||||
return ""
|
||||
}
|
||||
return v.(string)
|
||||
}
|
||||
|
||||
|
|
@ -306,6 +311,12 @@ func (qs *QuadStore) sizeForIterator(isAll bool, dir quad.Direction, val string)
|
|||
if isAll {
|
||||
return qs.Size()
|
||||
}
|
||||
if qs.noSizes {
|
||||
if dir == quad.Predicate {
|
||||
return (qs.Size() / 100) + 1
|
||||
}
|
||||
return (qs.Size() / 1000) + 1
|
||||
}
|
||||
if val, ok := qs.lru.Get(val + string(dir.Prefix())); ok {
|
||||
return val
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@ type tagDir struct {
|
|||
func (t tagDir) String() string {
|
||||
if t.dir == quad.Any {
|
||||
if t.justLocal {
|
||||
return fmt.Sprintf("%s.__execd as %s, %s.__execd_hash as %s_hash", t.table, t.tag, t.table, t.tag)
|
||||
return fmt.Sprintf("%s.__execd as \"%s\", %s.__execd_hash as %s_hash", t.table, t.tag, t.table, t.tag)
|
||||
}
|
||||
return fmt.Sprintf("%s.%s as %s, %s.%s_hash as %s_hash", t.table, t.tag, t.tag, t.table, t.tag, t.tag)
|
||||
return fmt.Sprintf("%s.\"%s\" as \"%s\", %s.%s_hash as %s_hash", t.table, t.tag, t.tag, t.table, t.tag, t.tag)
|
||||
}
|
||||
return fmt.Sprintf("%s.%s as %s, %s.%s_hash as %s_hash", t.table, t.dir, t.tag, t.table, t.dir, t.tag)
|
||||
return fmt.Sprintf("%s.%s as \"%s\", %s.%s_hash as %s_hash", t.table, t.dir, t.tag, t.table, t.dir, t.tag)
|
||||
}
|
||||
|
||||
type tableDef struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue