You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.4 KiB

  1. package weed_server
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/glog"
  4. "github.com/chrislusf/seaweedfs/weed/operation"
  5. "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
  6. "github.com/chrislusf/seaweedfs/weed/storage/needle"
  7. "github.com/tidwall/gjson"
  8. )
  9. func (vs *VolumeServer) Query(req *volume_server_pb.QueryRequest, stream volume_server_pb.VolumeServer_QueryServer) error {
  10. for _, fid := range req.FromFileIds {
  11. vid, id_cookie, err := operation.ParseFileId(fid)
  12. if err != nil {
  13. glog.V(0).Infof("volume query failed to parse fid %s: %v", fid, err)
  14. return err
  15. }
  16. n := new(needle.Needle)
  17. volumeId, _ := needle.NewVolumeId(vid)
  18. n.ParsePath(id_cookie)
  19. cookie := n.Cookie
  20. if _, err := vs.store.ReadVolumeNeedle(volumeId, n); err != nil {
  21. glog.V(0).Infof("volume query failed to read fid %s: %v", fid, err)
  22. return err
  23. }
  24. if n.Cookie != cookie {
  25. glog.V(0).Infof("volume query failed to read fid cookie %s: %v", fid, err)
  26. return err
  27. }
  28. if req.InputSerialization.CsvInput!=nil{
  29. }
  30. if req.InputSerialization.JsonInput!=nil{
  31. err = stream.Send(&volume_server_pb.QueriedStripe{
  32. Records:nil,
  33. })
  34. if err != nil {
  35. // println("sending", bytesread, "bytes err", err.Error())
  36. return err
  37. }
  38. gjson.ForEachLine(string(n.Data), func(line gjson.Result) bool{
  39. println(line.String())
  40. return true
  41. })
  42. }
  43. }
  44. return nil
  45. }