func marshalQuadDirections(q quad.Quad) (s, p, o, l []byte, err error) { s, err = proto.MarshalValue(q.Subject) if err != nil { return } p, err = proto.MarshalValue(q.Predicate) if err != nil { return } o, err = proto.MarshalValue(q.Object) if err != nil { return } l, err = proto.MarshalValue(q.Label) if err != nil { return } return }
func nodeValues(h NodeHash, v quad.Value) (int, []interface{}, error) { var ( nodeKey int values = []interface{}{h.toSQL(), nil, nil}[:1] ) switch v := v.(type) { case quad.IRI: nodeKey = 1 values = append(values, string(v), true) case quad.BNode: nodeKey = 2 values = append(values, string(v), true) case quad.String: nodeKey = 3 values = append(values, escapeNullByte(string(v))) case quad.TypedString: nodeKey = 4 values = append(values, escapeNullByte(string(v.Value)), string(v.Type)) case quad.LangString: nodeKey = 5 values = append(values, escapeNullByte(string(v.Value)), v.Lang) case quad.Int: nodeKey = 6 values = append(values, int64(v)) case quad.Bool: nodeKey = 7 values = append(values, bool(v)) case quad.Float: nodeKey = 8 values = append(values, float64(v)) case quad.Time: nodeKey = 9 values = append(values, time.Time(v)) default: nodeKey = 0 p, err := proto.MarshalValue(v) if err != nil { glog.Errorf("couldn't marshal value: %v", err) return 0, nil, err } values = append(values, p) } return nodeKey, values, nil }