/** * Add results from a value of type tabular data. * This is a recursive function. */ private void add(String attributeName, ImmutableList.Builder<String> valuePath, TabularData tds) { // @see TabularData#keySet JavaDoc: // "Set<List<?>>" but is declared as a {@code Set<?>} for // compatibility reasons. The returned set can be used to iterate // over the keys." Set<List<?>> keys = (Set<List<?>>) tds.keySet(); for (List<?> key : keys) { // ie: attributeName=LastGcInfo.Par Survivor Space // i haven't seen this be smaller or larger than List<1>, but // might as well loop it. CompositeData compositeData = tds.get(key.toArray()); String attributeName2 = Joiner.on('.').join(key); add(attributeName, newValuePath(valuePath, attributeName2), compositeData); } }
Map<Object, Object> returnable = new HashMap<>(); @SuppressWarnings("unchecked") Set<List<?>> keySet = (Set<List<?>>) data.keySet(); for (List<?> keys : keySet) { CompositeData cd = data.get(keys.toArray());
for (Object key : tabularData.keySet()) {
public String[] getPropertyKeys() { List<String> keys = new ArrayList<String>(); for(Object key : propsData.keySet()) keys.add((String)key); return keys.toArray(new String[keys.size()]); } }
@Override public void execute(NodeProbe probe) { TabularData data = probe.getFailureDetectorPhilValues(); System.out.printf("%10s,%16s%n", "Endpoint", "Phi"); for (Object o : data.keySet()) { @SuppressWarnings({ "rawtypes", "unchecked" }) CompositeData datum = data.get(((List) o).toArray(new Object[((List) o).size()])); System.out.printf("%10s,%16.8f%n",datum.get("Endpoint"), datum.get("PHI")); } } }
@Override public void execute(NodeProbe probe) { TabularData data = probe.getFailureDetectorPhilValues(); System.out.printf("%10s,%16s%n", "Endpoint", "Phi"); for (Object o : data.keySet()) { @SuppressWarnings({ "rawtypes", "unchecked" }) CompositeData datum = data.get(((List) o).toArray(new Object[((List) o).size()])); System.out.printf("%10s,%16.8f%n",datum.get("Endpoint"), datum.get("PHI")); } } }
@Override public void execute(NodeProbe probe) { TabularData data = probe.getFailureDetectorPhilValues(); System.out.printf("%10s,%16s%n", "Endpoint", "Phi"); for (Object o : data.keySet()) { @SuppressWarnings({ "rawtypes", "unchecked" }) CompositeData datum = data.get(((List) o).toArray(new Object[((List) o).size()])); System.out.printf("%10s,%16.8f%n",datum.get("Endpoint"), datum.get("PHI")); } } }
private Map<String, Object> handleTabularData(TabularData tabularData) { Map<String, Object> rowKeyToRowData = new HashMap<>(); tabularData.keySet().forEach(rowKey -> { List<?> rowKeyAsList = (List<?>) rowKey; rowKeyToRowData.put(createKey(rowKeyAsList), tabularData.get(rowKeyAsList.toArray())); }); return rowKeyToRowData; }
public static Map<List<?>, Map<String, Object>> tabularDataToMapOfMaps(TabularData table) { Map<List<?>, Map<String, Object>> result = Maps.newLinkedHashMap(); for (Object k : table.keySet()) { final Object[] kValues = ((List<?>)k).toArray(); CompositeData v = table.get(kValues); result.put((List<?>)k, compositeDataToMap(v)); } return result; }
public static Map<List<?>, Map<String, Object>> tabularDataToMapOfMaps(TabularData table) { Map<List<?>, Map<String, Object>> result = Maps.newLinkedHashMap(); for (Object k : table.keySet()) { final Object[] kValues = ((List<?>)k).toArray(); CompositeData v = (CompositeData) table.get(kValues); result.put((List<?>)k, compositeDataToMap(v)); } return result; }
public static List convert(TabularData table) { List rows = new ArrayList<>(); Set<List<?>> keys = (Set<List<?>>) table.keySet(); for (List<?> key : keys) { Map<String, Object> row = convert(table.get(key.toArray())); if (row == null) { // do nothing } else if (row.size() == 2 && row.containsKey("key") && row.get("value") instanceof Map) { LinkedHashMap m = new LinkedHashMap(); m.put("key", row.get("key")); m.putAll((Map)row.get("value")); rows.add(m); } else { rows.add(row); } } return rows; }
private static Object convertFromTabularDataToMap( Object value ) { final TabularData data = ( TabularData ) value; final Set<List<?>> keys = ( Set<List<?>> ) data.keySet(); final Map<String, Object> map = new HashMap<>(); for ( final List<?> key : keys ) { final Object subValue = convertValue( data.get( key.toArray() ) ); if ( key.size() == 1 ) { map.put( convertValue( key.get( 0 ) ).toString(), subValue ); } else { map.put( convertValue( key ).toString(), subValue ); } } value = map; return value; }
private static List<Map<String, Object>> toList(TabularData data) { ImmutableList.Builder<Map<String, Object>> builder = ImmutableList.builder(); // never trust JMX to do the right thing Set<List<?>> keySet = (Set<List<?>>) data.keySet(); if (keySet != null) { for (List<?> key : keySet) { if (key != null && !key.isEmpty()) { Object[] index = key.toArray(new Object[key.size()]); CompositeData value = data.get(index); if (value != null) { builder.add(toMap(value)); } } } } return builder.build(); } }
private static Object convertFromTabularDataToMap( Object value ) { final TabularData data = ( TabularData ) value; final Set<List<?>> keys = ( Set<List<?>> ) data.keySet(); final Map<String, Object> map = new HashMap<>(); for ( final List<?> key : keys ) { final Object subValue = convertValue( data.get( key.toArray() ) ); if ( key.size() == 1 ) { map.put( convertValue( key.get( 0 ) ).toString(), subValue ); } else { map.put( convertValue( key ).toString(), subValue ); } } value = map; return value; }
@SuppressWarnings("unchecked") private static List<Map<String, Object>> toList(TabularData data) { ImmutableList.Builder<Map<String, Object>> builder = ImmutableList.builder(); // never trust JMX to do the right thing Set<List<?>> keySet = (Set<List<?>>) data.keySet(); if (keySet != null) { for (List<?> key : keySet) { if (key != null && !key.isEmpty()) { Object[] index = key.toArray(new Object[0]); CompositeData value = data.get(index); if (value != null) { builder.add(toMap(value)); } } } } return builder.build(); }
@SuppressWarnings("unchecked") private static List<Map<String, Object>> toList(TabularData data) { ImmutableList.Builder<Map<String, Object>> builder = ImmutableList.builder(); // never trust JMX to do the right thing Set<List<?>> keySet = (Set<List<?>>) data.keySet(); if (keySet != null) { for (List<?> key : keySet) { if (key != null && !key.isEmpty()) { Object[] index = key.toArray(new Object[0]); CompositeData value = data.get(index); if (value != null) { builder.add(toMap(value)); } } } } return builder.build(); } }
private static Object convertFromTabularDataToMap( Object value ) { final TabularData data = ( TabularData ) value; final Set<List<?>> keys = ( Set<List<?>> ) data.keySet(); final Map<String, Object> map = new HashMap<>(); for ( final List<?> key : keys ) { final Object subValue = convertValue( data.get( key.toArray() ) ); if ( key.size() == 1 ) { map.put( convertValue( key.get( 0 ) ).toString(), subValue ); } else { map.put( convertValue( key ).toString(), subValue ); } } value = map; return value; }
private static Object convertFromTabularDataToMap( Object value ) { final TabularData data = ( TabularData ) value; final Set<List<?>> keys = ( Set<List<?>> ) data.keySet(); final Map<String, Object> map = new HashMap<>(); for ( final List<?> key : keys ) { final Object subValue = convertValue( data.get( key.toArray() ) ); if ( key.size() == 1 ) { map.put( convertValue( key.get( 0 ) ).toString(), subValue ); } else { map.put( convertValue( key ).toString(), subValue ); } } value = map; return value; }
/** * Add results from a value of type tabular data. * This is a recursive function. */ private void add(String attributeName, ImmutableList.Builder<String> valuePath, TabularData tds) { // @see TabularData#keySet JavaDoc: // "Set<List<?>>" but is declared as a {@code Set<?>} for // compatibility reasons. The returned set can be used to iterate // over the keys." Set<List<?>> keys = (Set<List<?>>) tds.keySet(); for (List<?> key : keys) { // ie: attributeName=LastGcInfo.Par Survivor Space // i haven't seen this be smaller or larger than List<1>, but // might as well loop it. CompositeData compositeData = tds.get(key.toArray()); String attributeName2 = Joiner.on('.').join(key); add(attributeName, newValuePath(valuePath, attributeName2), compositeData); } }
/** * parse and print the tabular data */ protected void printTabularData(TabularData statsReport, PrintWriter msgWriter, String tabStr) { Set names = statsReport.keySet(); for ( Object name : names ) { Object[] key = ( (java.util.List) name).toArray(); CompositeData compData = statsReport.get(key); printMessage(""); printCompositeDataRecursively(compData, msgWriter, tabStr); } }