private void TestPersistence(ulong count, ExpandableArrayOfKeys keys) { using (var validEntries = new BitVector(_pool)) { validEntries.EnsureCapacity(count); validEntries.ChangeAll(true); using (var stream = new FileStream(@"c:\temp\data.d", FileMode.Create, FileAccess.ReadWrite)) { using (var writer = new BinaryWriter(stream)) { keys.Write(writer, (ulong)count, validEntries); } } using (var keys2 = new ExpandableArrayOfKeys(_pool)) { using (var stream = new FileStream(@"c:\temp\data.d", FileMode.Open, FileAccess.Read)) { using (var reader = new BinaryReader(stream)) { { keys2.Read(reader, (ulong)count, validEntries); } } } } } }
public void ReadDataFromStore(string docRootPath, int count) { CheckState(); if (count > 0 && (docRootPath == null || !Directory.Exists(docRootPath))) { throw new ArgumentException("Count is non-zero, but storage root is invalid: " + docRootPath); } m_docRootPath = docRootPath; if (count < 0) { throw new ArgumentOutOfRangeException("count", count, "Count cannot be negative"); } m_untrimmedDocumentCount = count; m_capacity = count; DocumentIdToIndex.Clear(); if (m_untrimmedDocumentCount == 0) { return; } var timer = Stopwatch.StartNew(); using (var reader = new BinaryReader(new FileStream(Path.Combine(docRootPath, "_keysvalid.dat"), FileMode.Open, FileAccess.Read, FileShare.Read, 1 << 22, FileOptions.SequentialScan))) { //ReadBitVectorFromStore(reader, ValidDocumentsBitmap, m_untrimmedDocumentCount); ValidDocumentsBitmap.Read(reader, (ulong)m_untrimmedDocumentCount); } using (var reader = new BinaryReader(new FileStream(Path.Combine(docRootPath, "_keys.dat"), FileMode.Open, FileAccess.Read, FileShare.Read, 1 << 22, FileOptions.SequentialScan))) { DocumentKeys.Read(reader, (ulong)m_untrimmedDocumentCount, ValidDocumentsBitmap); for (var i = 0; i < m_untrimmedDocumentCount; i++) { if (!DocumentIdToIndex.TryAdd(DocumentKeys.GetIntPtrAt(i), i)) { throw new Exception("Failed to add the key at offset " + i + " to map"); } } } timer.Stop(); if (m_logger.IsInfoEnabled) { m_logger.InfoFormat("Loaded container structure for document {0}/{1} in {2} milliseconds. {3} columns, {4} rows.", DocDesc.DocumentType, DocDesc.Name, timer.ElapsedMilliseconds, FieldIdToColumnStore.Count, m_untrimmedDocumentCount); } }
private void TestPersistence(ulong count, ExpandableArrayOfKeys keys) { using (var validEntries = new BitVector(_pool)) { validEntries.EnsureCapacity(count); validEntries.ChangeAll(true); using (var stream = new FileStream(@"c:\temp\data.d", FileMode.Create, FileAccess.ReadWrite)) { using (var writer = new BinaryWriter(stream)) { keys.Write(writer, (ulong) count, validEntries); } } using (var keys2 = new ExpandableArrayOfKeys(_pool)) { using (var stream = new FileStream(@"c:\temp\data.d", FileMode.Open, FileAccess.Read)) { using (var reader = new BinaryReader(stream)) { { keys2.Read(reader, (ulong) count, validEntries); } } } } } }