content_summary.cc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #include <hdfspp/content_summary.h>
  19. #include <sstream>
  20. #include <iomanip>
  21. namespace hdfs {
  22. ContentSummary::ContentSummary()
  23. : length(0),
  24. filecount(0),
  25. directorycount(0),
  26. quota(0),
  27. spaceconsumed(0),
  28. spacequota(0) {
  29. }
  30. std::string ContentSummary::str(bool include_quota) const {
  31. std::stringstream ss;
  32. if(include_quota){
  33. ss << this->quota << " "
  34. << spacequota << " "
  35. << spaceconsumed << " ";
  36. }
  37. ss << directorycount << " "
  38. << filecount << " "
  39. << length << " "
  40. << path;
  41. return ss.str();
  42. }
  43. std::string ContentSummary::str_du() const {
  44. std::stringstream ss;
  45. ss << std::left << std::setw(10) << length
  46. << path;
  47. return ss.str();
  48. }
  49. }