Skip to content

Commit

Permalink
Merge pull request #564 from zinggAI/issue561
Browse files Browse the repository at this point in the history
issue 561, null pointer due to insufficient data
  • Loading branch information
sonalgoyal committed Apr 25, 2023
2 parents c456b40 + fc2db88 commit eb7ecb2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion common/core/src/main/java/zingg/common/core/block/Block.java
Expand Up @@ -11,6 +11,7 @@

import zingg.common.client.FieldDefinition;
import zingg.common.client.ZFrame;
import zingg.common.client.ZinggClientException;
import zingg.common.client.util.ListMap;
import zingg.common.core.hash.HashFunction;

Expand Down Expand Up @@ -201,9 +202,10 @@ protected void setFunctionsMap(ListMap<T, HashFunction<D,R,C,T>> m) {
* @param node
* @param used
* @return
* @throws ZinggClientException
*/
public Tree<Canopy<R>> getBlockingTree(Tree<Canopy<R>> tree, Canopy<R>parent,
Canopy<R>node, List<FieldDefinition> fieldsOfInterest) throws Exception {
Canopy<R>node, List<FieldDefinition> fieldsOfInterest) throws Exception, ZinggClientException {
if (LOG.isDebugEnabled()) {
LOG.debug("Tree so far ");
LOG.debug(tree);
Expand Down Expand Up @@ -253,6 +255,9 @@ public Tree<Canopy<R>> getBlockingTree(Tree<Canopy<R>> tree, Canopy<R>parent,
}
else {
LOG.debug("Min size reached " + size + " for node " + node);
if (tree==null) {
throw new ZinggClientException("Unable to create Zingg models due to insufficient data. Please run Zingg after adding more data");
}
}
// tree.addLeaf(parent, node);
node.clearBeforeSaving();
Expand Down
Expand Up @@ -44,7 +44,7 @@ public abstract Block<D,R,C,T> getBlock(ZFrame<D,R,C> sample, ZFrame<D,R,C> posi
public Tree<Canopy<R>> createBlockingTree(ZFrame<D,R,C> testData,
ZFrame<D,R,C> positives, double sampleFraction, long blockSize,
Arguments args,
ListMap<T, HashFunction<D,R,C,T>> hashFunctions) throws Exception {
ListMap<T, HashFunction<D,R,C,T>> hashFunctions) throws Exception, ZinggClientException {
ZFrame<D,R,C> sample = testData.sample(false, sampleFraction);
sample = sample.cache();
long totalCount = sample.count();
Expand Down Expand Up @@ -82,7 +82,7 @@ public Tree<Canopy<R>> createBlockingTree(ZFrame<D,R,C> testData,

public Tree<Canopy<R>> createBlockingTreeFromSample(ZFrame<D,R,C> testData,
ZFrame<D,R,C> positives, double sampleFraction, long blockSize, Arguments args,
ListMap hashFunctions) throws Exception {
ListMap hashFunctions) throws Exception, ZinggClientException {
ZFrame<D,R,C> sample = testData.sample(false, sampleFraction);
return createBlockingTree(sample, positives, sampleFraction, blockSize, args, hashFunctions);
}
Expand Down

0 comments on commit eb7ecb2

Please sign in to comment.