func (this *AlterIndex) UnmarshalJSON(body []byte) error { var _unmarshalled struct { _ string `json:"#operator"` Index string `json:"index"` Keys string `json:"keyspace"` Names string `json:"namespace"` Rename string `json:"rename"` Using datastore.IndexType `json:"using"` } err := json.Unmarshal(body, &_unmarshalled) if err != nil { return err } ksref := algebra.NewKeyspaceRef(_unmarshalled.Names, _unmarshalled.Keys, "") this.node = algebra.NewAlterIndex(ksref, _unmarshalled.Index, _unmarshalled.Using, _unmarshalled.Rename) this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Names, _unmarshalled.Keys) if err != nil { return err } indexer, err := this.keyspace.Indexer(_unmarshalled.Using) if err != nil { return err } this.index, err = indexer.IndexByName(_unmarshalled.Index) return err }
func (this *InferKeyspace) UnmarshalJSON(body []byte) error { var _unmarshalled struct { _ string `json:"#operator"` Keysp string `json:"keyspace"` Namesp string `json:"namespace"` Using datastore.InferenceType `json:"using"` With json.RawMessage `json:"with"` } err := json.Unmarshal(body, &_unmarshalled) if err != nil { return err } this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Namesp, _unmarshalled.Keysp) if err != nil { return err } ksref := algebra.NewKeyspaceRef(_unmarshalled.Namesp, _unmarshalled.Keysp, "") var with value.Value if len(_unmarshalled.With) > 0 { with = value.NewValue(_unmarshalled.With) } this.node = algebra.NewInferKeyspace(ksref, _unmarshalled.Using, with) return nil }
func (this *BuildIndexes) UnmarshalJSON(body []byte) error { var _unmarshalled struct { _ string `json:"#operator"` Keys string `json:"keyspace"` Names string `json:"namespace"` Using datastore.IndexType `json:"using"` Indexes []string `json:"indexes"` } err := json.Unmarshal(body, &_unmarshalled) if err != nil { return err } ksref := algebra.NewKeyspaceRef(_unmarshalled.Names, _unmarshalled.Keys, "") this.node = algebra.NewBuildIndexes(ksref, _unmarshalled.Using, _unmarshalled.Indexes...) this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Names, _unmarshalled.Keys) return err }
func (this *Merge) UnmarshalJSON(body []byte) error { var _unmarshalled struct { _ string `json:"#operator"` Keys string `json:"keyspace"` Names string `json:"namespace"` As string `json:"as"` Key string `json:"key"` Update json.RawMessage `json:"update"` Delete json.RawMessage `json:"delete"` Insert json.RawMessage `json:"insert"` } err := json.Unmarshal(body, &_unmarshalled) if err != nil { return err } this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Names, _unmarshalled.Keys) if err != nil { return err } this.ref = algebra.NewKeyspaceRef(_unmarshalled.Names, _unmarshalled.Keys, _unmarshalled.As) if _unmarshalled.Key != "" { this.key, err = parser.Parse(_unmarshalled.Key) if err != nil { return err } } ops := []json.RawMessage{ _unmarshalled.Update, _unmarshalled.Delete, _unmarshalled.Insert, } for i, child := range ops { if len(child) == 0 { continue } var op_type struct { Operator string `json:"#operator"` } err = json.Unmarshal(child, &op_type) if err != nil { return err } switch i { case 0: this.update, err = MakeOperator(op_type.Operator, child) case 1: this.delete, err = MakeOperator(op_type.Operator, child) case 2: this.insert, err = MakeOperator(op_type.Operator, child) } if err != nil { return err } } return err }
func (this *CreateIndex) UnmarshalJSON(body []byte) error { var _unmarshalled struct { _ string `json:"#operator"` Keysp string `json:"keyspace"` Namesp string `json:"namespace"` Index string `json:"index"` Keys []string `json:"keys"` Using datastore.IndexType `json:"using"` Partition []string `json:"partition"` Where string `json:"where"` With json.RawMessage `json:"with"` } err := json.Unmarshal(body, &_unmarshalled) if err != nil { return err } this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Namesp, _unmarshalled.Keysp) if err != nil { return err } ksref := algebra.NewKeyspaceRef(_unmarshalled.Namesp, _unmarshalled.Keysp, "") keys := make(expression.Expressions, len(_unmarshalled.Keys)) for i, k := range _unmarshalled.Keys { keys[i], err = parser.Parse(k) if err != nil { return err } } var partition expression.Expressions if len(_unmarshalled.Partition) > 0 { partition = make(expression.Expressions, len(_unmarshalled.Partition)) for i, p := range _unmarshalled.Partition { partition[i], err = parser.Parse(p) if err != nil { return err } } } var where expression.Expression if _unmarshalled.Where != "" { where, err = parser.Parse(_unmarshalled.Where) if err != nil { return err } } var with value.Value if len(_unmarshalled.With) > 0 { with = value.NewValue(_unmarshalled.With) } this.node = algebra.NewCreateIndex(_unmarshalled.Index, ksref, keys, partition, where, _unmarshalled.Using, with) return nil }