github.com/dolthub/go-mysql-server@v0.18.0/sql/encodings/dec8_bin.go (about)

     1  // Copyright 2023 Dolthub, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package encodings
    16  
    17  // Dec8_bin_RuneWeight returns the weight of a given rune based on its relational sort order from
    18  // the `dec8_bin` collation.
    19  func Dec8_bin_RuneWeight(r rune) int32 {
    20  	weight, ok := dec8_bin_Weights[r]
    21  	if ok {
    22  		return weight
    23  	} else if r >= 0 && r <= 163 {
    24  		return r + 0
    25  	} else {
    26  		return 2147483647
    27  	}
    28  }
    29  
    30  // dec8_bin_Weights contain a map from rune to weight for the `dec8_bin` collation. The
    31  // map primarily contains mappings that have a random order. Mappings that fit into a sequential range (and are long
    32  // enough) are defined in the calling function to save space.
    33  var dec8_bin_Weights = map[rune]int32{
    34  	165: 164,
    35  	167: 165,
    36  	164: 166,
    37  	169: 167,
    38  	170: 168,
    39  	171: 169,
    40  	176: 170,
    41  	177: 171,
    42  	178: 172,
    43  	179: 173,
    44  	181: 174,
    45  	182: 175,
    46  	183: 176,
    47  	185: 177,
    48  	186: 178,
    49  	187: 179,
    50  	188: 180,
    51  	189: 181,
    52  	191: 182,
    53  	192: 183,
    54  	193: 184,
    55  	194: 185,
    56  	195: 186,
    57  	196: 187,
    58  	197: 188,
    59  	198: 189,
    60  	199: 190,
    61  	200: 191,
    62  	201: 192,
    63  	202: 193,
    64  	203: 194,
    65  	204: 195,
    66  	205: 196,
    67  	206: 197,
    68  	207: 198,
    69  	209: 199,
    70  	210: 200,
    71  	211: 201,
    72  	212: 202,
    73  	213: 203,
    74  	214: 204,
    75  	338: 205,
    76  	216: 206,
    77  	217: 207,
    78  	218: 208,
    79  	219: 209,
    80  	220: 210,
    81  	376: 211,
    82  	223: 212,
    83  	224: 213,
    84  	225: 214,
    85  	226: 215,
    86  	227: 216,
    87  	228: 217,
    88  	229: 218,
    89  	230: 219,
    90  	231: 220,
    91  	232: 221,
    92  	233: 222,
    93  	234: 223,
    94  	235: 224,
    95  	236: 225,
    96  	237: 226,
    97  	238: 227,
    98  	239: 228,
    99  	241: 229,
   100  	242: 230,
   101  	243: 231,
   102  	244: 232,
   103  	245: 233,
   104  	246: 234,
   105  	339: 235,
   106  	248: 236,
   107  	249: 237,
   108  	250: 238,
   109  	251: 239,
   110  	252: 240,
   111  	255: 241,
   112  }