private void updateSegmentationCache(String segmentName) throws HiveException, LensException { if (enableCaching) { allSegmentations.put(segmentName.trim().toLowerCase(), new Segmentation(refreshTable(segmentName))); } }
private void updateSegmentationCache(String segmentName) throws HiveException, LensException { if (enableCaching) { allSegmentations.put(segmentName.trim().toLowerCase(), new Segmentation(refreshTable(segmentName))); } }
public Segmentation getSegmentationTable(String tableName) throws HiveException, LensException { return new Segmentation(getTableWithTypeFailFast(tableName, CubeTableType.SEGMENTATION)); }
public Segmentation getSegmentationTable(String tableName) throws HiveException, LensException { return new Segmentation(getTableWithTypeFailFast(tableName, CubeTableType.SEGMENTATION)); }
public Segmentation getSegmentation(String segName, boolean throwException) throws LensException { segName = segName.trim().toLowerCase(); Segmentation seg = allSegmentations.get(segName); if (seg == null) { synchronized (allSegmentations) { if (!allSegmentations.containsKey(segName)) { Table tbl = getTableWithType(segName, CubeTableType.SEGMENTATION, throwException); seg = tbl == null ? null : new Segmentation(tbl); if (enableCaching && seg != null) { allSegmentations.put(segName, seg); } } else { seg = allSegmentations.get(segName); } } } return seg; }
public Segmentation getSegmentation(String segName, boolean throwException) throws LensException { segName = segName.trim().toLowerCase(); Segmentation seg = allSegmentations.get(segName); if (seg == null) { synchronized (allSegmentations) { if (!allSegmentations.containsKey(segName)) { Table tbl = getTableWithType(segName, CubeTableType.SEGMENTATION, throwException); seg = tbl == null ? null : new Segmentation(tbl); if (enableCaching && seg != null) { allSegmentations.put(segName, seg); } } else { seg = allSegmentations.get(segName); } } } return seg; }
/** * * @param baseCubeName The cube name ot which segmentation belong to * @param segmentationName The segmentation name * @param segments Participating cube segements * @param weight Weight of segmentation * @param properties Properties of segmentation * @throws LensException */ public void createSegmentation(String baseCubeName, String segmentationName, Set<Segment> segments, double weight, Map<String, String> properties) throws LensException { Segmentation cubeSeg = new Segmentation(baseCubeName, segmentationName, segments, weight, properties); createSegmentation(cubeSeg); // do a get to update cache getSegmentation(segmentationName); }
/** * * @param baseCubeName The cube name ot which segmentation belong to * @param segmentationName The segmentation name * @param segments Participating cube segements * @param weight Weight of segmentation * @param properties Properties of segmentation * @throws LensException */ public void createSegmentation(String baseCubeName, String segmentationName, Set<Segment> segments, double weight, Map<String, String> properties) throws LensException { Segmentation cubeSeg = new Segmentation(baseCubeName, segmentationName, segments, weight, properties); createSegmentation(cubeSeg); // do a get to update cache getSegmentation(segmentationName); }
public static Segmentation segmentationFromXSegmentation(XSegmentation seg) throws LensException { Map<String, String> props = new HashMap<>(); // Skip properties with keyword internal. These properties are internal to lens // and users are not supposed to see them. for(String prop : mapFromXProperties(seg.getProperties()).keySet()) { if (!(prop.toLowerCase().startsWith(MetastoreConstants.SEGMENTATION_KEY_PFX))) { props.put(prop, mapFromXProperties(seg.getProperties()).get(prop)); } } return new Segmentation(seg.getCubeName(), seg.getName(), segmentsFromXSegments(seg.getSegements()), seg.getWeight(), props); }
public static Segmentation segmentationFromXSegmentation(XSegmentation seg) throws LensException { Map<String, String> props = new HashMap<>(); // Skip properties with keyword internal. These properties are internal to lens // and users are not supposed to see them. for(String prop : mapFromXProperties(seg.getProperties()).keySet()) { if (!(prop.toLowerCase().startsWith(MetastoreConstants.SEGMENTATION_KEY_PFX))) { props.put(prop, mapFromXProperties(seg.getProperties()).get(prop)); } } return new Segmentation(seg.getCubeName(), seg.getName(), segmentsFromXSegments(seg.getSegements()), seg.getWeight(), props); }
Segmentation segmentation = new Segmentation(Hive.get(conf).getTable(segmentName)); segmentation.addSegment(seg5); segmentation.addProperties(new HashMap<String, String>(){{put("new_key", "new_val"); }});