Examples of SelectResult


Examples of com.amazonaws.services.simpledb.model.SelectResult

    public void renameSubclass(String oldClassName, Class newClass) {
        logger.info("Renaming DTYPE for " + oldClassName + " to " + newClass.getSimpleName());
        try {
            String newClassName = newClass.getSimpleName();
            String domainName = factory.getDomainName(newClass);
            SelectResult result;
            List<Item> items;
            int i = 0;
            String nextToken = null;
            while (i == 0 || nextToken != null) {
                result = executeQueryForRenameSubclass(oldClassName, newClass, domainName, nextToken);
                items = result.getItems();
                putNewValue(domainName, items, EntityManagerFactoryImpl.DTYPE, newClassName);
                nextToken = result.getNextToken();
                i++;
                if (i % 100 == 0) {
                    System.out.println("Renamed " + i + " subclassed objects so far...");
                }
            }
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.SelectResult

            db.putAttributes(new PutAttributesRequest(domainName, item.getName(), atts));
        }
    }

    private SelectResult executeQueryForRenameSubclass(String oldClassName, Class newClass, String domainName, String nextToken) throws AmazonClientException {
        SelectResult result = DomainHelper.selectItems(factory.getSimpleDb(), domainName, "'DTYPE' = '" + oldClassName + "'", nextToken, consistentRead);
        return result;
    }
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.SelectResult

        return result;
    }

    private SelectResult executeQueryForRename(String oldAttributeName, String newAttributeName, String domainName, String nextToken)
            throws AmazonClientException {
        SelectResult result = DomainHelper.selectItems(factory.getSimpleDb(), domainName, "['" + oldAttributeName + "' starts-with ''] intersection not ['"
                + newAttributeName + "' starts-with ''] ", nextToken, consistentRead);
        return result;
    }
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.SelectResult

        if (backingList == null) {
            backingList = new GrowthList();
        }

        while (backingList.size() <= index) {
            SelectResult qr;
            try {
                if (logger.isLoggable(Level.FINER))
                    logger.finer("query for lazylist=" + origQuery);

                int limit = maxResults - backingList.size();
                String limitQuery = realQuery + " limit " + (noLimit() ? maxResultsPerToken : Math.min(maxResultsPerToken, limit));
                if (em.getFactory().isPrintQueries())
                    System.out.println("query in lazylist=" + limitQuery);
                qr = DomainHelper.selectItems(this.em.getSimpleDb(), limitQuery, nextToken, isConsistentRead());

                if (logger.isLoggable(Level.FINER))
                    logger.finer("got items for lazylist=" + qr.getItems().size());

                for (Item item : qr.getItems()) {
                    backingList.add((E) em.buildObject(genericReturnType, item.getName(), item.getAttributes()));
                }

                if (qr.getNextToken() == null || (!noLimit() && qr.getItems().size() == limit)) {
                    nextToken = null;
                    break;
                }

                if (!noLimit() && qr.getItems().size() > limit) {
                    throw new PersistenceException("Got more results than the limit.");
                }

                nextToken = qr.getNextToken();
            } catch (AmazonClientException e) {
                throw new PersistenceException("Query failed: Domain=" + domainName + " -> " + origQuery, e);
            }
        }
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.SelectResult

        attrs.add(new Attribute("eventType", "EVENT|com.netflix.simianarmy.aws.TestSimpleDBRecorder$EventTypes"));
        attrs.add(new Attribute("field1", "value1"));
        attrs.add(new Attribute("field2", "value2"));
        item.setAttributes(attrs);
        item.setName("MONKEY-" + id + "-region");
        SelectResult result = new SelectResult();
        result.setItems(Arrays.asList(item));
        return result;
    }
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.SelectResult

        return result;
    }

    @Test
    public void testFindEvent() {
        SelectResult result1 = mkSelectResult("testId1");
        result1.setNextToken("nextToken");
        SelectResult result2 = mkSelectResult("testId2");

        ArgumentCaptor<SelectRequest> arg = ArgumentCaptor.forClass(SelectRequest.class);

        when(sdbMock.select(any(SelectRequest.class))).thenReturn(result1).thenReturn(result2);
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.SelectResult

    LOGGER.debug("Count items for query " + countQuery);
        validateSelectQuery(countQuery);

        final String escapedQuery = getEscapedQuery(countQuery, entityInformation);

        final SelectResult selectResult = invokeFindImpl(consistentRead, escapedQuery);
        for (Item item : selectResult.getItems()) {
            if (item.getName().equals("Domain")) {
                for (Attribute attribute : item.getAttributes()) {
                    if (attribute.getName().equals("Count")) {
                        return Long.parseLong(attribute.getValue());
                    }
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.SelectResult

        List<String> referenceFieldsNames = ReflectionUtils.getReferencedAttributeNames(entityClass);

        final DomainItemBuilder<T> domainItemBuilder = new DomainItemBuilder<T>();

        final SelectResult selectResult = invokeFindImpl(consistentRead, escapedQuery);

        if (referenceFieldsNames.isEmpty()) {
            return domainItemBuilder.populateDomainItems(entityInformation, selectResult);
        }

        for (Item item : selectResult.getItems()) {

            T populatedItem = domainItemBuilder.populateDomainItem(entityInformation, item);

            result.add(populatedItem);
            for (Attribute attribute : item.getAttributes()) {
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.SelectResult

        final String escapedQuery = getEscapedQuery(query, entityInformation);
        SelectRequest selectRequest = new SelectRequest(escapedQuery, consistentRead);

        selectRequest.setNextToken(nextToken);

        final SelectResult selectResult = getDB().select(selectRequest);

        return domainItemBuilder.populateDomainItems(entityInformation, selectResult);
    }
View Full Code Here

Examples of com.amazonaws.services.simpledb.model.SelectResult

    private String getNextToken(String query, boolean consistentRead) {
        LOGGER.debug("Get next token for query: " + query);

        Assert.isTrue(query.contains("limit"), "Only queries with limit have a next token!");

        final SelectResult selectResult = getDB().select(new SelectRequest(query, consistentRead));

        return selectResult.getNextToken();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.