如何计算Cloudant中的文档大小?

时间:2017-01-18 16:48:43

标签: ibm-cloud cloudant

我将使用Cloudant存储从API返回的一些文档,如何估算文档所需的近似空间,这是一个示例文档:

For Row_S = 2 To MAX_Row_S
  SourceMonth = Worksheets(NBG_SourceRegionDataWorksheetName).Cells(Row_S, SOP).Value
  SourceMonth = DatePart("m", SourceMonth)
  SourceYear = Worksheets(NBG_SourceRegionDataWorksheetName).Cells(Row_S, SOP).Value
  SourceYear = DatePart("yyyy", SourceYear)
  SourceCarmaker = Worksheets(NBG_SourceRegionDataWorksheetName).Cells(Row_S, carmaker).Value
  SourceProject = Worksheets(NBG_SourceRegionDataWorksheetName).Cells(Row_S, Project).Value
  SourceFamily = Worksheets(NBG_SourceRegionDataWorksheetName).Cells(Row_S, Family).Value
  SourceStatus = Worksheets(NBG_SourceRegionDataWorksheetName).Cells(Row_S, Status).Value
  SourceShare = Worksheets(NBG_SourceRegionDataWorksheetName).Cells(Row_S, Share).Value
  SourceCst = Worksheets(NBG_SourceRegionDataWorksheetName).Cells(Row_S, "A").Value
  SourcePID = Worksheets(NBG_SourceRegionDataWorksheetName).Cells(Row_S, ProjectID).Value

  ' Take the data from NBG_Data_Region sheet to be Compared with each row of the NBG_Data_Source_Region sheet
  For Row_T = 2 To MAX_Row_T
    If Row_T >= MAX_Row_T Then
        Exit For
    End If

    NBGMonth = Worksheets(NBG_RegionaDataWorksheetName).Cells(Row_T, SOP).Value
    NBGMonth = DatePart("m", NBGMonth)
    NBGYear = Worksheets(NBG_RegionaDataWorksheetName).Cells(Row_T, SOP).Value
    NBGYear = DatePart("yyyy", NBGYear)
    NBGCarmaker = Worksheets(NBG_RegionaDataWorksheetName).Cells(Row_T, carmaker).Value
    NBGProject = Worksheets(NBG_RegionaDataWorksheetName).Cells(Row_T, Project).Value
    NBGFamily = Worksheets(NBG_RegionaDataWorksheetName).Cells(Row_T, Family).Value
    NBGStatus = Worksheets(NBG_RegionaDataWorksheetName).Cells(Row_T, Status).Value
    NBGShare = Worksheets(NBG_RegionaDataWorksheetName).Cells(Row_T, Share).Value
    NBGCst = Worksheets(NBG_RegionaDataWorksheetName).Cells(Row_T, "A").Value
    NBGPID = Worksheets(NBG_RegionaDataWorksheetName).Cells(Row_T, ProjectID).Value

    ' StatusBar Show
    Application.StatusBar = "Running"
    'Application.StatusBar = "VerifyMultipleCustomerProjects. Progress: " & Row_S & " of " & MAX_Row_S
    ' Check if any project in the NBG_Data_Region have multiple customers and add it ti the sheet Issue_MultipleCustomerProjects

    ' NAF 20161208

    'Test with Source of YEAR and MONTH
     If ((NBGMonth = SourceMonth Or Worksheets(Issue_MultipleCustomerProjectsWorksheetName).Range("C21") = True) And _
        (NBGYear = SourceYear Or Worksheets(Issue_MultipleCustomerProjectsWorksheetName).Range("C25") = True) And _
        (SourceCarmaker = NBGCarmaker Or Worksheets(Issue_MultipleCustomerProjectsWorksheetName).Range("G25") = True) And _
        (SourceProject = NBGProject Or Worksheets(Issue_MultipleCustomerProjectsWorksheetName).Range("F25") = True) And _
        (SourceFamily = NBGFamily Or Worksheets(Issue_MultipleCustomerProjectsWorksheetName).Range("E25") = True) And _
        (SourceShare + NBGShare <> 1 Or Worksheets(Issue_MultipleCustomerProjectsWorksheetName).Range("H25") = True) And NBGCst <> SourceCst) Then

谢谢

2 个答案:

答案 0 :(得分:2)

如果将json保存在文件中,可以尝试类似

的内容
cat file.json | jq --compact-output '' | wc -c

表示上面的文件大约是398个字符。在Cloudant中,您还可能会产生索引空间,具体取决于您的设置。

答案 1 :(得分:1)

此外,您可以针对https://$USERNAME.cloudant.com/$DATABASE发出GET请求,它会返回有关数据库的详细信息,以便您进行准确估算。可以在此处找到更多信息:https://docs.cloudant.com/database.html#read