private static void CompareUncompressed(string jsonFilePath) { string bionFilePath = Path.ChangeExtension(jsonFilePath, ".bion"); string comparePath = Path.ChangeExtension(jsonFilePath, "compare.json"); JsonBionConverter.JsonToBion(jsonFilePath, bionFilePath); JsonBionConverter.BionToJson(bionFilePath, comparePath); Verify.JsonEqual(jsonFilePath, comparePath); }
private static void ToJson(string fromPath, string toPath, string dictionaryPath) { VerifyFileExists(fromPath); VerifyFileExists(dictionaryPath); using (new ConsoleWatch($"Converting {fromPath} to {toPath}...", () => $"Done. {FileLength.MB(fromPath)} BION to {FileLength.MB(toPath)} JSON")) { JsonBionConverter.BionToJson(fromPath, toPath, dictionaryPath); } }
public int Write(JsonTextWriter writer, ISearchResult wordMatches, int skip = 0, int take = -1) { int matchCount = 0; ContainerEntry lastRun = ContainerEntry.Empty; ContainerEntry lastResult = ContainerEntry.Empty; while (!wordMatches.Done) { int count = wordMatches.Page(ref _termPositions); for (int i = 0; i < count; ++i) { long position = _termPositions[i]; // If this position isn't in the last run's results array, find the run which contains it if (!lastRun.Contains(position)) { // Close previous run, if any if (!lastRun.IsEmpty()) { WriteRunSubsetEnd(writer); } // Find containing run lastRun = FindContainerAtDepth(position, _runDepth); // Write run subset _bionReader.Seek(lastRun.StartByteOffset); WriteRunSubsetStart(writer); } // Find and write result ContainerEntry result = FindContainerAtDepth(position, _runDepth + 2); if (!result.IsEmpty() && !lastResult.Equals(result)) { matchCount++; if (matchCount <= skip) { continue; } _bionReader.Seek(result.StartByteOffset); JsonBionConverter.BionToJson(_bionReader, writer); if (take >= 0 && matchCount >= skip + take) { break; } } } if (take >= 0 && matchCount >= skip + take) { break; } } // Close last run, if any if (!lastRun.IsEmpty()) { WriteRunSubsetEnd(writer); } return(matchCount); }