• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / iotdb / #10006

06 Sep 2023 05:15AM CUT coverage: 47.697% (+0.006%) from 47.691%
#10006

push

travis_ci

web-flow
[RatisConsensus] retry cache expiration time should be longer than retriable-client wait duration (#11045) (#11052)

13 of 13 new or added lines in 1 file covered. (100.0%)

80213 of 168172 relevant lines covered (47.7%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/utils/IoTPrinter.java
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,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19

20
package org.apache.iotdb.cli.utils;
21

22
import org.apache.commons.lang3.StringUtils;
23

24
import java.io.PrintStream;
25
import java.lang.Character.UnicodeScript;
26
import java.util.List;
27

28
public class IoTPrinter {
29
  private static final PrintStream SCREEN_PRINTER = new PrintStream(System.out);
×
30

31
  private IoTPrinter() {}
32

33
  public static void printf(String format, Object... args) {
34
    SCREEN_PRINTER.printf(format, args);
×
35
  }
×
36

37
  public static void print(String msg) {
38
    SCREEN_PRINTER.print(msg);
×
39
  }
×
40

41
  public static void printException(Exception msg) {
42
    SCREEN_PRINTER.println(msg);
×
43
  }
×
44

45
  public static void println() {
46
    SCREEN_PRINTER.println();
×
47
  }
×
48

49
  public static void println(String msg) {
50
    SCREEN_PRINTER.println(msg);
×
51
  }
×
52

53
  public static void printBlockLine(List<Integer> maxSizeList) {
54
    StringBuilder blockLine = new StringBuilder();
×
55
    for (Integer integer : maxSizeList) {
×
56
      blockLine.append("+").append(StringUtils.repeat("-", integer));
×
57
    }
×
58
    blockLine.append("+");
×
59
    println(blockLine.toString());
×
60
  }
×
61

62
  public static void printRow(List<List<String>> lists, int i, List<Integer> maxSizeList) {
63
    printf("|");
×
64
    int count;
65
    int maxSize;
66
    String element;
67
    StringBuilder paddingStr;
68
    for (int j = 0; j < maxSizeList.size(); j++) {
×
69
      maxSize = maxSizeList.get(j);
×
70
      element = lists.get(j).get(i);
×
71
      count = computeHANCount(element);
×
72

73
      if (count > 0) {
×
74
        int remain = maxSize - (element.length() + count);
×
75
        if (remain > 0) {
×
76
          paddingStr = padding(remain);
×
77
          maxSize = maxSize - count;
×
78
          element = paddingStr.append(element).toString();
×
79
        } else if (remain == 0) {
×
80
          maxSize = maxSize - count;
×
81
        }
82
      }
83

84
      printf("%" + maxSize + "s|", element);
×
85
    }
86
    println();
×
87
  }
×
88

89
  public static void printCount(int cnt) {
90
    if (cnt == 0) {
×
91
      println("Empty set.");
×
92
    } else {
93
      println("Total line number = " + cnt);
×
94
    }
95
  }
×
96

97
  public static StringBuilder padding(int count) {
98
    StringBuilder sb = new StringBuilder();
×
99
    for (int k = 0; k < count; k++) {
×
100
      sb.append(' ');
×
101
    }
102

103
    return sb;
×
104
  }
105

106
  /** compute the number of Chinese characters included in the String */
107
  public static int computeHANCount(String s) {
108
    return (int)
×
109
        s.codePoints()
×
110
            .filter(codePoint -> UnicodeScript.of(codePoint) == UnicodeScript.HAN)
×
111
            .count();
×
112
  }
113
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc