ROdps { private static LinkedHashMap<String, String> parsePartition(String part) throws ROdpsException { LinkedHashMap<String, String> ret = new LinkedHashMap<String, String>(); String[] pts = part.split(",|/"); for (String p : pts) { String[] kv = p.split("="); if (kv.length != 2) { throw new ROdpsException("Partition expression error:" + part); } if (kv[1].startsWith("'") && kv[1].endsWith("'") || kv[1].startsWith("\"") && kv[1].endsWith("\"")) { kv[1] = kv[1].substring(1, kv[1].length() - 1); } ret.put(kv[0], kv[1]); } return ret; } ROdps(String projectName, String accessID, String accessKey, String endPoint,
      String dtEndpoint, String logviewHost, String log4j_properties); void setBizId(String s); void set(String key, String value); void unset(String key); void writeTableFromDT(String projectName, String tableName, String partition,
      String dataFilePathName, String columnDelimiter, String rowDelimiter, long recordCount,
      int threadNumber); List<List<String>> loadTableFromDT(String projectName, String tableName, String partition,
      String tempFile, String colDelimiter, String rowDelimiter, int limit, int threadNumber); boolean useProject(String projectName); String getProjectName(String projectName); long getTableSize(String projectName, String tableName, String partition); List<DataFrameItem> describeTable(String projectName, String tableName, String partition); boolean dropTable(String projectName, String tableName); boolean isTableExist(String projectName, String tableName, String partition); String getTableSchemaJson(String projectName, String tableName); int getIndexFromColName(String colName, String tableSchemaJson); List<String> runSqlTask(String sql); List<DataFrameItem> getTables(String projectName, String pattern); static String formatPartition(String part, String valueDim, String fieldDim); boolean setLogPath(String log_path);  }
@Test public void testParsePartition() throws ROdpsException { assertTrue(rodps.formatPartition("pt=1/ds=2", "'", " and ").equals("pt='1' and ds='2'")); assertTrue(rodps.formatPartition("pt=1,ds=2", "'", " and ").equals("pt='1' and ds='2'")); assertTrue(rodps.formatPartition("pt='1',ds='2'", "'", " and ").equals("pt='1' and ds='2'")); assertTrue(rodps.formatPartition("pt=\"1\",ds=\"2\"", "'", " and ").equals( "pt='1' and ds='2'")); assertTrue(rodps.formatPartition("pt=\"1\",ds=\"2\"", "", ",").equals("pt=1,ds=2")); assertTrue(rodps.formatPartition("pt='1',ds='2012-01-01 00:11:11'", "", ",").equals( "pt=1,ds=2012-01-01 00:11:11")); try { assertTrue(rodps.formatPartition("pt='1',ds='a,b'", "", ",").equals( "pt=1,ds=2012-01-01 00:11:11")); assertTrue(false); } catch (Exception e) { assertTrue(true); } try { assertTrue(rodps.formatPartition("pt='1',ds='a=b'", "", ",").equals( "pt=1,ds=2012-01-01 00:11:11")); assertTrue(false); } catch (Exception e) { assertTrue(true); } try { assertTrue(rodps.formatPartition("pt='1',ds=',a=b'", "", ",").equals( "pt=1,ds=2012-01-01 00:11:11")); assertTrue(false); } catch (Exception e) { assertTrue(true); } }