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")
|
||||
)
|
||||
|
||||
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
|
||||
oldHorizon := qs.horizon
|
||||
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 {
|
||||
err := qs.buildQuadWrite(tx, d.Quad, d.ID.Int(), d.Action == graph.Add)
|
||||
if err != nil {
|
||||
if err == graph.ErrQuadExists && ignoreDuplicate{
|
||||
if err == graph.ErrQuadExists && ignoreDup{
|
||||
continue
|
||||
}
|
||||
if err == graph.ErrQuadNotExist && ignoreMissing{
|
||||
if err == graph.ErrQuadNotExist && ignoreMiss{
|
||||
continue
|
||||
}
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ var (
|
|||
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{}
|
||||
resizeMap := make(map[string]int64)
|
||||
sizeChange := int64(0)
|
||||
|
|
@ -196,10 +196,10 @@ func (qs *QuadStore) ApplyDeltas(deltas []graph.Delta, ignoreDuplicate bool, ign
|
|||
batch.Put(keyFor(d), bytes)
|
||||
err = qs.buildQuadWrite(batch, d.Quad, d.ID.Int(), d.Action == graph.Add)
|
||||
if err != nil {
|
||||
if err == graph.ErrQuadExists && ignoreDuplicate{
|
||||
if err == graph.ErrQuadExists && ignoreDup{
|
||||
continue
|
||||
}
|
||||
if err == graph.ErrQuadNotExist && ignoreMissing{
|
||||
if err == graph.ErrQuadNotExist && ignoreMiss{
|
||||
continue
|
||||
}
|
||||
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 {
|
||||
var err error
|
||||
switch d.Action {
|
||||
case graph.Add:
|
||||
err = qs.AddDelta(d)
|
||||
if err != nil && ignoreDuplicate{
|
||||
if err != nil && ignoreDupl{
|
||||
err = nil
|
||||
}
|
||||
case graph.Delete:
|
||||
err = qs.RemoveDelta(d)
|
||||
if err != nil && ignoreMissing{
|
||||
if err != nil && ignoreMiss{
|
||||
err = nil
|
||||
}
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ func (qs *QuadStore) updateLog(d graph.Delta) error {
|
|||
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)
|
||||
ids := make(map[string]int)
|
||||
// Pre-check the existence condition.
|
||||
|
|
@ -226,7 +226,7 @@ func (qs *QuadStore) ApplyDeltas(in []graph.Delta, ignoreDuplicate bool, ignoreM
|
|||
switch d.Action {
|
||||
case graph.Add:
|
||||
if qs.checkValid(key) {
|
||||
if ignoreDuplicate {
|
||||
if ignoreDup {
|
||||
continue
|
||||
}else{
|
||||
return graph.ErrQuadExists
|
||||
|
|
@ -234,7 +234,7 @@ func (qs *QuadStore) ApplyDeltas(in []graph.Delta, ignoreDuplicate bool, ignoreM
|
|||
}
|
||||
case graph.Delete:
|
||||
if !qs.checkValid(key) {
|
||||
if ignoreMissing {
|
||||
if ignoreMiss {
|
||||
continue
|
||||
}else{
|
||||
return graph.ErrQuadNotExist
|
||||
|
|
|
|||
|
|
@ -33,13 +33,18 @@ type Single struct {
|
|||
}
|
||||
|
||||
func NewSingleReplication(qs graph.QuadStore, opts graph.Options) (graph.QuadWriter, error) {
|
||||
ignoreMissing, imset := opts.BoolKey("ignore_missing")
|
||||
if !imset {
|
||||
ignoreMissing = *graph.IgnoreMissing
|
||||
var ignoreMissing, ignoreDuplicate bool
|
||||
|
||||
if *graph.IgnoreMissing{
|
||||
ignoreMissing = true
|
||||
}else{
|
||||
ignoreMissing,_ = opts.BoolKey("ignore_missing")
|
||||
}
|
||||
ignoreDuplicate, idset := opts.BoolKey("ignore_duplicate")
|
||||
if !idset {
|
||||
ignoreDuplicate = *graph.IgnoreDup
|
||||
|
||||
if *graph.IgnoreDup{
|
||||
ignoreDuplicate = true
|
||||
}else{
|
||||
ignoreDuplicate,_ = opts.BoolKey("ignore_duplicate")
|
||||
}
|
||||
|
||||
return &Single{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue