@Test public void parse2() { BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("rrdtool2.out"))); RrdToolOutputParser instance = new RrdToolOutputParser(); TimeSeriesMulti result = instance.parse(reader); assertThat(result.getTime().size(), equalTo(241)); assertThat(result.getValues().size(), equalTo(18)); assertThat(result.getValues().keySet(), equalTo((Set<String>) new HashSet<String>( Arrays.asList("Setpoint", "Fan1cfm", "Temp1", "Temp3", "Fan2Rpm", "TempOvrSet", "Fan2cfm", "Totalcfm", "Fan1Status", "Temp2", "Fan1Rpm", "Fan2Status", "Fan3cfm", "Fan3Rpm", "Fan3Status", "Fan4cfm", "Fan4Rpm", "Fan4Status")))); ListDouble values = result.getValues().get("Temp1"); assertThat(values.size(), equalTo(241)); assertThat(result.getTime().get(0), equalTo(Timestamp.of(1355416920, 0))); assertThat(values.getDouble(0), equalTo(9.2500000000e+01)); assertThat(result.getTime().get(150), equalTo(Timestamp.of(1355470920, 0))); assertThat(values.getDouble(150), equalTo(9.1000000000e+01)); assertThat(result.getTime().get(240), equalTo(Timestamp.of(1355503320, 0))); assertThat(values.getDouble(240), equalTo(Double.NaN)); }
public TimeSeriesMulti parse(BufferedReader reader) { try { List<String> names = Arrays.asList(reader.readLine().trim().split("(\\s+)")); reader.readLine(); String line; List<Timestamp> time = new ArrayList<>(); List<CircularBufferDouble> buffers = new ArrayList<>(names.size()); for (int i = 0; i < names.size(); i++) { buffers.add(new CircularBufferDouble(1000000)); } while ((line = reader.readLine()) != null) { String[] tokens = line.trim().split("(\\s|[:])+"); Timestamp timestamp = Timestamp.of(Integer.parseInt(tokens[0]), 0); time.add(timestamp); for (int i = 0; i < buffers.size(); i++) { String valueText = tokens[i + 1]; Double value; if ("nan".equals(valueText) || "-nan".equals(valueText)) { value = Double.NaN; } else { value = Double.parseDouble(valueText); } buffers.get(i).addDouble(value); } } Map<String, ListDouble> values = new HashMap<>(); for (int i = 0; i < names.size(); i++) { values.put(names.get(i), buffers.get(i)); } return new TimeSeriesMulti(time, values); } catch(IOException ex) { throw new RuntimeException("Couldn't parse file", ex); } }
RrdToolOutputParser { public TimeSeriesMulti parse(BufferedReader reader) { try { List<String> names = Arrays.asList(reader.readLine().trim().split("(\\s+)")); reader.readLine(); String line; List<Timestamp> time = new ArrayList<>(); List<CircularBufferDouble> buffers = new ArrayList<>(names.size()); for (int i = 0; i < names.size(); i++) { buffers.add(new CircularBufferDouble(1000000)); } while ((line = reader.readLine()) != null) { String[] tokens = line.trim().split("(\\s|[:])+"); Timestamp timestamp = Timestamp.of(Integer.parseInt(tokens[0]), 0); time.add(timestamp); for (int i = 0; i < buffers.size(); i++) { String valueText = tokens[i + 1]; Double value; if ("nan".equals(valueText) || "-nan".equals(valueText)) { value = Double.NaN; } else { value = Double.parseDouble(valueText); } buffers.get(i).addDouble(value); } } Map<String, ListDouble> values = new HashMap<>(); for (int i = 0; i < names.size(); i++) { values.put(names.get(i), buffers.get(i)); } return new TimeSeriesMulti(time, values); } catch(IOException ex) { throw new RuntimeException("Couldn't parse file", ex); } } }
RrdToolOutputParser { public TimeSeriesMulti parse(BufferedReader reader) { try { List<String> names = Arrays.asList(reader.readLine().trim().split("(\\s+)")); reader.readLine(); String line; List<Timestamp> time = new ArrayList<>(); List<CircularBufferDouble> buffers = new ArrayList<>(names.size()); for (int i = 0; i < names.size(); i++) { buffers.add(new CircularBufferDouble(1000000)); } while ((line = reader.readLine()) != null) { String[] tokens = line.trim().split("(\\s|[:])+"); Timestamp timestamp = Timestamp.of(Integer.parseInt(tokens[0]), 0); time.add(timestamp); for (int i = 0; i < buffers.size(); i++) { String valueText = tokens[i + 1]; Double value; if ("nan".equals(valueText) || "-nan".equals(valueText)) { value = Double.NaN; } else { value = Double.parseDouble(valueText); } buffers.get(i).addDouble(value); } } Map<String, ListDouble> values = new HashMap<>(); for (int i = 0; i < names.size(); i++) { values.put(names.get(i), buffers.get(i)); } return new TimeSeriesMulti(time, values); } catch(IOException ex) { throw new RuntimeException("Couldn't parse file", ex); } }  }
RrdToolOutputParser { public TimeSeriesMulti parse(BufferedReader reader) { try { List<String> names = Arrays.asList(reader.readLine().trim().split("(\\s+)")); reader.readLine(); String line; List<Timestamp> time = new ArrayList<>(); List<CircularBufferDouble> buffers = new ArrayList<>(names.size()); for (int i = 0; i < names.size(); i++) { buffers.add(new CircularBufferDouble(1000000)); } while ((line = reader.readLine()) != null) { String[] tokens = line.trim().split("(\\s|[:])+"); Timestamp timestamp = Timestamp.of(Integer.parseInt(tokens[0]), 0); time.add(timestamp); for (int i = 0; i < buffers.size(); i++) { String valueText = tokens[i + 1]; Double value; if ("nan".equals(valueText) || "-nan".equals(valueText)) { value = Double.NaN; } else { value = Double.parseDouble(valueText); } buffers.get(i).addDouble(value); } } Map<String, ListDouble> values = new HashMap<>(); for (int i = 0; i < names.size(); i++) { values.put(names.get(i), buffers.get(i)); } return new TimeSeriesMulti(time, values); } catch(IOException ex) { throw new RuntimeException("Couldn't parse file", ex); } }  TimeSeriesMulti parse(BufferedReader reader); }
RrdToolOutputParser { public TimeSeriesMulti parse(BufferedReader reader) { try { List<String> names = Arrays.asList(reader.readLine().trim().split("(\\s+)")); reader.readLine(); String line; List<Timestamp> time = new ArrayList<>(); List<CircularBufferDouble> buffers = new ArrayList<>(names.size()); for (int i = 0; i < names.size(); i++) { buffers.add(new CircularBufferDouble(1000000)); } while ((line = reader.readLine()) != null) { String[] tokens = line.trim().split("(\\s|[:])+"); Timestamp timestamp = Timestamp.of(Integer.parseInt(tokens[0]), 0); time.add(timestamp); for (int i = 0; i < buffers.size(); i++) { String valueText = tokens[i + 1]; Double value; if ("nan".equals(valueText) || "-nan".equals(valueText)) { value = Double.NaN; } else { value = Double.parseDouble(valueText); } buffers.get(i).addDouble(value); } } Map<String, ListDouble> values = new HashMap<>(); for (int i = 0; i < names.size(); i++) { values.put(names.get(i), buffers.get(i)); } return new TimeSeriesMulti(time, values); } catch(IOException ex) { throw new RuntimeException("Couldn't parse file", ex); } }  TimeSeriesMulti parse(BufferedReader reader);  }