@Test public void testSetStorageGroup() { MTree root = new MTree("root"); try { root.setStorageGroup("root.laptop.d1"); assertEquals(true, root.isPathExist("root.laptop.d1")); assertEquals(true, root.checkFileNameByPath("root.laptop.d1")); assertEquals("root.laptop.d1", root.getFileNameByPath("root.laptop.d1")); assertEquals(false, root.isPathExist("root.laptop.d1.s1")); assertEquals(true, root.checkFileNameByPath("root.laptop.d1.s1")); assertEquals("root.laptop.d1", root.getFileNameByPath("root.laptop.d1.s1")); } catch (PathErrorException e) { e.printStackTrace(); fail(e.getMessage()); } try { root.setStorageGroup("root.laptop.d2"); } catch (PathErrorException e) { fail(e.getMessage()); } try { root.setStorageGroup("root.laptop"); } catch (PathErrorException e) { Assert.assertEquals( "The seriesPath of root.laptop already exist, it can't be set to the storage group", e.getMessage()); } assertEquals(root.isPathExist("root.laptop.d1.s0"), false); assertEquals(root.isPathExist("root.laptop.d1.s1"), false); assertEquals(root.isPathExist("root.laptop.d2.s0"), false); assertEquals(root.isPathExist("root.laptop.d2.s1"), false); try { assertEquals("root.laptop.d1", root.getFileNameByPath("root.laptop.d1.s0")); root.addTimeseriesPath("root.laptop.d1.s0", "INT32", "RLE", new String[0]); assertEquals("root.laptop.d1", root.getFileNameByPath("root.laptop.d1.s1")); root.addTimeseriesPath("root.laptop.d1.s1", "INT32", "RLE", new String[0]); assertEquals("root.laptop.d2", root.getFileNameByPath("root.laptop.d2.s0")); root.addTimeseriesPath("root.laptop.d2.s0", "INT32", "RLE", new String[0]); assertEquals("root.laptop.d2", root.getFileNameByPath("root.laptop.d2.s1")); root.addTimeseriesPath("root.laptop.d2.s1", "INT32", "RLE", new String[0]); } catch (PathErrorException e) { e.printStackTrace(); fail(e.getMessage()); } try { root.deletePath("root.laptop.d1.s0"); } catch (PathErrorException e) { e.printStackTrace(); fail(e.getMessage()); } assertEquals(root.isPathExist("root.laptop.d1.s0"), false); try { root.deletePath("root.laptop.d1"); } catch (PathErrorException e) { e.printStackTrace(); fail(e.getMessage()); } assertEquals(root.isPathExist("root.laptop.d1.s1"), false); assertEquals(root.isPathExist("root.laptop.d1"), false); assertEquals(root.isPathExist("root.laptop"), true); assertEquals(root.isPathExist("root.laptop.d2"), true); assertEquals(root.isPathExist("root.laptop.d2.s0"), true); }
public void setStorageGroup(String path) throws PathErrorException { String[] nodeNames = path.split(separator); MNode cur = root; if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new PathErrorException( String.format("The storage group can't be set to the %s node", path)); } int i = 1; while (i < nodeNames.length - 1) { MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(nodeNames[i], cur, false)); } else if (temp.isStorageLevel()) { throw new PathErrorException( String.format("The prefix of %s has been set to the storage group.", path)); } cur = cur.getChild(nodeNames[i]); i++; } MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(nodeNames[i], cur, false)); } else { throw new PathErrorException( String.format("The seriesPath of %s already exist, it can't be set to the storage group", path)); } cur = cur.getChild(nodeNames[i]); cur.setStorageLevel(true); setDataFileName(path, cur); }
MTree implements Serializable { public void setStorageGroup(String path) throws PathErrorException { String[] nodeNames = path.split(separator); MNode cur = root; if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new PathErrorException( String.format("The storage group can't be set to the %s node", path)); } int i = 1; while (i < nodeNames.length - 1) { MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(nodeNames[i], cur, false)); } else if (temp.isStorageLevel()) { throw new PathErrorException( String.format("The prefix of %s has been set to the storage group.", path)); } cur = cur.getChild(nodeNames[i]); i++; } MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(nodeNames[i], cur, false)); } else { throw new PathErrorException( String.format("The seriesPath of %s already exist, it can't be set to the storage group", path)); } cur = cur.getChild(nodeNames[i]); cur.setStorageLevel(true); setDataFileName(path, cur); } }
MTree implements Serializable { public void setStorageGroup(String path) throws PathErrorException { String[] nodeNames = path.split(separator); MNode cur = root; if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new PathErrorException( String.format("The storage group can't be set to the %s node", path)); } int i = 1; while (i < nodeNames.length - 1) { MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(nodeNames[i], cur, false)); } else if (temp.isStorageLevel()) { throw new PathErrorException( String.format("The prefix of %s has been set to the storage group.", path)); } cur = cur.getChild(nodeNames[i]); i++; } MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(nodeNames[i], cur, false)); } else { throw new PathErrorException( String.format("The seriesPath of %s already exist, it can't be set to the storage group", path)); } cur = cur.getChild(nodeNames[i]); cur.setStorageLevel(true); setDataFileName(path, cur); } MTree(String rootName);  MTree(MNode root); }
MTree implements Serializable { public void setStorageGroup(String path) throws PathErrorException { String[] nodeNames = path.split(separator); MNode cur = root; if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new PathErrorException( String.format("The storage group can't be set to the %s node", path)); } int i = 1; while (i < nodeNames.length - 1) { MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(nodeNames[i], cur, false)); } else if (temp.isStorageLevel()) { throw new PathErrorException( String.format("The prefix of %s has been set to the storage group.", path)); } cur = cur.getChild(nodeNames[i]); i++; } MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(nodeNames[i], cur, false)); } else { throw new PathErrorException( String.format("The seriesPath of %s already exist, it can't be set to the storage group", path)); } cur = cur.getChild(nodeNames[i]); cur.setStorageLevel(true); setDataFileName(path, cur); } MTree(String rootName);  MTree(MNode root); void addTimeseriesPath(String timeseriesPath, String dataType, String encoding,
      String[] args); boolean isPathExist(String path); boolean isPathExist(MNode node, String path); void setStorageGroup(String path); String deletePath(String path); boolean hasPath(String path); ColumnSchema getSchemaForOnePath(String path); ColumnSchema getSchemaForOnePath(MNode node, String path); ColumnSchema getSchemaForOnePathWithCheck(MNode node, String path); ColumnSchema getSchemaForOnePathWithCheck(String path); MNode getNodeByPath(String path); MNode getNodeByPathWithFileLevelCheck(String path); String getDeviceTypeByPath(String path); String getFileNameByPath(String path); String getFileNameByPath(MNode node, String path); String getFileNameByPathWithCheck(MNode node, String path); boolean checkFileNameByPath(String path); HashMap<String, ArrayList<String>> getAllPath(String pathReg); List<List<String>> getShowTimeseriesPath(String pathReg); List<String> getLeafNodePathInNextLevel(String path); ArrayList<String> getAllPathInList(String path); int getFileCountForOneType(String path); ArrayList<String> getAllType(); HashSet<String> getAllStorageGroup(); ArrayList<String> getDeviceForOneType(String type); ArrayList<ColumnSchema> getSchemaForOneType(String path); ArrayList<ColumnSchema> getSchemaForOneFileNode(String path); Map<String, ColumnSchema> getSchemaMapForOneFileNode(String path); Map<String, Integer> getNumSchemaMapForOneFileNode(String path); String toString(); MNode getRoot(); }
MTree implements Serializable { public void setStorageGroup(String path) throws PathErrorException { String[] nodeNames = path.split(separator); MNode cur = root; if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new PathErrorException( String.format("The storage group can't be set to the %s node", path)); } int i = 1; while (i < nodeNames.length - 1) { MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(nodeNames[i], cur, false)); } else if (temp.isStorageLevel()) { throw new PathErrorException( String.format("The prefix of %s has been set to the storage group.", path)); } cur = cur.getChild(nodeNames[i]); i++; } MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(nodeNames[i], cur, false)); } else { throw new PathErrorException( String.format("The seriesPath of %s already exist, it can't be set to the storage group", path)); } cur = cur.getChild(nodeNames[i]); cur.setStorageLevel(true); setDataFileName(path, cur); } MTree(String rootName);  MTree(MNode root); void addTimeseriesPath(String timeseriesPath, String dataType, String encoding,
      String[] args); boolean isPathExist(String path); boolean isPathExist(MNode node, String path); void setStorageGroup(String path); String deletePath(String path); boolean hasPath(String path); ColumnSchema getSchemaForOnePath(String path); ColumnSchema getSchemaForOnePath(MNode node, String path); ColumnSchema getSchemaForOnePathWithCheck(MNode node, String path); ColumnSchema getSchemaForOnePathWithCheck(String path); MNode getNodeByPath(String path); MNode getNodeByPathWithFileLevelCheck(String path); String getDeviceTypeByPath(String path); String getFileNameByPath(String path); String getFileNameByPath(MNode node, String path); String getFileNameByPathWithCheck(MNode node, String path); boolean checkFileNameByPath(String path); HashMap<String, ArrayList<String>> getAllPath(String pathReg); List<List<String>> getShowTimeseriesPath(String pathReg); List<String> getLeafNodePathInNextLevel(String path); ArrayList<String> getAllPathInList(String path); int getFileCountForOneType(String path); ArrayList<String> getAllType(); HashSet<String> getAllStorageGroup(); ArrayList<String> getDeviceForOneType(String type); ArrayList<ColumnSchema> getSchemaForOneType(String path); ArrayList<ColumnSchema> getSchemaForOneFileNode(String path); Map<String, ColumnSchema> getSchemaMapForOneFileNode(String path); Map<String, Integer> getNumSchemaMapForOneFileNode(String path); String toString(); MNode getRoot();  }