Skip to content

Commit cbc70e0

Browse files
committed
impl memo
1 parent 7de6da0 commit cbc70e0

File tree

2 files changed

+86
-4
lines changed

2 files changed

+86
-4
lines changed

sandbox/SandboxConsoleApp/Program.cs

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,90 @@
1010
using System.Collections.Generic;
1111
using System.Collections.Immutable;
1212
using System.Collections.ObjectModel;
13+
using System.IO;
14+
using System.IO.Compression;
1315
using System.Linq;
1416
using System.Numerics;
1517
using System.Runtime.CompilerServices;
1618
using System.Security.Cryptography.X509Certificates;
1719
using System.Text;
20+
using System.Xml.Linq;
1821

1922

2023

2124
// ---
2225

2326

2427

25-
var person = new Person();
26-
var bin = MemoryPackSerializer.Serialize(person);
28+
//var encoder = new BrotliEncoder(4, 22);
2729

28-
// overwrite data to existing instance.
29-
MemoryPackSerializer.Deserialize(bin, ref person);
30+
//// new BrotliDecoder().Decompress(
3031

3132

33+
////encoder.Compress(, , , , true);
34+
35+
36+
37+
38+
//encoder.Dispose();
39+
40+
41+
42+
43+
44+
45+
46+
47+
//var person = new Person();
48+
//var bin = MemoryPackSerializer.Serialize(person);
49+
50+
//// overwrite data to existing instance.
51+
//MemoryPackSerializer.Deserialize(bin, ref person);
52+
53+
//internal void WriteCore(ReadOnlySpan<byte> buffer, bool isFinalBlock = false)
54+
//{
55+
// if (_mode != CompressionMode.Compress)
56+
// throw new InvalidOperationException(SR.BrotliStream_Decompress_UnsupportedOperation);
57+
// EnsureNotDisposed();
58+
59+
// OperationStatus lastResult = OperationStatus.DestinationTooSmall;
60+
// Span<byte> output = new Span<byte>(_buffer);
61+
// while (lastResult == OperationStatus.DestinationTooSmall)
62+
// {
63+
// int bytesConsumed;
64+
// int bytesWritten;
65+
// lastResult = _encoder.Compress(buffer, output, out bytesConsumed, out bytesWritten, isFinalBlock);
66+
// if (lastResult == OperationStatus.InvalidData)
67+
// throw new InvalidOperationException(SR.BrotliStream_Compress_InvalidData);
68+
// if (bytesWritten > 0)
69+
// _stream.Write(output.Slice(0, bytesWritten));
70+
// if (bytesConsumed > 0)
71+
// buffer = buffer.Slice(bytesConsumed);
72+
// }
73+
//}
74+
75+
76+
//internal static partial class BrotliUtils
77+
//{
78+
// public const int WindowBits_Min = 10;
79+
// public const int WindowBits_Default = 22;
80+
// public const int WindowBits_Max = 24;
81+
// public const int Quality_Min = 0;
82+
// public const int Quality_Default = 4;
83+
// public const int Quality_Max = 11;
84+
// public const int MaxInputSize = int.MaxValue - 515; // 515 is the max compressed extra bytes
85+
86+
// internal static int GetQualityFromCompressionLevel(CompressionLevel compressionLevel) =>
87+
// compressionLevel switch
88+
// {
89+
// CompressionLevel.NoCompression => Quality_Min,
90+
// CompressionLevel.Fastest => 1,
91+
// CompressionLevel.Optimal => Quality_Default,
92+
// CompressionLevel.SmallestSize => Quality_Max,
93+
// _ => throw new ArgumentException(SR.ArgumentOutOfRange_Enum, nameof(compressionLevel))
94+
// };
95+
//}
96+
3297

3398
[MemoryPackable(GenerateType.Collection)]
3499
public partial class ListGenerics<T> : List<T>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//using System.Numerics;
2+
3+
//namespace MemoryPack.Collections;
4+
5+
//// NOTE: try to implement columnar compression for MemoryPack
6+
7+
//// https://www.timescale.com/blog/time-series-compression-algorithms-explained/
8+
//// https://github.com/apache/parquet-format/blob/master/Encodings.md
9+
10+
//public sealed class CompressedArray<T>
11+
// where T : INumberBase<T>
12+
//{
13+
// public void Add()
14+
// {
15+
16+
// }
17+
//}

0 commit comments

Comments
 (0)