/** * Sets the value of the specified attribute in the current item to the * given value. */ public Item withDouble(String attrName, double val) { checkInvalidAttrName(attrName); return withNumber(attrName, Double.valueOf(val)); }
return withString(attrName, (String)val); if (val instanceof Number) return withNumber(attrName, (Number)val); if (val instanceof byte[]) return withBinary(attrName, (byte[])val);
/** * Sets the value of the specified attribute in the current item to the * given value. */ public Item withInt(String attrName, int val) { checkInvalidAttrName(attrName); return withNumber(attrName, Integer.valueOf(val)); }
/** * Sets the value of the specified attribute in the current item to the * given value. */ public Item withBigInteger(String attrName, BigInteger val) { checkInvalidAttrName(attrName); return withNumber(attrName, val); }
/** * Sets the value of the specified attribute in the current item to the * given value. */ public Item withFloat(String attrName, float val) { checkInvalidAttrName(attrName); return withNumber(attrName, Float.valueOf(val)); }
/** * Sets the value of the specified attribute in the current item to the * given value. */ public Item withLong(String attrName, long val) { checkInvalidAttrName(attrName); return withNumber(attrName, Long.valueOf(val)); }
/** * Sets the value of the specified attribute in the current item to the * given value. */ public Item withShort(String attrName, short val) { checkInvalidAttrName(attrName); return withNumber(attrName, Short.valueOf(val)); }
/** * Sets the value of the specified attribute in the current item to the * given value. */ public Item withInt(String attrName, int val) { checkInvalidAttrName(attrName); return withNumber(attrName, Integer.valueOf(val)); }
/** * Sets the value of the specified attribute in the current item to the * given value. */ public Item withLong(String attrName, long val) { checkInvalidAttrName(attrName); return withNumber(attrName, Long.valueOf(val)); }
/** * Sets the value of the specified attribute in the current item to the * given value. */ public Item withShort(String attrName, short val) { checkInvalidAttrName(attrName); return withNumber(attrName, Short.valueOf(val)); }
/** * Sets the value of the specified attribute in the current item to the * given value. */ public Item withBigInteger(String attrName, BigInteger val) { checkInvalidAttrName(attrName); return withNumber(attrName, val); }
/** * Sets the value of the specified attribute in the current item to the * given value. */ public Item withFloat(String attrName, float val) { checkInvalidAttrName(attrName); return withNumber(attrName, Float.valueOf(val)); }
/** * Sets the value of the specified attribute in the current item to the * given value. */ public Item withDouble(String attrName, double val) { checkInvalidAttrName(attrName); return withNumber(attrName, Double.valueOf(val)); }
private static void loadSampleForums(String tableName) { Table table = dynamoDB.getTable(tableName); try { System.out.println("Adding data to " + tableName); Item item = new Item().withPrimaryKey("Name", "Amazon DynamoDB") .withString("Category", "Amazon Web Services") .withNumber("Threads", 2).withNumber("Messages", 4) .withNumber("Views", 1000); table.putItem(item); item = new Item().withPrimaryKey("Name", "Amazon S3") .withString("Category", "Amazon Web Services") .withNumber("Threads", 0); table.putItem(item); } catch (Exception e) { System.err.println("Failed to create item in " + tableName); System.err.println(e.getMessage()); } }
private static void loadSampleForums(String tableName) { Table table = dynamoDB.getTable(tableName); try { System.out.println("Adding data to " + tableName); Item item = new Item().withPrimaryKey("Name", "Amazon DynamoDB") .withString("Category", "Amazon Web Services") .withNumber("Threads", 2) .withNumber("Messages", 4) .withNumber("Views", 1000); table.putItem(item); item = new Item().withPrimaryKey("Name", "Amazon S3") .withString("Category", "Amazon Web Services") .withNumber("Threads", 0); table.putItem(item); } catch (Exception e) { System.err.println("Failed to create item in " + tableName); System.err.println(e.getMessage()); } }
private static void uploadProduct(String tableName, int productIndex) { Table table = dynamoDB.getTable(tableName); try { System.out.println("Processing record #" + productIndex); Item item = new Item() .withPrimaryKey("Id", productIndex) .withString("Title", "Book " + productIndex + " Title") .withString("ISBN", "111-1111111111") .withStringSet( "Authors", new HashSet<String>(Arrays.asList("Author1"))) .withNumber("Price", 2) .withString("Dimensions", "8.5 x 11.0 x 0.5") .withNumber("PageCount", 500) .withBoolean("InPublication", true) .withString("ProductCategory", "Book"); table.putItem(item); } catch (Exception e) { System.err.println("Failed to create item " + productIndex + " in " + tableName); System.err.println(e.getMessage()); } }
.withStringSet( "Authors", new HashSet<String>(Arrays.asList("Author12", "Author22"))) .withNumber("Price", 20) .withString("Dimensions", "8.5x11.0x.75") .withNumber("PageCount", 500) .withBoolean("InPublication", false) .withString("ProductCategory", "Book"); .withStringSet( "Authors", new HashSet<String>(Arrays.asList("Author21", "Author 22"))) .withNumber("Price", 20) .withString("Dimensions", "8.5x11.0x.75") .withNumber("PageCount", 500) .withBoolean("InPublication", true) .withString("ProductCategory", "Book");
.withItemsToPut(new Item() .withPrimaryKey("Name", "Amazon RDS") .withNumber("Threads", 0));
@Override public boolean write(Job job) { Timer.Context context = writeTimer.time(); ObjectMapper objectMapper = new ObjectMapper(); Table table = dynamoDB.getTable(tableName); try { String jobJSON = objectMapper.writeValueAsString(job); Item item = new Item() .withPrimaryKey("JobKey", jobIdKey(job)) .withString("UniqueId", job.getUniqueID()) .withString("JobHandle", job.getJobHandle()) .withNumber("When", job.getTimeToRun()) .withString("Priority", job.getPriority().toString()) .withString("JobQueue", job.getFunctionName()) .withString("JSON", jobJSON); table.putItem(item); return true; } catch (JsonProcessingException e) { e.printStackTrace(); } finally { context.stop(); } return false; }
public static void putItem( String issueId, String title, String description, String createDate, String lastUpdateDate, String dueDate, Integer priority, String status) { Table table = dynamoDB.getTable(tableName); Item item = new Item() .withPrimaryKey("IssueId", issueId) .withString("Title", title) .withString("Description", description) .withString("CreateDate", createDate) .withString("LastUpdateDate", lastUpdateDate) .withString("DueDate", dueDate) .withNumber("Priority", priority) .withString("Status", status); table.putItem(item); }