func (this *IntersectScan) processKey(item value.AnnotatedValue, context *Context) bool { m := item.GetAttachment("meta") meta, ok := m.(map[string]interface{}) if !ok { context.Error(errors.NewError(nil, fmt.Sprintf("Missing or invalid meta %v of type %T.", m, m))) return false } k := meta["id"] key, ok := k.(string) if !ok { context.Error(errors.NewError(nil, fmt.Sprintf("Missing or invalid primary key %v of type %T.", k, k))) return false } count := this.counts[key] this.counts[key] = count + 1 if count+1 == len(this.scans) { delete(this.values, key) return this.sendItem(item) } if count == 0 { this.values[key] = item } return true }
func (this *Distinct) processItem(item value.AnnotatedValue, context *Context) bool { p := item.GetAttachment("projection") if p == nil { p = item } this.set.Put(p.(value.Value), item) return true }
func (this *Clone) processItem(item value.AnnotatedValue, context *Context) bool { target, ok := item.GetAttachment("target").(value.Value) if !ok { target = item } item.SetAttachment("clone", target.CopyForUpdate()) return this.sendItem(item) }
func (this *FinalProject) processItem(item value.AnnotatedValue, context *Context) bool { pv := item.GetAttachment("projection") if pv != nil { v := pv.(value.Value) return this.sendItem(value.NewAnnotatedValue(v)) } return this.sendItem(item) }
func (this *Unset) processItem(item value.AnnotatedValue, context *Context) bool { clone, ok := item.GetAttachment("clone").(value.AnnotatedValue) if !ok { context.Error(errors.NewError(nil, fmt.Sprintf("Invalid UPDATE clone of type %T.", clone))) return false } for _, t := range this.plan.Node().Terms() { unsetPath(t, clone, context) } return this.sendItem(item) }
func (this *Set) processItem(item value.AnnotatedValue, context *Context) bool { clone, ok := item.GetAttachment("clone").(value.AnnotatedValue) if !ok { context.Error(errors.NewError(nil, fmt.Sprintf("Invalid UPDATE clone of type %T.", clone))) return false } var e error for _, t := range this.plan.Node().Terms() { clone, e = setPath(t, clone, item, context) if e != nil { context.Error(errors.NewError(e, "Error evaluating SET clause.")) return false } } item.SetAttachment("clone", clone) return this.sendItem(item) }
func (this *UnionScan) processKey(item value.AnnotatedValue, context *Context) bool { m := item.GetAttachment("meta") meta, ok := m.(map[string]interface{}) if !ok { context.Error(errors.NewError(nil, fmt.Sprintf("Missing or invalid meta %v of type %T.", m, m))) return false } k := meta["id"] key, ok := k.(string) if !ok { context.Error(errors.NewError(nil, fmt.Sprintf("Missing or invalid primary key %v of type %T.", k, k))) return false } if this.values[key] != nil { return true } this.values[key] = item return this.sendItem(item) }
func (this *base) requireKey(item value.AnnotatedValue, context *Context) (string, bool) { mv := item.GetAttachment("meta") if mv == nil { context.Error(errors.NewError(nil, "Unable to find meta.")) return "", false } meta := mv.(map[string]interface{}) key, ok := meta["id"] if !ok { context.Error(errors.NewError(nil, "Unable to find key.")) return "", false } act := value.NewValue(key).Actual() switch act := act.(type) { case string: return act, true default: e := errors.NewError(nil, fmt.Sprintf("Unable to process non-string key %v of type %T.", act, act)) context.Error(e) return "", false } }