MCPcopy Create free account
hub / github.com/apache/fory / computeStringStatistics

Method computeStringStatistics

go/fory/meta/meta_string_encoder.go:231–263  ·  view source on GitHub ↗
(input string)

Source from the content-addressed store, hash-verified

229}
230
231func (e *Encoder) computeStringStatistics(input string) *stringStatistics {
232 digitCount, upperCount := 0, 0
233 canLowerSpecialEncoded := true
234 canLowerUpperDigitSpecialEncoded := true
235 for _, c := range []byte(input) {
236 if canLowerUpperDigitSpecialEncoded {
237 if !(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' ||
238 c >= '0' && c <= '9' || c == e.specialChar1 || c == e.specialChar2) {
239 canLowerUpperDigitSpecialEncoded = false
240 }
241 }
242
243 if canLowerSpecialEncoded {
244 if !(c >= 'a' && c <= 'z' || c == '.' || c == '_' || c == '$' || c == '|') {
245 canLowerSpecialEncoded = false
246 }
247 }
248
249 if c >= '0' && c <= '9' {
250 digitCount++
251 }
252
253 if c >= 'A' && c <= 'Z' {
254 upperCount++
255 }
256 }
257 return &stringStatistics{
258 digitCount: digitCount,
259 upperCount: upperCount,
260 canLowerSpecialEncoded: canLowerSpecialEncoded,
261 canLowerUpperDigitSpecialEncoded: canLowerUpperDigitSpecialEncoded,
262 }
263}
264
265func countUppers(str string) int {
266 cnt := 0

Callers 1

ComputeEncodingWithMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected