You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by pr...@apache.org on 2016/05/18 09:25:48 UTC
[1/2] lens git commit: LENS-1040 : cubesegmentation commands are
conflicting with cube commands
Repository: lens
Updated Branches:
refs/heads/master f3e6bc542 -> 20c1a53f4
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-server/src/main/java/org/apache/lens/server/metastore/JAXBUtils.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/metastore/JAXBUtils.java b/lens-server/src/main/java/org/apache/lens/server/metastore/JAXBUtils.java
index 1e11325..1b6b819 100644
--- a/lens-server/src/main/java/org/apache/lens/server/metastore/JAXBUtils.java
+++ b/lens-server/src/main/java/org/apache/lens/server/metastore/JAXBUtils.java
@@ -502,20 +502,20 @@ public final class JAXBUtils {
return xpList;
}
- public static Set<XCubeSegment> xCubeSegmentsFromCubeSegments(Set<CubeSegment> segs) {
- Set<XCubeSegment> xsegs = new HashSet<XCubeSegment>();
+ public static Set<XSegment> xSegmentsFromSegments(Set<Segment> segs) {
+ Set<XSegment> xsegs = new HashSet<XSegment>();
if (segs != null && !segs.isEmpty()) {
- for (CubeSegment seg : segs) {
- XCubeSegment xcubeSeg = XCF.createXCubeSegment();
+ for (Segment seg : segs) {
+ XSegment xcubeSeg = XCF.createXSegment();
xcubeSeg.setCubeName(seg.getName());
- xcubeSeg.setSegmentParameters(getXpropertiesFromCubeSegment(seg));
+ xcubeSeg.setSegmentParameters(getXpropertiesFromSegment(seg));
xsegs.add(xcubeSeg);
}
}
return xsegs;
}
- public static XProperties getXpropertiesFromCubeSegment(CubeSegment cseg) {
+ public static XProperties getXpropertiesFromSegment(Segment cseg) {
XProperties xproperties = XCF.createXProperties();
for (String prop : cseg.getProperties().keySet()) {
String segPrefix = MetastoreUtil.getSegmentPropertyKey(cseg.getName());
@@ -699,7 +699,7 @@ public final class JAXBUtils {
mapFromXProperties(fact.getProperties()));
}
- public static CubeSegmentation cubeSegmentationFromXCubeSegmentation(XCubeSegmentation seg) throws LensException {
+ 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
@@ -709,9 +709,9 @@ public final class JAXBUtils {
props.put(prop, mapFromXProperties(seg.getProperties()).get(prop));
}
}
- return new CubeSegmentation(seg.getCubeName(),
+ return new Segmentation(seg.getCubeName(),
seg.getName(),
- cubeSegmentsFromXCubeSegments(seg.getCubeSegements()),
+ segmentsFromXSegments(seg.getSegements()),
seg.getWeight(),
props);
}
@@ -731,18 +731,18 @@ public final class JAXBUtils {
return fact;
}
- public static XCubeSegmentation xsegmentationFromCubeSegmentation(CubeSegmentation cSeg) {
- XCubeSegmentation seg = XCF.createXCubeSegmentation();
+ public static XSegmentation xsegmentationFromSegmentation(Segmentation cSeg) {
+ XSegmentation seg = XCF.createXSegmentation();
seg.setName(cSeg.getName());
seg.setProperties(new XProperties());
- seg.setCubeSegements(new XCubeSegments());
+ seg.setSegements(new XSegments());
seg.setWeight(cSeg.weight());
seg.setCubeName(cSeg.getBaseCube());
if (xPropertiesFromMap(cSeg.getProperties()) != null) {
seg.getProperties().getProperty().addAll(xPropertiesFromMap(cSeg.getProperties()));
}
- seg.getCubeSegements().getCubeSegment().
- addAll(xCubeSegmentsFromCubeSegments(cSeg.getCubeSegments()));
+ seg.getSegements().getSegment().
+ addAll(xSegmentsFromSegments(cSeg.getSegments()));
return seg;
}
@@ -843,16 +843,16 @@ public final class JAXBUtils {
return storageTableMap;
}
- public static Set<CubeSegment> cubeSegmentsFromXCubeSegments(XCubeSegments segs) {
- Set<CubeSegment> cubeSegs = new HashSet<>();
- for (XCubeSegment xcube : segs.getCubeSegment()){
+ public static Set<Segment> segmentsFromXSegments(XSegments segs) {
+ Set<Segment> cubeSegs = new HashSet<>();
+ for (XSegment xcube : segs.getSegment()){
Map<String, String> segProp = new HashMap<>();
if (xcube.getSegmentParameters() != null) {
for (XProperty prop : xcube.getSegmentParameters().getProperty()) {
segProp.put(prop.getName(), prop.getValue());
}
}
- cubeSegs.add(new CubeSegment(xcube.getCubeName(), segProp));
+ cubeSegs.add(new Segment(xcube.getCubeName(), segProp));
}
return cubeSegs;
}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-server/src/main/java/org/apache/lens/server/metastore/MetastoreResource.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/metastore/MetastoreResource.java b/lens-server/src/main/java/org/apache/lens/server/metastore/MetastoreResource.java
index 7395c83..6f10d58 100644
--- a/lens-server/src/main/java/org/apache/lens/server/metastore/MetastoreResource.java
+++ b/lens-server/src/main/java/org/apache/lens/server/metastore/MetastoreResource.java
@@ -146,13 +146,13 @@ public class MetastoreResource {
SEGMENTATION {
@Override
public List<String> doGetAll(LensSessionHandle sessionid) throws LensException {
- return getSvc().getAllCubeSegmentations(sessionid, null);
+ return getSvc().getAllSegmentations(sessionid, null);
}
@Override
public void doDelete(LensSessionHandle sessionid, String entityName, Boolean cascade) throws LensException {
if (cascade == null) {
- getSvc().dropCubeSegmentation(sessionid, entityName);
+ getSvc().dropSegmentation(sessionid, entityName);
} else {
throw new NotImplementedException();
}
@@ -807,20 +807,20 @@ public class MetastoreResource {
}
/**
- * Get all cube segmentations that belong to a cube in the metastore
+ * Get all segmentations that belong to a cube in the metastore
*
* @param sessionid The sessionid in which user is working
* @param cubeName name of the base cube or derived cube
- * @return List of {@link XCubeSegmentation} objects
+ * @return List of {@link XSegmentation} objects
*/
@GET
- @Path("/cubes/{cubeName}/cubesegmentations")
- public StringList getAllCubeSegmentationsOfCube(
+ @Path("/cubes/{cubeName}/segmentations")
+ public StringList getAllSegmentationsOfCube(
@QueryParam("sessionid") LensSessionHandle sessionid, @PathParam("cubeName") String cubeName)
throws LensException {
checkSessionId(sessionid);
try {
- return new StringList(getSvc().getAllCubeSegmentations(sessionid, cubeName));
+ return new StringList(getSvc().getAllSegmentations(sessionid, cubeName));
} catch (LensException exc) {
checkTableNotFound(exc, cubeName);
throw exc;
@@ -843,14 +843,14 @@ public class MetastoreResource {
/**
- * Get all cube segmentations in the current database
+ * Get all segmentations in the current database
*
* @param sessionid The sessionid in which user is working
- * @return StringList consisting of all cube segmentations
+ * @return StringList consisting of all segmentations
*/
@GET
- @Path("/cubesegmentations")
- public StringList getAllCubeSegmentations(@QueryParam("sessionid") LensSessionHandle sessionid)
+ @Path("/segmentations")
+ public StringList getAllSegmentations(@QueryParam("sessionid") LensSessionHandle sessionid)
throws LensException {
checkSessionId(sessionid);
return Entity.SEGMENTATION.getAll(sessionid);
@@ -874,15 +874,15 @@ public class MetastoreResource {
}
/**
- * Delete all cube segmentations
+ * Delete all segmentations
*
* @param sessionid The sessionid in which user is working
* @return APIResult with state {@link Status#SUCCEEDED} in case of successful delete. APIResult with state {@link
* Status#FAILED} in case of delete failure. APIResult with state {@link Status#PARTIAL} in case of partial delete.
*/
@DELETE
- @Path("cubesegmentations")
- public APIResult deleteAllCubeSegmentations(@QueryParam("sessionid") LensSessionHandle sessionid) {
+ @Path("segmentations")
+ public APIResult deleteAllSegmentations(@QueryParam("sessionid") LensSessionHandle sessionid) {
return Entity.SEGMENTATION.deleteAll(sessionid, null);
}
@@ -908,23 +908,23 @@ public class MetastoreResource {
}
/**
- * Get the cube segmentation specified by name
+ * Get the segmentation specified by name
*
* @param sessionid The sessionid in which user is working
- * @param cubeSegmentationName The cube segmentation name
- * @return JAXB representation of {@link XCubeSegmentation}
+ * @param segmentationName The segmentation name
+ * @return JAXB representation of {@link XSegmentation}
*/
@GET
- @Path("/cubesegmentations/{cubeSegmentationName}")
- public JAXBElement<XCubeSegmentation> getCubeSegmentation(@QueryParam("sessionid") LensSessionHandle sessionid,
- @PathParam("cubeSegmentationName") String cubeSegmentationName)
+ @Path("/segmentations/{segmentationName}")
+ public JAXBElement<XSegmentation> getSegmentation(@QueryParam("sessionid") LensSessionHandle sessionid,
+ @PathParam("segmentationName") String segmentationName)
throws LensException {
checkSessionId(sessionid);
try {
- return X_CUBE_OBJECT_FACTORY.createXCubeSegmentation(getSvc().
- getCubeSegmentation(sessionid, cubeSegmentationName));
+ return X_CUBE_OBJECT_FACTORY.createXSegmentation(getSvc().
+ getSegmentation(sessionid, segmentationName));
} catch (LensException exc) {
- checkTableNotFound(exc, cubeSegmentationName);
+ checkTableNotFound(exc, segmentationName);
throw exc;
}
}
@@ -953,23 +953,23 @@ public class MetastoreResource {
}
/**
- * Create a new cube segmentation
+ * Create a new segmentation
*
* @param sessionid The sessionid in which user is working
- * @param seg The {@link XCubeSegmentation} representation of the cube segmentation
+ * @param seg The {@link XSegmentation} representation of the segmentation
* @return {@link APIResult} with state {@link Status#SUCCEEDED}, if create was successful. {@link APIResult} with
* state {@link Status#FAILED}, if create has failed
*/
@POST
- @Path("/cubesegmentations")
- public APIResult createCubeSegmentation(@QueryParam("sessionid") LensSessionHandle sessionid, XCubeSegmentation seg)
+ @Path("/segmentations")
+ public APIResult createSegmentation(@QueryParam("sessionid") LensSessionHandle sessionid, XSegmentation seg)
throws LensException {
checkSessionId(sessionid);
try {
- log.info("Create cube segmentation");
- getSvc().createCubeSegmentation(sessionid, seg);
+ log.info("Create segmentation");
+ getSvc().createSegmentation(sessionid, seg);
} catch (LensException exc) {
- log.error("Exception creating cube segmentation:", exc);
+ log.error("Exception creating segmentation:", exc);
return failure(processLensException(exc));
}
return success();
@@ -1002,25 +1002,25 @@ public class MetastoreResource {
}
/**
- * Update cube segmentation
+ * Update segmentation
*
* @param sessionid The sessionid in which user is working
- * @param cubeSegmentationName name of cube segmentation
- * @param seg The {@link XCubeSegmentation} representation of the updated fact table definition
+ * @param segmentationName name of segmentation
+ * @param seg The {@link XSegmentation} representation of the updated fact table definition
* @return {@link APIResult} with state {@link Status#SUCCEEDED}, if update was successful. {@link APIResult} with
* state {@link Status#FAILED}, if update has failed
*/
@PUT
- @Path("/cubesegmentations/{cubeSegmentationName}")
- public APIResult updateCubeSegmentation(@QueryParam("sessionid") LensSessionHandle sessionid,
- @PathParam("cubeSegmentationName") String cubeSegmentationName, XCubeSegmentation seg)
+ @Path("/segmentations/{segmentationName}")
+ public APIResult updateSegmentation(@QueryParam("sessionid") LensSessionHandle sessionid,
+ @PathParam("segmentationName") String segmentationName, XSegmentation seg)
throws LensException {
checkSessionId(sessionid);
try {
- getSvc().updateCubeSegmentation(sessionid, seg);
+ getSvc().updateSegmentation(sessionid, seg);
} catch (LensException exc) {
- checkTableNotFound(exc, cubeSegmentationName);
- log.error("Error updating segmentation {}", cubeSegmentationName, exc);
+ checkTableNotFound(exc, segmentationName);
+ log.error("Error updating segmentation {}", segmentationName, exc);
return failure(processLensException(exc));
}
return success();
@@ -1046,19 +1046,19 @@ public class MetastoreResource {
/**
- * Drop the cube segmentation, specified by name
+ * Drop the segmentation, specified by name
*
* @param sessionid The sessionid in which user is working
- * @param cubeSegmentationName The cube segmentation name
+ * @param segmentationName The segmentation name
* @return {@link APIResult} with state {@link Status#SUCCEEDED}, if drop was successful. {@link APIResult} with state
* {@link Status#FAILED}, if drop has failed
*/
@DELETE
- @Path("/cubesegmentations/{cubeSegmentationName}")
- public APIResult dropCubeSegmentation(@QueryParam("sessionid") LensSessionHandle sessionid,
- @PathParam("cubeSegmentationName") String cubeSegmentationName)
+ @Path("/segmentations/{segmentationName}")
+ public APIResult dropSegmentation(@QueryParam("sessionid") LensSessionHandle sessionid,
+ @PathParam("segmentationName") String segmentationName)
throws LensException {
- return Entity.SEGMENTATION.delete(sessionid, cubeSegmentationName, null);
+ return Entity.SEGMENTATION.delete(sessionid, segmentationName, null);
}
/**
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-server/src/test/java/org/apache/lens/server/metastore/TestMetastoreService.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/metastore/TestMetastoreService.java b/lens-server/src/test/java/org/apache/lens/server/metastore/TestMetastoreService.java
index d5f5561..5424404 100644
--- a/lens-server/src/test/java/org/apache/lens/server/metastore/TestMetastoreService.java
+++ b/lens-server/src/test/java/org/apache/lens/server/metastore/TestMetastoreService.java
@@ -1633,12 +1633,12 @@ public class TestMetastoreService extends LensJerseyTest {
}
}
- private XCubeSegmentation createCubeSegmentation(String segName) {
- return createCubeSegmentation(segName, "testCube");
+ private XSegmentation createSegmentation(String segName) {
+ return createSegmentation(segName, "testCube");
}
- private XCubeSegmentation createCubeSegmentation(String segName, String cubeName) {
- XCubeSegmentation seg = cubeObjectFactory.createXCubeSegmentation();
+ private XSegmentation createSegmentation(String segName, String cubeName) {
+ XSegmentation seg = cubeObjectFactory.createXSegmentation();
//Create Xproperties
XProperties props1 = cubeObjectFactory.createXProperties();
@@ -1653,24 +1653,24 @@ public class TestMetastoreService extends LensJerseyTest {
prop2.setValue("prop_val2");
props2.getProperty().add(prop2);
- // Create XcubeSegments
- XCubeSegments cubes = new XCubeSegments();
- XCubeSegment c1 = cubeObjectFactory.createXCubeSegment();
+ // Create XSegments
+ XSegments cubes = new XSegments();
+ XSegment c1 = cubeObjectFactory.createXSegment();
c1.setCubeName("cube1");
c1.setSegmentParameters(props1);
- XCubeSegment c2 = cubeObjectFactory.createXCubeSegment();
+ XSegment c2 = cubeObjectFactory.createXSegment();
c2.setCubeName("cube2");
c2.setSegmentParameters(props2);
- cubes.getCubeSegment().add(c1);
- cubes.getCubeSegment().add(c2);
+ cubes.getSegment().add(c1);
+ cubes.getSegment().add(c2);
seg.setProperties(new XProperties());
seg.setName(segName);
seg.setWeight(10.0);
seg.setCubeName(cubeName);
- seg.setCubeSegements(cubes);
+ seg.setSegements(cubes);
Map<String, String> properties = LensUtil.getHashMap("foo", "bar");
seg.getProperties().getProperty().addAll(JAXBUtils.xPropertiesFromMap(properties));
@@ -1678,44 +1678,44 @@ public class TestMetastoreService extends LensJerseyTest {
}
@Test(dataProvider = "mediaTypeData")
- public void testCreateAndAlterCubeSegmentation(MediaType mediaType) throws Exception {
- final String segname = "testCreateCubeSegmentation";
- final String DB = dbPFX + "testCreateCubeSegmentation_DB" + mediaType.getSubtype();
+ public void testCreateAndAlterSegmentation(MediaType mediaType) throws Exception {
+ final String segname = "testCreateSegmentation";
+ final String DB = dbPFX + "testCreateSegmentation_DB" + mediaType.getSubtype();
String prevDb = getCurrentDatabase(mediaType);
createDatabase(DB, mediaType);
setCurrentDatabase(DB, mediaType);
try {
- XCubeSegmentation seg = createCubeSegmentation(segname);
+ XSegmentation seg = createSegmentation(segname);
APIResult result = target()
.path("metastore")
- .path("cubesegmentations").queryParam("sessionid", lensSessionId)
+ .path("segmentations").queryParam("sessionid", lensSessionId)
.request(mediaType)
.post(Entity.entity(
- new GenericEntity<JAXBElement<XCubeSegmentation>>(
- cubeObjectFactory.createXCubeSegmentation(seg)){}, mediaType),
+ new GenericEntity<JAXBElement<XSegmentation>>(
+ cubeObjectFactory.createXSegmentation(seg)){}, mediaType),
APIResult.class);
assertSuccess(result);
- // Get all cube segmentations, this should contain the cube segmentation created earlier
- StringList segNames = target().path("metastore/cubesegmentations")
+ // Get all segmentations, this should contain the segmentation created earlier
+ StringList segNames = target().path("metastore/segmentations")
.queryParam("sessionid", lensSessionId).request(mediaType).get(StringList.class);
assertTrue(segNames.getElements().contains(segname.toLowerCase()));
- // Get the created cubesegmentation
- JAXBElement<XCubeSegmentation> gotCubeSegmentation = target().path("metastore/cubesegmentations")
+ // Get the created segmentation
+ JAXBElement<XSegmentation> gotSegmentation = target().path("metastore/segmentations")
.path(segname)
.queryParam("sessionid", lensSessionId).request(mediaType)
- .get(new GenericType<JAXBElement<XCubeSegmentation>>() {});
- XCubeSegmentation gotSeg = gotCubeSegmentation.getValue();
+ .get(new GenericType<JAXBElement<XSegmentation>>() {});
+ XSegmentation gotSeg = gotSegmentation.getValue();
assertTrue(gotSeg.getName().equalsIgnoreCase(segname));
assertEquals(gotSeg.getWeight(), 10.0);
- CubeSegmentation cs = JAXBUtils.cubeSegmentationFromXCubeSegmentation(seg);
+ Segmentation cs = JAXBUtils.segmentationFromXSegmentation(seg);
- // Check for cube segemnts
+ // Check for segemnts
boolean foundCube1 = false;
- for (CubeSegment cube : cs.getCubeSegments()) {
+ for (Segment cube : cs.getSegments()) {
if (cube.getName().equalsIgnoreCase("cube1")
&& cube.getProperties().get("prop_key1").equals("prop_val1")) {
foundCube1 = true;
@@ -1725,40 +1725,40 @@ public class TestMetastoreService extends LensJerseyTest {
assertTrue(foundCube1);
assertEquals(cs.getProperties().get("foo"), "bar");
- // update cube segmentation
- XCubeSegmentation update = JAXBUtils.xsegmentationFromCubeSegmentation(cs);
- XCubeSegments cubes = new XCubeSegments();
- XCubeSegment c1 = cubeObjectFactory.createXCubeSegment();
+ // update segmentation
+ XSegmentation update = JAXBUtils.xsegmentationFromSegmentation(cs);
+ XSegments cubes = new XSegments();
+ XSegment c1 = cubeObjectFactory.createXSegment();
c1.setCubeName("cube11");
- XCubeSegment c2 = cubeObjectFactory.createXCubeSegment();
+ XSegment c2 = cubeObjectFactory.createXSegment();
c2.setCubeName("cube22");
- cubes.getCubeSegment().add(c1);
- cubes.getCubeSegment().add(c2);
+ cubes.getSegment().add(c1);
+ cubes.getSegment().add(c2);
update.setWeight(20.0);
- update.setCubeSegements(cubes);
+ update.setSegements(cubes);
- result = target().path("metastore").path("cubesegmentations").path(segname)
+ result = target().path("metastore").path("segmentations").path(segname)
.queryParam("sessionid", lensSessionId).request(mediaType)
- .put(Entity.entity(new GenericEntity<JAXBElement<XCubeSegmentation>>(
- cubeObjectFactory.createXCubeSegmentation(update)){}, mediaType),
+ .put(Entity.entity(new GenericEntity<JAXBElement<XSegmentation>>(
+ cubeObjectFactory.createXSegmentation(update)){}, mediaType),
APIResult.class);
assertSuccess(result);
// Get the updated table
- JAXBElement<XCubeSegmentation> gotUpdatedCubeSeg = target().path("metastore/cubesegmentations").path(segname)
+ JAXBElement<XSegmentation> gotUpdatedSeg = target().path("metastore/segmentations").path(segname)
.queryParam("sessionid", lensSessionId).request(mediaType)
- .get(new GenericType<JAXBElement<XCubeSegmentation>>() {});
- XCubeSegmentation gotUpSeg = gotUpdatedCubeSeg.getValue();
- CubeSegmentation usg = JAXBUtils.cubeSegmentationFromXCubeSegmentation(gotUpSeg);
+ .get(new GenericType<JAXBElement<XSegmentation>>() {});
+ XSegmentation gotUpSeg = gotUpdatedSeg.getValue();
+ Segmentation usg = JAXBUtils.segmentationFromXSegmentation(gotUpSeg);
- assertEquals(usg.getCubeSegments().size(), 2);
- for (CubeSegment segmnt : usg.getCubeSegments()) {
+ assertEquals(usg.getSegments().size(), 2);
+ for (Segment segmnt : usg.getSegments()) {
assertTrue(segmnt.getName().equals("cube11") || segmnt.getName().equals("cube22"));
}
- // Finally, drop the cube segmentation
- result = target().path("metastore").path("cubesegmentations").path(segname)
+ // Finally, drop the segmentation
+ result = target().path("metastore").path("segmentations").path(segname)
.queryParam("sessionid", lensSessionId).request(mediaType)
.delete(APIResult.class);
@@ -1766,7 +1766,7 @@ public class TestMetastoreService extends LensJerseyTest {
// Drop again, this time it should give a 404
try {
- target().path("metastore").path("cubesegmentations").path(segname)
+ target().path("metastore").path("segmentations").path(segname)
.queryParam("cascade", "true")
.queryParam("sessionid", lensSessionId).request(mediaType)
.delete(APIResult.class);
[2/2] lens git commit: LENS-1040 : cubesegmentation commands are
conflicting with cube commands
Posted by pr...@apache.org.
LENS-1040 : cubesegmentation commands are conflicting with cube commands
Project: http://git-wip-us.apache.org/repos/asf/lens/repo
Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/20c1a53f
Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/20c1a53f
Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/20c1a53f
Branch: refs/heads/master
Commit: 20c1a53f4c186c88eab94ce0932417bf17418c75
Parents: f3e6bc5
Author: Sushil Mohanty <su...@gmail.com>
Authored: Wed May 18 14:55:13 2016 +0530
Committer: Rajat Khandelwal <ra...@gmail.com>
Committed: Wed May 18 14:55:13 2016 +0530
----------------------------------------------------------------------
lens-api/src/main/resources/cube-0.1.xsd | 48 ++---
.../LensCubeSegmentationCommands.java | 137 -------------
.../annotations/LensSegmentationCommands.java | 137 +++++++++++++
.../cli/TestLensCubeSegmentationCommands.java | 156 ---------------
.../lens/cli/TestLensSegmentationCommands.java | 156 +++++++++++++++
lens-cli/src/test/resources/seg1.xml | 20 +-
.../java/org/apache/lens/client/LensClient.java | 24 +--
.../apache/lens/client/LensMetadataClient.java | 56 +++---
.../lens/cube/metadata/CubeMetastoreClient.java | 88 ++++-----
.../apache/lens/cube/metadata/CubeSegment.java | 35 ----
.../lens/cube/metadata/CubeSegmentation.java | 190 -------------------
.../lens/cube/metadata/MetastoreConstants.java | 4 +-
.../org/apache/lens/cube/metadata/Segment.java | 35 ++++
.../apache/lens/cube/metadata/Segmentation.java | 190 +++++++++++++++++++
.../cube/metadata/TestCubeMetastoreClient.java | 46 ++---
.../apache/lens/examples/SampleMetastore.java | 10 +-
lens-examples/src/main/resources/seg1.xml | 20 +-
lens-examples/src/test/resources/yaml/seg1.yaml | 2 +-
.../api/metastore/CubeMetastoreService.java | 28 +--
.../metastore/CubeMetastoreServiceImpl.java | 32 ++--
.../apache/lens/server/metastore/JAXBUtils.java | 36 ++--
.../server/metastore/MetastoreResource.java | 90 ++++-----
.../server/metastore/TestMetastoreService.java | 94 ++++-----
23 files changed, 817 insertions(+), 817 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-api/src/main/resources/cube-0.1.xsd
----------------------------------------------------------------------
diff --git a/lens-api/src/main/resources/cube-0.1.xsd b/lens-api/src/main/resources/cube-0.1.xsd
index 4a6a5d7..d6c6bd2 100644
--- a/lens-api/src/main/resources/cube-0.1.xsd
+++ b/lens-api/src/main/resources/cube-0.1.xsd
@@ -1020,10 +1020,10 @@
</xs:sequence>
</xs:complexType>
- <xs:complexType name="x_cube_segment">
+ <xs:complexType name="x_segment">
<xs:annotation>
<xs:documentation>
- cube segment belong to the segmentation
+ Segment belong to the segmentation
</xs:documentation>
</xs:annotation>
<xs:sequence>
@@ -1031,8 +1031,8 @@
<xs:annotation>
<xs:documentation>
Segment properties.
- The following properties can be specified at a cube segment level :
- 1. lens.metastore.cube.column.mapping : The column mapping for columns of cube segment if they are
+ The following properties can be specified at a segment level :
+ 1. lens.metastore.cube.column.mapping : The column mapping for columns of segment if they are
different in underlying cube. The value is speciified with comma separated map entries specified with
key-values separated by equalto. Example value: id=id1,name=name1
</xs:documentation>
@@ -1042,14 +1042,14 @@
<xs:attribute name="cube_name" type="xs:string" use="required"/>
</xs:complexType>
- <xs:complexType name="x_cube_segments">
+ <xs:complexType name="x_segments">
<xs:annotation>
<xs:documentation>
- Segments in segmentation. There can be two or more such cube segments.
+ Segments in segmentation. There can be two or more such segments.
</xs:documentation>
</xs:annotation>
<xs:sequence>
- <xs:element name="cube_segment" minOccurs="2" maxOccurs="unbounded" type="x_cube_segment"/>
+ <xs:element name="segment" minOccurs="2" maxOccurs="unbounded" type="x_segment"/>
</xs:sequence>
</xs:complexType>
@@ -1271,56 +1271,56 @@
</xs:attribute>
</xs:complexType>
- <xs:element name="x_cube_segmentation" type="x_cube_segmentation"/>
+ <xs:element name="x_segmentation" type="x_segmentation"/>
- <xs:complexType name="x_cube_segmentation">
+ <xs:complexType name="x_segmentation">
<xs:annotation>
<xs:documentation>
- Cube segmentation is associated to a base cube and consists of two or more cube segments. All
- cube segments together make cube segmentation complete.
+ Segmentation is associated to a base cube and consists of two or more segments. All
+ segments together make segmentation complete.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element type="x_properties" name="properties" maxOccurs="1" minOccurs="0">
<xs:annotation>
<xs:documentation>
- Properties that can be set for cubesegmentation are
- 1. cube.segmentation.absolute.start.time: start time of the cube segmentation.
- For queries that ask for time before this, this cubesegmentation is not a candidate. Time format
+ Properties that can be set for segmentation are
+ 1. cube.segmentation.absolute.start.time: start time of the segmentation.
+ For queries that ask for time before this, this segmentation is not a candidate. Time format
can be specified in yyyy[-mm[-dd[-hh[:MM[:ss[,SSS]]]]]] format.
- 2. cube.segmentation.relative.start.time: Here you can specify cubesegmentations's relative validity
- relative to current time. Useful if you want to specify e.g. this cubesegmentation is valid
+ 2. cube.segmentation.relative.start.time: Here you can specify segmentations's relative validity
+ relative to current time. Useful if you want to specify e.g. this segmentation is valid
for today - 90 days. Can be specified as just a time difference e.g. "-90 days".
Or can be specified in relative syntax.
e.g. now.year or now.day - 6 hour etc.
- 3. cube.segmentation.absolute.end.time: If you're deprecating a cubesegmentation, put the final date till
- which the data of the cubesegmentation will be valid here. Format same as absolute start time.
- 4. cube.segmentation.relative.end.time: You can specify the end date for cubesegmentation
- relative to current date e.g. cubesegmentationas is valid for next 90 days starting from today.
+ 3. cube.segmentation.absolute.end.time: If you're deprecating a segmentation, put the final date till
+ which the data of the segmentation will be valid here. Format same as absolute start time.
+ 4. cube.segmentation.relative.end.time: You can specify the end date for segmentation
+ relative to current date e.g. segmentationas is valid for next 90 days starting from today.
This can be specified as just a time difference e.g. "+90 days".
</xs:documentation>
</xs:annotation>
</xs:element>
- <xs:element name="cube_segements" type="x_cube_segments" maxOccurs="1" minOccurs="0"/>
+ <xs:element name="segements" type="x_segments" maxOccurs="1" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>
- Name of cube segmentation
+ Name of Segmentation
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="cube_name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>
- The base or parent cube to which the cube segmentation is associated.
+ The base or parent cube to which the segmentation is associated.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="weight" use="required" >
<xs:annotation>
<xs:documentation>
- The weight of the cube segmentation. LENS will use this attribute to decide the lightest table to
+ The weight of the segmentation. LENS will use this attribute to decide the lightest table to
query when there are more than one eligible tables.
</xs:documentation>
</xs:annotation>
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-cli/src/main/java/org/apache/lens/cli/commands/annotations/LensCubeSegmentationCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/annotations/LensCubeSegmentationCommands.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/annotations/LensCubeSegmentationCommands.java
deleted file mode 100644
index ed2ad7a..0000000
--- a/lens-cli/src/main/java/org/apache/lens/cli/commands/annotations/LensCubeSegmentationCommands.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.lens.cli.commands.annotations;
-
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.lens.api.APIResult;
-import org.apache.lens.api.metastore.XCubeSegmentation;
-import org.apache.lens.cli.commands.BaseTableCrudCommand;
-
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-import org.springframework.stereotype.Component;
-
-import lombok.NonNull;
-
-@Component
-@UserDocumentation(title = "Commands for CubeSegmentation Management",
- description = "These command provide CRUD for CubeSegmentation")
-public class LensCubeSegmentationCommands extends BaseTableCrudCommand<XCubeSegmentation> {
-
- /**
- * Show cube segmentation
- *
- * @return the string
- */
- @CliCommand(value = "show cubesegmentations",
- help = "display list of cubesegmentations in current database. "
- + "If optional <cube_name> is supplied, only cubesegmentations "
- + "belonging to cube <cube_name> will be displayed")
- public String showCubeSegmentations(
- @CliOption(key = {"", "cube_name"}, mandatory = false, help = "<cube_name>") String cubeName) {
- return showAll(cubeName);
- }
- /**
- * Creates the cubesegmentation
- *
- * @param path the cubesegmentation spec
- * @return the string
- */
- @CliCommand(value = "create cubesegmentation",
- help = "create a new cubesegmentation, taking spec from <path-to-cubesegmentation-spec file>")
- public String createCubeSegmentation(
- @CliOption(key = {"", "path"}, mandatory = true, help =
- "<path-to-cubesegmentation-spec file>") @NonNull final File path) {
- return create(path, false);
- }
-
- /**
- * Describe cubesegmentation.
- *
- * @param name the cubesegmentation name
- * @return the string
- */
- @CliCommand(value = "describe cubesegmentation", help = "describe cubesegmentation <cubesegmentation_name>")
- public String describeCubeSegmentation(
- @CliOption(key = {"", "name"}, mandatory = true, help = "<cubesegmentation_name>") String name) {
- return formatJson(getClient().getCubeSegmentation(name));
- }
-
-
- /**
- * Update cubesegmentation.
- *
- * @param name the cubesegmentation to be updated
- * @param path path to spec file
- * @return the string
- */
- @CliCommand(value = "update cubesegmentation",
- help = "update cubesegmentation <cubesegmentation_name>, taking spec from <path-to-cubesegmentation-spec file>")
- public String updateCubeSegmentation(
- @CliOption(key = {"", "name"}, mandatory = true, help = "<cubesegmentation_name>") String name,
- @CliOption(key = {"", "path"}, mandatory = true, help = "<path-to-cubesegmentation-spec-file>")
- @NonNull final File path) {
- return update(name, path);
- }
-
- /**
- * Drop cubesegmentation.
- *
- * @param name the cubesegmentation to be dropped
- * @return the string
- */
- @CliCommand(value = "drop cubesegmentation", help = "drop cubesegmentation <cubesegmentation_name>")
- public String dropCubeSegmentation(
- @CliOption(key = {"", "name"}, mandatory = true, help = "<cubesegmentation_name>") String name) {
- return drop(name, false);
- }
-
- @Override
- public List<String> getAll() {
- return getClient().getAllCubeSegmentations();
- }
-
- @Override
- protected APIResult doCreate(String path, boolean ignoreIfExists) {
- return getClient().createCubeSegmentation(path);
- }
-
- @Override
- protected XCubeSegmentation doRead(String name) {
- return getClient().getCubeSegmentation(name);
- }
-
- @Override
- public APIResult doUpdate(String name, String path) {
- return getClient().updateCubeSegmentation(name, path);
- }
-
- @Override
- protected APIResult doDelete(String name, boolean cascade) {
- return getClient().dropCubeSegmentation(name);
- }
-
- @Override
- protected List<String> getAll(String filter) {
- return getClient().getAllCubeSegmentations(filter);
- }
-}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-cli/src/main/java/org/apache/lens/cli/commands/annotations/LensSegmentationCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/annotations/LensSegmentationCommands.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/annotations/LensSegmentationCommands.java
new file mode 100644
index 0000000..e53442d
--- /dev/null
+++ b/lens-cli/src/main/java/org/apache/lens/cli/commands/annotations/LensSegmentationCommands.java
@@ -0,0 +1,137 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.lens.cli.commands.annotations;
+
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.lens.api.APIResult;
+import org.apache.lens.api.metastore.XSegmentation;
+import org.apache.lens.cli.commands.BaseTableCrudCommand;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+import org.springframework.stereotype.Component;
+
+import lombok.NonNull;
+
+@Component
+@UserDocumentation(title = "Commands for Segmentation Management",
+ description = "These command provide CRUD for Segmentation")
+public class LensSegmentationCommands extends BaseTableCrudCommand<XSegmentation> {
+
+ /**
+ * Show segmentation
+ *
+ * @return the string
+ */
+ @CliCommand(value = "show segmentations",
+ help = "display list of segmentations in current database. "
+ + "If optional <cube_name> is supplied, only segmentations "
+ + "belonging to cube <cube_name> will be displayed")
+ public String showSegmentations(
+ @CliOption(key = {"", "cube_name"}, mandatory = false, help = "<cube_name>") String cubeName) {
+ return showAll(cubeName);
+ }
+ /**
+ * Creates the segmentation
+ *
+ * @param path the segmentation spec
+ * @return the string
+ */
+ @CliCommand(value = "create segmentation",
+ help = "create a new segmentation, taking spec from <path-to-segmentation-spec file>")
+ public String createSegmentation(
+ @CliOption(key = {"", "path"}, mandatory = true, help =
+ "<path-to-segmentation-spec file>") @NonNull final File path) {
+ return create(path, false);
+ }
+
+ /**
+ * Describe segmentation.
+ *
+ * @param name the segmentation name
+ * @return the string
+ */
+ @CliCommand(value = "describe segmentation", help = "describe segmentation <segmentation_name>")
+ public String describeSegmentation(
+ @CliOption(key = {"", "name"}, mandatory = true, help = "<segmentation_name>") String name) {
+ return formatJson(getClient().getSegmentation(name));
+ }
+
+
+ /**
+ * Update segmentation.
+ *
+ * @param name the segmentation to be updated
+ * @param path path to spec file
+ * @return the string
+ */
+ @CliCommand(value = "update segmentation",
+ help = "update segmentation <segmentation_name>, taking spec from <path-to-segmentation-spec file>")
+ public String updateSegmentation(
+ @CliOption(key = {"", "name"}, mandatory = true, help = "<segmentation_name>") String name,
+ @CliOption(key = {"", "path"}, mandatory = true, help = "<path-to-segmentation-spec-file>")
+ @NonNull final File path) {
+ return update(name, path);
+ }
+
+ /**
+ * Drop segmentation.
+ *
+ * @param name the segmentation to be dropped
+ * @return the string
+ */
+ @CliCommand(value = "drop segmentation", help = "drop segmentation <segmentation_name>")
+ public String dropSegmentation(
+ @CliOption(key = {"", "name"}, mandatory = true, help = "<segmentation_name>") String name) {
+ return drop(name, false);
+ }
+
+ @Override
+ public List<String> getAll() {
+ return getClient().getAllSegmentations();
+ }
+
+ @Override
+ protected APIResult doCreate(String path, boolean ignoreIfExists) {
+ return getClient().createSegmentation(path);
+ }
+
+ @Override
+ protected XSegmentation doRead(String name) {
+ return getClient().getSegmentation(name);
+ }
+
+ @Override
+ public APIResult doUpdate(String name, String path) {
+ return getClient().updateSegmentation(name, path);
+ }
+
+ @Override
+ protected APIResult doDelete(String name, boolean cascade) {
+ return getClient().dropSegmentation(name);
+ }
+
+ @Override
+ protected List<String> getAll(String filter) {
+ return getClient().getAllSegmentations(filter);
+ }
+}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-cli/src/test/java/org/apache/lens/cli/TestLensCubeSegmentationCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensCubeSegmentationCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensCubeSegmentationCommands.java
deleted file mode 100644
index 53a52de..0000000
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensCubeSegmentationCommands.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.lens.cli;
-
-import static org.testng.Assert.*;
-
-import java.io.*;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import javax.ws.rs.NotFoundException;
-
-import org.apache.lens.cli.commands.LensCubeCommands;
-import org.apache.lens.cli.commands.annotations.LensCubeSegmentationCommands;
-import org.apache.lens.client.LensClient;
-
-import org.testng.annotations.Test;
-
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-public class TestLensCubeSegmentationCommands extends LensCliApplicationTest {
-
- private static LensCubeSegmentationCommands command = null;
- private static LensCubeCommands cubeCommands = null;
-
- private void createSampleCube() throws URISyntaxException {
- URL cubeSpec = TestLensCubeCommands.class.getClassLoader().getResource("sample-cube.xml");
- String cubeList = getCubeCommand().showCubes();
- assertFalse(cubeList.contains("sample_cube"), cubeList);
- getCubeCommand().createCube(new File(cubeSpec.toURI()));
- cubeList = getCubeCommand().showCubes();
- assertTrue(cubeList.contains("sample_cube"), cubeList);
- }
-
- private static LensCubeSegmentationCommands getCommand() {
- if (command == null) {
- LensClient client = new LensClient();
- command = new LensCubeSegmentationCommands();
- command.setClient(client);
- }
- return command;
- }
-
- private static LensCubeCommands getCubeCommand() {
- if (cubeCommands == null) {
- LensClient client = new LensClient();
- cubeCommands = new LensCubeCommands();
- cubeCommands.setClient(client);
- }
- return cubeCommands;
- }
-
- public static void testCreateSegmentation() throws IOException {
- LensCubeSegmentationCommands command = getCommand();
- String segList = command.showCubeSegmentations(null);
- assertEquals(command.showCubeSegmentations("sample_cube"), "No cubesegmentation found for sample_cube");
- assertEquals(segList, "No cubesegmentation found");
- URL segSpec = TestLensCubeSegmentationCommands.class.getClassLoader().getResource("seg1.xml");
- try {
- command.createCubeSegmentation(new File(segSpec.toURI()));
- } catch (Exception e) {
- fail("Unable to create cubesegmentation" + e.getMessage());
- }
- segList = command.showCubeSegmentations(null);
- assertEquals(command.showCubeSegmentations("sample_cube"), segList);
- try {
- assertEquals(command.showCubeSegmentations("blah"), segList);
- fail();
- } catch (NotFoundException e) {
- log.info("blah is not a cubesegmentation", e);
- }
- }
-
- public static void testUpdateSegmentation() {
- try {
- LensCubeSegmentationCommands command = getCommand();
- URL segSpec = TestLensCubeSegmentationCommands.class.getClassLoader().getResource("seg1.xml");
- StringBuilder sb = new StringBuilder();
- BufferedReader bufferedReader = new BufferedReader(new FileReader(segSpec.getFile()));
- String s;
- while ((s = bufferedReader.readLine()) != null) {
- sb.append(s).append("\n");
- }
-
- bufferedReader.close();
- String xmlContent = sb.toString();
- xmlContent = xmlContent.replace("<property name=\"seg1.prop\" value=\"s1\"/>\n",
- "<property name=\"seg1.prop\" value=\"s1\"/>" + "\n<property name=\"seg1.prop1\" value=\"s2\"/>\n");
-
- File newFile = new File("target/seg2.xml");
- Writer writer = new OutputStreamWriter(new FileOutputStream(newFile));
- writer.write(xmlContent);
- writer.close();
-
- String desc = command.describeCubeSegmentation("seg1");
- log.debug(desc);
- String propString = "seg1.prop: s1";
- String propString1 = "seg1.prop1: s2";
-
- assertTrue(desc.contains(propString));
-
- command.updateCubeSegmentation("seg1", new File("target/seg2.xml"));
- desc = command.describeCubeSegmentation("seg1");
- log.debug(desc);
- assertTrue(desc.contains(propString), "The sample property value is not set");
- assertTrue(desc.contains(propString1), "The sample property value is not set");
-
- newFile.delete();
-
- } catch (Throwable t) {
- log.error("Updating of the cubesegmentation failed with ", t);
- fail("Updating of the cubesegmentation failed with " + t.getMessage());
- }
-
- }
-
- public static void testDropSegmentation() {
- LensCubeSegmentationCommands command = getCommand();
- String segList = command.showCubeSegmentations(null);
- assertEquals("seg1", segList, "seg1 segmentation should be found");
- command.dropCubeSegmentation("seg1");
- segList = command.showCubeSegmentations(null);
- assertEquals(segList, "No cubesegmentation found");
- }
-
- private void dropSampleCube() {
- getCubeCommand().dropCube("sample_cube");
- }
-
- @Test
- public void testCubeSegmentationCommands() throws IOException, URISyntaxException {
- createSampleCube();
- testCreateSegmentation();
- testUpdateSegmentation();
- testDropSegmentation();
- dropSampleCube();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-cli/src/test/java/org/apache/lens/cli/TestLensSegmentationCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensSegmentationCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensSegmentationCommands.java
new file mode 100644
index 0000000..e6d4bc5
--- /dev/null
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensSegmentationCommands.java
@@ -0,0 +1,156 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.lens.cli;
+
+import static org.testng.Assert.*;
+
+import java.io.*;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import javax.ws.rs.NotFoundException;
+
+import org.apache.lens.cli.commands.LensCubeCommands;
+import org.apache.lens.cli.commands.annotations.LensSegmentationCommands;
+import org.apache.lens.client.LensClient;
+
+import org.testng.annotations.Test;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class TestLensSegmentationCommands extends LensCliApplicationTest {
+
+ private static LensSegmentationCommands command = null;
+ private static LensCubeCommands cubeCommands = null;
+
+ private void createSampleCube() throws URISyntaxException {
+ URL cubeSpec = TestLensCubeCommands.class.getClassLoader().getResource("sample-cube.xml");
+ String cubeList = getCubeCommand().showCubes();
+ assertFalse(cubeList.contains("sample_cube"), cubeList);
+ getCubeCommand().createCube(new File(cubeSpec.toURI()));
+ cubeList = getCubeCommand().showCubes();
+ assertTrue(cubeList.contains("sample_cube"), cubeList);
+ }
+
+ private static LensSegmentationCommands getCommand() {
+ if (command == null) {
+ LensClient client = new LensClient();
+ command = new LensSegmentationCommands();
+ command.setClient(client);
+ }
+ return command;
+ }
+
+ private static LensCubeCommands getCubeCommand() {
+ if (cubeCommands == null) {
+ LensClient client = new LensClient();
+ cubeCommands = new LensCubeCommands();
+ cubeCommands.setClient(client);
+ }
+ return cubeCommands;
+ }
+
+ public static void testCreateSegmentation() throws IOException {
+ LensSegmentationCommands command = getCommand();
+ String segList = command.showSegmentations(null);
+ assertEquals(command.showSegmentations("sample_cube"), "No segmentation found for sample_cube");
+ assertEquals(segList, "No segmentation found");
+ URL segSpec = TestLensSegmentationCommands.class.getClassLoader().getResource("seg1.xml");
+ try {
+ command.createSegmentation(new File(segSpec.toURI()));
+ } catch (Exception e) {
+ fail("Unable to create segmentation" + e.getMessage());
+ }
+ segList = command.showSegmentations(null);
+ assertEquals(command.showSegmentations("sample_cube"), segList);
+ try {
+ assertEquals(command.showSegmentations("blah"), segList);
+ fail();
+ } catch (NotFoundException e) {
+ log.info("blah is not a segmentation", e);
+ }
+ }
+
+ public static void testUpdateSegmentation() {
+ try {
+ LensSegmentationCommands command = getCommand();
+ URL segSpec = TestLensSegmentationCommands.class.getClassLoader().getResource("seg1.xml");
+ StringBuilder sb = new StringBuilder();
+ BufferedReader bufferedReader = new BufferedReader(new FileReader(segSpec.getFile()));
+ String s;
+ while ((s = bufferedReader.readLine()) != null) {
+ sb.append(s).append("\n");
+ }
+
+ bufferedReader.close();
+ String xmlContent = sb.toString();
+ xmlContent = xmlContent.replace("<property name=\"seg1.prop\" value=\"s1\"/>\n",
+ "<property name=\"seg1.prop\" value=\"s1\"/>" + "\n<property name=\"seg1.prop1\" value=\"s2\"/>\n");
+
+ File newFile = new File("target/seg2.xml");
+ Writer writer = new OutputStreamWriter(new FileOutputStream(newFile));
+ writer.write(xmlContent);
+ writer.close();
+
+ String desc = command.describeSegmentation("seg1");
+ log.debug(desc);
+ String propString = "seg1.prop: s1";
+ String propString1 = "seg1.prop1: s2";
+
+ assertTrue(desc.contains(propString));
+
+ command.updateSegmentation("seg1", new File("target/seg2.xml"));
+ desc = command.describeSegmentation("seg1");
+ log.debug(desc);
+ assertTrue(desc.contains(propString), "The sample property value is not set");
+ assertTrue(desc.contains(propString1), "The sample property value is not set");
+
+ newFile.delete();
+
+ } catch (Throwable t) {
+ log.error("Updating of the segmentation failed with ", t);
+ fail("Updating of the segmentation failed with " + t.getMessage());
+ }
+
+ }
+
+ public static void testDropSegmentation() {
+ LensSegmentationCommands command = getCommand();
+ String segList = command.showSegmentations(null);
+ assertEquals("seg1", segList, "seg1 segmentation should be found");
+ command.dropSegmentation("seg1");
+ segList = command.showSegmentations(null);
+ assertEquals(segList, "No segmentation found");
+ }
+
+ private void dropSampleCube() {
+ getCubeCommand().dropCube("sample_cube");
+ }
+
+ @Test
+ public void testSegmentationCommands() throws IOException, URISyntaxException {
+ createSampleCube();
+ testCreateSegmentation();
+ testUpdateSegmentation();
+ testDropSegmentation();
+ dropSampleCube();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-cli/src/test/resources/seg1.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/seg1.xml b/lens-cli/src/test/resources/seg1.xml
index 848ac10..8a39915 100644
--- a/lens-cli/src/test/resources/seg1.xml
+++ b/lens-cli/src/test/resources/seg1.xml
@@ -19,27 +19,27 @@
under the License.
-->
-<x_cube_segmentation cube_name="sample_cube" name="seg1" weight="100.0" xmlns="uri:lens:cube:0.1"
+<x_segmentation cube_name="sample_cube" name="seg1" weight="100.0" xmlns="uri:lens:cube:0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
<properties>
<property name="seg1.prop" value="s1"/>
<property name="cube.segmentation.relative.start.time" value="now -10days"/>
</properties>
- <cube_segements>
- <cube_segment cube_name="cube11">
+ <segements>
+ <segment cube_name="cube11">
<segment_parameters>
<property name="lens.metastore.cube.column.mapping" value="foo=bar"/>
</segment_parameters>
- </cube_segment>
- <cube_segment cube_name="cube22">
+ </segment>
+ <segment cube_name="cube22">
<segment_parameters>
<property name="lens.metastore.cube.column.mapping" value="foo1=bar1"/>
</segment_parameters>
- </cube_segment>
- <cube_segment cube_name="cube33">
+ </segment>
+ <segment cube_name="cube33">
<segment_parameters>
<property name="lens.metastore.cube.column.mapping" value="foo2=bar2"/>
</segment_parameters>
- </cube_segment>
- </cube_segements>
-</x_cube_segmentation>
+ </segment>
+ </segements>
+</x_segmentation>
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-client/src/main/java/org/apache/lens/client/LensClient.java
----------------------------------------------------------------------
diff --git a/lens-client/src/main/java/org/apache/lens/client/LensClient.java b/lens-client/src/main/java/org/apache/lens/client/LensClient.java
index 43da691..480b6f8 100644
--- a/lens-client/src/main/java/org/apache/lens/client/LensClient.java
+++ b/lens-client/src/main/java/org/apache/lens/client/LensClient.java
@@ -695,28 +695,28 @@ public class LensClient {
return this.connection.getLogs(logFile);
}
- public XCubeSegmentation getCubeSegmentation(String segName) {
- return mc.getCubeSegmentation(segName);
+ public XSegmentation getSegmentation(String segName) {
+ return mc.getSegmentation(segName);
}
- public List<String> getAllCubeSegmentations() {
- return mc.getAllCubeSegmentations();
+ public List<String> getAllSegmentations() {
+ return mc.getAllSegmentations();
}
- public List<String> getAllCubeSegmentations(String filter) {
- return mc.getAllCubeSegmentations(filter);
+ public List<String> getAllSegmentations(String filter) {
+ return mc.getAllSegmentations(filter);
}
- public APIResult createCubeSegmentation(String segSpec) {
- return mc.createCubeSegmentation(segSpec);
+ public APIResult createSegmentation(String segSpec) {
+ return mc.createSegmentation(segSpec);
}
- public APIResult updateCubeSegmentation(String segName, String segSpec) {
- return mc.updateCubeSegmentation(segName, segSpec);
+ public APIResult updateSegmentation(String segName, String segSpec) {
+ return mc.updateSegmentation(segName, segSpec);
}
- public APIResult dropCubeSegmentation(String segName) {
- return mc.dropCubeSegmentation(segName);
+ public APIResult dropSegmentation(String segName) {
+ return mc.dropSegmentation(segName);
}
}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-client/src/main/java/org/apache/lens/client/LensMetadataClient.java
----------------------------------------------------------------------
diff --git a/lens-client/src/main/java/org/apache/lens/client/LensMetadataClient.java b/lens-client/src/main/java/org/apache/lens/client/LensMetadataClient.java
index f2d42ca..a1a78c5 100644
--- a/lens-client/src/main/java/org/apache/lens/client/LensMetadataClient.java
+++ b/lens-client/src/main/java/org/apache/lens/client/LensMetadataClient.java
@@ -359,17 +359,17 @@ public class LensMetadataClient {
return factTables.getElements();
}
- public List<String> getAllCubeSegmentations(String cubeName) {
+ public List<String> getAllSegmentations(String cubeName) {
if (cubeName == null) {
- return getAllCubeSegmentations();
+ return getAllSegmentations();
}
WebTarget target = getMetastoreWebTarget();
- StringList cubeSegmentations;
- cubeSegmentations = target.path("cubes").path(cubeName).path("cubesegmentations")
+ StringList segmentations;
+ segmentations = target.path("cubes").path(cubeName).path("segmentations")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.get(StringList.class);
- return cubeSegmentations.getElements();
+ return segmentations.getElements();
}
@@ -384,15 +384,15 @@ public class LensMetadataClient {
return factTables.getElements();
}
- public List<String> getAllCubeSegmentations() {
+ public List<String> getAllSegmentations() {
WebTarget target = getMetastoreWebTarget();
- StringList cubeSegmentations;
- cubeSegmentations = target.path("cubesegmentations")
+ StringList segmentations;
+ segmentations = target.path("segmentations")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.get(StringList.class);
- return cubeSegmentations.getElements();
+ return segmentations.getElements();
}
@@ -406,9 +406,9 @@ public class LensMetadataClient {
}
- public APIResult deleteAllCubeSegmentations() {
+ public APIResult deleteAllSegmentations() {
WebTarget target = getMetastoreWebTarget();
- return target.path("cubesegmentations")
+ return target.path("segmentations")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
@@ -424,12 +424,12 @@ public class LensMetadataClient {
return table.getValue();
}
- public XCubeSegmentation getCubeSegmentation(String segName) {
+ public XSegmentation getSegmentation(String segName) {
WebTarget target = getMetastoreWebTarget();
- JAXBElement<XCubeSegmentation> seg = target.path("cubesegmentations").path(segName)
+ JAXBElement<XSegmentation> seg = target.path("segmentations").path(segName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .get(new GenericType<JAXBElement<XCubeSegmentation>>() {
+ .get(new GenericType<JAXBElement<XSegmentation>>() {
});
return seg.getValue();
}
@@ -450,18 +450,18 @@ public class LensMetadataClient {
}
}
- public APIResult createCubeSegmentation(XCubeSegmentation seg) {
+ public APIResult createSegmentation(XSegmentation seg) {
WebTarget target = getMetastoreWebTarget();
- return target.path("cubesegmentations")
+ return target.path("segmentations")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .post(Entity.xml(new GenericEntity<JAXBElement<XCubeSegmentation>>(objFact
- .createXCubeSegmentation(seg)){}), APIResult.class);
+ .post(Entity.xml(new GenericEntity<JAXBElement<XSegmentation>>(objFact
+ .createXSegmentation(seg)){}), APIResult.class);
}
- public APIResult createCubeSegmentation(String segSpec) {
+ public APIResult createSegmentation(String segSpec) {
try {
- return createCubeSegmentation(this.<XCubeSegmentation>readFromXML(segSpec));
+ return createSegmentation(this.<XSegmentation>readFromXML(segSpec));
} catch (JAXBException | IOException e) {
return failureAPIResult(e);
}
@@ -483,18 +483,18 @@ public class LensMetadataClient {
}
}
- public APIResult updateCubeSegmentation(String segName, XCubeSegmentation seg) {
+ public APIResult updateSegmentation(String segName, XSegmentation seg) {
WebTarget target = getMetastoreWebTarget();
- return target.path("cubesegmentations").path(segName)
+ return target.path("segmentations").path(segName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML_TYPE)
- .put(Entity.xml(new GenericEntity<JAXBElement<XCubeSegmentation>>(objFact.
- createXCubeSegmentation(seg)){}), APIResult.class);
+ .put(Entity.xml(new GenericEntity<JAXBElement<XSegmentation>>(objFact.
+ createXSegmentation(seg)){}), APIResult.class);
}
- public APIResult updateCubeSegmentation(String segName, String seg) {
+ public APIResult updateSegmentation(String segName, String seg) {
try {
- return updateCubeSegmentation(segName, this.<XCubeSegmentation>readFromXML(seg));
+ return updateSegmentation(segName, this.<XSegmentation>readFromXML(seg));
} catch (JAXBException | IOException e) {
return failureAPIResult(e);
}
@@ -514,9 +514,9 @@ public class LensMetadataClient {
return dropFactTable(factName, false);
}
- public APIResult dropCubeSegmentation(String segName) {
+ public APIResult dropSegmentation(String segName) {
WebTarget target = getMetastoreWebTarget();
- return target.path("cubesegmentations").path(segName)
+ return target.path("segmentations").path(segName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-cube/src/main/java/org/apache/lens/cube/metadata/CubeMetastoreClient.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/metadata/CubeMetastoreClient.java b/lens-cube/src/main/java/org/apache/lens/cube/metadata/CubeMetastoreClient.java
index 71f6b39..de8f23b 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/metadata/CubeMetastoreClient.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/metadata/CubeMetastoreClient.java
@@ -81,8 +81,8 @@ public class CubeMetastoreClient {
private final Map<String, CubeFactTable> allFactTables = Maps.newConcurrentMap();
private volatile boolean allFactTablesPopulated = false;
//map from segmentation name to segmentation
- private final Map<String, CubeSegmentation> allCubeSegmentations = Maps.newConcurrentMap();
- private volatile boolean allCubeSegmentationPopulated = false;
+ private final Map<String, Segmentation> allSegmentations = Maps.newConcurrentMap();
+ private volatile boolean allSegmentationPopulated = false;
// map from storage name to storage
private final Map<String, Storage> allStorages = Maps.newConcurrentMap();
private volatile boolean allStoragesPopulated = false;
@@ -718,18 +718,18 @@ public class CubeMetastoreClient {
*
* @param baseCubeName The cube name ot which segmentation belong to
* @param segmentationName The segmentation name
- * @param cubeSegments Participating cube segements
+ * @param segments Participating cube segements
* @param weight Weight of segmentation
* @param properties Properties of segmentation
* @throws HiveException
*/
- public void createCubeSegmentation(String baseCubeName, String segmentationName, Set<CubeSegment> cubeSegments,
+ public void createSegmentation(String baseCubeName, String segmentationName, Set<Segment> segments,
double weight, Map<String, String> properties) throws HiveException {
- CubeSegmentation cubeSeg =
- new CubeSegmentation(baseCubeName, segmentationName, cubeSegments, weight, properties);
- createCubeSegmentation(cubeSeg);
+ Segmentation cubeSeg =
+ new Segmentation(baseCubeName, segmentationName, segments, weight, properties);
+ createSegmentation(cubeSeg);
// do a get to update cache
- getCubeSegmentation(segmentationName);
+ getSegmentation(segmentationName);
}
/**
@@ -795,7 +795,7 @@ public class CubeMetastoreClient {
}
}
- public void createCubeSegmentation(CubeSegmentation cubeSeg)
+ public void createSegmentation(Segmentation cubeSeg)
throws HiveException {
// create virtual cube table in metastore
createCubeHiveTable(cubeSeg);
@@ -1428,12 +1428,12 @@ public class CubeMetastoreClient {
return CubeTableType.FACT.name().equals(tableType);
}
- public boolean isCubeSegmentation(String segName) throws HiveException {
+ public boolean isSegmentation(String segName) throws HiveException {
Table tbl = getTable(segName);
- return isCubeSegmentation(tbl);
+ return isSegmentation(tbl);
}
- boolean isCubeSegmentation(Table tbl) {
+ boolean isSegmentation(Table tbl) {
String tableType = tbl.getParameters().get(MetastoreConstants.TABLE_TYPE_KEY);
return CubeTableType.SEGMENTATION.name().equals(tableType);
}
@@ -1563,12 +1563,12 @@ public class CubeMetastoreClient {
return isFactTable(tbl) ? new CubeFactTable(tbl) : null;
}
- public CubeSegmentation getCubeSegmentationTable(String tableName) throws HiveException {
- return getCubeSegmentationTable(getTable(tableName));
+ public Segmentation getSegmentationTable(String tableName) throws HiveException {
+ return getSegmentationTable(getTable(tableName));
}
- private CubeSegmentation getCubeSegmentationTable(Table tbl) throws HiveException {
- return isCubeSegmentation(tbl) ? new CubeSegmentation(tbl) : null;
+ private Segmentation getSegmentationTable(Table tbl) throws HiveException {
+ return isSegmentation(tbl) ? new Segmentation(tbl) : null;
}
/**
@@ -1735,18 +1735,18 @@ public class CubeMetastoreClient {
return fact;
}
- public CubeSegmentation getCubeSegmentation(String segName) throws HiveException {
+ public Segmentation getSegmentation(String segName) throws HiveException {
segName = segName.trim().toLowerCase();
- CubeSegmentation seg = allCubeSegmentations.get(segName);
+ Segmentation seg = allSegmentations.get(segName);
if (seg == null) {
- synchronized (allCubeSegmentations) {
- if (!allCubeSegmentations.containsKey(segName)) {
- seg = getCubeSegmentationTable(segName);
+ synchronized (allSegmentations) {
+ if (!allSegmentations.containsKey(segName)) {
+ seg = getSegmentationTable(segName);
if (enableCaching && seg != null) {
- allCubeSegmentations.put(segName, seg);
+ allSegmentations.put(segName, seg);
}
} else {
- seg = allCubeSegmentations.get(segName);
+ seg = allSegmentations.get(segName);
}
}
}
@@ -1898,17 +1898,17 @@ public class CubeMetastoreClient {
}
/**
- * Get all cube segmentations in metastore
+ * Get all segmentations in metastore
*
- * @return List of cube segmentation objects
+ * @return List of segmentation objects
* @throws HiveException
*/
- public Collection<CubeSegmentation> getAllCubeSegmentations() throws HiveException {
- if (!allCubeSegmentationPopulated) {
- List<CubeSegmentation> segs = new ArrayList<>();
+ public Collection<Segmentation> getAllSegmentations() throws HiveException {
+ if (!allSegmentationPopulated) {
+ List<Segmentation> segs = new ArrayList<>();
try {
for (String table : getAllHiveTableNames()) {
- CubeSegmentation seg = getCubeSegmentation(table);
+ Segmentation seg = getSegmentation(table);
if (seg != null) {
segs.add(seg);
}
@@ -1919,7 +1919,7 @@ public class CubeMetastoreClient {
allFactTablesPopulated = enableCaching;
return segs;
} else {
- return allCubeSegmentations.values();
+ return allSegmentations.values();
}
}
@@ -1967,7 +1967,7 @@ public class CubeMetastoreClient {
return cubeFacts;
}
- public List<CubeSegmentation> getAllCubeSegmentations(CubeInterface cube) throws HiveException {
+ public List<Segmentation> getAllSegmentations(CubeInterface cube) throws HiveException {
String cubeName = null;
if (cube != null) {
if (cube instanceof DerivedCube) {
@@ -1975,9 +1975,9 @@ public class CubeMetastoreClient {
}
cubeName = cube.getName();
}
- List<CubeSegmentation> cubeSegs = new ArrayList<>();
+ List<Segmentation> cubeSegs = new ArrayList<>();
try {
- for (CubeSegmentation seg : getAllCubeSegmentations()) {
+ for (Segmentation seg : getAllSegmentations()) {
if (cubeName == null || seg.getBaseCube().equalsIgnoreCase(cubeName)) {
cubeSegs.add(seg);
}
@@ -2208,12 +2208,12 @@ public class CubeMetastoreClient {
}
- public void dropCubeSegmentation(String segName) throws HiveException {
- if (isCubeSegmentation(segName)) {
+ public void dropSegmentation(String segName) throws HiveException {
+ if (isSegmentation(segName)) {
dropHiveTable(segName);
- allCubeSegmentations.remove(segName.trim().toLowerCase());
+ allSegmentations.remove(segName.trim().toLowerCase());
} else {
- throw new HiveException(segName + " is not a CubeSegmentation");
+ throw new HiveException(segName + " is not a Segmentation");
}
}
@@ -2315,23 +2315,23 @@ public class CubeMetastoreClient {
}
}
- public void alterCubeSegmentation(String segName, CubeSegmentation seg)
+ public void alterSegmentation(String segName, Segmentation seg)
throws HiveException {
Table segTbl = getTable(segName);
- if (isCubeSegmentation(segTbl)) {
- if (!(getCubeSegmentation(segName) == seg)) {
- dropCubeSegmentation(segName);
- createCubeSegmentation(seg);
+ if (isSegmentation(segTbl)) {
+ if (!(getSegmentation(segName) == seg)) {
+ dropSegmentation(segName);
+ createSegmentation(seg);
updateSegmentationCache(segName);
}
} else {
- throw new HiveException(segName + " is not a cube segment");
+ throw new HiveException(segName + " is not a segment");
}
}
private void updateSegmentationCache(String segmentName) throws HiveException {
if (enableCaching) {
- allCubeSegmentations.put(segmentName.trim().toLowerCase(), getCubeSegmentationTable(refreshTable(segmentName)));
+ allSegmentations.put(segmentName.trim().toLowerCase(), getSegmentationTable(refreshTable(segmentName)));
}
}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-cube/src/main/java/org/apache/lens/cube/metadata/CubeSegment.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/metadata/CubeSegment.java b/lens-cube/src/main/java/org/apache/lens/cube/metadata/CubeSegment.java
deleted file mode 100644
index 8143c3b..0000000
--- a/lens-cube/src/main/java/org/apache/lens/cube/metadata/CubeSegment.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.lens.cube.metadata;
-
-import java.util.Map;
-
-import lombok.Getter;
-
-public class CubeSegment implements Named {
- @Getter
- private String name;
- @Getter
- private Map<String, String> properties;
-
- public CubeSegment(String name, Map<String, String> properties) {
- this.name = name;
- this.properties = properties;
- }
-}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-cube/src/main/java/org/apache/lens/cube/metadata/CubeSegmentation.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/metadata/CubeSegmentation.java b/lens-cube/src/main/java/org/apache/lens/cube/metadata/CubeSegmentation.java
deleted file mode 100644
index a93fafe..0000000
--- a/lens-cube/src/main/java/org/apache/lens/cube/metadata/CubeSegmentation.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.lens.cube.metadata;
-
-import java.util.*;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.hadoop.hive.metastore.api.FieldSchema;
-import org.apache.hadoop.hive.ql.metadata.Table;
-
-import com.google.common.collect.Lists;
-
-public class CubeSegmentation extends AbstractCubeTable {
-
- private String cubeName;
- private final Set<CubeSegment> cubeSegments;
- private static final List<FieldSchema> COLUMNS = new ArrayList<>();
-
- static {
- COLUMNS.add(new FieldSchema("dummy", "string", "dummy column"));
- }
-
- public CubeSegmentation(Table hiveTable) {
- super(hiveTable);
- this.cubeSegments = getCubeSegments(getName(), getProperties());
- this.cubeName = getCubeName(getName(), getProperties());
- }
-
- public CubeSegmentation(String cubeName, String segmentName, Set<CubeSegment> cubeSegments) {
- this(cubeName, segmentName, cubeSegments, 0L);
- }
-
- public CubeSegmentation(String cubeName, String segmentName, Set<CubeSegment> cubeSegments, double weight) {
- this(cubeName, segmentName, cubeSegments, weight, new HashMap<String, String>());
- }
-
- public CubeSegmentation(String baseCube, String segmentName, Set<CubeSegment> cubeSegments,
- double weight, Map<String, String> properties) {
- super(segmentName, COLUMNS, properties, weight);
- this.cubeName = baseCube;
- this.cubeSegments = cubeSegments;
- addProperties();
- }
-
- public static Set<String> getSegmentNames(Set<CubeSegment> segments) {
- Set<String> names = new HashSet<>();
- for (CubeSegment seg : segments) {
- names.add(seg.getName());
- }
- return names;
- }
-
- @Override
- protected void addProperties() {
- super.addProperties();
- addCubeName(getName(), getProperties(), cubeName);
- addCubeSegmentProperties(getName(), getProperties(), cubeSegments);
- }
-
- private static void addCubeName(String segName, Map<String, String> props, String cubeName) {
- props.put(MetastoreUtil.getSegmentationCubeNameKey(segName), cubeName);
- }
-
- private static void addCubeSegmentProperties(String name, Map<String, String> props,
- Set<CubeSegment> cubeSegments) {
- if (cubeSegments != null){
- props.put(MetastoreUtil.getSegmentsListKey(name),
- MetastoreUtil.getNamedStr(cubeSegments));
- for (CubeSegment cubeSegment : cubeSegments) {
- for (Map.Entry<String, String> segProp : cubeSegment.getProperties().entrySet()) {
- if (!segProp.getKey().startsWith(MetastoreUtil.getSegmentPropertyKey(cubeSegment.getName()))) {
- props.put(MetastoreUtil.getSegmentPropertyKey(cubeSegment.getName()).concat(segProp.getKey()),
- segProp.getValue());
- }
- }
- }
- }
- }
-
- private static Set<CubeSegment> getCubeSegments(String name, Map<String, String> props) {
- Set<CubeSegment> cubeSegments = new HashSet<>();
- String segmentsString = MetastoreUtil.getNamedStringValue(props, MetastoreUtil.getSegmentsListKey(name));
- if (!StringUtils.isBlank(segmentsString)) {
- String[] segments = segmentsString.split(",");
- for (String seg : segments) {
- Map<String, String> segProps = new HashMap<>();
- String segmentPropStr = MetastoreUtil.getSegmentPropertyKey(seg);
- for (String key : props.keySet()) {
- if (key.startsWith(segmentPropStr)){
- segProps.put(key, props.get(key));
- }
- }
- cubeSegments.add(new CubeSegment(seg, segProps));
- }
- }
- return cubeSegments;
- }
-
- public void addCubeSegment(CubeSegment cubeSeg) {
- if (!cubeSegments.contains(cubeSeg)) {
- cubeSegments.add(cubeSeg);
- addCubeSegmentProperties(getName(), getProperties(), cubeSegments);
- }
- }
-
- public void dropCubeSegment(CubeSegment cubeSeg) {
- if (cubeSegments.contains(cubeSeg)) {
- cubeSegments.remove(cubeSeg);
- addCubeSegmentProperties(getName(), getProperties(), cubeSegments);
- }
- }
-
- public void alterCubeSegment(Set<CubeSegment> cubeSegs) {
- if (!cubeSegments.equals(cubeSegs)) {
- cubeSegments.clear();
- cubeSegments.addAll(cubeSegs);
- addCubeSegmentProperties(getName(), getProperties(), cubeSegments);
- }
- }
-
- public void alterBaseCubeName(String cubeName) {
- this.cubeName = cubeName;
- addCubeName(getName(), getProperties(), cubeName);
- }
-
- public String getBaseCube() {
- return cubeName;
- }
-
- public Set<CubeSegment> getCubeSegments() {
- return cubeSegments;
- }
-
- @Override
- public CubeTableType getTableType() {
- return CubeTableType.SEGMENTATION;
- }
-
- @Override
- public Set<String> getStorages() {
- return null;
- }
-
-
- public Date getAbsoluteStartTime() {
- return getDateFromProperty(MetastoreConstants.SEGMENTATION_ABSOLUTE_START_TIME, false, true);
- }
-
- public Date getRelativeStartTime() {
- return getDateFromProperty(MetastoreConstants.SEGMENTATION_RELATIVE_START_TIME, true, true);
- }
-
- public Date getStartTime() {
- return Collections.max(Lists.newArrayList(getRelativeStartTime(), getAbsoluteStartTime()));
- }
-
- public Date getAbsoluteEndTime() {
- return getDateFromProperty(MetastoreConstants.SEGMENTATION_ABSOLUTE_END_TIME, false, false);
- }
-
- public Date getRelativeEndTime() {
- return getDateFromProperty(MetastoreConstants.SEGMENTATION_RELATIVE_END_TIME, true, false);
- }
-
- public Date getEndTime() {
- return Collections.min(Lists.newArrayList(getRelativeEndTime(), getAbsoluteEndTime()));
- }
- static String getCubeName(String segName, Map<String, String> props) {
- return props.get(MetastoreUtil.getSegmentationCubeNameKey(segName));
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-cube/src/main/java/org/apache/lens/cube/metadata/MetastoreConstants.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/metadata/MetastoreConstants.java b/lens-cube/src/main/java/org/apache/lens/cube/metadata/MetastoreConstants.java
index 1aae267..61675bc 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/metadata/MetastoreConstants.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/metadata/MetastoreConstants.java
@@ -56,13 +56,13 @@ public final class MetastoreConstants {
public static final String FACT_ABSOLUTE_END_TIME = "cube.fact.absolute.end.time";
public static final String FACT_RELATIVE_END_TIME = "cube.fact.relative.end.time";
- // cube segmentation constants
+ // Segmentation constants
public static final String SEGMENTATION_KEY_PFX = "cube.segmentation.internal.";
public static final String SEGMENTATION_ABSOLUTE_START_TIME = "cube.segmentation.absolute.start.time";
public static final String SEGMENTATION_RELATIVE_START_TIME = "cube.segmentation.relative.start.time";
public static final String SEGMENTATION_ABSOLUTE_END_TIME = "cube.segmentation.absolute.end.time";
public static final String SEGMENTATION_RELATIVE_END_TIME = "cube.segmentation.relative.end.time";
- public static final String SEGMENTATION_CUBE_SEGMENT_SFX = ".cubesegments";
+ public static final String SEGMENTATION_CUBE_SEGMENT_SFX = ".segments";
public static final String SEGMENT_PROP_SFX = ".props.";
// dim table constants
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-cube/src/main/java/org/apache/lens/cube/metadata/Segment.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/metadata/Segment.java b/lens-cube/src/main/java/org/apache/lens/cube/metadata/Segment.java
new file mode 100644
index 0000000..8527b9c
--- /dev/null
+++ b/lens-cube/src/main/java/org/apache/lens/cube/metadata/Segment.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.lens.cube.metadata;
+
+import java.util.Map;
+
+import lombok.Getter;
+
+public class Segment implements Named {
+ @Getter
+ private String name;
+ @Getter
+ private Map<String, String> properties;
+
+ public Segment(String name, Map<String, String> properties) {
+ this.name = name;
+ this.properties = properties;
+ }
+}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-cube/src/main/java/org/apache/lens/cube/metadata/Segmentation.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/metadata/Segmentation.java b/lens-cube/src/main/java/org/apache/lens/cube/metadata/Segmentation.java
new file mode 100644
index 0000000..1e3cef3
--- /dev/null
+++ b/lens-cube/src/main/java/org/apache/lens/cube/metadata/Segmentation.java
@@ -0,0 +1,190 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.cube.metadata;
+
+import java.util.*;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.ql.metadata.Table;
+
+import com.google.common.collect.Lists;
+
+public class Segmentation extends AbstractCubeTable {
+
+ private String cubeName;
+ private final Set<Segment> segments;
+ private static final List<FieldSchema> COLUMNS = new ArrayList<>();
+
+ static {
+ COLUMNS.add(new FieldSchema("dummy", "string", "dummy column"));
+ }
+
+ public Segmentation(Table hiveTable) {
+ super(hiveTable);
+ this.segments = getSegments(getName(), getProperties());
+ this.cubeName = getCubeName(getName(), getProperties());
+ }
+
+ public Segmentation(String cubeName, String segmentName, Set<Segment> segments) {
+ this(cubeName, segmentName, segments, 0L);
+ }
+
+ public Segmentation(String cubeName, String segmentName, Set<Segment> segments, double weight) {
+ this(cubeName, segmentName, segments, weight, new HashMap<String, String>());
+ }
+
+ public Segmentation(String baseCube, String segmentName, Set<Segment> segments,
+ double weight, Map<String, String> properties) {
+ super(segmentName, COLUMNS, properties, weight);
+ this.cubeName = baseCube;
+ this.segments = segments;
+ addProperties();
+ }
+
+ public static Set<String> getSegmentNames(Set<Segment> segments) {
+ Set<String> names = new HashSet<>();
+ for (Segment seg : segments) {
+ names.add(seg.getName());
+ }
+ return names;
+ }
+
+ @Override
+ protected void addProperties() {
+ super.addProperties();
+ addCubeName(getName(), getProperties(), cubeName);
+ addSegmentProperties(getName(), getProperties(), segments);
+ }
+
+ private static void addCubeName(String segName, Map<String, String> props, String cubeName) {
+ props.put(MetastoreUtil.getSegmentationCubeNameKey(segName), cubeName);
+ }
+
+ private static void addSegmentProperties(String name, Map<String, String> props,
+ Set<Segment> segments) {
+ if (segments != null){
+ props.put(MetastoreUtil.getSegmentsListKey(name),
+ MetastoreUtil.getNamedStr(segments));
+ for (Segment segment : segments) {
+ for (Map.Entry<String, String> segProp : segment.getProperties().entrySet()) {
+ if (!segProp.getKey().startsWith(MetastoreUtil.getSegmentPropertyKey(segment.getName()))) {
+ props.put(MetastoreUtil.getSegmentPropertyKey(segment.getName()).concat(segProp.getKey()),
+ segProp.getValue());
+ }
+ }
+ }
+ }
+ }
+
+ private static Set<Segment> getSegments(String name, Map<String, String> props) {
+ Set<Segment> segments = new HashSet<>();
+ String segmentsString = MetastoreUtil.getNamedStringValue(props, MetastoreUtil.getSegmentsListKey(name));
+ if (!StringUtils.isBlank(segmentsString)) {
+ String[] segs = segmentsString.split(",");
+ for (String seg : segs) {
+ Map<String, String> segProps = new HashMap<>();
+ String segmentPropStr = MetastoreUtil.getSegmentPropertyKey(seg);
+ for (String key : props.keySet()) {
+ if (key.startsWith(segmentPropStr)){
+ segProps.put(key, props.get(key));
+ }
+ }
+ segments.add(new Segment(seg, segProps));
+ }
+ }
+ return segments;
+ }
+
+ public void addSegment(Segment cubeSeg) {
+ if (!segments.contains(cubeSeg)) {
+ segments.add(cubeSeg);
+ addSegmentProperties(getName(), getProperties(), segments);
+ }
+ }
+
+ public void dropSegment(Segment cubeSeg) {
+ if (segments.contains(cubeSeg)) {
+ segments.remove(cubeSeg);
+ addSegmentProperties(getName(), getProperties(), segments);
+ }
+ }
+
+ public void alterSegment(Set<Segment> cubeSegs) {
+ if (!segments.equals(cubeSegs)) {
+ segments.clear();
+ segments.addAll(cubeSegs);
+ addSegmentProperties(getName(), getProperties(), segments);
+ }
+ }
+
+ public void alterBaseCubeName(String cubeName) {
+ this.cubeName = cubeName;
+ addCubeName(getName(), getProperties(), cubeName);
+ }
+
+ public String getBaseCube() {
+ return cubeName;
+ }
+
+ public Set<Segment> getSegments() {
+ return segments;
+ }
+
+ @Override
+ public CubeTableType getTableType() {
+ return CubeTableType.SEGMENTATION;
+ }
+
+ @Override
+ public Set<String> getStorages() {
+ return null;
+ }
+
+
+ public Date getAbsoluteStartTime() {
+ return getDateFromProperty(MetastoreConstants.SEGMENTATION_ABSOLUTE_START_TIME, false, true);
+ }
+
+ public Date getRelativeStartTime() {
+ return getDateFromProperty(MetastoreConstants.SEGMENTATION_RELATIVE_START_TIME, true, true);
+ }
+
+ public Date getStartTime() {
+ return Collections.max(Lists.newArrayList(getRelativeStartTime(), getAbsoluteStartTime()));
+ }
+
+ public Date getAbsoluteEndTime() {
+ return getDateFromProperty(MetastoreConstants.SEGMENTATION_ABSOLUTE_END_TIME, false, false);
+ }
+
+ public Date getRelativeEndTime() {
+ return getDateFromProperty(MetastoreConstants.SEGMENTATION_RELATIVE_END_TIME, true, false);
+ }
+
+ public Date getEndTime() {
+ return Collections.min(Lists.newArrayList(getRelativeEndTime(), getAbsoluteEndTime()));
+ }
+ static String getCubeName(String segName, Map<String, String> props) {
+ return props.get(MetastoreUtil.getSegmentationCubeNameKey(segName));
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-cube/src/test/java/org/apache/lens/cube/metadata/TestCubeMetastoreClient.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/java/org/apache/lens/cube/metadata/TestCubeMetastoreClient.java b/lens-cube/src/test/java/org/apache/lens/cube/metadata/TestCubeMetastoreClient.java
index e06ff5b..f84f2e0 100644
--- a/lens-cube/src/test/java/org/apache/lens/cube/metadata/TestCubeMetastoreClient.java
+++ b/lens-cube/src/test/java/org/apache/lens/cube/metadata/TestCubeMetastoreClient.java
@@ -1095,8 +1095,8 @@ public class TestCubeMetastoreClient {
}
@Test(priority = 1)
- public void testCubeSegmentation() throws Exception {
- String segmentName = "testMetastoreCubeSegmentation";
+ public void testSegmentation() throws Exception {
+ String segmentName = "testMetastoreSegmentation";
Table cubeTbl = client.getHiveTable(CUBE_NAME);
assertTrue(client.isCube(cubeTbl));
@@ -1107,37 +1107,37 @@ public class TestCubeMetastoreClient {
Map<String, String> prop3 = new HashMap<String, String>(){{put("foo3", "bar3"); }};
Map<String, String> prop5 = new HashMap<String, String>(){{put("foo5", "bar5"); }};
- CubeSegment seg1 = new CubeSegment("cube1", prop1);
- CubeSegment seg2 = new CubeSegment("cube2", prop2);
- CubeSegment seg3 = new CubeSegment("cube3", prop3);
- CubeSegment seg5 = new CubeSegment("cube5", prop5);
+ Segment seg1 = new Segment("cube1", prop1);
+ Segment seg2 = new Segment("cube2", prop2);
+ Segment seg3 = new Segment("cube3", prop3);
+ Segment seg5 = new Segment("cube5", prop5);
- Set<CubeSegment> cubeSegs = Sets.newHashSet(seg1, seg2, seg3);
+ Set<Segment> cubeSegs = Sets.newHashSet(seg1, seg2, seg3);
- //create cube segmentation
- client.createCubeSegmentation(CUBE_NAME, segmentName, cubeSegs, 0L, props);
- assertEquals(client.getCubeSegmentation(segmentName).getCubeSegments().size(), 3);
+ //create segmentation
+ client.createSegmentation(CUBE_NAME, segmentName, cubeSegs, 0L, props);
+ assertEquals(client.getSegmentation(segmentName).getSegments().size(), 3);
- //Alter cube segmentation
- CubeSegmentation segmentation = new CubeSegmentation(Hive.get(conf).getTable(segmentName));
- segmentation.addCubeSegment(seg5);
+ //Alter segmentation
+ Segmentation segmentation = new Segmentation(Hive.get(conf).getTable(segmentName));
+ segmentation.addSegment(seg5);
segmentation.addProperties(new HashMap<String, String>(){{put("new_key", "new_val"); }});
segmentation.alterBaseCubeName("segCubeAltered");
segmentation.alterWeight(100.0);
- client.alterCubeSegmentation(segmentName, segmentation);
+ client.alterSegmentation(segmentName, segmentation);
- assertNotNull(client.getCubeSegmentation(segmentName));
- assertEquals(client.getCubeSegmentation(segmentName).getCubeSegments().size(), 4);
- assertEquals(client.getCubeSegmentation(segmentName).getBaseCube(), "segCubeAltered");
- assertEquals(client.getCubeSegmentation(segmentName).weight(), 100.0);
+ assertNotNull(client.getSegmentation(segmentName));
+ assertEquals(client.getSegmentation(segmentName).getSegments().size(), 4);
+ assertEquals(client.getSegmentation(segmentName).getBaseCube(), "segCubeAltered");
+ assertEquals(client.getSegmentation(segmentName).weight(), 100.0);
- //drop cubesegment to segmentation
- segmentation.dropCubeSegment(seg5);
- client.alterCubeSegmentation(segmentName, segmentation);
- assertEquals(client.getCubeSegmentation(segmentName).getCubeSegments().size(), 3);
+ //drop Segment to segmentation
+ segmentation.dropSegment(seg5);
+ client.alterSegmentation(segmentName, segmentation);
+ assertEquals(client.getSegmentation(segmentName).getSegments().size(), 3);
//drop segmentation
- client.dropCubeSegmentation(segmentName);
+ client.dropSegmentation(segmentName);
assertFalse(client.tableExists(segmentName));
}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java b/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
index a04a67f..e5a397b 100644
--- a/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
+++ b/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
@@ -119,7 +119,7 @@ public class SampleMetastore {
createCubes();
createDimensions();
createFacts();
- createCubeSegmentations();
+ createSegmentations();
createDimensionTables();
try {
DatabaseUtil.initializeDatabaseStorage();
@@ -171,10 +171,10 @@ public class SampleMetastore {
createFact("sales-aggr-continuous-fact.xml");
}
- private void createCubeSegmentations() throws JAXBException, IOException {
- result = metaClient.createCubeSegmentation("seg1.xml");
+ private void createSegmentations() throws JAXBException, IOException {
+ result = metaClient.createSegmentation("seg1.xml");
if (result.getStatus().equals(APIResult.Status.FAILED)) {
- System.err.println("Creating cubesegmentation from : " + "seg1.xml"
+ System.err.println("Creating segmentation from : " + "seg1.xml"
+ " failed, reason:" + result.getMessage());
retCode = 1;
}
@@ -199,7 +199,7 @@ public class SampleMetastore {
System.out.println("Dimensions:" + metastore.metaClient.getAllDimensions());
System.out.println("Fact tables:" + metastore.metaClient.getAllFactTables());
System.out.println("Dimension tables:" + metastore.metaClient.getAllDimensionTables());
- System.out.println("CubeSegmentations:" + metastore.metaClient.getAllCubeSegmentations());
+ System.out.println("Segmentations:" + metastore.metaClient.getAllSegmentations());
if (metastore.retCode != 0) {
System.exit(metastore.retCode);
}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-examples/src/main/resources/seg1.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/seg1.xml b/lens-examples/src/main/resources/seg1.xml
index c1576d7..879572c 100644
--- a/lens-examples/src/main/resources/seg1.xml
+++ b/lens-examples/src/main/resources/seg1.xml
@@ -19,26 +19,26 @@
under the License.
-->
-<x_cube_segmentation cube_name="sample_cube" name="seg1" weight="100.0" xmlns="uri:lens:cube:0.1"
+<x_segmentation cube_name="sample_cube" name="seg1" weight="100.0" xmlns="uri:lens:cube:0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
<properties>
<property name= "cube.segmentation.relative.start.time" value="now -10days"/>
</properties>
- <cube_segements>
- <cube_segment cube_name="cube11">
+ <segements>
+ <segment cube_name="cube11">
<segment_parameters>
<property name="lens.metastore.cube.column.mapping" value="foo=bar"/>
</segment_parameters>
- </cube_segment>
- <cube_segment cube_name="cube22">
+ </segment>
+ <segment cube_name="cube22">
<segment_parameters>
<property name="lens.metastore.cube.column.mapping" value="foo1=bar1"/>
</segment_parameters>
- </cube_segment>
- <cube_segment cube_name="cube33">
+ </segment>
+ <segment cube_name="cube33">
<segment_parameters>
<property name="lens.metastore.cube.column.mapping" value="foo2=bar2"/>
</segment_parameters>
- </cube_segment>
- </cube_segements>
-</x_cube_segmentation>
+ </segment>
+ </segements>
+</x_segmentation>
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-examples/src/test/resources/yaml/seg1.yaml
----------------------------------------------------------------------
diff --git a/lens-examples/src/test/resources/yaml/seg1.yaml b/lens-examples/src/test/resources/yaml/seg1.yaml
index dd2f339..ba20333 100644
--- a/lens-examples/src/test/resources/yaml/seg1.yaml
+++ b/lens-examples/src/test/resources/yaml/seg1.yaml
@@ -15,7 +15,7 @@
# limitations under the License.
properties:
cube.segmentation.relative.start.time: now -10days
-cubeSegements:
+segements:
-
segmentParameters:
lens.metastore.cube.column.mapping: foo=bar
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-server-api/src/main/java/org/apache/lens/server/api/metastore/CubeMetastoreService.java
----------------------------------------------------------------------
diff --git a/lens-server-api/src/main/java/org/apache/lens/server/api/metastore/CubeMetastoreService.java b/lens-server-api/src/main/java/org/apache/lens/server/api/metastore/CubeMetastoreService.java
index 431164f..3e9f286 100644
--- a/lens-server-api/src/main/java/org/apache/lens/server/api/metastore/CubeMetastoreService.java
+++ b/lens-server-api/src/main/java/org/apache/lens/server/api/metastore/CubeMetastoreService.java
@@ -574,49 +574,49 @@ public interface CubeMetastoreService extends LensService {
/**
*
* @param sessionid The session id
- * @param cubeSeg The cube segmentation
+ * @param cubeSeg The segmentation
* @throws LensException
*/
- void createCubeSegmentation(LensSessionHandle sessionid, XCubeSegmentation cubeSeg) throws LensException;
+ void createSegmentation(LensSessionHandle sessionid, XSegmentation cubeSeg) throws LensException;
/**
- * Create cube segmentation
+ * Create segmentation
*
* @param sessionid The session id
- * @param segName Cube segmentation name
- * @return {@link XCubeSegmentation}
+ * @param segName Ssegmentation name
+ * @return {@link XSegmentation}
* @throws LensException
*/
- XCubeSegmentation getCubeSegmentation(LensSessionHandle sessionid, String segName) throws LensException;
+ XSegmentation getSegmentation(LensSessionHandle sessionid, String segName) throws LensException;
/**
- * Get cube segmentation given by name
+ * Get segmentation given by name
*
* @param sessionid The session id
- * @param cubeSeg The cube segmentation
+ * @param cubeSeg The segmentation
* @throws LensException
*/
- void updateCubeSegmentation(LensSessionHandle sessionid, XCubeSegmentation cubeSeg) throws LensException;
+ void updateSegmentation(LensSessionHandle sessionid, XSegmentation cubeSeg) throws LensException;
/**
- * Update cube segmentation
+ * Update segmentation
*
* @param sessionid The session id
- * @param cubeSegName Cube segmentation name
+ * @param cubeSegName Segmentation name
* @throws LensException
*/
- void dropCubeSegmentation(LensSessionHandle sessionid, String cubeSegName) throws LensException;
+ void dropSegmentation(LensSessionHandle sessionid, String cubeSegName) throws LensException;
/**
- * Get all cube segmentations belong to Cube
+ * Get all segmentations belong to Cube
*
* @param sessionid The session id
* @param cubeName The cube Name
* @return
* @throws LensException
*/
- List<String> getAllCubeSegmentations(LensSessionHandle sessionid, String cubeName) throws LensException;
+ List<String> getAllSegmentations(LensSessionHandle sessionid, String cubeName) throws LensException;
}
http://git-wip-us.apache.org/repos/asf/lens/blob/20c1a53f/lens-server/src/main/java/org/apache/lens/server/metastore/CubeMetastoreServiceImpl.java
----------------------------------------------------------------------
diff --git a/lens-server/src/main/java/org/apache/lens/server/metastore/CubeMetastoreServiceImpl.java b/lens-server/src/main/java/org/apache/lens/server/metastore/CubeMetastoreServiceImpl.java
index c503f16..595520e 100644
--- a/lens-server/src/main/java/org/apache/lens/server/metastore/CubeMetastoreServiceImpl.java
+++ b/lens-server/src/main/java/org/apache/lens/server/metastore/CubeMetastoreServiceImpl.java
@@ -508,12 +508,12 @@ public class CubeMetastoreServiceImpl extends BaseLensService implements CubeMet
}
@Override
- public XCubeSegmentation getCubeSegmentation(LensSessionHandle sessionid, String cubeSegName) throws LensException {
+ public XSegmentation getSegmentation(LensSessionHandle sessionid, String cubeSegName) throws LensException {
try {
acquire(sessionid);
CubeMetastoreClient msClient = getClient(sessionid);
- CubeSegmentation cubeSeg = msClient.getCubeSegmentation(cubeSegName);
- return JAXBUtils.xsegmentationFromCubeSegmentation(cubeSeg);
+ Segmentation cubeSeg = msClient.getSegmentation(cubeSegName);
+ return JAXBUtils.xsegmentationFromSegmentation(cubeSeg);
} catch (HiveException e) {
throw new LensException(e);
} finally {
@@ -542,16 +542,16 @@ public class CubeMetastoreServiceImpl extends BaseLensService implements CubeMet
}
@Override
- public void createCubeSegmentation(LensSessionHandle sessionid, XCubeSegmentation cubeSeg) throws LensException {
+ public void createSegmentation(LensSessionHandle sessionid, XSegmentation cubeSeg) throws LensException {
try {
acquire(sessionid);
- getClient(sessionid).createCubeSegmentation(
+ getClient(sessionid).createSegmentation(
cubeSeg.getCubeName(),
cubeSeg.getName(),
- JAXBUtils.cubeSegmentsFromXCubeSegments(cubeSeg.getCubeSegements()),
+ JAXBUtils.segmentsFromXSegments(cubeSeg.getSegements()),
cubeSeg.getWeight(),
JAXBUtils.mapFromXProperties(cubeSeg.getProperties()));
- log.info("Created cube segmentation " + cubeSeg.getName());
+ log.info("Created segmentation " + cubeSeg.getName());
} catch (HiveException e) {
throw new LensException(e);
} finally {
@@ -575,11 +575,11 @@ public class CubeMetastoreServiceImpl extends BaseLensService implements CubeMet
}
@Override
- public void updateCubeSegmentation(LensSessionHandle sessionid, XCubeSegmentation cubeSeg) throws LensException {
+ public void updateSegmentation(LensSessionHandle sessionid, XSegmentation cubeSeg) throws LensException {
try {
acquire(sessionid);
- getClient(sessionid).alterCubeSegmentation(cubeSeg.getName(), cubeSegmentationFromXCubeSegmentation(cubeSeg));
- log.info("Updated cube segmentation " + cubeSeg.getName());
+ getClient(sessionid).alterSegmentation(cubeSeg.getName(), segmentationFromXSegmentation(cubeSeg));
+ log.info("Updated segmentation " + cubeSeg.getName());
} catch (HiveException e) {
throw new LensException(e);
} finally {
@@ -601,11 +601,11 @@ public class CubeMetastoreServiceImpl extends BaseLensService implements CubeMet
}
@Override
- public void dropCubeSegmentation(LensSessionHandle sessionid, String cubeSegName) throws LensException {
+ public void dropSegmentation(LensSessionHandle sessionid, String cubeSegName) throws LensException {
try {
acquire(sessionid);
- getClient(sessionid).dropCubeSegmentation(cubeSegName);
- log.info("Dropped cube segemntation " + cubeSegName);
+ getClient(sessionid).dropSegmentation(cubeSegName);
+ log.info("Dropped segemntation " + cubeSegName);
} catch (HiveException e) {
throw new LensException(e);
} finally {
@@ -637,7 +637,7 @@ public class CubeMetastoreServiceImpl extends BaseLensService implements CubeMet
}
@Override
- public List<String> getAllCubeSegmentations(LensSessionHandle sessionid, String cubeName) throws LensException {
+ public List<String> getAllSegmentations(LensSessionHandle sessionid, String cubeName) throws LensException {
try {
acquire(sessionid);
CubeMetastoreClient client = getClient(sessionid);
@@ -645,9 +645,9 @@ public class CubeMetastoreServiceImpl extends BaseLensService implements CubeMet
if (cubeName != null && seg == null) {
throw new LensException("Could not get table: " + cubeName + " as a cube");
}
- Collection<CubeSegmentation> segs = client.getAllCubeSegmentations(seg);
+ Collection<Segmentation> segs = client.getAllSegmentations(seg);
List<String> segNames = new ArrayList<String>(segs.size());
- for (CubeSegmentation cs : segs) {
+ for (Segmentation cs : segs) {
segNames.add(cs.getName());
}
return segNames;