Merge pull request #244 from andrew-d/andrew-remove-ResultTree

Remove deprecated ResultTree API
This commit is contained in:
Barak Michener 2015-04-28 19:35:49 -04:00
commit 7f1607693a
23 changed files with 0 additions and 221 deletions

View file

@ -140,10 +140,6 @@ func (it *AllIterator) Err() error {
return it.err
}
func (it *AllIterator) ResultTree() *graph.ResultTree {
return graph.NewResultTree(it.Result())
}
func (it *AllIterator) Result() graph.Value {
if it.done {
return nil

View file

@ -191,10 +191,6 @@ func (it *Iterator) Err() error {
return it.err
}
func (it *Iterator) ResultTree() *graph.ResultTree {
return graph.NewResultTree(it.Result())
}
func (it *Iterator) Result() graph.Value {
if it.done {
return nil

View file

@ -209,10 +209,6 @@ func (it *Iterator) SubIterators() []graph.Iterator {
return nil
}
func (it *Iterator) ResultTree() *graph.ResultTree {
return graph.NewResultTree(it.Result())
}
func (it *Iterator) Result() graph.Value {
return it.result
}

View file

@ -86,9 +86,6 @@ type Iterator interface {
// Returns the current result.
Result() Value
// DEPRECATED -- Fills a ResultTree struct with Result().
ResultTree() *ResultTree
// These methods are the heart and soul of the iterator, as they constitute
// the iteration interface.
//

View file

@ -109,11 +109,6 @@ func (it *Int64) Err() error {
return nil
}
// DEPRECATED
func (it *Int64) ResultTree() *graph.ResultTree {
return graph.NewResultTree(it.Result())
}
func (it *Int64) Result() graph.Value {
return it.result
}

View file

@ -102,16 +102,6 @@ func (it *And) SubIterators() []graph.Iterator {
return iters
}
// DEPRECATED Returns the ResultTree for this iterator, recurses to it's subiterators.
func (it *And) ResultTree() *graph.ResultTree {
tree := graph.NewResultTree(it.Result())
tree.AddSubtree(it.primaryIt.ResultTree())
for _, sub := range it.internalIterators {
tree.AddSubtree(sub.ResultTree())
}
return tree
}
func (it *And) Describe() graph.Description {
subIts := make([]graph.Description, len(it.internalIterators))
for i, sub := range it.internalIterators {

View file

@ -149,11 +149,6 @@ func (it *Fixed) Err() error {
return nil
}
// DEPRECATED
func (it *Fixed) ResultTree() *graph.ResultTree {
return graph.NewResultTree(it.Result())
}
func (it *Fixed) Result() graph.Value {
return it.result
}

View file

@ -121,13 +121,6 @@ func (it *HasA) TagResults(dst map[string]graph.Value) {
it.primaryIt.TagResults(dst)
}
// DEPRECATED Return results in a ResultTree.
func (it *HasA) ResultTree() *graph.ResultTree {
tree := graph.NewResultTree(it.Result())
tree.AddSubtree(it.primaryIt.ResultTree())
return tree
}
func (it *HasA) Describe() graph.Description {
primary := it.primaryIt.Describe()
return graph.Description{

View file

@ -96,10 +96,6 @@ func (it *Null) Result() graph.Value {
return nil
}
func (it *Null) ResultTree() *graph.ResultTree {
return graph.NewResultTree(it.Result())
}
func (it *Null) SubIterators() []graph.Iterator {
return nil
}

View file

@ -99,13 +99,6 @@ func (it *LinksTo) TagResults(dst map[string]graph.Value) {
it.primaryIt.TagResults(dst)
}
// DEPRECATED
func (it *LinksTo) ResultTree() *graph.ResultTree {
tree := graph.NewResultTree(it.Result())
tree.AddSubtree(it.primaryIt.ResultTree())
return tree
}
func (it *LinksTo) Describe() graph.Description {
primary := it.primaryIt.Describe()
return graph.Description{

View file

@ -131,13 +131,6 @@ func (it *Materialize) Describe() graph.Description {
// Register this iterator as a Materialize iterator.
func (it *Materialize) Type() graph.Type { return graph.Materialize }
// DEPRECATED
func (it *Materialize) ResultTree() *graph.ResultTree {
tree := graph.NewResultTree(it.Result())
tree.AddSubtree(it.subIt.ResultTree())
return tree
}
func (it *Materialize) Result() graph.Value {
if it.aborted {
return it.subIt.Result()

View file

@ -66,14 +66,6 @@ func (it *Not) SubIterators() []graph.Iterator {
return []graph.Iterator{it.primaryIt, it.allIt}
}
// DEPRECATED
func (it *Not) ResultTree() *graph.ResultTree {
tree := graph.NewResultTree(it.Result())
tree.AddSubtree(it.primaryIt.ResultTree())
tree.AddSubtree(it.allIt.ResultTree())
return tree
}
// Next advances the Not iterator. It returns whether there is another valid
// new value. It fetches the next value of the all iterator which is not
// contained by the primary iterator.

View file

@ -72,11 +72,6 @@ func (it *Optional) Clone() graph.Iterator {
return out
}
// DEPRECATED
func (it *Optional) ResultTree() *graph.ResultTree {
return graph.NewResultTree(it.Result())
}
func (it *Optional) Err() error {
return it.err
}

View file

@ -102,15 +102,6 @@ func (it *Or) TagResults(dst map[string]graph.Value) {
it.internalIterators[it.currentIterator].TagResults(dst)
}
// DEPRECATED Returns the ResultTree for this graph.iterator, recurses to it's subiterators.
func (it *Or) ResultTree() *graph.ResultTree {
tree := graph.NewResultTree(it.Result())
for _, sub := range it.internalIterators {
tree.AddSubtree(sub.ResultTree())
}
return tree
}
func (it *Or) Describe() graph.Description {
var subIts []graph.Description
for i, sub := range it.internalIterators {

View file

@ -64,13 +64,6 @@ func (it *Unique) SubIterators() []graph.Iterator {
return []graph.Iterator{it.subIt}
}
// DEPRECATED
func (it *Unique) ResultTree() *graph.ResultTree {
tree := graph.NewResultTree(it.Result())
tree.AddSubtree(it.subIt.ResultTree())
return tree
}
// Next advances the subiterator, continuing until it returns a value which it
// has not previously seen.
func (it *Unique) Next() bool {

View file

@ -140,11 +140,6 @@ func (it *Comparison) Err() error {
return it.err
}
// DEPRECATED
func (it *Comparison) ResultTree() *graph.ResultTree {
return graph.NewResultTree(it.Result())
}
func (it *Comparison) Result() graph.Value {
return it.result
}

View file

@ -123,10 +123,6 @@ func (it *AllIterator) Err() error {
return it.iter.Error()
}
func (it *AllIterator) ResultTree() *graph.ResultTree {
return graph.NewResultTree(it.Result())
}
func (it *AllIterator) Result() graph.Value {
return it.result
}

View file

@ -159,10 +159,6 @@ func (it *Iterator) Err() error {
return it.iter.Error()
}
func (it *Iterator) ResultTree() *graph.ResultTree {
return graph.NewResultTree(it.Result())
}
func (it *Iterator) Result() graph.Value {
return it.result
}

View file

@ -138,10 +138,6 @@ func (it *Iterator) Err() error {
return it.err
}
func (it *Iterator) ResultTree() *graph.ResultTree {
return graph.NewResultTree(it.Result())
}
func (it *Iterator) Result() graph.Value {
return it.result
}

View file

@ -110,13 +110,6 @@ func (it *LinksTo) TagResults(dst map[string]graph.Value) {
it.primaryIt.TagResults(dst)
}
// DEPRECATED
func (it *LinksTo) ResultTree() *graph.ResultTree {
tree := graph.NewResultTree(it.Result())
tree.AddSubtree(it.primaryIt.ResultTree())
return tree
}
// Optimize the LinksTo, by replacing it if it can be.
func (it *LinksTo) Optimize() (graph.Iterator, bool) {
return it, false

View file

@ -153,10 +153,6 @@ func (it *Iterator) Err() error {
return it.err
}
func (it *Iterator) ResultTree() *graph.ResultTree {
return graph.NewResultTree(it.Result())
}
func (it *Iterator) Result() graph.Value {
return it.result
}

View file

@ -1,59 +0,0 @@
// Copyright 2014 The Cayley Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package graph
import (
"bytes"
"fmt"
)
type ResultTree struct {
result Value
subtrees []*ResultTree
}
func NewResultTree(result Value) *ResultTree {
return &ResultTree{result: result}
}
func (t *ResultTree) String() string {
var buf bytes.Buffer
fmt.Fprintf(&buf, "(%d", t.result)
for _, sub := range t.subtrees {
fmt.Fprintf(&buf, " %s", sub)
}
buf.WriteByte(')')
return buf.String()
}
func (t *ResultTree) AddSubtree(sub *ResultTree) {
t.subtrees = append(t.subtrees, sub)
}
func StringResultTreeEvaluator(it Nexter) string {
var buf bytes.Buffer
for it.Next() {
fmt.Fprintln(&buf, it.ResultTree())
for it.NextPath() {
buf.WriteByte(' ')
fmt.Fprintln(&buf, it.ResultTree())
}
}
return buf.String()
}
func PrintResultTreeEvaluator(it Nexter) {
fmt.Print(StringResultTreeEvaluator(it))
}

View file

@ -1,45 +0,0 @@
// Copyright 2014 The Cayley Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package graph_test
import (
"testing"
. "github.com/google/cayley/graph"
"github.com/google/cayley/graph/iterator"
)
func TestSingleIterator(t *testing.T) {
all := iterator.NewInt64(1, 3)
result := StringResultTreeEvaluator(all)
expected := "(1)\n(2)\n(3)\n"
if expected != result {
t.Errorf("Expected %q got %q", expected, result)
}
}
func TestAndIterator(t *testing.T) {
all1 := iterator.NewInt64(1, 3)
all2 := iterator.NewInt64(3, 5)
and := iterator.NewAnd(nil)
and.AddSubIterator(all1)
and.AddSubIterator(all2)
result := StringResultTreeEvaluator(and)
expected := "(3 (3) (3))\n"
if expected != result {
t.Errorf("Expected %q got %q", expected, result)
}
}