public void MemoryMappedHugeArraySimpleTest() { // make sure to initialize the native hooks to create a memory mapping. Native.Initialize(); using (var intArray = new MemoryMappedHugeArray <int>(1000, 1024)) { var intArrayRef = new int[1000]; var randomGenerator = new RandomGenerator(66707770); // make this deterministic for (int idx = 0; idx < 1000; idx++) { if (randomGenerator.Generate(2.0) > 1) { // add data. intArrayRef[idx] = idx; intArray[idx] = idx; } else { intArrayRef[idx] = int.MaxValue; intArray[idx] = int.MaxValue; } } for (int idx = 0; idx < 1000; idx++) { Assert.AreEqual(intArrayRef[idx], intArray[idx]); } } }
/// <summary> /// Disposes of all native resources associated with this memory dynamic graph. /// </summary> public void Dispose() { _coordinates.Dispose(); _coordinates = null; _edges.Dispose(); _edges = null; _edgeData.Dispose(); _edgeData = null; _vertices.Dispose(); _vertices = null; }
/// <summary> /// Creates a new memory mapped file dynamic graph. /// </summary> /// <param name="estimatedSize"></param> /// <param name="coordinates"></param> /// <param name="vertices"></param> /// <param name="edges"></param> /// <param name="edgeData"></param> /// <param name="edgeShapes"></param> public MemoryMappedFileDynamicGraph(long estimatedSize, MemoryMappedHugeArray <GeoCoordinateSimple> coordinates, MemoryMappedHugeArray <uint> vertices, MemoryMappedHugeArray <uint> edges, MemoryMappedHugeArray <TEdgeData> edgeData, IHugeArray <GeoCoordinateSimple[]> edgeShapes) : base(estimatedSize, coordinates, vertices, edges, edgeData, edgeShapes) { _coordinates = coordinates; _vertices = vertices; _edges = edges; _edgeData = edgeData; }
/// <summary> /// Creates a new memory mapped file dynamic graph. /// </summary> /// <param name="estimatedSize"></param> /// <param name="coordinates"></param> /// <param name="vertices"></param> /// <param name="edges"></param> /// <param name="edgeData"></param> /// <param name="edgeShapes"></param> public MemoryMappedGraph(long estimatedSize, MemoryMappedHugeArray <GeoCoordinateSimple> coordinates, MemoryMappedHugeArray <uint> vertices, MemoryMappedHugeArray <uint> edges, MemoryMappedHugeArray <TEdgeData> edgeData, HugeCoordinateCollectionIndex edgeShapes) : base(estimatedSize, coordinates, vertices, edges, edgeData, edgeShapes) { _coordinates = coordinates; _vertices = vertices; _edges = edges; _edgeData = edgeData; _shapes = edgeShapes; }
public void MemoryMappedHugeArrayResizeTests() { // make sure to initialize the native hooks to create a memory mapping. Native.Initialize(); var randomGenerator = new RandomGenerator(66707770); // make this deterministic using (var intArray = new MemoryMappedHugeArray<int>(1000, 300)) { var intArrayRef = new int[1000]; for (int idx = 0; idx < 1000; idx++) { if (randomGenerator.Generate(2.0) > 1) { // add data. intArrayRef[idx] = idx; intArray[idx] = idx; } else { intArrayRef[idx] = int.MaxValue; intArray[idx] = int.MaxValue; } } Array.Resize<int>(ref intArrayRef, 335); intArray.Resize(335); Assert.AreEqual(intArrayRef.Length, intArray.Length); for (int idx = 0; idx < intArrayRef.Length; idx++) { Assert.AreEqual(intArrayRef[idx], intArray[idx]); } } using (var intArray = new MemoryMappedHugeArray<int>(1000, 300)) { var intArrayRef = new int[1000]; for (int idx = 0; idx < 1000; idx++) { if (randomGenerator.Generate(2.0) > 1) { // add data. intArrayRef[idx] = idx; intArray[idx] = idx; } else { intArrayRef[idx] = int.MaxValue; intArray[idx] = int.MaxValue; } } Array.Resize<int>(ref intArrayRef, 1235); intArray.Resize(1235); Assert.AreEqual(intArrayRef.Length, intArray.Length); for (int idx = 0; idx < intArrayRef.Length; idx++) { Assert.AreEqual(intArrayRef[idx], intArray[idx]); } } }
public void MemoryMappedHugeArraySimpleTest() { // make sure to initialize the native hooks to create a memory mapping. Native.Initialize(); using (var intArray = new MemoryMappedHugeArray<int>(1000, 1024)) { var intArrayRef = new int[1000]; var randomGenerator = new RandomGenerator(66707770); // make this deterministic for (int idx = 0; idx < 1000; idx++) { if (randomGenerator.Generate(2.0) > 1) { // add data. intArrayRef[idx] = idx; intArray[idx] = idx; } else { intArrayRef[idx] = int.MaxValue; intArray[idx] = int.MaxValue; } } for (int idx = 0; idx < 1000; idx++) { Assert.AreEqual(intArrayRef[idx], intArray[idx]); } } }
public void MemoryMappedHugeArrayResizeTests() { // make sure to initialize the native hooks to create a memory mapping. Native.Initialize(); var randomGenerator = new RandomGenerator(66707770); // make this deterministic using (var intArray = new MemoryMappedHugeArray <int>(1000, 300)) { var intArrayRef = new int[1000]; for (int idx = 0; idx < 1000; idx++) { if (randomGenerator.Generate(2.0) > 1) { // add data. intArrayRef[idx] = idx; intArray[idx] = idx; } else { intArrayRef[idx] = int.MaxValue; intArray[idx] = int.MaxValue; } } Array.Resize <int>(ref intArrayRef, 335); intArray.Resize(335); Assert.AreEqual(intArrayRef.Length, intArray.Length); for (int idx = 0; idx < intArrayRef.Length; idx++) { Assert.AreEqual(intArrayRef[idx], intArray[idx]); } } using (var intArray = new MemoryMappedHugeArray <int>(1000, 300)) { var intArrayRef = new int[1000]; for (int idx = 0; idx < 1000; idx++) { if (randomGenerator.Generate(2.0) > 1) { // add data. intArrayRef[idx] = idx; intArray[idx] = idx; } else { intArrayRef[idx] = int.MaxValue; intArray[idx] = int.MaxValue; } } Array.Resize <int>(ref intArrayRef, 1235); intArray.Resize(1235); Assert.AreEqual(intArrayRef.Length, intArray.Length); for (int idx = 0; idx < intArrayRef.Length; idx++) { Assert.AreEqual(intArrayRef[idx], intArray[idx]); } } }