Search in sources :

Example 16 with Featuregroup

use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup in project hopsworks by logicalclocks.

the class TestJoinController method setup.

@Before
public void setup() {
    fs = new Featurestore();
    fs.setHiveDbId(1l);
    fs.setProject(new Project("test_proj"));
    cachedFeaturegroup = new CachedFeaturegroup();
    cachedFeaturegroup.setTimeTravelFormat(TimeTravelFormat.NONE);
    fg1 = new Featuregroup(1);
    fg1.setName("fg1");
    fg1.setVersion(1);
    fg1.setCachedFeaturegroup(cachedFeaturegroup);
    fg1.setFeaturestore(fs);
    fg2 = new Featuregroup(2);
    fg2.setName("fg2");
    fg2.setVersion(1);
    fg2.setCachedFeaturegroup(cachedFeaturegroup);
    fg2.setFeaturestore(fs);
    joinController = new JoinController(new ConstructorController());
}
Also used : Project(io.hops.hopsworks.persistence.entity.project.Project) Featurestore(io.hops.hopsworks.persistence.entity.featurestore.Featurestore) Featuregroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup) CachedFeaturegroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.CachedFeaturegroup) ConstructorController(io.hops.hopsworks.common.featurestore.query.ConstructorController) CachedFeaturegroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.CachedFeaturegroup) Before(org.junit.Before)

Example 17 with Featuregroup

use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup in project hopsworks by logicalclocks.

the class TrainingDatasetControllerTest method testConvertToFilterLogic_multipleConditions.

public void testConvertToFilterLogic_multipleConditions() throws Exception {
    // fg.feature > 1 and fg.feature > 2
    List<TrainingDatasetFilter> filters = new ArrayList<>();
    filters.add(createTrainingDatasetFilter(null, AND, "L"));
    filters.add(createTrainingDatasetFilter(createTrainingDatasetFilterCondition("test_f", GREATER_THAN, "2", 0), SINGLE, "L.R"));
    filters.add(createTrainingDatasetFilter(createTrainingDatasetFilterCondition("test_f", GREATER_THAN, "1", 0), SINGLE, "L.L"));
    Map<String, Feature> featureLookup = Maps.newHashMap();
    Feature feature = new Feature("test_f", "fg0");
    Featuregroup featuregroup = new Featuregroup();
    featuregroup.setId(0);
    feature.setFeatureGroup(featuregroup);
    featureLookup.put("0.test_f", feature);
    FilterLogic actual = target.convertToFilterLogic(filters, featureLookup, "L");
    Feature f1 = new Feature("test_f", "fg0", null, false, null, null);
    f1.setFeatureGroup(featuregroup);
    Filter left = new Filter(f1, GREATER_THAN, "1");
    Filter right = new Filter(f1, GREATER_THAN, "2");
    Assert.assertEquals(actual.getType(), AND);
    Assert.assertEquals(actual.getLeftFilter(), left);
    Assert.assertNull(actual.getLeftLogic());
    Assert.assertEquals(actual.getRightFilter(), right);
    Assert.assertNull(actual.getRightLogic());
}
Also used : TrainingDatasetFilter(io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDatasetFilter) TrainingDatasetFilter(io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDatasetFilter) Filter(io.hops.hopsworks.common.featurestore.query.filter.Filter) SqlFilterLogic(io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.SqlFilterLogic) FilterLogic(io.hops.hopsworks.common.featurestore.query.filter.FilterLogic) Featuregroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup) ArrayList(java.util.ArrayList) Feature(io.hops.hopsworks.common.featurestore.query.Feature)

Example 18 with Featuregroup

use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup in project hopsworks by logicalclocks.

the class TestPitJoinController method testAddEventTimeOn.

@Test
public void testAddEventTimeOn() {
    Featuregroup fg1 = new Featuregroup(1);
    fg1.setEventTime("ts");
    List<Feature> oldOn = Collections.singletonList(new Feature("ft1"));
    List<Feature> newOn = pitJoinController.addEventTimeOn(oldOn, fg1, "fg0");
    Assert.assertEquals(2, newOn.size());
    // should respect order
    Assert.assertEquals("ts", newOn.get(1).getName());
}
Also used : Featuregroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup) CachedFeaturegroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.CachedFeaturegroup) Feature(io.hops.hopsworks.common.featurestore.query.Feature) Test(org.junit.Test)

Example 19 with Featuregroup

use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup in project hopsworks by logicalclocks.

the class TestPitJoinController method testIsPitEnabledTrueQuery.

@Test
public void testIsPitEnabledTrueQuery() {
    Featuregroup fg1 = new Featuregroup(1);
    fg1.setEventTime("ts");
    Featuregroup fg2 = new Featuregroup(2);
    fg2.setEventTime("ts");
    Query right1 = new Query("fs", fg1);
    Query right2 = new Query("fs", fg2);
    Query leftQuery = new Query("fs", fg1);
    Join join1 = new Join(leftQuery, right1, null, null, null, null, null);
    Join join2 = new Join(leftQuery, right2, null, null, null, null, null);
    List<Join> joins = Arrays.asList(join1, join2);
    leftQuery.setJoins(joins);
    Assert.assertEquals(true, pitJoinController.isPitEnabled(leftQuery));
}
Also used : Query(io.hops.hopsworks.common.featurestore.query.Query) Featuregroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup) CachedFeaturegroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.CachedFeaturegroup) Join(io.hops.hopsworks.common.featurestore.query.join.Join) Test(org.junit.Test)

Example 20 with Featuregroup

use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup in project hopsworks by logicalclocks.

the class TestPitJoinController method testDropIrrelevantSubqueryFeatures.

@Test
public void testDropIrrelevantSubqueryFeatures() {
    Featuregroup fg1 = new Featuregroup(1);
    Featuregroup fg2 = new Featuregroup(2);
    Featuregroup fg3 = new Featuregroup(3);
    Query leftQuery = new Query("fs", fg1);
    List<Feature> selectedFeatures = Arrays.asList(new Feature(fg1), new Feature(fg2), new Feature(fg1), new Feature(fg3));
    leftQuery.setFeatures(selectedFeatures);
    Query rightQuery = new Query("fs", fg3);
    List<Feature> filteredSelect = pitJoinController.dropIrrelevantSubqueryFeatures(leftQuery, rightQuery);
    Assert.assertEquals(3, filteredSelect.size());
}
Also used : Query(io.hops.hopsworks.common.featurestore.query.Query) Featuregroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup) CachedFeaturegroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.CachedFeaturegroup) Feature(io.hops.hopsworks.common.featurestore.query.Feature) Test(org.junit.Test)

Aggregations

Featuregroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup)48 CachedFeaturegroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.CachedFeaturegroup)20 Users (io.hops.hopsworks.persistence.entity.user.Users)19 ArrayList (java.util.ArrayList)17 Project (io.hops.hopsworks.persistence.entity.project.Project)15 Path (javax.ws.rs.Path)13 DatasetPath (io.hops.hopsworks.common.dataset.util.DatasetPath)12 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)12 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)11 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)11 FeatureGroupFeatureDTO (io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO)11 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)11 Featurestore (io.hops.hopsworks.persistence.entity.featurestore.Featurestore)11 ApiOperation (io.swagger.annotations.ApiOperation)11 Produces (javax.ws.rs.Produces)11 FeaturegroupController (io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupController)9 Feature (io.hops.hopsworks.common.featurestore.query.Feature)9 FilterController (io.hops.hopsworks.common.featurestore.query.filter.FilterController)8 OnDemandFeaturegroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.ondemand.OnDemandFeaturegroup)8 HashMap (java.util.HashMap)8