@Override public Map<String, AttributeValue> put(final String attr, final AttributeValueUpdate value) throws IOException { return this.put(new AttributeUpdates().with(attr, value)); }
/** * With this attribute. * @param name Attribute name * @param value The value * @return AttributeUpdates */ public AttributeUpdates with(final String name, final AttributeValueUpdate value) { return new AttributeUpdates( this.attrs.with(String.format(Locale.ENGLISH, name), value) ); }
/** * With this attribute. * @param name Attribute name * @param value The value * @return AttributeUpdates * @since 0.14.3 */ public AttributeUpdates with(final String name, final AttributeValue value) { return this.with( name, new AttributeValueUpdate(value, AttributeAction.PUT) ); }
@Override public void update(final String table, final Attributes keys, final AttributeUpdates attrs) throws IOException { try { JdbcSession session = new JdbcSession(this.connection()); for (final AttributeValueUpdate value : attrs.values()) { session = session.set(H2Data.value(value.getValue())); } for (final AttributeValue value : keys.values()) { session = session.set(H2Data.value(value)); } session.sql( String.format( "UPDATE %s SET %s WHERE %s", H2Data.encodeTableName(table), Joiner.on(',').join( Iterables.transform(attrs.keySet(), H2Data.WHERE) ), Joiner.on(H2Data.AND).join( Iterables.transform(keys.keySet(), H2Data.WHERE) ) ) ); session.execute(); } catch (final SQLException ex) { throw new IOException(ex); } }
/** * With this attribute. * @param name Attribute name * @param value The value * @return AttributeUpdates */ public AttributeUpdates with(final String name, final AttributeValueUpdate value) { return new AttributeUpdates( this.attrs.with(String.format(Locale.ENGLISH, name), value) ); }
/** * With this attribute. * @param name Attribute name * @param value The value * @return AttributeUpdates * @since 0.14.3 */ public AttributeUpdates with(final String name, final AttributeValue value) { return this.with( name, new AttributeValueUpdate(value, AttributeAction.PUT) ); }
@Override public void update(final String table, final Attributes keys, final AttributeUpdates attrs) throws IOException { try { JdbcSession session = new JdbcSession(this.connection()); for (final AttributeValueUpdate value : attrs.values()) { session = session.set(H2Data.value(value.getValue())); } for (final AttributeValue value : keys.values()) { session = session.set(H2Data.value(value)); } session.sql( String.format( "UPDATE %s SET %s WHERE %s", H2Data.encodeTableName(table), Joiner.on(',').join( Iterables.transform(attrs.keySet(), H2Data.WHERE) ), Joiner.on(H2Data.AND).join( Iterables.transform(keys.keySet(), H2Data.WHERE) ) ) ); session.execute(); } catch (final SQLException ex) { throw new IOException(ex); } }
@Override public Map<String, AttributeValue> put(final String attr, final AttributeValueUpdate value) throws IOException { return this.put(new AttributeUpdates().with(attr, value)); }
/** * With these AttributeUpdates. * @param map AttributeUpdates to add * @return AttributeUpdates */ public AttributeUpdates with(final Map<String, AttributeValueUpdate> map) { final ConcurrentMap<String, AttributeValueUpdate> attribs = new ConcurrentHashMap<String, AttributeValueUpdate>(map.size()); for (final Map.Entry<String, AttributeValueUpdate> entry : map.entrySet()) { attribs.put( String.format(Locale.ENGLISH, entry.getKey()), entry.getValue() ); } return new AttributeUpdates(this.attrs.with(attribs)); }
/** * With this attribute. * @param name Attribute name * @param value The value * @return AttributeUpdates * @since 0.14.3 */ public AttributeUpdates with(final String name, final Object value) { final AttributeValue attr; if (value instanceof Long || value instanceof Integer) { attr = new AttributeValue().withN(value.toString()); } else { attr = new AttributeValue(value.toString()); } return this.with(name, attr); }
|| mean > mbefore && !reverse) { item.put( new AttributeUpdates() .with("artifact", metric.xpath("/index/@artifact").get(0)) .with( "champions", new AttributeValueUpdate() .withAction(AttributeAction.ADD) .with("mean", new DyNum(mean).update()) .with("sigma", new DyNum(sigma).update()) );
/** * With these AttributeUpdates. * @param map AttributeUpdates to add * @return AttributeUpdates */ public AttributeUpdates with(final Map<String, AttributeValueUpdate> map) { final ConcurrentMap<String, AttributeValueUpdate> attribs = new ConcurrentHashMap<String, AttributeValueUpdate>(map.size()); for (final Map.Entry<String, AttributeValueUpdate> entry : map.entrySet()) { attribs.put( String.format(Locale.ENGLISH, entry.getKey()), entry.getValue() ); } return new AttributeUpdates(this.attrs.with(attribs)); }
/** * With this attribute. * @param name Attribute name * @param value The value * @return AttributeUpdates * @since 0.14.3 */ public AttributeUpdates with(final String name, final Object value) { final AttributeValue attr; if (value instanceof Long || value instanceof Integer) { attr = new AttributeValue().withN(value.toString()); } else { attr = new AttributeValue(value.toString()); } return this.with(name, attr); }
new AttributeUpdates() .with( "pos", new AttributeValueUpdate() .with("psum", new DyNum(diff).update(AttributeAction.ADD)) ); } else { before.put( new AttributeUpdates() .with( "neg", new AttributeValueUpdate() .with("nsum", new DyNum(-diff).update(AttributeAction.ADD)) ); .next(); after.put( new AttributeUpdates() .with( "navg", new DyNum( .with( "pavg", new DyNum( final double neg = (double) Long.parseLong(fin.get("neg").getN());
@Override public Map<String, AttributeValue> put( final Map<String, AttributeValueUpdate> attrs) throws IOException { final Map<String, AttributeValue> keys = new HashMap<String, AttributeValue>(0); for (final String attr : this.data.keys(this.table)) { keys.put(attr, this.attributes.get(attr)); } try { this.data.update( this.table, new Attributes(keys), new AttributeUpdates(attrs) ); } catch (final IOException ex) { throw new IllegalStateException(ex); } return Maps.transformValues( attrs, new Function<AttributeValueUpdate, AttributeValue>() { @Override public AttributeValue apply(final AttributeValueUpdate update) { return update.getValue(); } } ); }
if (!item.has(DefaultDynamo.SYSLOG)) { item.put( new AttributeUpdates().with( DefaultDynamo.SYSLOG, new AttributeValueUpdate() new AttributeUpdates().with( DefaultDynamo.BUCKET, new AttributeValueUpdate()
@Override public Map<String, AttributeValue> put( final Map<String, AttributeValueUpdate> attrs) throws IOException { final Map<String, AttributeValue> keys = new HashMap<String, AttributeValue>(0); for (final String attr : this.data.keys(this.table)) { keys.put(attr, this.attributes.get(attr)); } try { this.data.update( this.table, new Attributes(keys), new AttributeUpdates(attrs) ); } catch (final IOException ex) { throw new IllegalStateException(ex); } return Maps.transformValues( attrs, new Function<AttributeValueUpdate, AttributeValue>() { @Override public AttributeValue apply(final AttributeValueUpdate update) { return update.getValue(); } } ); }