Shortended function signature and changed flag priority
This commit is contained in:
parent
cca6d53623
commit
50c3e5f93c
5 changed files with 23 additions and 18 deletions
|
|
@ -185,7 +185,7 @@ var (
|
||||||
metaBucket = []byte("meta")
|
metaBucket = []byte("meta")
|
||||||
)
|
)
|
||||||
|
|
||||||
func (qs *QuadStore) ApplyDeltas(deltas []graph.Delta, ignoreDuplicate bool, ignoreMissing bool) error {
|
func (qs *QuadStore) ApplyDeltas(deltas []graph.Delta, ignoreDup, ignoreMiss bool) error {
|
||||||
oldSize := qs.size
|
oldSize := qs.size
|
||||||
oldHorizon := qs.horizon
|
oldHorizon := qs.horizon
|
||||||
err := qs.db.Update(func(tx *bolt.Tx) error {
|
err := qs.db.Update(func(tx *bolt.Tx) error {
|
||||||
|
|
@ -209,10 +209,10 @@ func (qs *QuadStore) ApplyDeltas(deltas []graph.Delta, ignoreDuplicate bool, ign
|
||||||
for _, d := range deltas {
|
for _, d := range deltas {
|
||||||
err := qs.buildQuadWrite(tx, d.Quad, d.ID.Int(), d.Action == graph.Add)
|
err := qs.buildQuadWrite(tx, d.Quad, d.ID.Int(), d.Action == graph.Add)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == graph.ErrQuadExists && ignoreDuplicate{
|
if err == graph.ErrQuadExists && ignoreDup{
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err == graph.ErrQuadNotExist && ignoreMissing{
|
if err == graph.ErrQuadNotExist && ignoreMiss{
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ var (
|
||||||
cps = [4]quad.Direction{quad.Label, quad.Predicate, quad.Subject, quad.Object}
|
cps = [4]quad.Direction{quad.Label, quad.Predicate, quad.Subject, quad.Object}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (qs *QuadStore) ApplyDeltas(deltas []graph.Delta, ignoreDuplicate bool, ignoreMissing bool) error {
|
func (qs *QuadStore) ApplyDeltas(deltas []graph.Delta, ignoreDup, ignoreMiss bool) error {
|
||||||
batch := &leveldb.Batch{}
|
batch := &leveldb.Batch{}
|
||||||
resizeMap := make(map[string]int64)
|
resizeMap := make(map[string]int64)
|
||||||
sizeChange := int64(0)
|
sizeChange := int64(0)
|
||||||
|
|
@ -196,10 +196,10 @@ func (qs *QuadStore) ApplyDeltas(deltas []graph.Delta, ignoreDuplicate bool, ign
|
||||||
batch.Put(keyFor(d), bytes)
|
batch.Put(keyFor(d), bytes)
|
||||||
err = qs.buildQuadWrite(batch, d.Quad, d.ID.Int(), d.Action == graph.Add)
|
err = qs.buildQuadWrite(batch, d.Quad, d.ID.Int(), d.Action == graph.Add)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == graph.ErrQuadExists && ignoreDuplicate{
|
if err == graph.ErrQuadExists && ignoreDup{
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err == graph.ErrQuadNotExist && ignoreMissing{
|
if err == graph.ErrQuadNotExist && ignoreMiss{
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -100,18 +100,18 @@ func newQuadStore() *QuadStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (qs *QuadStore) ApplyDeltas(deltas []graph.Delta, ignoreDuplicate bool, ignoreMissing bool) error {
|
func (qs *QuadStore) ApplyDeltas(deltas []graph.Delta, ignoreDupl, ignoreMiss bool) error {
|
||||||
for _, d := range deltas {
|
for _, d := range deltas {
|
||||||
var err error
|
var err error
|
||||||
switch d.Action {
|
switch d.Action {
|
||||||
case graph.Add:
|
case graph.Add:
|
||||||
err = qs.AddDelta(d)
|
err = qs.AddDelta(d)
|
||||||
if err != nil && ignoreDuplicate{
|
if err != nil && ignoreDupl{
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
case graph.Delete:
|
case graph.Delete:
|
||||||
err = qs.RemoveDelta(d)
|
err = qs.RemoveDelta(d)
|
||||||
if err != nil && ignoreMissing{
|
if err != nil && ignoreMiss{
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ func (qs *QuadStore) updateLog(d graph.Delta) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (qs *QuadStore) ApplyDeltas(in []graph.Delta, ignoreDuplicate bool, ignoreMissing bool) error {
|
func (qs *QuadStore) ApplyDeltas(in []graph.Delta, ignoreDup, ignoreMiss bool) error {
|
||||||
qs.session.SetSafe(nil)
|
qs.session.SetSafe(nil)
|
||||||
ids := make(map[string]int)
|
ids := make(map[string]int)
|
||||||
// Pre-check the existence condition.
|
// Pre-check the existence condition.
|
||||||
|
|
@ -226,7 +226,7 @@ func (qs *QuadStore) ApplyDeltas(in []graph.Delta, ignoreDuplicate bool, ignoreM
|
||||||
switch d.Action {
|
switch d.Action {
|
||||||
case graph.Add:
|
case graph.Add:
|
||||||
if qs.checkValid(key) {
|
if qs.checkValid(key) {
|
||||||
if ignoreDuplicate {
|
if ignoreDup {
|
||||||
continue
|
continue
|
||||||
}else{
|
}else{
|
||||||
return graph.ErrQuadExists
|
return graph.ErrQuadExists
|
||||||
|
|
@ -234,7 +234,7 @@ func (qs *QuadStore) ApplyDeltas(in []graph.Delta, ignoreDuplicate bool, ignoreM
|
||||||
}
|
}
|
||||||
case graph.Delete:
|
case graph.Delete:
|
||||||
if !qs.checkValid(key) {
|
if !qs.checkValid(key) {
|
||||||
if ignoreMissing {
|
if ignoreMiss {
|
||||||
continue
|
continue
|
||||||
}else{
|
}else{
|
||||||
return graph.ErrQuadNotExist
|
return graph.ErrQuadNotExist
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,18 @@ type Single struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSingleReplication(qs graph.QuadStore, opts graph.Options) (graph.QuadWriter, error) {
|
func NewSingleReplication(qs graph.QuadStore, opts graph.Options) (graph.QuadWriter, error) {
|
||||||
ignoreMissing, imset := opts.BoolKey("ignore_missing")
|
var ignoreMissing, ignoreDuplicate bool
|
||||||
if !imset {
|
|
||||||
ignoreMissing = *graph.IgnoreMissing
|
if *graph.IgnoreMissing{
|
||||||
|
ignoreMissing = true
|
||||||
|
}else{
|
||||||
|
ignoreMissing,_ = opts.BoolKey("ignore_missing")
|
||||||
}
|
}
|
||||||
ignoreDuplicate, idset := opts.BoolKey("ignore_duplicate")
|
|
||||||
if !idset {
|
if *graph.IgnoreDup{
|
||||||
ignoreDuplicate = *graph.IgnoreDup
|
ignoreDuplicate = true
|
||||||
|
}else{
|
||||||
|
ignoreDuplicate,_ = opts.BoolKey("ignore_duplicate")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Single{
|
return &Single{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue