Uses 1489K of libraries. Click here for Pure Java version (10361L/54K).
1 | !7 |
2 | |
3 | !include #1028186 // new LineCompCompressor |
4 | |
5 | cprint CompressorSpike { |
6 | switchable S snippetID = #1020763; |
7 | LinkedHashMap<S> versions; |
8 | |
9 | start-thread { |
10 | print("Snippet ID: " + snippetID); |
11 | dm_onFieldChange snippetID(r { setField(versions := null); dm_reload() }); |
12 | if (versions == null) { |
13 | versions = mapToLinkedHashMap(reversed(textChangesOfSnippet(snippetID)), sv -> pair(str(sv.versionID), sv.previousValue)); |
14 | versions.put("latest", loadSnippet(snippetID)); |
15 | versions = mapValuesToLinkedHashMap toLinesAndBack(versions); // canonicalize line breaks |
16 | change(); |
17 | } |
18 | print("Have " + nVersions(versions) + " with a total of " + nLines(totalLineCount(values(versions)))); |
19 | |
20 | time "Compressing" { |
21 | LineCompCompressor compressor = new(versions); |
22 | compressor.verify = true; |
23 | compressor.run(); |
24 | } |
25 | |
26 | S out = compressor.asText(); |
27 | //printWithPrecedingNL(out); |
28 | File file = saveTextFile_infoBox(javaxDataDir("Compressed Snippet Version History/versions-of-" + psI(snippetID) + ".linecomp"), out); |
29 | print(renderFileInfo(gzipFile(file))); |
30 | |
31 | // Make .zip and .tgz for comparison |
32 | File zipFile = replaceFileExtension(file, ".zip"); |
33 | { |
34 | temp ZipOutputStream zipOut = zipOutputStream(zipFile); |
35 | for (S id, text : versions) |
36 | zip_addTextFile(zipOut, id, text); |
37 | } |
38 | printFileInfo(zipFile); |
39 | |
40 | File tgzFile = replaceFileExtension(file, ".tgz"); |
41 | zip2tgz(zipFile, tgzFile); |
42 | printFileInfo(tgzFile); |
43 | |
44 | checkDecompression(file, mapValues lines(versions)); |
45 | } |
46 | |
47 | void checkDecompression(File file, Map<S, LS> textIDToLines) { |
48 | temp BufferedReader reader = bufferedUtf8Reader(file); |
49 | LineCompReader lcr = new(reader); |
50 | assertEquals(keysList(textIDToLines), asList(lcr.versions())); |
51 | for (S version : keys(textIDToLines)) |
52 | assertEquals(lcr.textForVersion(version), lines_rtrim(textIDToLines.get(version))); |
53 | print("Decompression OK for " + nVersions(textIDToLines)); |
54 | } |
55 | } |
Began life as a copy of #1028167
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028217 |
Snippet name: | Line-Based Multi-Version Compressor Spike, faster version [dev.] |
Eternal ID of this version: | #1028217/4 |
Text MD5: | bd6a02cc057da41af9421025e7716cec |
Transpilation MD5: | a79ab3e7fa0667c4f2b3b2ca96b519a1 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-05-27 00:32:52 |
Source code size: | 2065 bytes / 55 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 209 / 516 |
Version history: | 3 change(s) |
Referenced in: | [show references] |