public Set<String> select(Collection<String> names) { return select(names, keyValues); }
public static Set<String> select(Collection<String> ks, String[] keys) { Set<String> selected = new LinkedHashSet<String>(); if (ks == null) return selected; if (keys == null) { selected.addAll(ks); return selected; } for (String key : ks) { if (isSelected(key, keys)) selected.add(key); } return selected; }
for (String key : keys.getKeyValues()) { if (!tableSchema.containsKey(key)) { log.info("Removing non-selected key '{}'", key);
public void tikzHistogram(Statistics st) { tikzHistogram(st, new Keys(st.keySet()), System.out); }
for (String key : keys.getKeyValues()) { if (!tableSchema.containsKey(key)) { log.info("Removing non-selected key '{}'", key);
public static Set<String> select(Data item, String filter) { if (filter == null || item == null) return new LinkedHashSet<String>(); return select(item, filter.split(",")); }
/** * @see stream.Processor#process(stream.Data) */ @Override public Data process(Data input) { Iterator<String> it = input.keySet().iterator(); while (it.hasNext()) { String key = it.next(); if (keys != null && !Keys.isSelected(key, keys)) { log.debug("Skipping non-selected key {}", key); continue; } Serializable value = input.get(key); if (toRemove(value.getClass())) { log.debug( "Removing key '{}' as type '{}' is matching the set of types to remove!", key, value.getClass()); it.remove(); } else { log.debug("Type {} not set to be removed.", value.getClass()); } } return input; }
public static String joinValues(Data item, String[] keys, String glue) { StringBuffer s = new StringBuffer(); for (String key : select(item, keys)) { Serializable value = item.get(key); if (value != null) { if (s.length() > 0) { s.append(glue); } s.append(value.toString()); } } return s.toString(); }
/** * @see stream.Processor#process(stream.Data) */ @Override public Data process(Data input) { Iterator<String> it = input.keySet().iterator(); while (it.hasNext()) { String key = it.next(); if (keys != null && !Keys.isSelected(key, keys)) { log.debug("Skipping non-selected key {}", key); continue; } Serializable value = input.get(key); if (toRemove(value.getClass())) { log.debug( "Removing key '{}' as type '{}' is matching the set of types to remove!", key, value.getClass()); it.remove(); } else { log.debug("Type {} not set to be removed.", value.getClass()); } } return input; }
public static Set<String> select(Data item, String[] keys) { Set<String> selected = new LinkedHashSet<String>(); if (item == null) return selected; return select(item.keySet(), keys); }
@Override public Data process(Data data) { if (keys == null) return data; Set<String> ks = keys.select(data); for (String key : ks) data.remove(key); return data; } }
public Set<String> select(Data item) { if (item == null) { return new HashSet<String>(); } return select(item.keySet()); }
public void tikzHistogram(Statistics st, Keys ks, OutputStream out) { List<String> keyList = new ArrayList<String>(ks.select(st.keySet())); tikzHistogram(st, keyList, out); }
/** * This class returns the keys that need to be written based on the * selection pattern. * * @param item * The item to extract keys from. * @return The keys matching the selection pattern. */ protected Set<String> selectedKeys(Data item) { if (keys == null) { return new LinkedHashSet<String>(item.keySet()); } else { return keys.select(item.keySet()); } }
/** * This class returns the keys that need to be written based on the * selection pattern. * * @param item * The item to extract keys from. * @return The keys matching the selection pattern. */ protected Set<String> selectedKeys(Data item) { if (keys == null) { return new LinkedHashSet<String>(item.keySet()); } else { return keys.select(item.keySet()); } }
/** * @see stream.Processor#process(stream.Data) */ @Override public Data process(Data item) { for( String key : keys.select( item)) { states.put( key, item.get( key)); } for( String key : states.keySet()) { if( ! item.containsKey( key )) { item.put( key, states.get( key)); } } return item; } }
/** * @see stream.DataProcessor#process(stream.Data) */ @Override public Data process(Data data) { if (keys == null) return data; Data result = DataFactory.create(); for (String key : keys.select(data)) { result.put(key, data.get(key)); } return result; } }
/** * @see stream.DataProcessor#process(stream.Data) */ @Override public Data process(Data data) { if (keys == null) return data; Data result = DataFactory.create(); for (String key : keys.select(data)) { result.put(key, data.get(key)); } return result; } }
/** * @see stream.Processor#process(stream.Data) */ @Override public Data process(Data input) { if (input == null) return input; try { if (socket == null) connect(); String json; if (keys != null) { Set<String> selected = keys.select(input); Data item = DataFactory.create(); for (String k : selected) { item.put(k, input.get(k)); } log.debug("Sending item {}", item); json = JSONObject.toJSONString(item); } else { json = JSONObject.toJSONString(input); } out.println(json); } catch (Exception e) { log.error("Faild to send item: {}", e.getMessage()); e.printStackTrace(); } return input; }
/** * @see stream.Processor#process(stream.Data) */ @Override public Data process(Data input) { if (input == null) return input; try { if (socket == null) connect(); String json; if (keys != null) { Set<String> selected = keys.select(input); Data item = DataFactory.create(); for (String k : selected) { item.put(k, input.get(k)); } log.debug("Sending item {}", item); json = JSONObject.toJSONString(item); } else { json = JSONObject.toJSONString(input); } out.println(json); } catch (Exception e) { log.error("Faild to send item: {}", e.getMessage()); e.printStackTrace(); } return input; }