Rename Provenance -> Label

's/Provenance/Label/g' 's/provenance/label/g' with human vetting.
This commit is contained in:
kortschak 2014-07-29 08:44:39 +09:30
parent 410202f3e0
commit 274d9ef57e
20 changed files with 416 additions and 416 deletions

View file

@ -17,7 +17,7 @@ package iterator
// "Value Comparison" is a unary operator -- a filter across the values in the
// relevant subiterator.
//
// This is hugely useful for things like provenance, but value ranges in general
// This is hugely useful for things like label, but value ranges in general
// come up from time to time. At *worst* we're as big as our underlying iterator.
// At best, we're the null iterator.
//

View file

@ -124,7 +124,7 @@ func PositionOf(prefix []byte, d quad.Direction, qs *TripleStore) int {
return qs.hasher.Size() + 2
case quad.Object:
return 2*qs.hasher.Size() + 2
case quad.Provenance:
case quad.Label:
return -1
}
}
@ -136,7 +136,7 @@ func PositionOf(prefix []byte, d quad.Direction, qs *TripleStore) int {
return 2
case quad.Object:
return qs.hasher.Size() + 2
case quad.Provenance:
case quad.Label:
return -1
}
}
@ -148,7 +148,7 @@ func PositionOf(prefix []byte, d quad.Direction, qs *TripleStore) int {
return 2*qs.hasher.Size() + 2
case quad.Object:
return 2
case quad.Provenance:
case quad.Label:
return -1
}
}
@ -160,7 +160,7 @@ func PositionOf(prefix []byte, d quad.Direction, qs *TripleStore) int {
return qs.hasher.Size() + 2
case quad.Object:
return 3*qs.hasher.Size() + 2
case quad.Provenance:
case quad.Label:
return 2
}
}

View file

@ -73,7 +73,7 @@ func (o ordered) Less(i, j int) bool {
o[i].Subject == o[j].Subject &&
o[i].Predicate == o[j].Predicate &&
o[i].Object == o[j].Object &&
o[i].Provenance < o[j].Provenance:
o[i].Label < o[j].Label:
return true
@ -359,8 +359,8 @@ func TestSetIterator(t *testing.T) {
t.Errorf("Failed to get expected results from predicate iterator, got:%v expect:%v", got, expect)
}
// Provenance iterator.
it = qs.TripleIterator(quad.Provenance, qs.ValueOf("status_graph"))
// Label iterator.
it = qs.TripleIterator(quad.Label, qs.ValueOf("status_graph"))
expect = []*quad.Quad{
{"B", "status", "cool", "status_graph"},

View file

@ -125,8 +125,8 @@ func (qs *TripleStore) createKeyFor(d [3]quad.Direction, triple *quad.Quad) []by
func (qs *TripleStore) createProvKeyFor(d [3]quad.Direction, triple *quad.Quad) []byte {
key := make([]byte, 0, 2+(qs.hasher.Size()*4))
// TODO(kortschak) Remove dependence on String() method.
key = append(key, []byte{quad.Provenance.Prefix(), d[0].Prefix()}...)
key = append(key, qs.convertStringToByteHash(triple.Get(quad.Provenance))...)
key = append(key, []byte{quad.Label.Prefix(), d[0].Prefix()}...)
key = append(key, qs.convertStringToByteHash(triple.Get(quad.Label))...)
key = append(key, qs.convertStringToByteHash(triple.Get(d[0]))...)
key = append(key, qs.convertStringToByteHash(triple.Get(d[1]))...)
key = append(key, qs.convertStringToByteHash(triple.Get(d[2]))...)
@ -176,9 +176,9 @@ func (qs *TripleStore) RemoveTriple(t *quad.Quad) {
qs.UpdateValueKeyBy(t.Get(quad.Subject), -1, batch)
qs.UpdateValueKeyBy(t.Get(quad.Predicate), -1, batch)
qs.UpdateValueKeyBy(t.Get(quad.Object), -1, batch)
if t.Get(quad.Provenance) != "" {
if t.Get(quad.Label) != "" {
batch.Delete(qs.createProvKeyFor(pso, t))
qs.UpdateValueKeyBy(t.Get(quad.Provenance), -1, batch)
qs.UpdateValueKeyBy(t.Get(quad.Label), -1, batch)
}
err = qs.db.Write(batch, nil)
if err != nil {
@ -197,7 +197,7 @@ func (qs *TripleStore) buildTripleWrite(batch *leveldb.Batch, t *quad.Quad) {
batch.Put(qs.createKeyFor(spo, t), bytes)
batch.Put(qs.createKeyFor(osp, t), bytes)
batch.Put(qs.createKeyFor(pos, t), bytes)
if t.Get(quad.Provenance) != "" {
if t.Get(quad.Label) != "" {
batch.Put(qs.createProvKeyFor(pso, t), bytes)
}
}
@ -207,8 +207,8 @@ func (qs *TripleStore) buildWrite(batch *leveldb.Batch, t *quad.Quad) {
qs.UpdateValueKeyBy(t.Get(quad.Subject), 1, nil)
qs.UpdateValueKeyBy(t.Get(quad.Predicate), 1, nil)
qs.UpdateValueKeyBy(t.Get(quad.Object), 1, nil)
if t.Get(quad.Provenance) != "" {
qs.UpdateValueKeyBy(t.Get(quad.Provenance), 1, nil)
if t.Get(quad.Label) != "" {
qs.UpdateValueKeyBy(t.Get(quad.Label), 1, nil)
}
}
@ -272,8 +272,8 @@ func (qs *TripleStore) AddTripleSet(t_s []*quad.Quad) {
resizeMap[t.Subject]++
resizeMap[t.Predicate]++
resizeMap[t.Object]++
if t.Provenance != "" {
resizeMap[t.Provenance]++
if t.Label != "" {
resizeMap[t.Label]++
}
}
for k, v := range resizeMap {
@ -411,7 +411,7 @@ func (qs *TripleStore) TripleIterator(d quad.Direction, val graph.Value) graph.I
prefix = "po"
case quad.Object:
prefix = "os"
case quad.Provenance:
case quad.Label:
prefix = "cp"
default:
panic("unreachable " + d.String())

View file

@ -26,10 +26,10 @@ import (
)
type TripleDirectionIndex struct {
subject map[int64]*llrb.LLRB
predicate map[int64]*llrb.LLRB
object map[int64]*llrb.LLRB
provenance map[int64]*llrb.LLRB
subject map[int64]*llrb.LLRB
predicate map[int64]*llrb.LLRB
object map[int64]*llrb.LLRB
label map[int64]*llrb.LLRB
}
func NewTripleDirectionIndex() *TripleDirectionIndex {
@ -37,7 +37,7 @@ func NewTripleDirectionIndex() *TripleDirectionIndex {
tdi.subject = make(map[int64]*llrb.LLRB)
tdi.predicate = make(map[int64]*llrb.LLRB)
tdi.object = make(map[int64]*llrb.LLRB)
tdi.provenance = make(map[int64]*llrb.LLRB)
tdi.label = make(map[int64]*llrb.LLRB)
return &tdi
}
@ -49,8 +49,8 @@ func (tdi *TripleDirectionIndex) GetForDir(d quad.Direction) map[int64]*llrb.LLR
return tdi.object
case quad.Predicate:
return tdi.predicate
case quad.Provenance:
return tdi.provenance
case quad.Label:
return tdi.label
}
panic("illegal direction")
}
@ -104,9 +104,9 @@ func (ts *TripleStore) AddTripleSet(triples []*quad.Quad) {
func (ts *TripleStore) tripleExists(t *quad.Quad) (bool, int64) {
smallest := -1
var smallest_tree *llrb.LLRB
for d := quad.Subject; d <= quad.Provenance; d++ {
for d := quad.Subject; d <= quad.Label; d++ {
sid := t.Get(d)
if d == quad.Provenance && sid == "" {
if d == quad.Label && sid == "" {
continue
}
id, ok := ts.idMap[sid]
@ -148,9 +148,9 @@ func (ts *TripleStore) AddTriple(t *quad.Quad) {
ts.size++
ts.tripleIdCounter++
for d := quad.Subject; d <= quad.Provenance; d++ {
for d := quad.Subject; d <= quad.Label; d++ {
sid := t.Get(d)
if d == quad.Provenance && sid == "" {
if d == quad.Label && sid == "" {
continue
}
if _, ok := ts.idMap[sid]; !ok {
@ -160,8 +160,8 @@ func (ts *TripleStore) AddTriple(t *quad.Quad) {
}
}
for d := quad.Subject; d <= quad.Provenance; d++ {
if d == quad.Provenance && t.Get(d) == "" {
for d := quad.Subject; d <= quad.Label; d++ {
if d == quad.Label && t.Get(d) == "" {
continue
}
id := ts.idMap[t.Get(d)]
@ -183,8 +183,8 @@ func (ts *TripleStore) RemoveTriple(t *quad.Quad) {
ts.triples[tripleID] = quad.Quad{}
ts.size--
for d := quad.Subject; d <= quad.Provenance; d++ {
if d == quad.Provenance && t.Get(d) == "" {
for d := quad.Subject; d <= quad.Label; d++ {
if d == quad.Label && t.Get(d) == "" {
continue
}
id := ts.idMap[t.Get(d)]
@ -192,8 +192,8 @@ func (ts *TripleStore) RemoveTriple(t *quad.Quad) {
tree.Delete(Int64(tripleID))
}
for d := quad.Subject; d <= quad.Provenance; d++ {
if d == quad.Provenance && t.Get(d) == "" {
for d := quad.Subject; d <= quad.Label; d++ {
if d == quad.Label && t.Get(d) == "" {
continue
}
id, ok := ts.idMap[t.Get(d)]
@ -201,8 +201,8 @@ func (ts *TripleStore) RemoveTriple(t *quad.Quad) {
continue
}
stillExists := false
for d := quad.Subject; d <= quad.Provenance; d++ {
if d == quad.Provenance && t.Get(d) == "" {
for d := quad.Subject; d <= quad.Label; d++ {
if d == quad.Label && t.Get(d) == "" {
continue
}
nodeTree := ts.index.GetOrCreate(d, id)

View file

@ -58,7 +58,7 @@ func makeTestStore(data []*quad.Quad) (*TripleStore, []pair) {
ind []pair
)
for _, t := range data {
for _, qp := range []string{t.Subject, t.Predicate, t.Object, t.Provenance} {
for _, qp := range []string{t.Subject, t.Predicate, t.Object, t.Label} {
if _, ok := seen[qp]; !ok && qp != "" {
val++
ind = append(ind, pair{qp, val})

View file

@ -53,8 +53,8 @@ func NewIterator(qs *TripleStore, collection string, d quad.Direction, val graph
m.constraint = bson.M{"Predicate": m.name}
case quad.Object:
m.constraint = bson.M{"Object": m.name}
case quad.Provenance:
m.constraint = bson.M{"Provenance": m.name}
case quad.Label:
m.constraint = bson.M{"Label": m.name}
}
m.qs = qs
@ -143,7 +143,7 @@ func (it *Iterator) Check(v graph.Value) bool {
offset = (it.qs.hasher.Size() * 2)
case quad.Object:
offset = (it.qs.hasher.Size() * 2) * 2
case quad.Provenance:
case quad.Label:
offset = (it.qs.hasher.Size() * 2) * 3
}
val := v.(string)[offset : it.qs.hasher.Size()*2+offset]

View file

@ -69,7 +69,7 @@ func createNewMongoGraph(addr string, options graph.Options) error {
db.C("triples").EnsureIndex(indexOpts)
indexOpts.Key = []string{"Obj"}
db.C("triples").EnsureIndex(indexOpts)
indexOpts.Key = []string{"Provenance"}
indexOpts.Key = []string{"Label"}
db.C("triples").EnsureIndex(indexOpts)
return nil
}
@ -96,7 +96,7 @@ func (qs *TripleStore) getIdForTriple(t *quad.Quad) string {
id := qs.ConvertStringToByteHash(t.Subject)
id += qs.ConvertStringToByteHash(t.Predicate)
id += qs.ConvertStringToByteHash(t.Object)
id += qs.ConvertStringToByteHash(t.Provenance)
id += qs.ConvertStringToByteHash(t.Label)
return id
}
@ -153,11 +153,11 @@ func (qs *TripleStore) updateNodeBy(node_name string, inc int) {
func (qs *TripleStore) writeTriple(t *quad.Quad) bool {
tripledoc := bson.M{
"_id": qs.getIdForTriple(t),
"Subject": t.Subject,
"Predicate": t.Predicate,
"Object": t.Object,
"Provenance": t.Provenance,
"_id": qs.getIdForTriple(t),
"Subject": t.Subject,
"Predicate": t.Predicate,
"Object": t.Object,
"Label": t.Label,
}
err := qs.db.C("triples").Insert(tripledoc)
if err != nil {
@ -176,8 +176,8 @@ func (qs *TripleStore) AddTriple(t *quad.Quad) {
qs.updateNodeBy(t.Subject, 1)
qs.updateNodeBy(t.Predicate, 1)
qs.updateNodeBy(t.Object, 1)
if t.Provenance != "" {
qs.updateNodeBy(t.Provenance, 1)
if t.Label != "" {
qs.updateNodeBy(t.Label, 1)
}
}
@ -190,8 +190,8 @@ func (qs *TripleStore) AddTripleSet(in []*quad.Quad) {
ids[t.Subject]++
ids[t.Object]++
ids[t.Predicate]++
if t.Provenance != "" {
ids[t.Provenance]++
if t.Label != "" {
ids[t.Label]++
}
}
}
@ -212,8 +212,8 @@ func (qs *TripleStore) RemoveTriple(t *quad.Quad) {
qs.updateNodeBy(t.Subject, -1)
qs.updateNodeBy(t.Predicate, -1)
qs.updateNodeBy(t.Object, -1)
if t.Provenance != "" {
qs.updateNodeBy(t.Provenance, -1)
if t.Label != "" {
qs.updateNodeBy(t.Label, -1)
}
}
@ -227,7 +227,7 @@ func (qs *TripleStore) Quad(val graph.Value) *quad.Quad {
bsonDoc["Subject"].(string),
bsonDoc["Predicate"].(string),
bsonDoc["Object"].(string),
bsonDoc["Provenance"].(string),
bsonDoc["Label"].(string),
}
}
@ -292,7 +292,7 @@ func (qs *TripleStore) TripleDirection(in graph.Value, d quad.Direction) graph.V
offset = (qs.hasher.Size() * 2)
case quad.Object:
offset = (qs.hasher.Size() * 2) * 2
case quad.Provenance:
case quad.Label:
offset = (qs.hasher.Size() * 2) * 3
}
val := in.(string)[offset : qs.hasher.Size()*2+offset]
@ -328,8 +328,8 @@ func (qs *TripleStore) BulkLoad(dec quad.Unmarshaler) error {
emit(s_key, {"_id": s_key, "Name" : this.Subject, "Size" : 1})
emit(p_key, {"_id": p_key, "Name" : this.Predicate, "Size" : 1})
emit(o_key, {"_id": o_key, "Name" : this.Object, "Size" : 1})
if (this.Provenance != "") {
emit(c_key, {"_id": c_key, "Name" : this.Provenance, "Size" : 1})
if (this.Label != "") {
emit(c_key, {"_id": c_key, "Name" : this.Label, "Size" : 1})
}
}
`,