Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blockSize - a new config paramter for max size of the block #272

Merged
merged 6 commits into from May 23, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion client/src/main/java/zingg/client/Arguments.java
Expand Up @@ -106,6 +106,7 @@ public class Arguments implements Serializable {
boolean collectMetrics = true;
boolean showConcise = false;
float stopWordsCutoff = 0.1f;
long blockSize = 100L;

private static final String ENV_VAR_MARKER_START = "$";
private static final String ENV_VAR_MARKER_END = "$";
Expand Down Expand Up @@ -622,7 +623,15 @@ public boolean getShowConcise() {
public void setShowConcise(boolean showConcise) {
this.showConcise = showConcise;
}


public long getblockSize() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camel casing is missing - getBlockSize, same for setter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will break the json parsing - please also test one end to end case with 120l records and set block size in args. Use debug logs to verify

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to Camel Case.
Ran with examples/febrl120k/config.json. Output attached. Appropriate block size was selected.

return blockSize;
}

public void setblockSize(long blockSize){
this.blockSize = blockSize;
}

public String[] getPipeNames() {
Pipe[] input = this.getData();
String[] sourceNames = new String[input.length];
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/zingg/util/BlockingTreeUtil.java
Expand Up @@ -44,7 +44,7 @@ public static Tree<Canopy> createBlockingTree(Dataset<Row> testData,
LOG.debug("Learning blocking rules for sample count " + totalCount
+ " and pos " + positives.count() + " and testData count " + testData.count());
}
if (blockSize == -1) blockSize = Heuristics.getMaxBlockSize(totalCount);
if (blockSize == -1) blockSize = Heuristics.getMaxBlockSize(totalCount, args.getblockSize());
LOG.info("Learning indexing rules for block size " + blockSize);

positives = positives.coalesce(1);
Expand Down
10 changes: 4 additions & 6 deletions core/src/main/java/zingg/util/Heuristics.java
Expand Up @@ -3,21 +3,19 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import zingg.block.Block;

public class Heuristics {

public static final Log LOG = LogFactory.getLog(Heuristics.class);

public static long getMaxBlockSize(long totalCount) {
public static final long MIN_SIZE = 8L;
public static long getMaxBlockSize(long totalCount, long blockSizeFromConfig) {
long maxSize = 8;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt this be set to the min size var ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used MIN_SIZE

/*if (totalCount > 100 && totalCount < 500){
maxSize = totalCount / 5;
}
else {*/
maxSize = (long) (0.001 * totalCount);
LOG.debug("**Block size found **" + maxSize);
if (maxSize > 100) maxSize = 100;
LOG.debug("**Block size found **");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please print max size here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored

if (maxSize > blockSizeFromConfig) maxSize = blockSizeFromConfig;
if (maxSize <= 8) maxSize = 8;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the defined constant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used MIN_SIZE

//}
LOG.info("**Block size **" + maxSize + " and total count was " + totalCount);
Expand Down
34 changes: 34 additions & 0 deletions core/src/test/java/zingg/util/TestHeuristics.java
@@ -0,0 +1,34 @@
package zingg.util;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

public class TestHeuristics {
long blockSizeConfigured = 50L;

@Test
public void testMaxBlockSizeWhenCalculatedValueIsMoreThanConfigValue() throws Throwable {
long size = Heuristics.getMaxBlockSize(70000, blockSizeConfigured);
assertEquals(size, 50);
}

@Test
public void testMaxBlockSizeWhenCalculatedValueIsLessThanConfigValueButMoreThanMinValue() throws Throwable {
long size = Heuristics.getMaxBlockSize(25000, blockSizeConfigured);
assertEquals(size, 25);
}

@Test
public void testMaxBlockSizeWhenCalculatedValueIsLessThanMinValue() throws Throwable {
long size = Heuristics.getMaxBlockSize(5000, blockSizeConfigured);
assertEquals(size, Heuristics.MIN_SIZE);
}

@Test
public void testMaxBlockSizeWhenConfigValueItselfIsLessThanMinValue() throws Throwable {
long blockSizeConfigured = 5L;
long size = Heuristics.getMaxBlockSize(25000, blockSizeConfigured);
assertEquals(size, Heuristics.MIN_SIZE);
}
}