MCPcopy Create free account
hub / github.com/apache/impala / LeastLargerString

Method LeastLargerString

be/src/runtime/string-value.cc:81–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81string StringValue::LeastLargerString() const {
82 uint32_t len = Len();
83 const char* ptr = Ptr();
84 if (len == 0) return string("\00", 1);
85 int i = len - 1;
86 while (i >= 0 && ptr[i] == (int8_t)0xff) i--;
87 if (UNLIKELY(i == -1)) {
88 // All characters are 0xff.
89 // Return a string with these many 0xff chars plus one 0x00 char
90 string result;
91 result.reserve(len + 1);
92 result.append(len, 0xff);
93 result.append(1, 0x00);
94 return result;
95 }
96 // i is pointing at a character != 0xff.
97 // Copy characters of this in [0, i] to 'result' and perform a '+1' operation on the
98 // ith char.
99 string result;
100 result.reserve(i + 1);
101 // copy all i characters in [0, i-1] to 'result'
102 result.append(ptr, i);
103 // append a char which is ptr[i]+1
104 result.append(1, (uint8_t)(ptr[i]) + 1);
105 return result;
106}
107}

Callers 2

TestLeastLargerStringMethod · 0.80
InsertForGTMethod · 0.80

Calls 2

reserveMethod · 0.80
appendMethod · 0.45

Tested by 1

TestLeastLargerStringMethod · 0.64