-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MINOR] Improved code coverage control program and symbol table
This patch adds a couple of tests to systematically fix uncovered code. Furthermore, it removes incorrect and renames misleading methods on "pinned objects" that actually did not deal with our notion of pinned (i.e., disabled cleanup) data objects.
- Loading branch information
Showing
9 changed files
with
102 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/test/java/org/apache/sysds/test/component/cp/VariableMapTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.sysds.test.component.cp; | ||
|
||
import org.apache.sysds.common.Types.FileFormat; | ||
import org.apache.sysds.common.Types.ValueType; | ||
import org.apache.sysds.runtime.controlprogram.LocalVariableMap; | ||
import org.apache.sysds.runtime.controlprogram.caching.MatrixObject; | ||
import org.apache.sysds.runtime.matrix.data.MatrixBlock; | ||
import org.apache.sysds.runtime.meta.MatrixCharacteristics; | ||
import org.apache.sysds.runtime.meta.MetaDataFormat; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class VariableMapTest { | ||
|
||
@Test | ||
public void testPinnedMethods() { | ||
LocalVariableMap vars = createSymbolTable(); | ||
Assert.assertTrue(vars.getPinnedDataSize() > 2e5); | ||
vars.releaseAcquiredData(); //no impact on pinned status | ||
Assert.assertTrue(vars.getPinnedDataSize() > 2e5); | ||
vars.removeAll(); | ||
} | ||
|
||
@Test | ||
public void testSerializeDeserialize() { | ||
LocalVariableMap vars = createSymbolTable(); | ||
LocalVariableMap vars2 = LocalVariableMap.deserialize(vars.serialize()); | ||
vars2.setID(1); | ||
Assert.assertEquals(vars.toString(), vars2.toString()); | ||
LocalVariableMap vars3 = (LocalVariableMap) vars2.clone(); | ||
vars3.setID(1); | ||
Assert.assertEquals(vars.toString(), vars3.toString()); | ||
} | ||
|
||
private LocalVariableMap createSymbolTable() { | ||
LocalVariableMap vars = new LocalVariableMap(); | ||
vars.put("a", createPinnedMatrixObject(1)); | ||
vars.put("b", createPinnedMatrixObject(2)); | ||
return vars; | ||
} | ||
|
||
private MatrixObject createPinnedMatrixObject(int seed) { | ||
MatrixBlock mb1 = MatrixBlock.randOperations(150, 167, 0.3, 1, 1, "uniform", seed); | ||
MatrixObject mo = new MatrixObject(ValueType.FP64, "./tmp", | ||
new MetaDataFormat(new MatrixCharacteristics(), FileFormat.BINARY)); | ||
mo.acquireModify(mb1); | ||
mo.release(); | ||
mo.enableCleanup(false); | ||
mo.setDirty(false); | ||
return mo; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters