Adapt Go method names for CLOWNFISH-63. The Go bindings for Clownfish methods not marked as `public` now begin with a lower-case letter so that they are not exported.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/9f178803 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/9f178803 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/9f178803 Branch: refs/heads/master Commit: 9f178803379f2a7ef3ec1db34d3fb4a7fa7278f6 Parents: e351e2a Author: Marvin Humphrey <[email protected]> Authored: Mon Nov 2 18:25:54 2015 -0800 Committer: Marvin Humphrey <[email protected]> Committed: Fri Nov 6 19:40:52 2015 -0800 ---------------------------------------------------------------------- go/lucy/analysis_test.go | 6 +- go/lucy/index_test.go | 122 ++++++++++++++--------------- go/lucy/object.go | 2 +- go/lucy/object_test.go | 8 +- go/lucy/plan_test.go | 58 +++++++------- go/lucy/search_test.go | 90 +++++++++++----------- go/lucy/store_test.go | 174 +++++++++++++++++++++--------------------- 7 files changed, 230 insertions(+), 230 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/9f178803/go/lucy/analysis_test.go ---------------------------------------------------------------------- diff --git a/go/lucy/analysis_test.go b/go/lucy/analysis_test.go index 5a068a6..9470fbb 100644 --- a/go/lucy/analysis_test.go +++ b/go/lucy/analysis_test.go @@ -34,7 +34,7 @@ func TestTokenBasics(t *testing.T) { token.GetEndOffset() token.GetBoost() token.GetPosInc() - token.GetPos() + token.getPos() token.GetLen() } @@ -43,7 +43,7 @@ func TestInversionBasics(t *testing.T) { inv.Append(NewToken("foo")) inv.Append(NewToken("bar")) inv.Append(NewToken("baz")) - if size := inv.GetSize(); size != 3 { + if size := inv.getSize(); size != 3 { t.Errorf("Unexpected size: %d", size) } @@ -57,7 +57,7 @@ func TestInversionBasics(t *testing.T) { } inv.Reset() - inv.Invert() + inv.invert() if got := inv.Next().GetText(); got != "bar" { t.Errorf("Next after Invert yielded %s", got) } http://git-wip-us.apache.org/repos/asf/lucy/blob/9f178803/go/lucy/index_test.go ---------------------------------------------------------------------- diff --git a/go/lucy/index_test.go b/go/lucy/index_test.go index 407ff4c..4faab4e 100644 --- a/go/lucy/index_test.go +++ b/go/lucy/index_test.go @@ -113,11 +113,11 @@ func TestIndexerMisc(t *testing.T) { if _, ok := indexer.GetSchema().(Schema); !ok { t.Errorf("GetSchema") } - if _, ok := indexer.GetStockDoc().(Doc); !ok { - t.Errorf("GetStockDoc") + if _, ok := indexer.getStockDoc().(Doc); !ok { + t.Errorf("getStockDoc") } - if _, ok := indexer.GetSegWriter().(SegWriter); !ok { - t.Errorf("GetSegWriter") + if _, ok := indexer.getSegWriter().(SegWriter); !ok { + t.Errorf("getSegWriter") } indexer.AddDoc(&testDoc{Content: "gazi"}) indexer.Optimize() @@ -159,27 +159,27 @@ func TestIndexManagerAccessors(t *testing.T) { } manager.SetWriteLockTimeout(72) if got := manager.GetWriteLockTimeout(); got != 72 { - t.Errorf("Set/GetWriteLockTimeout: %d", got) + t.Errorf("set/GetWriteLockTimeout: %d", got) } manager.SetWriteLockInterval(42) if got := manager.GetWriteLockInterval(); got != 42 { - t.Errorf("Set/GetWriteLockInterval: %d", got) + t.Errorf("set/GetWriteLockInterval: %d", got) } - manager.SetMergeLockTimeout(73) - if got := manager.GetMergeLockTimeout(); got != 73 { - t.Errorf("Set/GetMergeLockTimeout: %d", got) + manager.setMergeLockTimeout(73) + if got := manager.getMergeLockTimeout(); got != 73 { + t.Errorf("set/getMergeLockTimeout: %d", got) } - manager.SetMergeLockInterval(43) - if got := manager.GetMergeLockInterval(); got != 43 { - t.Errorf("Set/GetMergeLockInterval: %d", got) + manager.setMergeLockInterval(43) + if got := manager.getMergeLockInterval(); got != 43 { + t.Errorf("set/getMergeLockInterval: %d", got) } - manager.SetDeletionLockTimeout(71) - if got := manager.GetDeletionLockTimeout(); got != 71 { - t.Errorf("Set/GetDeletionLockTimeout: %d", got) + manager.setDeletionLockTimeout(71) + if got := manager.getDeletionLockTimeout(); got != 71 { + t.Errorf("set/getDeletionLockTimeout: %d", got) } - manager.SetDeletionLockInterval(41) - if got := manager.GetDeletionLockInterval(); got != 41 { - t.Errorf("Set/GetDeletionLockInterval: %d", got) + manager.setDeletionLockInterval(41) + if got := manager.getDeletionLockInterval(); got != 41 { + t.Errorf("set/getDeletionLockInterval: %d", got) } } @@ -189,15 +189,15 @@ func TestIndexManagerLocks(t *testing.T) { if _, ok := manager.MakeWriteLock().(Lock); !ok { t.Errorf("MakeWriteLock") } - if _, ok := manager.MakeMergeLock().(Lock); !ok { - t.Errorf("MakeMergeLock") + if _, ok := manager.makeMergeLock().(Lock); !ok { + t.Errorf("makeMergeLock") } - if _, ok := manager.MakeDeletionLock().(Lock); !ok { - t.Errorf("MakeDeletionLock") + if _, ok := manager.makeDeletionLock().(Lock); !ok { + t.Errorf("makeDeletionLock") } snapFile := "snapshot_4a.json" - if _, ok := manager.MakeSnapshotReadLock(snapFile).(SharedLock); !ok { - t.Errorf("MakeDeletionLock") + if _, ok := manager.makeSnapshotReadLock(snapFile).(SharedLock); !ok { + t.Errorf("makeDeletionLock") } } @@ -231,8 +231,8 @@ func TestIndexManagerMisc(t *testing.T) { snapshot := NewSnapshot() snapshot.AddEntry("seg_4") snapshot.AddEntry("seg_5") - if got := manager.HighestSegNum(snapshot); got != 5 { - t.Errorf("HighestSegNum: %d", got) + if got := manager.highestSegNum(snapshot); got != 5 { + t.Errorf("highestSegNum: %d", got) } } @@ -243,7 +243,7 @@ func TestIndexManagerRecycle(t *testing.T) { indexer, _ := OpenIndexer(&OpenIndexerArgs{Index: index}) searcher, _ := OpenIndexSearcher(index) reader := searcher.GetReader().(PolyReader) - delWriter := indexer.GetSegWriter().GetDelWriter() + delWriter := indexer.getSegWriter().getDelWriter() segReaders, err := manager.Recycle(reader, delWriter, 0, true) if err != nil || len(segReaders) != 1 { t.Errorf("Recycle: (%d SegReaders) %v", len(segReaders), err) @@ -280,7 +280,7 @@ func TestTermInfoMisc(t *testing.T) { if got := other.GetDocFreq(); got != tinfo.GetDocFreq() { t.Errorf("Clone: (%d != %d)", got, tinfo.GetDocFreq()) } - tinfo.Reset() + tinfo.reset() if got := tinfo.GetDocFreq(); got != 0 { t.Errorf("Reset: expected 0, got %d", got) } @@ -315,10 +315,10 @@ func TestTermVectorMisc(t *testing.T) { folder := NewRAMFolder("") out, _ := folder.OpenOut("dump") - tv.Serialize(out) + tv.serialize(out) out.Close() in, _ := folder.OpenIn("dump") - dupe := clownfish.GetClass(tv).MakeObj().(TermVector).Deserialize(in) + dupe := clownfish.GetClass(tv).MakeObj().(TermVector).deserialize(in) if !tv.Equals(dupe) { t.Errorf("Unsuccessful serialization round trip") } @@ -334,24 +334,24 @@ func TestDocVectorMisc(t *testing.T) { indexer.AddDoc(&testDoc{Content: "foo bar baz"}) indexer.Commit() searcher, _ := OpenIndexSearcher(folder) - dv := searcher.FetchDocVec(1) - fieldBuf := dv.FieldBuf("content"); + dv := searcher.fetchDocVec(1) + fieldBuf := dv.fieldBuf("content"); if fieldBuf == nil { - t.Errorf("FieldBuf returned nil") + t.Errorf("fieldBuf returned nil") } - dv.AddFieldBuf("content", fieldBuf) - if got := dv.TermVector("content", "bar"); got == nil { - t.Errorf("TermVector returned nil") + dv.addFieldBuf("content", fieldBuf) + if got := dv.termVector("content", "bar"); got == nil { + t.Errorf("termVector returned nil") } out, _ := folder.OpenOut("dump") - dv.Serialize(out) + dv.serialize(out) out.Close() in, _ := folder.OpenIn("dump") - dupe := clownfish.GetClass(dv).MakeObj().(DocVector).Deserialize(in) + dupe := clownfish.GetClass(dv).MakeObj().(DocVector).deserialize(in) in.Close() if _, ok := dupe.(DocVector); !ok { - t.Errorf("Serialize/Deserialize") + t.Errorf("serialize/deserialize") } } @@ -401,7 +401,7 @@ func TestSortCacheMisc(t *testing.T) { searcher, _ := OpenIndexSearcher(folder) segReaders := searcher.GetReader().SegReaders() sortReader := segReaders[0].(SegReader).Obtain("Lucy::Index::SortReader").(SortReader) - sortCache := sortReader.FetchSortCache("content") + sortCache := sortReader.fetchSortCache("content") if card := sortCache.GetCardinality(); card != 4 { t.Errorf("GetCardinality: %d", card) @@ -424,50 +424,50 @@ func TestSortCacheMisc(t *testing.T) { t.Errorf("Find: %d", ord) } - if sortCache.GetNativeOrds() { + if sortCache.getNativeOrds() { t.Errorf("recent index shouldn't have native ords") } } func TestSimilarityMisc(t *testing.T) { sim := NewSimilarity() - if _, ok := sim.MakePosting().(Posting); !ok { - t.Errorf("MakePosting") + if _, ok := sim.makePosting().(Posting); !ok { + t.Errorf("makePosting") } - if got := sim.TF(4.0); got != 2.0 { - t.Errorf("TF: %f", got) + if got := sim.tF(4.0); got != 2.0 { + t.Errorf("tF: %f", got) } - if got := sim.IDF(40, 1000); got <= 0 { - t.Errorf("IDF: %f", got) + if got := sim.iDF(40, 1000); got <= 0 { + t.Errorf("iDF: %f", got) } - if got := sim.Coord(3, 4); got <= 0 { - t.Errorf("Coord: %f", got) + if got := sim.coord(3, 4); got <= 0 { + t.Errorf("coord: %f", got) } if got := sim.LengthNorm(4); got != 0.5 { t.Errorf("LengthNorm: %f", got) } - if got := sim.QueryNorm(4); got != 0.5 { - t.Errorf("QueryNorm: %f", got) + if got := sim.queryNorm(4); got != 0.5 { + t.Errorf("queryNorm: %f", got) } - if got := sim.EncodeNorm(sim.DecodeNorm(42)); got != 42 { - t.Errorf("Encode/DecodeNorm: %d", got) + if got := sim.encodeNorm(sim.decodeNorm(42)); got != 42 { + t.Errorf("encode/decodeNorm: %d", got) } } func TestSimilarityRoundTrip(t *testing.T) { sim := NewSimilarity() - dupe := sim.Load(sim.Dump()) + dupe := sim.load(sim.dump()) if !sim.Equals(dupe) { t.Errorf("Dump/Load round-trip") } folder := NewRAMFolder("") out, _ := folder.OpenOut("dump") - sim.Serialize(out) + sim.serialize(out) out.Close() in, _ := folder.OpenIn("dump") - dupe = clownfish.GetClass(sim).MakeObj().(Similarity).Deserialize(in) + dupe = clownfish.GetClass(sim).MakeObj().(Similarity).deserialize(in) if !sim.Equals(dupe) { - t.Errorf("Serialize/Deserialize round-trip") + t.Errorf("serialize/deserialize round-trip") } } @@ -500,12 +500,12 @@ func TestSegmentMisc(t *testing.T) { if got := seg.FetchMetadata("mycomponent"); !reflect.DeepEqual(got, metadata) { t.Errorf("Store/FetchMetadata: %v", got) } - if got := seg.GetMetadata(); got["mycomponent"] == nil { + if got := seg.getMetadata(); got["mycomponent"] == nil { t.Errorf("%v", got) } seg.SetCount(42) - seg.IncrementCount(5) + seg.incrementCount(5) if got := seg.GetCount(); got != 47 { t.Errorf("SetCount/GetCount: %d", got) } @@ -539,8 +539,8 @@ func TestFilePurgerMisc(t *testing.T) { snapshot := NewSnapshot() snapshot.WriteFile(folder, "") purger := NewFilePurger(folder, snapshot, nil) - purger.Purge() - if folder.Exists("foo") { + purger.purge() + if folder.exists("foo") { t.Errorf("Failed to purge file") } } http://git-wip-us.apache.org/repos/asf/lucy/blob/9f178803/go/lucy/object.go ---------------------------------------------------------------------- diff --git a/go/lucy/object.go b/go/lucy/object.go index bd0998b..b8585a4 100644 --- a/go/lucy/object.go +++ b/go/lucy/object.go @@ -27,7 +27,7 @@ import "unsafe" import "git-wip-us.apache.org/repos/asf/lucy-clownfish.git/runtime/go/clownfish" func (bv *BitVectorIMP) ToArray() []bool { - cap := bv.GetCapacity() + cap := bv.getCapacity() if cap != uint32(int(cap)) { panic(fmt.Sprintf("Capacity of range: %d", cap)) } http://git-wip-us.apache.org/repos/asf/lucy/blob/9f178803/go/lucy/object_test.go ---------------------------------------------------------------------- diff --git a/go/lucy/object_test.go b/go/lucy/object_test.go index f78fd69..46b12b4 100644 --- a/go/lucy/object_test.go +++ b/go/lucy/object_test.go @@ -46,10 +46,10 @@ func TestBitVecSingle(t *testing.T) { func TestBitVecMisc(t *testing.T) { bitVec := NewBitVector(0) - oldCap := bitVec.GetCapacity() + oldCap := bitVec.getCapacity() bitVec.Grow(64) - if newCap := bitVec.GetCapacity(); newCap <= oldCap { - t.Error("Grow/GetCapacity had unexpected result: %v %v", oldCap, newCap) + if newCap := bitVec.getCapacity(); newCap <= oldCap { + t.Error("Grow/getCapacity had unexpected result: %v %v", oldCap, newCap) } bitVec.Set(0) bitVec.Set(63) @@ -113,7 +113,7 @@ func TestBitVecBool(t *testing.T) { } dupe = seven.Clone().(BitVector) - dupe.Mimic(twelve) + dupe.mimic(twelve) if count := dupe.Count(); count != twelve.Count() { t.Errorf("Mimic: %d", count) } http://git-wip-us.apache.org/repos/asf/lucy/blob/9f178803/go/lucy/plan_test.go ---------------------------------------------------------------------- diff --git a/go/lucy/plan_test.go b/go/lucy/plan_test.go index 20b2935..7bb112c 100644 --- a/go/lucy/plan_test.go +++ b/go/lucy/plan_test.go @@ -41,12 +41,12 @@ func TestSchemaFetchType(t *testing.T) { func TestSchemaFetchAnalyzer(t *testing.T) { schema := createTestSchema() - analyzer := schema.FetchAnalyzer("content") + analyzer := schema.fetchAnalyzer("content") if _, ok := analyzer.(StandardTokenizer); !ok { - t.Errorf("Unexpected result for FetchAnalyzer: %T", analyzer) + t.Errorf("Unexpected result for fetchAnalyzer: %T", analyzer) } - if got := schema.FetchAnalyzer(""); got != nil { - t.Errorf("Expected nil from FetchAnalyzer, got %T %v", got, got) + if got := schema.fetchAnalyzer(""); got != nil { + t.Errorf("Expected nil from fetchAnalyzer, got %T %v", got, got) } } @@ -96,23 +96,23 @@ func TestSchemaAccessors(t *testing.T) { func TestSchemaDumpLoad(t *testing.T) { schema := createTestSchema() - dupe := schema.Load(schema.Dump()) + dupe := schema.load(schema.dump()) if _, ok := dupe.(Schema); !ok { - t.Errorf("Failed Dump/Load round trip produced a %T", dupe) + t.Errorf("Failed dump/load round trip produced a %T", dupe) } } func TestSchemaWrite(t *testing.T) { schema := createTestSchema() folder := NewRAMFolder("") - schema.Write(folder, "serialized_schema.json") + schema.write(folder, "serialized_schema.json") } func TestSchemaEat(t *testing.T) { cannibal := NewSchema() - cannibal.Eat(createTestSchema()) + cannibal.eat(createTestSchema()) if _, ok := cannibal.FetchType("content").(FieldType); !ok { - t.Error("Failed to Eat other Schema") + t.Error("Failed to eat other Schema") } } @@ -135,21 +135,21 @@ func runFieldTypeTests(t *testing.T, ft FieldType) { t.Errorf("SetSortable/Sortable") } ft.Binary() - ft.PrimitiveID() + ft.primitiveID() - // CompareValues, MakeTermStepper - if comparison := ft.CompareValues("foo", "bar"); comparison <= 0 { - t.Errorf("Unexpected CompareValues result: %d", comparison) + // compareValues, makeTermStepper + if comparison := ft.compareValues("foo", "bar"); comparison <= 0 { + t.Errorf("Unexpected compareValues result: %d", comparison) } switch ft.(type) { case BlobType: default: - if stepper, ok := ft.MakeTermStepper().(TermStepper); !ok { - t.Errorf("MakeTermStepper failed: %v", stepper) + if stepper, ok := ft.makeTermStepper().(TermStepper); !ok { + t.Errorf("makeTermStepper failed: %v", stepper) } } - // Equals, Dump/Load + // Equals, dump/load if !ft.Equals(ft) { t.Error("Equals self") } @@ -159,10 +159,10 @@ func runFieldTypeTests(t *testing.T, ft FieldType) { if ft.Equals(NewStringType()) { t.Error("Equals different field type") } - ft.DumpForSchema() - dupe := ft.Load(ft.Dump()).(FieldType) + ft.dumpForSchema() + dupe := ft.load(ft.dump()).(FieldType) if !ft.Equals(dupe) { - t.Errorf("Round-trip through Dump/Load produced %v", dupe) + t.Errorf("Round-trip through dump/load produced %v", dupe) } dupe.SetIndexed(true) if ft.Equals(dupe) { @@ -186,8 +186,8 @@ func TestFullTextTypeMisc(t *testing.T) { if !ft.Highlightable() { t.Error("SetHighlightable/Highlightable") } - if sim, ok := ft.MakeSimilarity().(Similarity); !ok { - t.Errorf("MakeSimilarity: %v", sim) + if sim, ok := ft.makeSimilarity().(Similarity); !ok { + t.Errorf("makeSimilarity: %v", sim) } if _, ok := ft.GetAnalyzer().(StandardTokenizer); !ok { t.Error("GetAnalyzer") @@ -196,23 +196,23 @@ func TestFullTextTypeMisc(t *testing.T) { func TestStringTypeMisc(t *testing.T) { ft := NewStringType(); - if sim, ok := ft.MakeSimilarity().(Similarity); !ok { - t.Errorf("MakeSimilarity: %v", sim) + if sim, ok := ft.makeSimilarity().(Similarity); !ok { + t.Errorf("makeSimilarity: %v", sim) } } func TestArchitectureBasics(t *testing.T) { arch := NewArchitecture() - if got := arch.IndexInterval(); got < 0 { - t.Errorf("IndexInterval: %d", got) + if got := arch.indexInterval(); got < 0 { + t.Errorf("indexInterval: %d", got) } - if got := arch.SkipInterval(); got < 0 { - t.Errorf("IndexInterval: %d", got) + if got := arch.skipInterval(); got < 0 { + t.Errorf("skipInterval: %d", got) } - if sim, ok := arch.MakeSimilarity().(Similarity); !ok { - t.Errorf("MakeSimilarity: %v", sim) + if sim, ok := arch.makeSimilarity().(Similarity); !ok { + t.Errorf("makeSimilarity: %v", sim) } if !arch.Equals(arch) { http://git-wip-us.apache.org/repos/asf/lucy/blob/9f178803/go/lucy/search_test.go ---------------------------------------------------------------------- diff --git a/go/lucy/search_test.go b/go/lucy/search_test.go index 319f0f7..fcd3c33 100644 --- a/go/lucy/search_test.go +++ b/go/lucy/search_test.go @@ -24,10 +24,10 @@ import "git-wip-us.apache.org/repos/asf/lucy-clownfish.git/runtime/go/clownfish" func checkQuerySerialize(t *testing.T, query Query) { folder := NewRAMFolder("") outStream, _ := folder.OpenOut("foo") - query.Serialize(outStream) + query.serialize(outStream) outStream.Close() inStream, _ := folder.OpenIn("foo") - dupe := clownfish.GetClass(query).MakeObj().(Query).Deserialize(inStream) + dupe := clownfish.GetClass(query).MakeObj().(Query).deserialize(inStream) if !query.Equals(dupe) { t.Errorf("Unsuccessful serialization round trip -- expected '%v', got '%v'", query.ToString(), dupe.ToString()) @@ -365,7 +365,7 @@ func TestRangeMatcherBasics(t *testing.T) { segReaders := searcher.GetReader().SegReaders() segReader := segReaders[0].(SegReader) sortReader := segReader.Obtain("Lucy::Index::SortReader").(SortReader) - sortCache := sortReader.FetchSortCache("content") + sortCache := sortReader.fetchSortCache("content") matcher := NewRangeMatcher(0, 0, sortCache, segReader.DocMax()) if docID := matcher.Next(); docID != 4 { t.Errorf("Next: %d", docID) @@ -390,23 +390,23 @@ func TestTopDocsBasics(t *testing.T) { NewMatchDoc(100, 3.0, nil), } td := NewTopDocs(matchDocs, 50) - td.SetTotalHits(20) - if totalHits := td.GetTotalHits(); totalHits != 20 { + td.setTotalHits(20) + if totalHits := td.getTotalHits(); totalHits != 20 { t.Errorf("Expected 20 total hits, got %d", totalHits) } td.SetMatchDocs(matchDocs) fetched := td.GetMatchDocs() - if docID := fetched[0].GetDocID(); docID != 42 { + if docID := fetched[0].getDocID(); docID != 42 { t.Errorf("Set/Get MatchDocs expected 42, got %d", docID) } folder := NewRAMFolder("") outstream, _ := folder.OpenOut("foo") - td.Serialize(outstream) + td.serialize(outstream) outstream.Close() inStream, _ := folder.OpenIn("foo") - dupe := clownfish.GetClass(td).MakeObj().(TopDocs).Deserialize(inStream) - if dupe.GetTotalHits() != td.GetTotalHits() { + dupe := clownfish.GetClass(td).MakeObj().(TopDocs).deserialize(inStream) + if dupe.getTotalHits() != td.getTotalHits() { t.Errorf("Failed round-trip serializetion of TopDocs") } } @@ -418,9 +418,9 @@ type simpleTestDoc struct { func TestHitsBasics(t *testing.T) { index := createTestIndex("a", "b") searcher, _ := OpenIndexSearcher(index) - topDocs := searcher.TopDocs(NewTermQuery("content", "a"), 10, nil) + topDocs := searcher.topDocs(NewTermQuery("content", "a"), 10, nil) hits := NewHits(searcher, topDocs, 0) - if got := hits.TotalHits(); got != topDocs.GetTotalHits() { + if got := hits.TotalHits(); got != topDocs.getTotalHits() { t.Errorf("TotalHits is off: %d", got) } var doc simpleTestDoc @@ -491,10 +491,10 @@ func TestSortSpecBasics(t *testing.T) { } outstream, _ := folder.OpenOut("foo") - sortSpec.Serialize(outstream) + sortSpec.serialize(outstream) outstream.Close() inStream, _ := folder.OpenIn("foo") - dupe := clownfish.GetClass(sortSpec).MakeObj().(SortSpec).Deserialize(inStream) + dupe := clownfish.GetClass(sortSpec).MakeObj().(SortSpec).deserialize(inStream) if len(dupe.GetRules()) != len(rules) { t.Errorf("Failed round-trip serializetion of SortSpec") } @@ -504,27 +504,27 @@ func TestHitQueueBasics(t *testing.T) { hitQ := NewHitQueue(nil, nil, 1) fortyTwo := NewMatchDoc(42, 1.0, nil) fortyThree := NewMatchDoc(43, 1.0, nil) - if !hitQ.LessThan(fortyThree, fortyTwo) { - t.Error("LessThan") + if !hitQ.lessThan(fortyThree, fortyTwo) { + t.Error("lessThan") } - if !hitQ.Insert(fortyTwo) { - t.Error("Insert") + if !hitQ.insert(fortyTwo) { + t.Error("insert") } - if hitQ.GetSize() != 1 { - t.Error("GetSize") + if hitQ.getSize() != 1 { + t.Error("getSize") } - if bumped := hitQ.Jostle(fortyThree); bumped.(MatchDoc).GetDocID() != 43 { - t.Error("Jostle") + if bumped := hitQ.jostle(fortyThree); bumped.(MatchDoc).getDocID() != 43 { + t.Error("jostle") } - if peeked := hitQ.Peek(); peeked.(MatchDoc).GetDocID() != 42 { - t.Error("Peek") + if peeked := hitQ.peek(); peeked.(MatchDoc).getDocID() != 42 { + t.Error("peek") } - if popped := hitQ.Pop(); popped.(MatchDoc).GetDocID() != 42 { - t.Error("Pop") + if popped := hitQ.pop(); popped.(MatchDoc).getDocID() != 42 { + t.Error("pop") } - hitQ.Insert(fortyTwo) - if got := hitQ.PopAll(); got[0].(MatchDoc).GetDocID() != 42 { - t.Error("PopAll") + hitQ.insert(fortyTwo) + if got := hitQ.popAll(); got[0].(MatchDoc).getDocID() != 42 { + t.Error("popAll") } } @@ -583,11 +583,11 @@ func TestSortCollectorBasics(t *testing.T) { searcher, _ := OpenIndexSearcher(index) collector := NewSortCollector(nil, nil, 1) searcher.Collect(NewTermQuery("content", "a"), collector) - if totalHits := collector.GetTotalHits(); totalHits != 2 { + if totalHits := collector.getTotalHits(); totalHits != 2 { t.Errorf("Unexpected TotalHits: %d", totalHits) } matchDocs := collector.PopMatchDocs() - if docID := matchDocs[0].GetDocID(); docID != 1 { + if docID := matchDocs[0].getDocID(); docID != 1 { t.Errorf("Weird MatchDoc: %d", docID) } } @@ -604,7 +604,7 @@ func TestIndexSearcherMisc(t *testing.T) { if _, ok := searcher.GetReader().(PolyReader); !ok { t.Error("GetReader") } - if _, ok := searcher.FetchDocVec(4).(DocVector); !ok { + if _, ok := searcher.fetchDocVec(4).(DocVector); !ok { t.Error("DocVector") } } @@ -640,9 +640,9 @@ func TestIndexSearcherHits(t *testing.T) { func TestIndexSearcherTopDocs(t *testing.T) { index := createTestIndex("a", "b") searcher, _ := OpenIndexSearcher(index) - topDocs := searcher.TopDocs(NewTermQuery("content", "b"), 10, nil) + topDocs := searcher.topDocs(NewTermQuery("content", "b"), 10, nil) matchDocs := topDocs.GetMatchDocs() - if docID := matchDocs[0].GetDocID(); docID != 2 { + if docID := matchDocs[0].getDocID(); docID != 2 { t.Errorf("TopDocs expected 2, got %d", docID) } } @@ -679,18 +679,18 @@ func TestIndexSearcherReadDoc(t *testing.T) { func TestMatchDocBasics(t *testing.T) { matchDoc := NewMatchDoc(0, 1.0, nil) - matchDoc.SetDocID(42) - if got := matchDoc.GetDocID(); got != 42 { - t.Errorf("Set/GetDocID: %d", got) + matchDoc.setDocID(42) + if got := matchDoc.getDocID(); got != 42 { + t.Errorf("set/getDocID: %d", got) } - matchDoc.SetScore(1.5) - if got := matchDoc.GetScore(); got != 1.5 { - t.Errorf("Set/GetScore: %f", got) + matchDoc.setScore(1.5) + if got := matchDoc.getScore(); got != 1.5 { + t.Errorf("set/getScore: %f", got) } values := []interface{}{"foo", int64(42)} - matchDoc.SetValues(values) - if got := matchDoc.GetValues(); !reflect.DeepEqual(got, values) { - t.Error("Get/SetValues") + matchDoc.setValues(values) + if got := matchDoc.getValues(); !reflect.DeepEqual(got, values) { + t.Error("get/setValues") } } @@ -699,11 +699,11 @@ func TestMatchDocSerialization(t *testing.T) { matchDoc := NewMatchDoc(100, 1.5, values) folder := NewRAMFolder("") outstream, _ := folder.OpenOut("foo") - matchDoc.Serialize(outstream) + matchDoc.serialize(outstream) outstream.Close() inStream, _ := folder.OpenIn("foo") - dupe := clownfish.GetClass(matchDoc).MakeObj().(MatchDoc).Deserialize(inStream) - if got := dupe.GetValues(); !reflect.DeepEqual(got, values) { + dupe := clownfish.GetClass(matchDoc).MakeObj().(MatchDoc).deserialize(inStream) + if got := dupe.getValues(); !reflect.DeepEqual(got, values) { t.Errorf("Failed round-trip serializetion of MatchDoc") } } http://git-wip-us.apache.org/repos/asf/lucy/blob/9f178803/go/lucy/store_test.go ---------------------------------------------------------------------- diff --git a/go/lucy/store_test.go b/go/lucy/store_test.go index 92a1867..69bb0d4 100644 --- a/go/lucy/store_test.go +++ b/go/lucy/store_test.go @@ -29,15 +29,15 @@ func TestRAMFileBasics(t *testing.T) { contents.Cat(fooBytes) ramFile := NewRAMFile(contents, false) - if ramFile.ReadOnly() { - t.Error("ReadOnly") + if ramFile.readOnly() { + t.Error("readOnly") } - ramFile.SetReadOnly(true) - if !ramFile.ReadOnly() { - t.Error("SetReadOnly/ReadOnly") + ramFile.setReadOnly(true) + if !ramFile.readOnly() { + t.Error("setReadOnly/readOnly") } - if got := ramFile.GetContents().YieldBlob(); !reflect.DeepEqual(got, fooBytes) { + if got := ramFile.getContents().YieldBlob(); !reflect.DeepEqual(got, fooBytes) { t.Errorf("GetContents: %v", got) } */ @@ -125,7 +125,7 @@ func TestIOStreamDupe(t *testing.T) { } dupe, err := inStream.Reopen("foo.dat", 99, 1) - if fileName := dupe.GetFilename(); fileName != "foo.dat" { + if fileName := dupe.getFilename(); fileName != "foo.dat" { t.Errorf("Reopen filename: %s", fileName) } if err != nil { @@ -145,15 +145,15 @@ func TestIOStreamFilePos(t *testing.T) { if err != nil { t.Errorf("WriteI32 error: %v", err) } - if got := outStream.Tell(); got != 4 { - t.Errorf("OutStream.Tell: %d", got) + if got := outStream.tell(); got != 4 { + t.Errorf("OutStream.tell: %d", got) } err = outStream.Grow(32) if err != nil { t.Errorf("Grow error: %v", err) } - if got := outStream.Length(); got != 4 { + if got := outStream.length(); got != 4 { t.Errorf("Grow/Length: %d", got) } @@ -161,21 +161,21 @@ func TestIOStreamFilePos(t *testing.T) { if err != nil { t.Errorf("Align error: %v", err) } - if got := outStream.Tell(); got != 8 { - t.Errorf("Align/Tell: %d", got) + if got := outStream.tell(); got != 8 { + t.Errorf("Align/tell: %d", got) } outStream.Close() inStream, _ := OpenInStream(file) - if got := inStream.Length(); got != 8 { - t.Errorf("InStream.Length: %d", got) + if got := inStream.length(); got != 8 { + t.Errorf("InStream.length: %d", got) } err = inStream.Seek(4) if err != nil { } - if got := inStream.Tell(); got != 4 { - t.Errorf("InStream.Tell: %d", got) + if got := inStream.tell(); got != 4 { + t.Errorf("InStream.tell: %d", got) } err = inStream.Seek(30) @@ -287,16 +287,16 @@ func TestIOStreamReadWrite(t *testing.T) { func TestIOStreamMisc(t *testing.T) { folder := NewRAMFolder("mydir") outStream, _ := folder.OpenOut("file.dat") - if got := outStream.GetPath(); got != "mydir/file.dat" { - t.Errorf("GetPath: %s", got) + if got := outStream.getPath(); got != "mydir/file.dat" { + t.Errorf("getPath: %s", got) } outStream.WriteU32(1) - outStream.Flush() + outStream.flush() outStream.Close() inStream, _ := folder.OpenIn("file.dat") - if got := inStream.GetFilename(); got != "mydir/file.dat" { - t.Errorf("GetFilename: %s", got) + if got := inStream.getFilename(); got != "mydir/file.dat" { + t.Errorf("getFilename: %s", got) } } @@ -307,8 +307,8 @@ func runFolderTests(t *testing.T, folder Folder) { if err != nil { t.Errorf("Initialize: %v", err) } - if !folder.Check() { - t.Errorf("Check") + if !folder.check() { + t.Errorf("check") } if problem := folder.MkDir("stuff"); problem != nil { @@ -343,24 +343,24 @@ func runFolderTests(t *testing.T, folder Folder) { t.Errorf("SlurpFile [non-existent file]: %v, %v", got, err) } - if !folder.Exists("stuff") { + if !folder.exists("stuff") { t.Errorf("Exists [directory]") } - if !folder.Exists("stuff/hello") { + if !folder.exists("stuff/hello") { t.Errorf("Exists [file]") } - if folder.Exists("stuff/nope") { + if folder.exists("stuff/nope") { t.Errorf("Exists [non-existent entry]") } - if !folder.IsDirectory("stuff") { - t.Errorf("IsDirectory [directory]") + if !folder.isDirectory("stuff") { + t.Errorf("isDirectory [directory]") } - if folder.IsDirectory("stuff/hello") { - t.Errorf("IsDirectory [file]") + if folder.isDirectory("stuff/hello") { + t.Errorf("isDirectory [file]") } - if folder.IsDirectory("nope") { - t.Errorf("IsDirectory [non-existent entry]") + if folder.isDirectory("nope") { + t.Errorf("isDirectory [non-existent entry]") } listExpected := []string{"stuff"} @@ -371,17 +371,17 @@ func runFolderTests(t *testing.T, folder Folder) { if got, err := folder.ListR(""); !reflect.DeepEqual(got, listRExpected) || err != nil { t.Errorf("Unexpected result for ListR: %v, %v", got, err) } - if stuff := folder.FindFolder("stuff"); stuff == nil { - t.Errorf("FindFolder") + if stuff := folder.findFolder("stuff"); stuff == nil { + t.Errorf("findFolder") } - if nope := folder.FindFolder("nope"); nope != nil { - t.Errorf("FindFolder [non-existent]") + if nope := folder.findFolder("nope"); nope != nil { + t.Errorf("findFolder [non-existent]") } - if stuff := folder.EnclosingFolder("stuff/hello"); stuff == nil { - t.Errorf("EnclosingFolder") + if stuff := folder.enclosingFolder("stuff/hello"); stuff == nil { + t.Errorf("enclosingFolder") } - if nope := folder.EnclosingFolder("nada/nope/nyet"); nope != nil { - t.Errorf("EnclosingFolder [non-existent]") + if nope := folder.enclosingFolder("nada/nope/nyet"); nope != nil { + t.Errorf("enclosingFolder [non-existent]") } if err := folder.HardLink("stuff/hello", "aloha"); err != nil { @@ -390,8 +390,8 @@ func runFolderTests(t *testing.T, folder Folder) { if err := folder.Rename("stuff/hello", "stuff/hola"); err != nil { t.Errorf("Rename: %v", err) } - if success := folder.Delete("stuff/hola"); !success { - t.Errorf("Delete") + if success := folder.delete("stuff/hola"); !success { + t.Errorf("delete") } if fh, err := folder.LocalOpenFileHandle("aloha", 0x1); fh == nil || err != nil { @@ -405,41 +405,41 @@ func runFolderTests(t *testing.T, folder Folder) { if err = folder.LocalMkDir("things"); err != nil { t.Errorf("LocalMkdir: %v", err) } - if !folder.LocalExists("things") { - t.Errorf("LocalExists") + if !folder.localExists("things") { + t.Errorf("localExists") } - if !folder.LocalIsDirectory("things") { - t.Errorf("LocalIsDirectory") + if !folder.localIsDirectory("things") { + t.Errorf("localIsDirectory") } - if things := folder.LocalFindFolder("things"); things == nil { - t.Errorf("LocalFindFolder") + if things := folder.localFindFolder("things"); things == nil { + t.Errorf("localFindFolder") } if dh, err := folder.LocalOpenDir(); dh == nil || err != nil { t.Errorf("LocalOpenDir: %v", err) } else { dh.Close() } - if !folder.LocalDelete("things") { - t.Errorf("LocalDelete") + if !folder.localDelete("things") { + t.Errorf("localDelete") } folder.Consolidate("stuff") - if success := folder.DeleteTree("stuff"); !success { - t.Errorf("DeleteTree") + if success := folder.deleteTree("stuff"); !success { + t.Errorf("deleteTree") } - folder.Close() + folder.close() } func TestRAMFolderBasics(t *testing.T) { folder := NewRAMFolder("orig") - if folder.GetPath() != "orig" { - t.Error("GetPath") + if folder.getPath() != "orig" { + t.Error("getPath") } - folder.SetPath("basedir") - if folder.GetPath() != "basedir" { - t.Error("SetPath/GetPath") + folder.setPath("basedir") + if folder.getPath() != "basedir" { + t.Error("setPath/getPath") } runFolderTests(t, folder) } @@ -452,12 +452,12 @@ func TestFSFolderBasics(t *testing.T) { func TestFileWindowBasics(t *testing.T) { window := NewFileWindow() - window.SetOffset(30) - if got := window.GetOffset(); got != 30 { - t.Errorf("SetOffset/GetOffset: %d", got) + window.setOffset(30) + if got := window.getOffset(); got != 30 { + t.Errorf("setOffset/getOffset: %d", got) } - if got := window.GetLen(); got != 0 { - t.Errorf("GetLen: %d", got) + if got := window.getLen(); got != 0 { + t.Errorf("getLen: %d", got) } } @@ -468,9 +468,9 @@ func runFileHandleCommonTests(t *testing.T, makeFH func(uint32) FileHandle) { t.Errorf("Failed to open FileHandle for write: %v", err) return } - fh.SetPath("fake") - if got := fh.GetPath(); got != "fake" { - t.Errorf("SetPath/GetPath: %v", got) + fh.setPath("fake") + if got := fh.getPath(); got != "fake" { + t.Errorf("setPath/getPath: %v", got) } err = fh.Grow(20) if err != nil { @@ -486,11 +486,11 @@ func runFileHandleCommonTests(t *testing.T, makeFH func(uint32) FileHandle) { if fh == nil { t.Errorf("Failed to open FileHandle for read: %v", err) } - fh.SetPath("fake") - if got := fh.GetPath(); got != "fake" { - t.Errorf("SetPath/GetPath: %v", got) + fh.setPath("fake") + if got := fh.getPath(); got != "fake" { + t.Errorf("setPath/getPath: %v", got) } - if got := fh.Length(); got != 5 { + if got := fh.length(); got != 5 { t.Errorf("Unexpected Length: %d", got) } buf := make([]byte, 3) @@ -526,8 +526,8 @@ func TestRAMFileHandleAll(t *testing.T) { } runFileHandleCommonTests(t, makeFH) fh := makeFH(0x1).(RAMFileHandle) // FH_READ_ONLY - if _, ok := fh.GetFile().(RAMFile); !ok { - t.Errorf("GetFile") + if _, ok := fh.getFile().(RAMFile); !ok { + t.Errorf("getFile") } } @@ -572,26 +572,26 @@ func runDirHandleCommonTests(t *testing.T, folder Folder, makeDH func() DirHandl t.Errorf("Failed to open DirHandle: %v", err) return } - if got := dh.GetDir(); got != folder.GetPath() { - t.Errorf("GetDir didn't match: '%v' '%v'", got, folder.GetPath()) + if got := dh.getDir(); got != folder.getPath() { + t.Errorf("getDir didn't match: '%v' '%v'", got, folder.getPath()) } count := 0 - for dh.Next() { + for dh.next() { count += 1 - entry := dh.GetEntry() + entry := dh.getEntry() switch entry { case "hello": - if dh.EntryIsDir() { + if dh.entryIsDir() { t.Errorf("Entry should not be directory") } - if dh.EntryIsSymlink() { + if dh.entryIsSymlink() { t.Errorf("File should not be symlink") } case "stuff": - if !dh.EntryIsDir() { + if !dh.entryIsDir() { t.Errorf("Entry should be directory") } - if dh.EntryIsSymlink() { + if dh.entryIsSymlink() { t.Errorf("Dir should not be symlink") } default: @@ -621,7 +621,7 @@ func TestFSDirHandleAll(t *testing.T) { defer os.RemoveAll(path) folder := NewFSFolder(path) makeDH := func() DirHandle { - dh, err := OpenFSDirHandle(folder.GetPath()) + dh, err := OpenFSDirHandle(folder.getPath()) if err != nil { t.Errorf("Failed to open DirHandle: %v", err) return nil @@ -636,11 +636,11 @@ func runLockCommonTests(t *testing.T, makeLock func(string, string) Lock) { lock := makeLock("foo", "dev.example.com") other := makeLock("foo", "dev.example.com") - if got := lock.GetName(); got != "foo" { - t.Errorf("GetName: %v", got) + if got := lock.getName(); got != "foo" { + t.Errorf("getName: %v", got) } - if got := lock.GetHost(); got != "dev.example.com" { - t.Errorf("GetHost: %v", got) + if got := lock.getHost(); got != "dev.example.com" { + t.Errorf("getHost: %v", got) } err = lock.Request() @@ -650,9 +650,9 @@ func runLockCommonTests(t *testing.T, makeLock func(string, string) Lock) { if !lock.IsLocked() { t.Errorf("Lock should be locked, but IsLocked returned false") } - if got := lock.GetLockPath(); len(got) == 0 { + if got := lock.getLockPath(); len(got) == 0 { // Lock path only valid when locked for shared locks. - t.Errorf("GetLockPath should work") + t.Errorf("getLockPath should work") } err = other.Request() if other.Shared() && err != nil {
