List of usage examples for com.amazonaws.services.simpledb.model ReplaceableItem ReplaceableItem
public ReplaceableItem(String name)
From source file:SimpleDBExample.java
License:Open Source License
/** * Creates an array of SimpleDB ReplaceableItems populated with sample data. * * @return An array of sample item data. *//*from www . java2 s.c o m*/ private static List<ReplaceableItem> createSampleData() { List<ReplaceableItem> sampleData = new ArrayList<ReplaceableItem>(); sampleData.add(new ReplaceableItem("Item_01").withAttributes( new ReplaceableAttribute("Category", "Clothes", true), new ReplaceableAttribute("Subcategory", "Sweater", true), new ReplaceableAttribute("Name", "Cathair Sweater", true), new ReplaceableAttribute("Color", "Siamese", true), new ReplaceableAttribute("Size", "Small", true), new ReplaceableAttribute("Size", "Medium", true), new ReplaceableAttribute("Size", "Large", true))); sampleData.add(new ReplaceableItem("Item_02").withAttributes( new ReplaceableAttribute("Category", "Clothes", true), new ReplaceableAttribute("Subcategory", "Pants", true), new ReplaceableAttribute("Name", "Designer Jeans", true), new ReplaceableAttribute("Color", "Paisley Acid Wash", true), new ReplaceableAttribute("Size", "30x32", true), new ReplaceableAttribute("Size", "32x32", true), new ReplaceableAttribute("Size", "32x34", true))); sampleData.add(new ReplaceableItem("Item_03").withAttributes( new ReplaceableAttribute("Category", "Clothes", true), new ReplaceableAttribute("Subcategory", "Pants", true), new ReplaceableAttribute("Name", "Sweatpants", true), new ReplaceableAttribute("Color", "Blue", true), new ReplaceableAttribute("Color", "Yellow", true), new ReplaceableAttribute("Color", "Pink", true), new ReplaceableAttribute("Size", "Large", true), new ReplaceableAttribute("Year", "2006", true), new ReplaceableAttribute("Year", "2007", true))); sampleData.add(new ReplaceableItem("Item_04").withAttributes( new ReplaceableAttribute("Category", "Car Parts", true), new ReplaceableAttribute("Subcategory", "Engine", true), new ReplaceableAttribute("Name", "Turbos", true), new ReplaceableAttribute("Make", "Audi", true), new ReplaceableAttribute("Model", "S4", true), new ReplaceableAttribute("Year", "2000", true), new ReplaceableAttribute("Year", "2001", true), new ReplaceableAttribute("Year", "2002", true))); sampleData.add(new ReplaceableItem("Item_05").withAttributes( new ReplaceableAttribute("Category", "Car Parts", true), new ReplaceableAttribute("Subcategory", "Emissions", true), new ReplaceableAttribute("Name", "O2 Sensor", true), new ReplaceableAttribute("Make", "Audi", true), new ReplaceableAttribute("Model", "S4", true), new ReplaceableAttribute("Year", "2000", true), new ReplaceableAttribute("Year", "2001", true), new ReplaceableAttribute("Year", "2002", true))); return sampleData; }
From source file:SimpleDBWrite.java
License:Open Source License
/** * Creates an array of SimpleDB ReplaceableItems populated with sample data. * * @return An array of sample item data. * @throws IOException //from www. ja v a 2 s. co m */ public static List<ReplaceableItem> createData(String searchItem) throws IOException { List<ReplaceableItem> Data = new ArrayList<ReplaceableItem>(); PriceParser myParser = new PriceParser(); ArrayList<resultItem> prodResultItems = myParser.Query2(searchItem, "1"); for (resultItem e : prodResultItems) { Data.add(new ReplaceableItem(e.name).withAttributes( new ReplaceableAttribute("Keyword", searchItem, true), new ReplaceableAttribute("Price", e.price, true), new ReplaceableAttribute("Site", "Walmart", true))); } return Data; }
From source file:SimpleDBPerformanceSample.java
License:Apache License
public static void main(String[] args) throws Exception { AmazonSimpleDB sdb = new AmazonSimpleDBClient( new PropertiesCredentials(SimpleDBSample.class.getResourceAsStream("AwsCredentials.properties"))); // ?[WGh|Cgw/*from ww w . ja v a 2 s . c o m*/ sdb.setEndpoint(args[0]); int roopCount = 100; long insertTimeSum = 0; long selectTimeSum = 0; long updateTimeSum = 0; long deleteTimeSum = 0; long startTime; long finishedTime; try { // h?C?? String myDomain = "MyStore"; sdb.createDomain(new CreateDomainRequest(myDomain)); for (int i = 0; i < roopCount; i++) { // ?f?[^ sdb.batchPutAttributes(new BatchPutAttributesRequest(myDomain, createSampleData())); // f?[^1?}(PutAttributes API) ReplaceableItem rItem = new ReplaceableItem("Item_06").withAttributes( new ReplaceableAttribute("Category", "Car Parts", true), new ReplaceableAttribute("Subcategory", "Exhaust", true), new ReplaceableAttribute("Name", "O2 Sensor", true), new ReplaceableAttribute("Make", "Audi", true), new ReplaceableAttribute("Model", "TT Coupe", true), new ReplaceableAttribute("Year", "2009", true), new ReplaceableAttribute("Year", "2010", true), new ReplaceableAttribute("Year", "2011", true)); PutAttributesRequest putAttributesRequest = new PutAttributesRequest(myDomain, rItem.getName(), rItem.getAttributes()); startTime = System.currentTimeMillis(); sdb.putAttributes(putAttributesRequest); finishedTime = System.currentTimeMillis(); insertTimeSum += finishedTime - startTime; // f?[^?iSelect API) String selectExpression = "select * from `" + myDomain + "` where Category = 'Clothes'"; SelectRequest selectRequest = new SelectRequest(selectExpression); startTime = System.currentTimeMillis(); sdb.select(selectRequest); finishedTime = System.currentTimeMillis(); selectTimeSum += finishedTime - startTime; // f?[^?X?V(PutAttributes API) List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>(); replaceableAttributes.add(new ReplaceableAttribute("Size", "Medium", true)); startTime = System.currentTimeMillis(); sdb.putAttributes(new PutAttributesRequest(myDomain, "Item_03", replaceableAttributes)); finishedTime = System.currentTimeMillis(); updateTimeSum += finishedTime - startTime; // f?[^??(DeleteAttributes API) startTime = System.currentTimeMillis(); sdb.deleteAttributes(new DeleteAttributesRequest(myDomain, "Item_03")); finishedTime = System.currentTimeMillis(); deleteTimeSum += finishedTime - startTime; // f?[^?? sdb.batchDeleteAttributes(new BatchDeleteAttributesRequest(myDomain, deleteSampleData())); } // h?C?? sdb.deleteDomain(new DeleteDomainRequest(myDomain)); System.out.println("insert:AVG:" + (float) insertTimeSum / roopCount); System.out.println("select:AVG:" + (float) selectTimeSum / roopCount); System.out.println("update:AVG:" + (float) updateTimeSum / roopCount); System.out.println("delete:AVG:" + (float) deleteTimeSum / roopCount); } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means your request made it " + "to Amazon SimpleDB, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with SimpleDB, " + "such as not being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } }
From source file:bench.auth.SimpleDBSample.java
License:Open Source License
/** * Creates an array of SimpleDB ReplaceableItems populated with sample data. * /*from ww w . j a v a 2s .co m*/ * @return An array of sample item data. */ private static List<ReplaceableItem> createSampleData() { List<ReplaceableItem> dataList = new ArrayList<ReplaceableItem>(); dataList.add(new ReplaceableItem("Item_01").withAttributes( new ReplaceableAttribute("Category", "Clothes", true), new ReplaceableAttribute("Subcategory", "Sweater", true), new ReplaceableAttribute("Name", "Cathair Sweater", true), new ReplaceableAttribute("Color", "Siamese", true), new ReplaceableAttribute("Size", "Small", true), new ReplaceableAttribute("Size", "Medium", true), new ReplaceableAttribute("Size", "Large", true))); dataList.add(new ReplaceableItem("Item_02").withAttributes( new ReplaceableAttribute("Category", "Clothes", true), new ReplaceableAttribute("Subcategory", "Pants", true), new ReplaceableAttribute("Name", "Designer Jeans", true), new ReplaceableAttribute("Color", "Paisley Acid Wash", true), new ReplaceableAttribute("Size", "30x32", true), new ReplaceableAttribute("Size", "32x32", true), new ReplaceableAttribute("Size", "32x34", true))); dataList.add(new ReplaceableItem("Item_03").withAttributes( new ReplaceableAttribute("Category", "Clothes", true), new ReplaceableAttribute("Subcategory", "Pants", true), new ReplaceableAttribute("Name", "Sweatpants", true), new ReplaceableAttribute("Color", "Blue", true), new ReplaceableAttribute("Color", "Yellow", true), new ReplaceableAttribute("Color", "Pink", true), new ReplaceableAttribute("Size", "Large", true), new ReplaceableAttribute("Year", "2006", true), new ReplaceableAttribute("Year", "2007", true))); dataList.add(new ReplaceableItem("Item_04").withAttributes( new ReplaceableAttribute("Category", "Car Parts", true), new ReplaceableAttribute("Subcategory", "Engine", true), new ReplaceableAttribute("Name", "Turbos", true), new ReplaceableAttribute("Make", "Audi", true), new ReplaceableAttribute("Model", "S4", true), new ReplaceableAttribute("Year", "2000", true), new ReplaceableAttribute("Year", "2001", true), new ReplaceableAttribute("Year", "2002", true))); dataList.add(new ReplaceableItem("Item_05").withAttributes( new ReplaceableAttribute("Category", "Car Parts", true), new ReplaceableAttribute("Subcategory", "Emissions", true), new ReplaceableAttribute("Name", "O2 Sensor", true), new ReplaceableAttribute("Make", "Audi", true), new ReplaceableAttribute("Model", "S4", true), new ReplaceableAttribute("Year", "2000", true), new ReplaceableAttribute("Year", "2001", true), new ReplaceableAttribute("Year", "2002", true))); return dataList; }
From source file:org.teiid.resource.adpter.simpledb.SimpleDbAPIClass.java
License:Open Source License
/** * Performs update on given domain and items * @param domainName/* w w w. j a v a 2 s . co m*/ * @param items */ public void performUpdate(String domainName, Map<String, Map<String, String>> items) { List<ReplaceableItem> itemsList = new ArrayList<ReplaceableItem>(); for (Map.Entry<String, Map<String, String>> item : items.entrySet()) { ReplaceableItem it = new ReplaceableItem(item.getKey()); List<ReplaceableAttribute> attributesList = new ArrayList<ReplaceableAttribute>(); for (Map.Entry<String, String> attribute : item.getValue().entrySet()) { attributesList.add(new ReplaceableAttribute(attribute.getKey(), attribute.getValue(), true)); } it.setAttributes(attributesList); itemsList.add(it); } BatchPutAttributesRequest req = new BatchPutAttributesRequest(domainName, itemsList); client.batchPutAttributes(req); }