MCPcopy Create free account
hub / github.com/apache/orc / getPaddedValue

Method getPaddedValue

java/core/src/test/org/apache/orc/TestUnicode.java:103–123  ·  view source on GitHub ↗
(String val, int maxLength, boolean rtrim)

Source from the content-addressed store, hash-verified

101
102 // copied from HiveBaseChar
103 public static String getPaddedValue(String val, int maxLength, boolean rtrim) {
104 if (val == null) {
105 return null;
106 }
107 if (maxLength < 0) {
108 return val;
109 }
110
111 int valLength = val.codePointCount(0, val.length());
112 if (valLength > maxLength) {
113 return enforceMaxLength(val, maxLength);
114 }
115
116 if (maxLength > valLength && rtrim == false) {
117 // Make sure we pad the right amount of spaces; valLength is in terms of code points,
118 // while StringUtils.rpad() is based on the number of java chars.
119 int padLength = val.length() + (maxLength - valLength);
120 val = StringUtils.rightPad(val, padLength);
121 }
122 return val;
123 }
124
125 public void testChar(int maxLength, boolean hasRTrim) throws Exception {
126 // char(n)

Callers 1

testCharMethod · 0.95

Calls 2

enforceMaxLengthMethod · 0.95
lengthMethod · 0.80

Tested by

no test coverage detected