Skip to content

Commit

Permalink
graph: remove unused horizon function
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Dec 23, 2017
1 parent fe0248e commit d994e2a
Show file tree
Hide file tree
Showing 20 changed files with 5 additions and 313 deletions.
10 changes: 0 additions & 10 deletions graph/bolt/bolt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,13 @@ func TestLoadDatabase(t *testing.T) {
t.Errorf("Could not convert from generic to Bolt QuadStore")
}

//Test horizon
horizon := qs.Horizon()
if v, _ := horizon.Int(); v != 1 {
t.Errorf("Unexpected horizon value, got:%d expect:1", v)
}

w.AddQuadSet(graphtest.MakeQuadSet())
if s := qs.Size(); s != 12 {
t.Errorf("Unexpected quadstore size, got:%d expect:12", s)
}
if s := ts2.SizeOf(qs.ValueOf(quad.Raw("B"))); s != 5 {
t.Errorf("Unexpected quadstore size, got:%d expect:5", s)
}
horizon = qs.Horizon()
if v, _ := horizon.Int(); v != 12 {
t.Errorf("Unexpected horizon value, got:%d expect:12", v)
}

w.RemoveQuad(quad.MakeRaw(
"A",
Expand Down
4 changes: 0 additions & 4 deletions graph/bolt/quadstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ func (qs *QuadStore) Size() int64 {
return sz
}

func (qs *QuadStore) Horizon() graph.PrimaryKey {
return graph.NewSequentialKey(qs.horizon)
}

func (qs *QuadStore) createDeltaKeyFor(id int64) []byte {
return []byte(fmt.Sprintf("%018x", id))
}
Expand Down
16 changes: 0 additions & 16 deletions graph/gaedatastore/quadstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,22 +500,6 @@ func (qs *QuadStore) NodeSize() int64 {
return foundMetadata.NodeCount
}

func (qs *QuadStore) Horizon() graph.PrimaryKey {
if qs.context == nil {
clog.Warningf("Warning: HTTP Request context is nil, cannot get horizon from datastore.")
return graph.NewUniqueKey("")
}
// Query log for last entry...
q := datastore.NewQuery("logentry").Order("-Timestamp").Limit(1)
var logEntries []LogEntry
keys, err := q.GetAll(qs.context, &logEntries)
if err != nil || len(logEntries) == 0 {
// Error fetching horizon, probably graph is empty
return graph.NewUniqueKey("")
}
return graph.NewSequentialKey(keys[0].IntID())
}

func compareTokens(a, b graph.Value) bool {
atok := a.(*Token)
btok := b.(*Token)
Expand Down
5 changes: 2 additions & 3 deletions graph/gaedatastore/quadstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ func makeGAE(t testing.TB) (graph.QuadStore, graph.Options, func()) {

func TestGAEAll(t *testing.T) {
graphtest.TestAll(t, makeGAE, &graphtest.Config{
NoPrimitives: true,
SkipIntHorizon: true,
UnTyped: true,
NoPrimitives: true,
UnTyped: true,
})
}

Expand Down
4 changes: 0 additions & 4 deletions graph/graphmock/graphmock.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ func (qs *Oldstore) NameOf(v graph.Value) quad.Value {

func (qs *Oldstore) Size() int64 { return 0 }

func (qs *Oldstore) Horizon() graph.PrimaryKey { return graph.NewSequentialKey(0) }

func (qs *Oldstore) DebugPrint() {}

func (qs *Oldstore) OptimizeIterator(it graph.Iterator) (graph.Iterator, bool) {
Expand Down Expand Up @@ -152,8 +150,6 @@ func (qs *Store) FixedIterator() graph.FixedIterator {

func (qs *Store) Close() error { return nil }

func (qs *Store) Horizon() graph.PrimaryKey { return graph.NewSequentialKey(0) }

func (qs *Store) DebugPrint() {}

func (qs *Store) QuadIterator(d quad.Direction, i graph.Value) graph.Iterator {
Expand Down
24 changes: 2 additions & 22 deletions graph/graphtest/graphtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type Config struct {

SkipDeletedFromIterator bool
SkipSizeCheckAfterDelete bool
SkipIntHorizon bool
// TODO(dennwc): these stores are not garbage-collecting nodes after quad removal
SkipNodeDelAfterQuadDel bool
}
Expand All @@ -41,7 +40,7 @@ var graphTests = []struct {
}{
{"load one quad", TestLoadOneQuad},
{"delete quad", TestDeleteQuad},
{"horizon int", TestHorizonInt},
{"sizes", TestSizes},
{"iterator", TestIterator},
{"hasa", TestHasA},
{"set iterator", TestSetIterator},
Expand Down Expand Up @@ -199,21 +198,12 @@ type ValueSizer interface {
SizeOf(graph.Value) int64
}

func TestHorizonInt(t testing.TB, gen testutil.DatabaseFunc, conf *Config) {
if conf.SkipIntHorizon {
t.SkipNow()
}
func TestSizes(t testing.TB, gen testutil.DatabaseFunc, conf *Config) {
qs, opts, closer := gen(t)
defer closer()

w := testutil.MakeWriter(t, qs, opts)

horizon, ok := qs.Horizon().Int()
if !ok && graph.NewSequentialKey(0) != qs.Horizon() {
t.Skip("horizon is not int")
}
require.Equal(t, int64(0), horizon, "Unexpected horizon value")

err := w.AddQuadSet(MakeQuadSet())
require.NoError(t, err)
exp := int64(22)
Expand All @@ -227,16 +217,6 @@ func TestHorizonInt(t testing.TB, gen testutil.DatabaseFunc, conf *Config) {
require.Equal(t, int64(5), s, "Unexpected quadstore value size")
}

horizon, ok = qs.Horizon().Int()
if !ok {
t.SkipNow()
}
exp = int64(1)
if conf.NoPrimitives {
exp = 11
}
require.Equal(t, exp, horizon, "Unexpected horizon value")

err = w.RemoveQuad(quad.MakeRaw(
"A",
"follows",
Expand Down
1 change: 0 additions & 1 deletion graph/kv/kvtest/kvtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type Config struct {
func (c Config) quadStore() *graphtest.Config {
return &graphtest.Config{
NoPrimitives: true,
SkipIntHorizon: true,
AlwaysRunIntegration: c.AlwaysRunIntegration,
}
}
Expand Down
4 changes: 0 additions & 4 deletions graph/kv/quadstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,6 @@ func (qs *QuadStore) horizon(ctx context.Context) int64 {
return h
}

func (qs *QuadStore) Horizon() graph.PrimaryKey {
return graph.NewSequentialKey(qs.horizon(context.TODO()))
}

func (qs *QuadStore) ValuesOf(ctx context.Context, vals []graph.Value) ([]quad.Value, error) {
out := make([]quad.Value, len(vals))
var (
Expand Down
10 changes: 0 additions & 10 deletions graph/leveldb/leveldb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,23 +133,13 @@ func TestLoadDatabase(t *testing.T) {
t.Errorf("Could not convert from generic to LevelDB QuadStore")
}

//Test horizon
horizon := qs.Horizon()
if v, _ := horizon.Int(); v != 1 {
t.Errorf("Unexpected horizon value, got:%d expect:1", v)
}

w.AddQuadSet(graphtest.MakeQuadSet())
if s := qs.Size(); s != 12 {
t.Errorf("Unexpected quadstore size, got:%d expect:12", s)
}
if s := ts2.SizeOf(qs.ValueOf(quad.Raw("B"))); s != 5 {
t.Errorf("Unexpected quadstore size, got:%d expect:5", s)
}
horizon = qs.Horizon()
if v, _ := horizon.Int(); v != 12 {
t.Errorf("Unexpected horizon value, got:%d expect:12", v)
}

w.RemoveQuad(quad.MakeRaw(
"A",
Expand Down
4 changes: 0 additions & 4 deletions graph/leveldb/quadstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,6 @@ func (qs *QuadStore) Size() int64 {
return qs.size
}

func (qs *QuadStore) Horizon() graph.PrimaryKey {
return graph.NewSequentialKey(qs.horizon)
}

func createKeyFor(d [4]quad.Direction, q quad.Quad) []byte {
key := make([]byte, 2+(quad.HashSize*4))
key[0] = d[0].Prefix()
Expand Down
4 changes: 0 additions & 4 deletions graph/memstore/quadstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,6 @@ func (qs *QuadStore) QuadIterator(d quad.Direction, value graph.Value) graph.Ite
return iterator.NewNull()
}

func (qs *QuadStore) Horizon() graph.PrimaryKey {
return graph.NewSequentialKey(qs.horizon)
}

func (qs *QuadStore) Size() int64 {
return int64(len(qs.prim))
}
Expand Down
12 changes: 0 additions & 12 deletions graph/mongo/quadstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,18 +533,6 @@ func (qs *QuadStore) Size() int64 {
return int64(count)
}

func (qs *QuadStore) Horizon() graph.PrimaryKey {
var log MongoLogEntry
err := qs.db.C("log").Find(nil).Sort("-_id").One(&log)
if err != nil {
if err == mgo.ErrNotFound {
return graph.NewSequentialKey(0)
}
clog.Errorf("Could not get Horizon from Mongo: %v", err)
}
return graph.NewUniqueKey(objidString(log.ID))
}

func (qs *QuadStore) FixedIterator() graph.FixedIterator {
return iterator.NewFixed(iterator.Identity)
}
Expand Down
20 changes: 0 additions & 20 deletions graph/nosql/quadstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,26 +580,6 @@ func (qs *QuadStore) Size() int64 {
return count
}

func (qs *QuadStore) Horizon() graph.PrimaryKey {
// FIXME: this picks a random record; we need to sort at least on timestamp,
// or emulate a global counter and use it as an id for log entries
log, err := qs.db.Query(colLog).One(context.TODO())
if err != nil {
if err == ErrNotFound {
return graph.NewSequentialKey(0)
}
clog.Errorf("could not get horizon: %v", err)
}
var id string
if v, ok := log[fldLogID].(String); ok {
id = string(v)
}
if id == "" {
return graph.PrimaryKey{}
}
return graph.NewUniqueKey(id)
}

func (qs *QuadStore) FixedIterator() graph.FixedIterator {
return iterator.NewFixed(iterator.Identity)
}
Expand Down
90 changes: 0 additions & 90 deletions graph/primarykey.go

This file was deleted.

Loading

0 comments on commit d994e2a

Please sign in to comment.