示例#1
0
        public static byte[] TrainFromBuffer(ICollection <byte[]> samples, int dictCapacity = DefaultDictCapacity)
        {
            var samplesBuffer = samples.SelectMany(sample => sample).ToArray();
            var samplesSizes  = samples.Select(sample => (size_t)sample.Length).ToArray();
            var dictBuffer    = new byte[dictCapacity];
            var dictSize      = ExternMethods.ZDICT_trainFromBuffer(dictBuffer, (size_t)dictCapacity, samplesBuffer, samplesSizes, (uint)samples.Count).EnsureZdictSuccess();

            if (dictCapacity == (int)dictSize)
            {
                return(dictBuffer);
            }
            var result = new byte[dictSize];

            Array.Copy(dictBuffer, result, (int)dictSize);
            return(result);
        }
示例#2
0
        // Token: 0x06000023 RID: 35 RVA: 0x000026F8 File Offset: 0x000008F8
        public static byte[] TrainFromBuffer(IEnumerable <byte[]> samples, int dictCapacity = 112640)
        {
            MemoryStream ms = new MemoryStream();

            UIntPtr[] array = samples.Select(delegate(byte[] sample)
            {
                ms.Write(sample, 0, sample.Length);
                return((UIntPtr)((ulong)((long)sample.Length)));
            }).ToArray <UIntPtr>();
            byte[] array2 = new byte[dictCapacity];
            int    num    = (int)((uint)ExternMethods.ZDICT_trainFromBuffer(array2, (UIntPtr)((ulong)((long)dictCapacity)), ms.ToArray(), array, (uint)array.Length).EnsureZdictSuccess());

            if (dictCapacity != num)
            {
                Array.Resize <byte>(ref array2, num);
            }
            return(array2);
        }
示例#3
0
        public static byte[] TrainFromBuffer(IEnumerable <byte[]> samples, int dictCapacity = DefaultDictCapacity)
        {
            var ms           = new MemoryStream();
            var samplesSizes = samples.Select(sample =>
            {
                ms.Write(sample, 0, sample.Length);
                return((size_t)sample.Length);
            }).ToArray();

            var dictBuffer = new byte[dictCapacity];
            var dictSize   = (int)ExternMethods
                             .ZDICT_trainFromBuffer(dictBuffer, (size_t)dictCapacity, ms.ToArray(), samplesSizes, (uint)samplesSizes.Length)
                             .EnsureZdictSuccess();

            if (dictCapacity != dictSize)
            {
                Array.Resize(ref dictBuffer, dictSize);
            }

            return(dictBuffer);
        }