本站源代码
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.

56 lines
1.8KB

  1. // Copyright (c) 2014 Couchbase, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package upsidedown
  15. import (
  16. "encoding/json"
  17. "sync/atomic"
  18. "github.com/blevesearch/bleve/index/store"
  19. )
  20. type indexStat struct {
  21. updates, deletes, batches, errors uint64
  22. analysisTime, indexTime uint64
  23. termSearchersStarted uint64
  24. termSearchersFinished uint64
  25. numPlainTextBytesIndexed uint64
  26. i *UpsideDownCouch
  27. }
  28. func (i *indexStat) statsMap() map[string]interface{} {
  29. m := map[string]interface{}{}
  30. m["updates"] = atomic.LoadUint64(&i.updates)
  31. m["deletes"] = atomic.LoadUint64(&i.deletes)
  32. m["batches"] = atomic.LoadUint64(&i.batches)
  33. m["errors"] = atomic.LoadUint64(&i.errors)
  34. m["analysis_time"] = atomic.LoadUint64(&i.analysisTime)
  35. m["index_time"] = atomic.LoadUint64(&i.indexTime)
  36. m["term_searchers_started"] = atomic.LoadUint64(&i.termSearchersStarted)
  37. m["term_searchers_finished"] = atomic.LoadUint64(&i.termSearchersFinished)
  38. m["num_plain_text_bytes_indexed"] = atomic.LoadUint64(&i.numPlainTextBytesIndexed)
  39. if o, ok := i.i.store.(store.KVStoreStats); ok {
  40. m["kv"] = o.StatsMap()
  41. }
  42. return m
  43. }
  44. func (i *indexStat) MarshalJSON() ([]byte, error) {
  45. m := i.statsMap()
  46. return json.Marshal(m)
  47. }
上海开阖软件有限公司 沪ICP备12045867号-1