<commit_before>part of redis;
/*
 * Free software licenced under 
 * GNU AFFERO GENERAL PUBLIC LICENSE
 * 
 * Check for document LICENCE forfull licence text
 * 
 * <NAME>
 */


Utf8Encoder RedisSerialiseEncoder = new Utf8Encoder();

class RedisSerialise {
  static List<int> Serialise(object){
     List s = new List();
     SerialiseConsumable(object,(v){
       s.addAll(v);
     });
     return s;
  }
  
  static void SerialiseConsumable(object,Function consumer(Iterable s)){
     if(object is String){
       List str = UTF8.encode(object);
       consumer(ASCII.encode("\$" + str.length.toString() + "\r\n"));
       consumer(str);
       consumer(ASCII.encode("\r\n"));
     }
     else if(object is Iterable){
       int len=object.length;
       consumer(ASCII.encode("*"+len.toString()+"\r\n"));
       for(int i=0;i<len;++i){
         SerialiseConsumable(object[i],consumer);
       }
     }
     else if(object is int){
       consumer(ASCII.encode(":"));
       consumer(ASCII.encode(object.toString()));
       consumer(ASCII.encode("\r\n"));
     }
     else if(object == null){
       consumer(ASCII.encode("\$-1")); //null bulk
     }
     else{
       throw("cant serialise such type");
     }
  }
}<commit_msg>serialiser is much faster 160K INCR operations<commit_after>part of redis;
/*
 * Free software licenced under 
 * GNU AFFERO GENERAL PUBLIC LICENSE
 * 
 * Check for document LICENCE forfull licence text
 * 
 * <NAME>
 */


Utf8Encoder RedisSerialiseEncoder = new Utf8Encoder();

class RedisSerialise {
  static List<int> Serialise(object){
     List s = new List();
     SerialiseConsumable(object,(v){
       s.addAll(v);
     });
     return s;
  }
  
  static void SerialiseConsumable(object,Function consumer(Iterable s)){
     if(object is String){
       var str = object;
       consumer(ASCII.encode("\$"));
       consumer(ASCII.encode(str.length.toString()));
       consumer(ASCII.encode("\r\n")); 
       consumer(UTF8.encode(str));
       consumer(ASCII.encode("\r\n"));
     }
     else if(object is Iterable){
       int len=object.length;
       consumer(ASCII.encode("*"));
       consumer(ASCII.encode(len.toString()));
       consumer(ASCII.encode("\r\n"));
       for(int i=0;i<len;++i){
         SerialiseConsumable(object[i],consumer);
       }
     }
     else if(object is int){
       consumer(ASCII.encode(":"));
       consumer(ASCII.encode(object.toString()));
       consumer(ASCII.encode("\r\n"));
     }
     else if(object == null){
       consumer(ASCII.encode("\$-1")); //null bulk
     }
     else{
       throw("cant serialise such type");
     }
  }
}
{'fraction_non_alphanumeric': 0.15502100038182512, 'fraction_numerical': 0.004963726613211149, 'mean_word_length': 2.6901408450704225, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '625949', 'n_tokens_mistral': 848, 'n_tokens_neox': 829, 'n_words': 170}