<commit_before>using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace TheFactory.Datastore {

    public interface IDatabase : IDisposable {
        void PushTablet(string filename);
        void PopTablet();

        IEnumerable<IKeyValuePair> Find(Slice term);

        void PushTabletStream(Stream stream, Action<IEnumerable<IKeyValuePair>> callback);

        Slice Get(Slice key);
        void Put(Slice key, Slice val);
        void Delete(Slice key);

        void Close();
    }

    public static class IDatabaseExtensions {
        public static IEnumerable<IKeyValuePair> Find(this IDatabase db) {
            return db.Find(null);
        }

        public static IEnumerable<IKeyValuePair> FindByPrefix(this IDatabase db, Slice term) {
            foreach (var kv in db.Find(term)) {
                if (!Slice.IsPrefix(kv.Key, term)) {
                    break;
                }
                yield return kv;
            }
            yield break;
        }

        public static Slice Get(this IDatabase db, string key) {
            return db.Get((Slice)Encoding.UTF8.GetBytes(key));
        }

        public static void Put(this IDatabase db, string key, Slice val) {
            db.Put((Slice)Encoding.UTF8.GetBytes(key), val);
        }

        public static void Put(this IDatabase db, string key, string val) {
            db.Put((Slice)Encoding.UTF8.GetBytes(key), (Slice)Encoding.UTF8.GetBytes(val));
        }

        public static void Delete(this IDatabase db, string key) {
            db.Delete((Slice)Encoding.UTF8.GetBytes(key));
        }
    }
}
<commit_msg>Add a FindByPrefix(string) overload<commit_after>using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace TheFactory.Datastore {

    public interface IDatabase : IDisposable {
        void PushTablet(string filename);
        void PopTablet();

        IEnumerable<IKeyValuePair> Find(Slice term);

        void PushTabletStream(Stream stream, Action<IEnumerable<IKeyValuePair>> callback);

        Slice Get(Slice key);
        void Put(Slice key, Slice val);
        void Delete(Slice key);

        void Close();
    }

    public static class IDatabaseExtensions {
        public static IEnumerable<IKeyValuePair> Find(this IDatabase db) {
            return db.Find(null);
        }

        public static IEnumerable<IKeyValuePair> FindByPrefix(this IDatabase db, Slice term) {
            foreach (var kv in db.Find(term)) {
                if (!Slice.IsPrefix(kv.Key, term)) {
                    break;
                }
                yield return kv;
            }
            yield break;
        }

        public static IEnumerable<IKeyValuePair> FindByPrefix(this IDatabase db, string term) {
            return db.FindByPrefix((Slice)Encoding.UTF8.GetBytes(term));
        }

        public static Slice Get(this IDatabase db, string key) {
            return db.Get((Slice)Encoding.UTF8.GetBytes(key));
        }

        public static void Put(this IDatabase db, string key, Slice val) {
            db.Put((Slice)Encoding.UTF8.GetBytes(key), val);
        }

        public static void Put(this IDatabase db, string key, string val) {
            db.Put((Slice)Encoding.UTF8.GetBytes(key), (Slice)Encoding.UTF8.GetBytes(val));
        }

        public static void Delete(this IDatabase db, string key) {
            db.Delete((Slice)Encoding.UTF8.GetBytes(key));
        }
    }
}

{'fraction_non_alphanumeric': 0.09626436781609195, 'fraction_numerical': 0.003160919540229885, 'mean_word_length': 2.2291280148423005, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '1074604', 'n_tokens_mistral': 999, 'n_tokens_neox': 958, 'n_words': 247}