Uses 1489K of libraries. Click here for Pure Java version (10361L/54K).
!7 !include #1028186 // new LineCompCompressor cprint CompressorSpike { switchable S snippetID = #1020763; LinkedHashMap<S> versions; start-thread { print("Snippet ID: " + snippetID); dm_onFieldChange snippetID(r { setField(versions := null); dm_reload() }); if (versions == null) { versions = mapToLinkedHashMap(reversed(textChangesOfSnippet(snippetID)), sv -> pair(str(sv.versionID), sv.previousValue)); versions.put("latest", loadSnippet(snippetID)); versions = mapValuesToLinkedHashMap toLinesAndBack(versions); // canonicalize line breaks change(); } print("Have " + nVersions(versions) + " with a total of " + nLines(totalLineCount(values(versions)))); time "Compressing" { LineCompCompressor compressor = new(versions); compressor.verify = true; compressor.run(); } S out = compressor.asText(); //printWithPrecedingNL(out); File file = saveTextFile_infoBox(javaxDataDir("Compressed Snippet Version History/versions-of-" + psI(snippetID) + ".linecomp"), out); print(renderFileInfo(gzipFile(file))); // Make .zip and .tgz for comparison File zipFile = replaceFileExtension(file, ".zip"); { temp ZipOutputStream zipOut = zipOutputStream(zipFile); for (S id, text : versions) zip_addTextFile(zipOut, id, text); } printFileInfo(zipFile); File tgzFile = replaceFileExtension(file, ".tgz"); zip2tgz(zipFile, tgzFile); printFileInfo(tgzFile); checkDecompression(file, mapValues lines(versions)); } void checkDecompression(File file, Map<S, LS> textIDToLines) { temp BufferedReader reader = bufferedUtf8Reader(file); LineCompReader lcr = new(reader); assertEquals(keysList(textIDToLines), asList(lcr.versions())); for (S version : keys(textIDToLines)) assertEquals(lcr.textForVersion(version), lines_rtrim(textIDToLines.get(version))); print("Decompression OK for " + nVersions(textIDToLines)); } }
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: | 208 / 515 |
Version history: | 3 change(s) |
Referenced in: | [show references] |