use of io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView in project hopsworks by logicalclocks.
the class FeatureViewFacade method findByFeaturestore.
public List<FeatureView> findByFeaturestore(Featurestore featurestore, QueryParam queryParam) {
Boolean latestVersion = false;
if (queryParam.getFilters().removeIf(filter -> filter.toString().equals("LATEST_VERSION"))) {
latestVersion = true;
}
Map<String, Object> extraParam = new HashMap<>();
extraParam.put("featurestore", featurestore);
String queryStr = buildQuery("SELECT fv FROM FeatureView fv ", queryParam.getFilters(), queryParam.getSorts(), "fv.featurestore = :featurestore ");
Query q = makeQuery(queryStr, queryParam, extraParam);
List<FeatureView> results = q.getResultList();
if (latestVersion) {
results = retainLatestVersion(results);
}
return results;
}
use of io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView in project hopsworks by logicalclocks.
the class FeatureViewFacadeTest method createFeatureView.
public FeatureView createFeatureView(String name, Integer version) {
FeatureView featureView = new FeatureView();
featureView.setName(name);
featureView.setVersion(version);
return featureView;
}
use of io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView in project hopsworks by logicalclocks.
the class FeatureViewFacadeTest method testRetainLatestVersion.
@Test
public void testRetainLatestVersion() {
FeatureView featureView1_1 = createFeatureView("test1", 1);
FeatureView featureView1_2 = createFeatureView("test1", 2);
FeatureView featureView2_1 = createFeatureView("test2", 1);
FeatureView featureView2_2 = createFeatureView("test2", 2);
FeatureView featureView3_1 = createFeatureView("test3", 1);
List<FeatureView> featureViews = Lists.newArrayList(featureView1_1, featureView1_2, featureView2_1, featureView2_2, featureView3_1);
List<FeatureView> actual = target.retainLatestVersion(featureViews);
List<FeatureView> expected = Lists.newArrayList(featureView1_2, featureView2_2, featureView3_1);
assertEquals(actual.size(), expected.size());
assertTrue(actual.containsAll(expected));
assertTrue(expected.containsAll(actual));
}
use of io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView in project hopsworks by logicalclocks.
the class FeatureViewResource method getAll.
@GET
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Get all Feature View metadata.", response = FeatureViewDTO.class)
public Response getAll(@Context SecurityContext sc, @Context HttpServletRequest req, @Context UriInfo uriInfo, @BeanParam FeatureViewBeanParam param) throws FeaturestoreException, ServiceException, IOException, MetadataException, DatasetException, SchematizedTagException {
Users user = jWTHelper.getUserPrincipal(sc);
ResourceRequest resourceRequest = makeResourceRequest(param);
List<FeatureView> featureViews = featureViewController.getByFeatureStore(featurestore, resourceRequest);
return Response.ok().entity(featureViewBuilder.build(featureViews, resourceRequest, project, user, uriInfo)).build();
}
use of io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView in project hopsworks by logicalclocks.
the class FeatureViewResource method getByNameVersion.
@GET
@Path("/{name: [a-z0-9_]*(?=[a-z])[a-z0-9_]+}/version/{version: [0-9]+}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Get Feature View metadata by name and version.", response = FeatureViewDTO.class)
public Response getByNameVersion(@Context SecurityContext sc, @Context HttpServletRequest req, @Context UriInfo uriInfo, @BeanParam FeatureViewBeanParam param, @ApiParam(value = "Name of the feature view", required = true) @PathParam("name") String name, @PathParam("version") Integer version) throws FeaturestoreException, ServiceException, IOException, MetadataException, DatasetException, SchematizedTagException {
Users user = jWTHelper.getUserPrincipal(sc);
ResourceRequest resourceRequest = makeResourceRequest(param);
List<FeatureView> featureViews = featureViewController.getByNameVersionAndFeatureStore(name, version, featurestore, resourceRequest);
return Response.ok().entity(featureViewBuilder.build(featureViews, resourceRequest, project, user, uriInfo)).build();
}
Aggregations