@Test public void testExtractTargetFromQuery() throws Exception { TargetSeries series = MiscUtils.extractTargetFromQuery("cpu.value.tes=2|tes=3"); assertEquals("cpu", series.getMeasurementName()); assertEquals("value", series.getFieldName()); try { series = MiscUtils.extractTargetFromQuery("cpuvalue|tes=3"); fail("Invalid request must throw an exception"); } catch (BadRequestException e) { } }
public static TargetSeries extractTargetFromQuery(String query) throws Exception { if (query == null || query.isEmpty()) { return null; } String[] queryParts = query.split("<=?"); if (queryParts.length > 1) { query = queryParts[1]; } String[] parts = query.split("=>"); query = parts[0]; String[] splits = query.split("\\."); if (splits.length < 2) { throw new BadRequestException( "Invalid query string:" + query + ". Must contain measurement and value field name"); } String measurementName = splits[0]; String valueFieldName = splits[1]; TagFilter tagFilter = null; if (splits.length >= 3) { try { tagFilter = buildTagFilter(splits[2]); } catch (InvalidFilterException e) { throw new BadRequestException(e); } } Function aggregationFunction = null; FunctionIteratorFactory template = null; if (parts.length > 1) { template = createIteratorChain(parts, 1); } return new TargetSeries(measurementName, valueFieldName, tagFilter, aggregationFunction, false, template); }
MiscUtils { public static TargetSeries extractTargetFromQuery(String query) throws Exception { if (query == null || query.isEmpty()) { return null; } String[] queryParts = query.split("<=?"); if (queryParts.length > 1) { query = queryParts[1]; } String[] parts = query.split("=>"); query = parts[0]; String[] splits = query.split("\\."); if (splits.length < 2) { throw new BadRequestException( "Invalid query string:" + query + ". Must contain measurement and value field name"); } String measurementName = splits[0]; String valueFieldName = splits[1]; TagFilter tagFilter = null; if (splits.length >= 3) { try { tagFilter = buildTagFilter(splits[2]); } catch (InvalidFilterException e) { throw new BadRequestException(e); } } Function aggregationFunction = null; FunctionIteratorFactory template = null; if (parts.length > 1) { template = createIteratorChain(parts, 1); } return new TargetSeries(measurementName, valueFieldName, tagFilter, aggregationFunction, false, template); } }
MiscUtils { public static TargetSeries extractTargetFromQuery(String query) throws Exception { if (query == null || query.isEmpty()) { return null; } String[] queryParts = query.split("<=?"); if (queryParts.length > 1) { query = queryParts[1]; } String[] parts = query.split("=>"); query = parts[0]; String[] splits = query.split("\\."); if (splits.length < 2) { throw new BadRequestException( "Invalid query string:" + query + ". Must contain measurement and value field name"); } String measurementName = splits[0]; String valueFieldName = splits[1]; TagFilter tagFilter = null; if (splits.length >= 3) { try { tagFilter = buildTagFilter(splits[2]); } catch (InvalidFilterException e) { throw new BadRequestException(e); } } Function aggregationFunction = null; FunctionIteratorFactory template = null; if (parts.length > 1) { template = createIteratorChain(parts, 1); } return new TargetSeries(measurementName, valueFieldName, tagFilter, aggregationFunction, false, template); } private  MiscUtils(); }
MiscUtils { public static TargetSeries extractTargetFromQuery(String query) throws Exception { if (query == null || query.isEmpty()) { return null; } String[] queryParts = query.split("<=?"); if (queryParts.length > 1) { query = queryParts[1]; } String[] parts = query.split("=>"); query = parts[0]; String[] splits = query.split("\\."); if (splits.length < 2) { throw new BadRequestException( "Invalid query string:" + query + ". Must contain measurement and value field name"); } String measurementName = splits[0]; String valueFieldName = splits[1]; TagFilter tagFilter = null; if (splits.length >= 3) { try { tagFilter = buildTagFilter(splits[2]); } catch (InvalidFilterException e) { throw new BadRequestException(e); } } Function aggregationFunction = null; FunctionIteratorFactory template = null; if (parts.length > 1) { template = createIteratorChain(parts, 1); } return new TargetSeries(measurementName, valueFieldName, tagFilter, aggregationFunction, false, template); } private  MiscUtils(); static long bucketCounter(Series series); static String[] splitAndNormalizeString(String input); static List<String> readAllLines(File file); static DataPoint buildDataPoint(long timestamp, long value); static DataPoint buildDataPoint(long timestamp, double value); static void ls(File file); static boolean delete(File file); static String tagsToString(List<Tag> tags); static String tagToString(List<String> tags); static TagFilter buildTagFilter(String tagFilter); static SimpleTagFilter buildSimpleFilter(String item); static FunctionIteratorFactory createIteratorChain(String[] parts, int startIndex); static Function createFunctionChain(String[] parts, int startIndex); static TargetSeries extractTargetFromQuery(String query); static Point buildDP(String dbName, String measurementName, List<String> valueFieldName, List<Tag> tags,
			long timestamp, List<Long> value, List<Boolean> fp); static String printBuffer(ByteBuffer buffer, int counter); static void writeStringToBuffer(String str, ByteBuffer buf); static void writeByteStringToBuffer(byte[] str, ByteBuffer buf); static ByteString getByteStringFromBuffer(ByteBuffer buf); static String getStringFromBuffer(ByteBuffer buf); static Point buildDataPoint(String dbName, String measurementName, List<String> valueFieldName,
			List<Tag> taglist, long timestamp, List<Long> values, List<Boolean> fp); static Point buildDataPoint(String dbName, String measurementName, String valueFieldName, List<Tag> taglist,
			long timestamp, long value); static Point buildDataPoint(String dbName, String measurementName, String valueFieldName, List<Tag> taglist,
			long timestamp, double value); static int tagHashCode(List<Tag> tags); }
MiscUtils { public static TargetSeries extractTargetFromQuery(String query) throws Exception { if (query == null || query.isEmpty()) { return null; } String[] queryParts = query.split("<=?"); if (queryParts.length > 1) { query = queryParts[1]; } String[] parts = query.split("=>"); query = parts[0]; String[] splits = query.split("\\."); if (splits.length < 2) { throw new BadRequestException( "Invalid query string:" + query + ". Must contain measurement and value field name"); } String measurementName = splits[0]; String valueFieldName = splits[1]; TagFilter tagFilter = null; if (splits.length >= 3) { try { tagFilter = buildTagFilter(splits[2]); } catch (InvalidFilterException e) { throw new BadRequestException(e); } } Function aggregationFunction = null; FunctionIteratorFactory template = null; if (parts.length > 1) { template = createIteratorChain(parts, 1); } return new TargetSeries(measurementName, valueFieldName, tagFilter, aggregationFunction, false, template); } private  MiscUtils(); static long bucketCounter(Series series); static String[] splitAndNormalizeString(String input); static List<String> readAllLines(File file); static DataPoint buildDataPoint(long timestamp, long value); static DataPoint buildDataPoint(long timestamp, double value); static void ls(File file); static boolean delete(File file); static String tagsToString(List<Tag> tags); static String tagToString(List<String> tags); static TagFilter buildTagFilter(String tagFilter); static SimpleTagFilter buildSimpleFilter(String item); static FunctionIteratorFactory createIteratorChain(String[] parts, int startIndex); static Function createFunctionChain(String[] parts, int startIndex); static TargetSeries extractTargetFromQuery(String query); static Point buildDP(String dbName, String measurementName, List<String> valueFieldName, List<Tag> tags,
			long timestamp, List<Long> value, List<Boolean> fp); static String printBuffer(ByteBuffer buffer, int counter); static void writeStringToBuffer(String str, ByteBuffer buf); static void writeByteStringToBuffer(byte[] str, ByteBuffer buf); static ByteString getByteStringFromBuffer(ByteBuffer buf); static String getStringFromBuffer(ByteBuffer buf); static Point buildDataPoint(String dbName, String measurementName, List<String> valueFieldName,
			List<Tag> taglist, long timestamp, List<Long> values, List<Boolean> fp); static Point buildDataPoint(String dbName, String measurementName, String valueFieldName, List<Tag> taglist,
			long timestamp, long value); static Point buildDataPoint(String dbName, String measurementName, String valueFieldName, List<Tag> taglist,
			long timestamp, double value); static int tagHashCode(List<Tag> tags);  }