Exemple #1
0
        public void CanReadDataset_External(string datasetName)
        {
            // INFO:
            // HDF lib says "external storage not supported with chunked layout". Same is true for compact layout.

            TestUtils.RunForAllVersions(version =>
            {
                // Arrange
                var absolutePrefix = datasetName == "absolute"
                    ? Path.GetTempPath()
                    : string.Empty;

                var externalFilePrefix = datasetName == "prefix"
                   ? Path.GetTempPath()
                   : null;

                var datasetAccess = new H5DatasetAccess()
                {
                    ExternalFilePrefix = externalFilePrefix
                };

                var filePath = TestUtils.PrepareTestFile(version, fileId => TestUtils.AddExternalDataset(fileId, datasetName, absolutePrefix, datasetAccess));
                var expected = TestData.MediumData.ToArray();

                for (int i = 33; i < 40; i++)
                {
                    expected[i] = 0;
                }

                // Act
                using var root = H5File.OpenReadCore(filePath, deleteOnClose: true);
                var parent     = root.Group("external");
                var dataset    = parent.Dataset(datasetName);
                var actual     = dataset.Read <int>();

                // Assert
                Assert.True(actual.SequenceEqual(expected));
            });
        }
Exemple #2
0
        public void CanReadDataset_External(string datasetName)
        {
            TestUtils.RunForAllVersions(version =>
            {
                // Arrange
                var absolutePrefix = datasetName == "absolute"
                    ? Path.GetTempPath()
                    : string.Empty;

                var externalFilePrefix = datasetName == "prefix"
                   ? Path.GetTempPath()
                   : null;

                var datasetAccess = new H5DatasetAccess()
                {
                    ExternalFilePrefix = externalFilePrefix
                };

                var filePath = TestUtils.PrepareTestFile(version, fileId => TestUtils.AddExternalDataset(fileId, datasetName, absolutePrefix, datasetAccess));
                var expected = TestData.MediumData;

                for (int i = 33; i < 40; i++)
                {
                    expected[i] = 0;
                }

                // Act
                using var root = H5File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read, deleteOnClose: true);
                var parent     = root.Group("external");
                var dataset    = parent.Dataset(datasetName);
                var actual     = dataset.Read <int>();

                // Assert
                Assert.True(actual.SequenceEqual(expected));
            });
        }