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
using data selector as wrapper over raw data #815
Changes from 2 commits
704c503
d6acbef
c14132c
6b53d07
02b3e46
5c5e845
d344cf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package zingg.common.core.data.df; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import zingg.common.client.IArguments; | ||
import zingg.common.client.ZFrame; | ||
import zingg.common.client.ZinggClientException; | ||
import zingg.common.client.cols.ZidAndFieldDefSelector; | ||
import zingg.common.client.util.ColName; | ||
import zingg.common.core.block.Canopy; | ||
import zingg.common.core.block.Tree; | ||
import zingg.common.core.context.Context; | ||
import zingg.common.core.preprocess.StopWordsRemover; | ||
import zingg.common.core.util.Analytics; | ||
import zingg.common.core.util.Metric; | ||
|
||
public class ZFrameDataSelector<S, D, R, C, T> { | ||
|
||
protected ZFrame<D,R,C> rawData; | ||
protected ZFrame<D,R,C> fieldDefColumnsDS; | ||
protected ZFrame<D,R,C> blockedData; | ||
protected IArguments args; | ||
protected Context<S,D,R,C,T> context; | ||
protected StopWordsRemover<S, D, R, C, T> stopWordsRemover; | ||
protected ZFrame<D, R, C> preprocessedRepartitionedData; | ||
|
||
public static final Log LOG = LogFactory.getLog(ZFrameDataSelector.class); | ||
|
||
public ZFrameDataSelector(ZFrame<D, R, C> rawData, IArguments args, Context<S,D,R,C,T> context,StopWordsRemover<S, D, R, C, T> stopWordsRemover) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this class shuld not be aware of the blocking tree loading and context etc. it should get the blocking tree and have a method to apply it. |
||
super(); | ||
this.rawData = rawData; | ||
this.args = args; | ||
this.context = context; | ||
this.stopWordsRemover = stopWordsRemover; | ||
} | ||
|
||
public ZFrame<D, R, C> getRawData() { | ||
return rawData; | ||
} | ||
|
||
public ZFrame<D, R, C> getFieldDefColumnsDS() { | ||
if (fieldDefColumnsDS==null) { | ||
ZidAndFieldDefSelector zidAndFieldDefSelector = new ZidAndFieldDefSelector(args.getFieldDefinition()); | ||
fieldDefColumnsDS = getRawData().select(zidAndFieldDefSelector.getCols()); | ||
} | ||
return fieldDefColumnsDS; | ||
// return getDSUtil().getFieldDefColumnsDS(testDataOriginal, args, true); | ||
} | ||
|
||
public ZFrame<D, R, C> getPreprocessedRepartitionedData() { | ||
return preprocessedRepartitionedData; | ||
} | ||
|
||
public ZFrame<D,R,C> getBlocked() throws Exception, ZinggClientException{ | ||
if (blockedData==null) { | ||
preprocessedRepartitionedData = stopWordsRemover.preprocessForStopWords(getFieldDefColumnsDS()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be a separate method |
||
preprocessedRepartitionedData = preprocessedRepartitionedData.repartition(args.getNumPartitions(), preprocessedRepartitionedData.col(ColName.ID_COL)); | ||
//testData = dropDuplicates(testData); | ||
long count = preprocessedRepartitionedData.count(); | ||
LOG.info("Read " + count); | ||
Analytics.track(Metric.DATA_COUNT, count, args.getCollectMetrics()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. count should be a method on this and Analytics should not be a part of this object - it should be driven from the executor |
||
LOG.debug("Blocking model file location is " + args.getBlockFile()); | ||
ZFrame<D, R, C> blocked1; //.cache(); | ||
Tree<Canopy<R>> tree = context.getBlockingTreeUtil().readBlockingTree(args); | ||
ZFrame<D, R, C> blocked = context.getBlockingTreeUtil().getBlockHashes(preprocessedRepartitionedData, tree); | ||
blocked1 = blocked.repartition(args.getNumPartitions(), blocked.col(ColName.HASH_COL)); | ||
this.blockedData = blocked1; | ||
} | ||
return blockedData; | ||
} | ||
|
||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to ZData