static void ai_compactLiveDB(bool withPhase2) {
new ai_compactLiveDB_Class c;
c.phase1();
if (!withPhase2) ret;
print("PHASE 2 in 5 SECONDS");
sleepSeconds(5);
c.phase2();
}
sclass ai_compactLiveDB_Class {
File mainLog, fTriples, file, file2;
void phase1() ctex {
// First, rotate webs-made.txt
mainLog = programFile(#1010745, "webs-made.txt");
rotateLogFile(mainLog);
File tripelizedDir = programDir(#1010745, "tripelized");
fTriples = programFile(#1010745, "triples.gz");
// Save triples
file = new File(tripelizedDir, "triples.new.gz");
OutputStream out = newGZIPOutputStream(file);
int n = ai_writeTripleFile(ai_allTriples(), out);
out.close();
// Save non-triples (don't have any)
file2 = new File(tripelizedDir, "webs-made.new.gz");
deleteFile(file2);
print("Stored " + nTriple(n) + " in " + f2s(file) + ", nothing in " + f2s(file2));
}
void phase2 {
print("PHASE 2.");
// Move data to backups
File fBackups = programFile(#1010745, "backups");
for (File f : earlierPartsOfLogFile(mainLog)) {
int n = 1;
File p;
while ((p = newFile(fBackups, dropSuffix(".gz", f.getName()) + ".part" + n + ".gz")).exists()) ++n;
renameFile_assertTrue(f, p);
}
// Backup triples.gz
int n = 1;
File p;
while ((p = newFile(fBackups, dropSuffix(".gz", fTriples.getName()) + ".part" + n + ".gz")).exists()) ++n;
renameFile_assertTrue(fTriples, p);
// Rename main files
renameFile_assertTrue(file, fTriples);
if (file2.exists())
renameFile_assertTrue(file2, programFile(#1010745, "webs-made.txt.part1.gz"));
print("DONE.");
}
}Began life as a copy of #1011778
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1013307 |
| Snippet name: | ai_compactLiveDB - just store all triples from memory, no attempts at cleaning up the DB |
| Eternal ID of this version: | #1013307/9 |
| Text MD5: | 743dd532dd44f3de97a65e7b3872cdeb |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-12-31 20:42:49 |
| Source code size: | 1795 bytes / 64 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 892 / 919 |
| Version history: | 8 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |