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

Java/Scala API should allow passing feature list as a list of string #12 #13

Merged
merged 1 commit into from
Feb 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@JsonIgnoreProperties(ignoreUnknown = true)
public class FeatureGroup {
Expand Down Expand Up @@ -57,7 +58,14 @@ public void show(int numRows) throws FeatureStoreException, IOException {
selectAll().show(numRows);
}

public Query select(List<Feature> features) throws FeatureStoreException, IOException {
public Query select(List<String> features) throws FeatureStoreException, IOException {
// Create a feature object for each string feature given by the user.
// For the query building each feature need only the name set.
List<Feature> featureObjList = features.stream().map(Feature::new).collect(Collectors.toList());
return selectFeatures(featureObjList);
}

public Query selectFeatures(List<Feature> features) throws FeatureStoreException, IOException {
return new Query(this, features);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Query {

Expand All @@ -38,25 +39,45 @@ public Query join(Query subquery) {
return join(subquery, JoinType.INNER);
}

public Query join(Query subquery, List<Feature> on) {
return join(subquery, on, JoinType.INNER);
public Query join(Query subquery, List<String> on) {
return joinFeatures(subquery, on.stream().map(Feature::new).collect(Collectors.toList()), JoinType.INNER);
}

public Query join(Query subquery, List<Feature> leftOn, List<Feature> rightOn) {
return join(subquery, leftOn, rightOn, JoinType.INNER);
public Query joinFeatures(Query subquery, List<Feature> on) {
return joinFeatures(subquery, on, JoinType.INNER);
}

public Query join(Query subquery, List<String> leftOn, List<String> rightOn) {
return joinFeatures(subquery, leftOn.stream().map(Feature::new).collect(Collectors.toList()),
rightOn.stream().map(Feature::new).collect(Collectors.toList()), JoinType.INNER);
}

public Query joinFeatures(Query subquery, List<Feature> leftOn, List<Feature> rightOn) {
return joinFeatures(subquery, leftOn, rightOn, JoinType.INNER);
}

public Query join(Query subquery, JoinType joinType) {
joins.add(new Join(subquery, joinType));
return this;
}

public Query join(Query subquery, List<Feature> on, JoinType joinType) {
public Query join(Query subquery, List<String> on, JoinType joinType) {
joins.add(new Join(subquery, on.stream().map(Feature::new).collect(Collectors.toList()), joinType));
return this;
}

public Query joinFeatures(Query subquery, List<Feature> on, JoinType joinType) {
joins.add(new Join(subquery, on, joinType));
return this;
}

public Query join(Query subquery, List<Feature> leftOn, List<Feature> rightOn, JoinType joinType) {
public Query join(Query subquery, List<String> leftOn, List<String> rightOn, JoinType joinType) {
joins.add(new Join(subquery, leftOn.stream().map(Feature::new).collect(Collectors.toList()),
rightOn.stream().map(Feature::new).collect(Collectors.toList()), joinType));
return this;
}

public Query joinFeatures(Query subquery, List<Feature> leftOn, List<Feature> rightOn, JoinType joinType) {
joins.add(new Join(subquery, leftOn, rightOn, joinType));
return this;
}
Expand Down