@Test public void testAddLeftNodePath() { MTree root = new MTree("root"); try { root.addTimeseriesPath("root.laptop.d1.s1", "INT32", "RLE", new String[0]); } catch (PathErrorException e) { e.printStackTrace(); fail(e.getMessage()); } try { root.addTimeseriesPath("root.laptop.d1.s1.b", "INT32", "RLE", new String[0]); } catch (PathErrorException e) { Assert.assertEquals( String.format("The Node [%s] is left node, the timeseries %s can't be created", "s1", "root.laptop.d1.s1.b"), e.getMessage()); } }
public void addTimeseriesPath(String timeseriesPath, String dataType, String encoding, String[] args) throws PathErrorException { String[] nodeNames = timeseriesPath.trim().split(separator); if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new PathErrorException(String.format("Timeseries %s is not right.", timeseriesPath)); } int i = 1; MNode cur = root; String levelPath = null; while (i < nodeNames.length) { String nodeName = nodeNames[i]; if (i == nodeNames.length - 1) { cur.setDataFileName(levelPath); break; } if (cur.isStorageLevel()) { levelPath = cur.getDataFileName(); } if (!cur.hasChild(nodeName)) { if (cur.isLeaf()) { throw new PathErrorException( String.format("The Node [%s] is left node, the timeseries %s can't be created", cur.getName(), timeseriesPath)); } cur.addChild(nodeName, new MNode(nodeName, cur, false)); } cur.setDataFileName(levelPath); cur = cur.getChild(nodeName); if (levelPath == null) { levelPath = cur.getDataFileName(); } i++; } TSDataType dt = TSDataType.valueOf(dataType); TSEncoding ed = TSEncoding.valueOf(encoding); MNode leaf = new MNode(nodeNames[nodeNames.length - 1], cur, dt, ed); if (args.length > 0) { for (int k = 0; k < args.length; k++) { String[] arg = args[k].split("="); leaf.getSchema().putKeyValueToArgs(arg[0], arg[1]); } } levelPath = cur.getDataFileName(); leaf.setDataFileName(levelPath); if (cur.isLeaf()) { throw new PathErrorException( String.format("The Node [%s] is left node, the timeseries %s can't be created", cur.getName(), timeseriesPath)); } cur.addChild(nodeNames[nodeNames.length - 1], leaf); }
MTree implements Serializable { public void addTimeseriesPath(String timeseriesPath, String dataType, String encoding, String[] args) throws PathErrorException { String[] nodeNames = timeseriesPath.trim().split(separator); if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new PathErrorException(String.format("Timeseries %s is not right.", timeseriesPath)); } int i = 1; MNode cur = root; String levelPath = null; while (i < nodeNames.length) { String nodeName = nodeNames[i]; if (i == nodeNames.length - 1) { cur.setDataFileName(levelPath); break; } if (cur.isStorageLevel()) { levelPath = cur.getDataFileName(); } if (!cur.hasChild(nodeName)) { if (cur.isLeaf()) { throw new PathErrorException( String.format("The Node [%s] is left node, the timeseries %s can't be created", cur.getName(), timeseriesPath)); } cur.addChild(nodeName, new MNode(nodeName, cur, false)); } cur.setDataFileName(levelPath); cur = cur.getChild(nodeName); if (levelPath == null) { levelPath = cur.getDataFileName(); } i++; } TSDataType dt = TSDataType.valueOf(dataType); TSEncoding ed = TSEncoding.valueOf(encoding); MNode leaf = new MNode(nodeNames[nodeNames.length - 1], cur, dt, ed); if (args.length > 0) { for (int k = 0; k < args.length; k++) { String[] arg = args[k].split("="); leaf.getSchema().putKeyValueToArgs(arg[0], arg[1]); } } levelPath = cur.getDataFileName(); leaf.setDataFileName(levelPath); if (cur.isLeaf()) { throw new PathErrorException( String.format("The Node [%s] is left node, the timeseries %s can't be created", cur.getName(), timeseriesPath)); } cur.addChild(nodeNames[nodeNames.length - 1], leaf); } }
MTree implements Serializable { public void addTimeseriesPath(String timeseriesPath, String dataType, String encoding, String[] args) throws PathErrorException { String[] nodeNames = timeseriesPath.trim().split(separator); if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new PathErrorException(String.format("Timeseries %s is not right.", timeseriesPath)); } int i = 1; MNode cur = root; String levelPath = null; while (i < nodeNames.length) { String nodeName = nodeNames[i]; if (i == nodeNames.length - 1) { cur.setDataFileName(levelPath); break; } if (cur.isStorageLevel()) { levelPath = cur.getDataFileName(); } if (!cur.hasChild(nodeName)) { if (cur.isLeaf()) { throw new PathErrorException( String.format("The Node [%s] is left node, the timeseries %s can't be created", cur.getName(), timeseriesPath)); } cur.addChild(nodeName, new MNode(nodeName, cur, false)); } cur.setDataFileName(levelPath); cur = cur.getChild(nodeName); if (levelPath == null) { levelPath = cur.getDataFileName(); } i++; } TSDataType dt = TSDataType.valueOf(dataType); TSEncoding ed = TSEncoding.valueOf(encoding); MNode leaf = new MNode(nodeNames[nodeNames.length - 1], cur, dt, ed); if (args.length > 0) { for (int k = 0; k < args.length; k++) { String[] arg = args[k].split("="); leaf.getSchema().putKeyValueToArgs(arg[0], arg[1]); } } levelPath = cur.getDataFileName(); leaf.setDataFileName(levelPath); if (cur.isLeaf()) { throw new PathErrorException( String.format("The Node [%s] is left node, the timeseries %s can't be created", cur.getName(), timeseriesPath)); } cur.addChild(nodeNames[nodeNames.length - 1], leaf); } MTree(String rootName);  MTree(MNode root); }
MTree implements Serializable { public void addTimeseriesPath(String timeseriesPath, String dataType, String encoding, String[] args) throws PathErrorException { String[] nodeNames = timeseriesPath.trim().split(separator); if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new PathErrorException(String.format("Timeseries %s is not right.", timeseriesPath)); } int i = 1; MNode cur = root; String levelPath = null; while (i < nodeNames.length) { String nodeName = nodeNames[i]; if (i == nodeNames.length - 1) { cur.setDataFileName(levelPath); break; } if (cur.isStorageLevel()) { levelPath = cur.getDataFileName(); } if (!cur.hasChild(nodeName)) { if (cur.isLeaf()) { throw new PathErrorException( String.format("The Node [%s] is left node, the timeseries %s can't be created", cur.getName(), timeseriesPath)); } cur.addChild(nodeName, new MNode(nodeName, cur, false)); } cur.setDataFileName(levelPath); cur = cur.getChild(nodeName); if (levelPath == null) { levelPath = cur.getDataFileName(); } i++; } TSDataType dt = TSDataType.valueOf(dataType); TSEncoding ed = TSEncoding.valueOf(encoding); MNode leaf = new MNode(nodeNames[nodeNames.length - 1], cur, dt, ed); if (args.length > 0) { for (int k = 0; k < args.length; k++) { String[] arg = args[k].split("="); leaf.getSchema().putKeyValueToArgs(arg[0], arg[1]); } } levelPath = cur.getDataFileName(); leaf.setDataFileName(levelPath); if (cur.isLeaf()) { throw new PathErrorException( String.format("The Node [%s] is left node, the timeseries %s can't be created", cur.getName(), timeseriesPath)); } cur.addChild(nodeNames[nodeNames.length - 1], leaf); } 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 addTimeseriesPath(String timeseriesPath, String dataType, String encoding, String[] args) throws PathErrorException { String[] nodeNames = timeseriesPath.trim().split(separator); if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new PathErrorException(String.format("Timeseries %s is not right.", timeseriesPath)); } int i = 1; MNode cur = root; String levelPath = null; while (i < nodeNames.length) { String nodeName = nodeNames[i]; if (i == nodeNames.length - 1) { cur.setDataFileName(levelPath); break; } if (cur.isStorageLevel()) { levelPath = cur.getDataFileName(); } if (!cur.hasChild(nodeName)) { if (cur.isLeaf()) { throw new PathErrorException( String.format("The Node [%s] is left node, the timeseries %s can't be created", cur.getName(), timeseriesPath)); } cur.addChild(nodeName, new MNode(nodeName, cur, false)); } cur.setDataFileName(levelPath); cur = cur.getChild(nodeName); if (levelPath == null) { levelPath = cur.getDataFileName(); } i++; } TSDataType dt = TSDataType.valueOf(dataType); TSEncoding ed = TSEncoding.valueOf(encoding); MNode leaf = new MNode(nodeNames[nodeNames.length - 1], cur, dt, ed); if (args.length > 0) { for (int k = 0; k < args.length; k++) { String[] arg = args[k].split("="); leaf.getSchema().putKeyValueToArgs(arg[0], arg[1]); } } levelPath = cur.getDataFileName(); leaf.setDataFileName(levelPath); if (cur.isLeaf()) { throw new PathErrorException( String.format("The Node [%s] is left node, the timeseries %s can't be created", cur.getName(), timeseriesPath)); } cur.addChild(nodeNames[nodeNames.length - 1], leaf); } 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();  }