You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemds.apache.org by mb...@apache.org on 2021/01/09 20:44:05 UTC

[systemds] branch master updated: [SYSTEMDS-2789] Cleanup disguised missing value detection

This is an automated email from the ASF dual-hosted git repository.

mboehm7 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/systemds.git


The following commit(s) were added to refs/heads/master by this push:
     new 83e5eef  [SYSTEMDS-2789] Cleanup disguised missing value detection
83e5eef is described below

commit 83e5eefd4f30095f05d8dfc549a2db1aae66f766
Author: Matthias Boehm <mb...@gmail.com>
AuthorDate: Sat Jan 9 21:38:22 2021 +0100

    [SYSTEMDS-2789] Cleanup disguised missing value detection
    
    * Fix thread-safeness for parfor environments (no static instance vars)
    * Fix hashmap/iterator handling (removed HashedMap, unnecessary casts)
    * Fix formatting related test
    
    DIA project WS2020/21, part 2
    
    Co-authored-by: David Kerschbaumer <da...@student.tugraz.at>
    Co-authored-by: Patrick Lovric <pa...@student.tugraz.at>
    Co-authored-by: Valentin Edelsbrunner <v....@student.tugraz.at>
---
 .../sysds/runtime/matrix/data/FrameBlock.java      |  23 +-
 .../org/apache/sysds/runtime/util/DMVUtils.java    |  73 ++---
 .../test/functions/builtin/BuiltinDMVTest.java     | 314 ++++++++++-----------
 3 files changed, 188 insertions(+), 222 deletions(-)

diff --git a/src/main/java/org/apache/sysds/runtime/matrix/data/FrameBlock.java b/src/main/java/org/apache/sysds/runtime/matrix/data/FrameBlock.java
index d157e37..e33052d 100644
--- a/src/main/java/org/apache/sysds/runtime/matrix/data/FrameBlock.java
+++ b/src/main/java/org/apache/sysds/runtime/matrix/data/FrameBlock.java
@@ -2102,9 +2102,7 @@ public class FrameBlock implements CacheBlock, Externalizable  {
 	}
 
 	public FrameBlock map(String lambdaExpr) {
-		if(!lambdaExpr.contains("->"))
-		{
-			//return map(getCompiledFunctionBlock(lambdaExpr));
+		if(!lambdaExpr.contains("->")) {
 			String args = lambdaExpr.substring(lambdaExpr.indexOf('(') + 1, lambdaExpr.indexOf(')'));
 			if(args.contains(",")) {
 				String[] arguments = args.split(",");
@@ -2134,18 +2132,15 @@ public class FrameBlock implements CacheBlock, Externalizable  {
 	}
 
 	public static FrameMapFunction getCompiledFunction(String lambdaExpr) {
-		String varname;
-		String expr;
-
 		String cname = "StringProcessing"+CLASS_ID.getNextID();
 		StringBuilder sb = new StringBuilder();
-
-
 		String[] parts = lambdaExpr.split("->");
+		
 		if( parts.length != 2 )
 			throw new DMLRuntimeException("Unsupported lambda expression: "+lambdaExpr);
-		varname = parts[0].trim();
-		expr = parts[1].trim();
+		
+		String varname = parts[0].trim();
+		String expr = parts[1].trim();
 
 		// construct class code
 		sb.append("import org.apache.sysds.runtime.util.UtilFunctions;\n");
@@ -2158,7 +2153,7 @@ public class FrameBlock implements CacheBlock, Externalizable  {
 		// compile class, and create FrameMapFunction object
 		try {
 			return (FrameMapFunction) CodegenUtils
-					.compileClass(cname, sb.toString()).newInstance();
+				.compileClass(cname, sb.toString()).newInstance();
 		}
 		catch(InstantiationException | IllegalAccessException e) {
 			throw new DMLRuntimeException("Failed to compile FrameMapFunction.", e);
@@ -2167,13 +2162,9 @@ public class FrameBlock implements CacheBlock, Externalizable  {
 
 
 	public FrameBlockMapFunction getCompiledFunctionBlock(String lambdaExpression) {
-		// split lambda expression
-		String expr;
-
 		String cname = "StringProcessing"+CLASS_ID.getNextID();
 		StringBuilder sb = new StringBuilder();
-
-		expr = lambdaExpression;
+		String expr = lambdaExpression;
 
 		sb.append("import org.apache.sysds.runtime.util.UtilFunctions;\n");
 		sb.append("import org.apache.sysds.runtime.matrix.data.FrameBlock.FrameBlockMapFunction;\n");
diff --git a/src/main/java/org/apache/sysds/runtime/util/DMVUtils.java b/src/main/java/org/apache/sysds/runtime/util/DMVUtils.java
index e850d01..95ce669 100644
--- a/src/main/java/org/apache/sysds/runtime/util/DMVUtils.java
+++ b/src/main/java/org/apache/sysds/runtime/util/DMVUtils.java
@@ -19,13 +19,13 @@
 
 package org.apache.sysds.runtime.util;
 
-import org.apache.commons.collections.map.HashedMap;
+import org.apache.sysds.runtime.DMLRuntimeException;
 import org.apache.sysds.runtime.matrix.data.FrameBlock;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 
 public class DMVUtils {
 	public static final char DIGIT = 'd';
@@ -37,20 +37,17 @@ public class DMVUtils {
 	public static final char OTHER = 'y';
 	public static final char ARBITRARY_LEN = '+';
 	public static final char MINUS = '-';
-	public static String DISGUISED_VAL = "";
 
 	public enum LEVEL_ENUM { LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5, LEVEL6}
 
 	public static FrameBlock syntacticalPatternDiscovery(FrameBlock frame, double threshold, String disguised_value) {
-
 		// Preparation
-		DISGUISED_VAL = disguised_value;
+		String disguisedVal = disguised_value;
 		int numCols = frame.getNumColumns();
 		int numRows = frame.getNumRows();
-		ArrayList<Map<String, Integer>> table_Hist = new ArrayList(numCols); // list of every column with values and their frequency
+		ArrayList<Map<String, Integer>> table_Hist = new ArrayList<>(numCols); // list of every column with values and their frequency
 
-		int idx;
-		for (idx = 0; idx < numCols; idx++) {
+		for (int idx = 0; idx < numCols; idx++) {
 			Object c = frame.getColumnData(idx);
 			String[] column = (String[]) c;
 			String key = "";
@@ -61,10 +58,10 @@ public class DMVUtils {
 		}
 
 		// Syntactic Pattern Discovery
-		idx = -1;
+		int idx = -1;
 		for (Map<String, Integer> col_Hist : table_Hist) {
 			idx++;
-			Map<String, Double> dominant_patterns_ratio = new HashedMap();
+			Map<String, Double> dominant_patterns_ratio = new HashMap<>();
 			Map<String, Integer> prev_pattern_hist = col_Hist;
 			for(LEVEL_ENUM level : LEVEL_ENUM.values()) {
 				dominant_patterns_ratio.clear();
@@ -72,7 +69,7 @@ public class DMVUtils {
 				dominant_patterns_ratio = calculatePatternsRatio(current_pattern_hist, numRows);
 				String dominant_pattern = findDominantPattern(dominant_patterns_ratio, threshold);
 				if(dominant_pattern != null) { //found pattern
-					detectDisguisedValues(dominant_pattern, frame.getColumnData(idx), idx, frame, level);
+					detectDisguisedValues(dominant_pattern, frame.getColumnData(idx), idx, frame, level, disguisedVal);
 					break;
 				}
 				prev_pattern_hist = current_pattern_hist;
@@ -83,13 +80,10 @@ public class DMVUtils {
 
 
 	public static Map<String, Double> calculatePatternsRatio(Map<String, Integer> patterns_hist, int nr_entries) {
-		Map<String, Double> patterns_ratio_map = new HashedMap();
-		Iterator it = patterns_hist.entrySet().iterator();
-		while(it.hasNext()) {
-			Map.Entry pair = (Map.Entry) it.next();
-			String pattern = (String) pair.getKey();
-			Double nr_occurences = new Double((Integer)pair.getValue());
-
+		Map<String, Double> patterns_ratio_map = new HashMap<>();
+		for(Entry<String, Integer> e : patterns_hist.entrySet()) {
+			String pattern = e.getKey();
+			double nr_occurences = e.getValue();
 			double current_ratio = nr_occurences / nr_entries; // percentage of current pattern in column
 			patterns_ratio_map.put(pattern, current_ratio);
 		}
@@ -97,16 +91,11 @@ public class DMVUtils {
 	}
 
 	public static String findDominantPattern(Map<String, Double> dominant_patterns, double threshold) {
-
-		Iterator it = dominant_patterns.entrySet().iterator();
-		while(it.hasNext()) {
-			Map.Entry pair = (Map.Entry) it.next();
-			String pattern = (String) pair.getKey();
-			Double pattern_ratio = (Double)pair.getValue();
-
+		for(Entry<String, Double> e : dominant_patterns.entrySet()) {
+			String pattern = e.getKey();
+			Double pattern_ratio = e.getValue();
 			if(pattern_ratio > threshold)
 				return pattern;
-
 		}
 		return null;
 	}
@@ -119,28 +108,24 @@ public class DMVUtils {
 			return;
 		}
 
-		if (!(maps.get(idx).containsKey(key))) {
+		if (!(maps.get(idx).containsKey(key)))
 			maps.get(idx).put(key, 1);
-		} else {
+		else
 			maps.get(idx).compute(key, (k, v) -> v + 1);
-		}
 	}
 
 	private static void addDistinctValueOrIncrementCounter(Map<String, Integer> map, String encoded_value, Integer nr_occurrences) {
-		if (!(map.containsKey(encoded_value))) {
+		if (!(map.containsKey(encoded_value)))
 			map.put(encoded_value, nr_occurrences);
-		} else {
+		else
 			map.compute(encoded_value, (k, v) -> v + nr_occurrences);
-		}
 	}
 
 	public static Map<String, Integer> LevelsExecutor(Map<String, Integer> old_pattern_hist, LEVEL_ENUM level) {
-		Map<String, Integer> new_pattern_hist = new HashedMap();
-		Iterator it = old_pattern_hist.entrySet().iterator();
-		while (it.hasNext()) {
-			Map.Entry pair = (Map.Entry) it.next();
-			String pattern = (String) pair.getKey();
-			Integer nr_of_occurrences = (Integer)pair.getValue();
+		Map<String, Integer> new_pattern_hist = new HashMap<>();
+		for(Entry<String, Integer> e : old_pattern_hist.entrySet()) {
+			String pattern = e.getKey();
+			Integer nr_of_occurrences = e.getValue();
 
 			String new_pattern;
 			switch(level) {
@@ -219,7 +204,6 @@ public class DMVUtils {
 		return tmp.toString();
 	}
 
-
 	public static String removeUpperLowerCase(String pattern) {
 		char[] chars = pattern.toCharArray();
 		StringBuilder tmp = new StringBuilder();
@@ -290,7 +274,7 @@ public class DMVUtils {
 	}
 
 	private static void detectDisguisedValues(String dom_pattern, Object col, int col_idx,
-		FrameBlock frameBlock, LEVEL_ENUM level)
+		FrameBlock frameBlock, LEVEL_ENUM level, String disguisedVal)
 	{
 		int row_idx = -1;
 		String pattern = "";
@@ -329,13 +313,14 @@ public class DMVUtils {
 					pattern = removeInnerCharacterInPattern(pattern, DIGIT, DOT);
 					pattern = removeInnerCharacterInPattern(pattern, ALPHA, SPACE);
 					pattern = acceptNegativeNumbersAsDigits(pattern);
+					break;
 				default:
-					//System.out.println("Could not find suitable level");
+					throw new DMLRuntimeException("Could not find suitable level");
 			}
 			row_idx++;
-			if(pattern.equals(dom_pattern)) continue;
-//			System.out.println("[" + level +"] Disguised value: " + frameBlock.get(row_idx, col_idx) + " (c=" + col_idx + ",r=" + row_idx + ")");
-			frameBlock.set(row_idx, col_idx, DISGUISED_VAL);
+			if(pattern.equals(dom_pattern))
+				continue;
+			frameBlock.set(row_idx, col_idx, disguisedVal);
 		}
 	}
 }
diff --git a/src/test/java/org/apache/sysds/test/functions/builtin/BuiltinDMVTest.java b/src/test/java/org/apache/sysds/test/functions/builtin/BuiltinDMVTest.java
index 10f4143..ccfabbf 100644
--- a/src/test/java/org/apache/sysds/test/functions/builtin/BuiltinDMVTest.java
+++ b/src/test/java/org/apache/sysds/test/functions/builtin/BuiltinDMVTest.java
@@ -35,166 +35,156 @@ import org.apache.sysds.test.TestUtils;
 
 public class BuiltinDMVTest extends AutomatedTestBase {
 
-    private final static String TEST_NAME = "disguisedMissingValue";
-    private final static String TEST_DIR = "functions/builtin/";
-    private static final String TEST_CLASS_DIR = TEST_DIR + BuiltinOutlierTest.class.getSimpleName() + "/";
-
-    @BeforeClass
-    public static void init() {
-        TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR);
-    }
-
-    @AfterClass
-    public static void cleanUp() {
-        if (TEST_CACHE_ENABLED) {
-            TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR);
-        }
-    }
-
-    @Override
-    public void setUp() {
-        TestUtils.clearAssertionInformation();
-        addTestConfiguration(TEST_NAME,new TestConfiguration(TEST_CLASS_DIR, TEST_NAME,new String[]{"B"}));
-        if (TEST_CACHE_ENABLED) {
-            setOutAndExpectedDeletionDisabled(true);
-        }
-    }
-
-    @Test
-    public void NormalStringFrameTest() {
-        FrameBlock f = generateRandomFrameBlock(1000, 4,null);
-        String[] disguised_values = new String[]{"?", "9999", "?", "9999"};
-        ArrayList<List<Integer>> positions = getDisguisedPositions(f, 4, disguised_values);
-        runMissingValueTest(f, ExecType.CP, 0.8, "DMV", positions);
-    }
-
-    @Test
-    public void PreDefinedStringsFrameTest() {
-        String[] testarray0 = new String[]{"77","77","55","89","43", "99", "46"}; // detect Weg
-        String[] testarray1 = new String[]{"8010","9999","8456","4565","89655", "86542", "45624"}; // detect ?
-        String[] testarray2 = new String[]{"David K","Valentin E","Patrick L","VEVE","DK", "VE", "PL"}; // detect 45
-        String[] testarray3 = new String[]{"3.42","45","0.456",".45","4589.245", "97", "33"}; // detect ka
-        String[] testarray4 = new String[]{"99","123","158","146","158", "174", "201"}; // detect 9999
-
-        String[][] teststrings = new String[][]{testarray0, testarray1, testarray2, testarray3, testarray4};
-        FrameBlock f = generateRandomFrameBlock(7, 5, teststrings);
-        String[] disguised_values = new String[]{"Patrick-Lovric-Weg-666", "?", "45", "ka", "9999"};
-        ArrayList<List<Integer>> positions = getDisguisedPositions(f, 1, disguised_values);
-        runMissingValueTest(f, ExecType.CP, 0.7,"NA", positions);
-    }
-
-    @Test
-    public void PreDefinedDoubleFrame() {
-        Double[] test_val = new Double[10000];
-        for(int i = 0; i < test_val.length; i++) {
-            test_val[i] = TestUtils.getPositiveRandomDouble();
-        }
-        String[] test_string = new String[test_val.length];
-        for(int j = 0; j < test_val.length; j++) {
-            test_string[j] = test_val[j].toString();
-        }
-
-        String[][] teststrings = new String[][]{test_string};
-        FrameBlock f = generateRandomFrameBlock(test_string.length, 1, teststrings);
-        String[] disguised_values = new String[]{"9999999999"};
-        ArrayList<List<Integer>> positions = getDisguisedPositions(f, 10, disguised_values);
-        runMissingValueTest(f, ExecType.CP, 0.6, "-1", positions);
-    }
-
-    private void runMissingValueTest(FrameBlock test_frame, ExecType et, Double threshold, String replacement,
-        ArrayList<List<Integer>> positions)
-    {
-        Types.ExecMode platformOld = setExecMode(et);
-
-        try {
-            getAndLoadTestConfiguration(TEST_NAME);
-
-            String HOME = SCRIPT_DIR + TEST_DIR;
-            fullDMLScriptName = HOME + TEST_NAME + ".dml";
-            programArgs = new String[] {"-nvargs", "F=" + input("F"), "O=" + output("O"),
-                    "threshold=" + threshold, "replacement=" + replacement
-            };
-
-            FrameWriterFactory.createFrameWriter(Types.FileFormat.CSV).
-                    writeFrameToHDFS(test_frame, input("F"), test_frame.getNumRows(), test_frame.getNumColumns());
-
-            runTest(true, false, null, -1);
-
-            FrameBlock outputFrame = readDMLFrameFromHDFS("O", Types.FileFormat.CSV);
-
-            for(int i = 0; i < positions.size(); i++) {
-                String[] output = (String[]) outputFrame.getColumnData(i);
-                for(int j = 0; j < positions.get(i).size(); j++) {
-                    if(replacement.equals("NA")) {
-                      TestUtils.compareScalars(null, output[positions.get(i).get(j)]);
-                    }
-                    else {
-                      TestUtils.compareScalars(replacement, output[positions.get(i).get(j)]);
-                    }
-                }
-            }
-        }
-        catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-        finally {
-            resetExecMode(platformOld);
-        }
-    }
-
-    private FrameBlock generateRandomFrameBlock(int rows, int cols, String[][] defined_strings)
-    {
-        Types.ValueType[] schema = new Types.ValueType[cols];
-        for(int i = 0; i < cols; i++) {
-            schema[i] = Types.ValueType.STRING;
-        }
-
-        if(defined_strings != null)
-        {
-            String[] names = new String[cols];
-            for(int i = 0; i < cols; i++)
-                names[i] = schema[i].toString();
-            FrameBlock frameBlock = new FrameBlock(schema, names);
-            frameBlock.ensureAllocatedColumns(rows);
-            for(int row = 0; row < rows; row++)
-                for(int col = 0; col < cols; col++)
-                    frameBlock.set(row, col, defined_strings[col][row]);
-            return frameBlock;
-        }
-        return TestUtils.generateRandomFrameBlock(rows, cols, schema ,TestUtils.getPositiveRandomInt());
-    }
-
-    private ArrayList<List<Integer>> getDisguisedPositions(FrameBlock frame, int amountValues, String[] disguisedValue)
-    {
-        ArrayList<List<Integer>> positions = new ArrayList<>();
-        int counter;
-        for(int i = 0; i < frame.getNumColumns(); i++)
-        {
-            counter = 0;
-            List<Integer> arrayToFill = new ArrayList<>();
-            while(counter < frame.getNumRows() && counter < amountValues)
-            {
-                int position = TestUtils.getPositiveRandomInt() % frame.getNumRows();
-                while(counter != 0 && arrayToFill.contains(position))
-                {
-                    position = (position + TestUtils.getPositiveRandomInt() + 5) % frame.getNumRows();
-                }
-                arrayToFill.add(position);
-                if(disguisedValue.length > 1)
-                {
-                    frame.set(position, i, disguisedValue[i]);
-                }
-                else if (disguisedValue.length == 1)
-                {
-                    frame.set(position, i, disguisedValue[0]);
-                }
-
-                counter++;
-            }
-            positions.add(i, arrayToFill);
-        }
-
-        return positions;
-    }
-
+	private final static String TEST_NAME = "disguisedMissingValue";
+	private final static String TEST_DIR = "functions/builtin/";
+	private static final String TEST_CLASS_DIR = TEST_DIR + BuiltinOutlierTest.class.getSimpleName() + "/";
+
+	@BeforeClass
+	public static void init() {
+		TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR);
+	}
+
+	@AfterClass
+	public static void cleanUp() {
+		if (TEST_CACHE_ENABLED) {
+			TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR);
+		}
+	}
+
+	@Override
+	public void setUp() {
+		TestUtils.clearAssertionInformation();
+		addTestConfiguration(TEST_NAME,new TestConfiguration(TEST_CLASS_DIR, TEST_NAME,new String[]{"B"}));
+		if (TEST_CACHE_ENABLED) {
+			setOutAndExpectedDeletionDisabled(true);
+		}
+	}
+
+	@Test
+	public void NormalStringFrameTest() {
+		FrameBlock f = generateRandomFrameBlock(1000, 4,null);
+		String[] disguised_values = new String[]{"?", "9999", "?", "9999"};
+		ArrayList<List<Integer>> positions = getDisguisedPositions(f, 4, disguised_values);
+		runMissingValueTest(f, ExecType.CP, 0.8, "DMV", positions);
+	}
+
+	@Test
+	public void PreDefinedStringsFrameTest() {
+		String[] testarray0 = new String[]{"77","77","55","89","43", "99", "46"}; // detect Weg
+		String[] testarray1 = new String[]{"8010","9999","8456","4565","89655", "86542", "45624"}; // detect ?
+		String[] testarray2 = new String[]{"David K","Valentin E","Patrick L","VEVE","DK", "VE", "PL"}; // detect 45
+		String[] testarray3 = new String[]{"3.42","45","0.456",".45","4589.245", "97", "33"}; // detect ka
+		String[] testarray4 = new String[]{"99","123","158","146","158", "174", "201"}; // detect 9999
+
+		String[][] teststrings = new String[][]{testarray0, testarray1, testarray2, testarray3, testarray4};
+		FrameBlock f = generateRandomFrameBlock(7, 5, teststrings);
+		String[] disguised_values = new String[]{"Patrick-Lovric-Weg-666", "?", "45", "ka", "9999"};
+		ArrayList<List<Integer>> positions = getDisguisedPositions(f, 1, disguised_values);
+		runMissingValueTest(f, ExecType.CP, 0.7,"NA", positions);
+	}
+
+	@Test
+	public void PreDefinedDoubleFrame() {
+		Double[] test_val = new Double[10000];
+		for(int i = 0; i < test_val.length; i++) {
+			test_val[i] = TestUtils.getPositiveRandomDouble();
+		}
+		String[] test_string = new String[test_val.length];
+		for(int j = 0; j < test_val.length; j++) {
+			test_string[j] = test_val[j].toString();
+		}
+
+		String[][] teststrings = new String[][]{test_string};
+		FrameBlock f = generateRandomFrameBlock(test_string.length, 1, teststrings);
+		String[] disguised_values = new String[]{"9999999999"};
+		ArrayList<List<Integer>> positions = getDisguisedPositions(f, 10, disguised_values);
+		runMissingValueTest(f, ExecType.CP, 0.6, "-1", positions);
+	}
+
+	private void runMissingValueTest(FrameBlock test_frame, ExecType et, Double threshold, String replacement,
+		ArrayList<List<Integer>> positions)
+	{
+		Types.ExecMode platformOld = setExecMode(et);
+
+		try {
+			getAndLoadTestConfiguration(TEST_NAME);
+
+			String HOME = SCRIPT_DIR + TEST_DIR;
+			fullDMLScriptName = HOME + TEST_NAME + ".dml";
+			programArgs = new String[] {"-nvargs", "F=" + input("F"),
+				"O=" + output("O"), "threshold=" + threshold, "replacement=" + replacement};
+
+			FrameWriterFactory.createFrameWriter(Types.FileFormat.CSV).
+					writeFrameToHDFS(test_frame, input("F"), test_frame.getNumRows(), test_frame.getNumColumns());
+
+			runTest(true, false, null, -1);
+
+			FrameBlock outputFrame = readDMLFrameFromHDFS("O", Types.FileFormat.CSV);
+
+			for(int i = 0; i < positions.size(); i++) {
+				String[] output = (String[]) outputFrame.getColumnData(i);
+				for(int j = 0; j < positions.get(i).size(); j++) {
+					if(replacement.equals("NA")) {
+					  TestUtils.compareScalars(null, output[positions.get(i).get(j)]);
+					}
+					else {
+					  TestUtils.compareScalars(replacement, output[positions.get(i).get(j)]);
+					}
+				}
+			}
+		}
+		catch (Exception ex) {
+			throw new RuntimeException(ex);
+		}
+		finally {
+			resetExecMode(platformOld);
+		}
+	}
+
+	private static FrameBlock generateRandomFrameBlock(int rows, int cols, String[][] defined_strings)
+	{
+		Types.ValueType[] schema = new Types.ValueType[cols];
+		for(int i = 0; i < cols; i++) {
+			schema[i] = Types.ValueType.STRING;
+		}
+
+		if(defined_strings != null) {
+			String[] names = new String[cols];
+			for(int i = 0; i < cols; i++)
+				names[i] = schema[i].toString();
+			FrameBlock frameBlock = new FrameBlock(schema, names);
+			frameBlock.ensureAllocatedColumns(rows);
+			for(int row = 0; row < rows; row++)
+				for(int col = 0; col < cols; col++)
+					frameBlock.set(row, col, defined_strings[col][row]);
+			return frameBlock;
+		}
+		return TestUtils.generateRandomFrameBlock(rows, cols, schema ,TestUtils.getPositiveRandomInt());
+	}
+
+	private static ArrayList<List<Integer>> getDisguisedPositions(FrameBlock frame,
+		int amountValues, String[] disguisedValue)
+	{
+		ArrayList<List<Integer>> positions = new ArrayList<>();
+		int counter;
+		for(int i = 0; i < frame.getNumColumns(); i++) {
+			counter = 0;
+			List<Integer> arrayToFill = new ArrayList<>();
+			while(counter < frame.getNumRows() && counter < amountValues) {
+				int position = TestUtils.getPositiveRandomInt() % frame.getNumRows();
+				while(counter != 0 && arrayToFill.contains(position)) {
+					position = (position + TestUtils.getPositiveRandomInt() + 5) % frame.getNumRows();
+				}
+				arrayToFill.add(position);
+				if(disguisedValue.length > 1)
+					frame.set(position, i, disguisedValue[i]);
+				else if (disguisedValue.length == 1)
+					frame.set(position, i, disguisedValue[0]);
+				counter++;
+			}
+			positions.add(i, arrayToFill);
+		}
+
+		return positions;
+	}
 }