Example usage for java.util SortedSet isEmpty

List of usage examples for java.util SortedSet isEmpty

Introduction

In this page you can find the example usage for java.util SortedSet isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:org.stockwatcher.data.cassandra.StockDAOImpl.java

@Override
public SortedSet<Exchange> getExchanges(StatementOptions options) {
    SortedSet<Exchange> exchanges = new TreeSet<Exchange>();
    try {//w w  w.j  a  va  2  s  .  c  om
        Statement statement = select().column("exchange_id").column("exchange_name").column("currency_code")
                .from("Exchange").where(eq("active", true));
        for (Row row : execute(statement, options)) {
            exchanges.add(createExchange(row));
        }
    } catch (DriverException e) {
        throw new DAOException(e);
    }
    if (exchanges.isEmpty()) {
        throw new DAOException("no active exchanges found");
    }
    return exchanges;
}

From source file:org.wrml.runtime.rest.ApiNavigator.java

public SortedSet<Parameter> getSurrogateKeyComponents(final URI uri, final Prototype prototype) {

    final SortedSet<ResourceMatchResult> results = match(uri);

    if (results == null || results.isEmpty()) {
        final URI apiUri = getApiUri();
        ApiNavigator.LOG.error(/*from  ww w. j  a  v a2  s .c  o m*/
                "2 This ApiNavigator has charted \"{}\", which is not a match for the specified URI: {}",
                new Object[] { apiUri, uri });
        throw new ApiNavigatorException("This ApiNavigator has charted \"" + apiUri
                + "\", which is not a match for the specified URI: " + uri + ".", null, this, Status.NOT_FOUND);
    }

    SortedSet<Parameter> surrogateKeyComponents = null;

    for (final ResourceMatchResult result : results) {

        final Resource resource = result.getResource();
        surrogateKeyComponents = resource.getSurrogateKeyComponents(uri, prototype);

        if (surrogateKeyComponents != null && !surrogateKeyComponents.isEmpty()) {
            break;
        }
    }

    return surrogateKeyComponents;
}

From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginView.java

/**
 * //from  w ww.  ja  va2  s . c  om
 * @param path int of the path to get the Time Options for
 * @param storedTimePref Long of anytime during the specific day that we want to return times for
 * @return populates the "times" TreeSet (time longs truncated at the "the seconds" position) 
 *          which populates Time Combo box, the truncTimeToFullTimeMap which maps the truncated times
 *          im times TreeSet to each times full Long value. The truncTimeToFullTimeMap chooses each time
 *          up to the second and maps it to the greatest equivalent time up to the milliseconds.
 *          
 */
protected void setTimeOptions(int path, Long storedTimePref) {
    try {
        timeSelectCombo.getItems().clear();
        overrideTimestamp = null;

        Date startDate = null, finishDate = null;
        if (storedTimePref != null) {
            StampBdb stampDb = Bdb.getStampDb();
            NidSet nidSet = new NidSet();
            nidSet.add(path);

            NidSetBI stamps = null;
            if (!storedTimePref.equals(getDefaultTime())) {
                startDate = getStartOfDay(new Date(storedTimePref));
                finishDate = getEndOfDay(new Date(storedTimePref));
                stamps = stampDb.getSpecifiedStamps(nidSet, startDate.getTime(), finishDate.getTime());
            } else {
                stamps = stampDb.getSpecifiedStamps(nidSet, Long.MIN_VALUE, Long.MAX_VALUE);
            }

            truncTimeToFullTimeMap.clear();
            times.clear();

            HashSet<Integer> stampSet = stamps.getAsSet();

            Date d = new Date(storedTimePref);
            if (dateIsLocalDate(d)) {
                // Get stamps of day
                Date todayStartDate = getStartOfDay(new Date());
                Date todayFinishDate = getEndOfDay(new Date());
                NidSetBI todayStamps = stampDb.getSpecifiedStamps(nidSet, todayStartDate.getTime(),
                        todayFinishDate.getTime());

                // If have stamps, no action, if not, show Latest and set stamps to latest stamp we have in stampset
                if (todayStamps.size() == 0) {
                    //                  timeSelectCombo.getItems().add(Long.MAX_VALUE);
                    NidSetBI allStamps = stampDb.getSpecifiedStamps(nidSet, Long.MIN_VALUE, Long.MAX_VALUE);
                    HashSet<Integer> allStampSet = allStamps.getAsSet();
                    SortedSet<Integer> s = new TreeSet<Integer>(allStampSet);
                    if (!s.isEmpty()) {
                        Integer stampToSet = s.last();
                        overrideTimestamp = stampDb.getPosition(stampToSet).getTime();
                        timeSelectCombo.getItems().add(Long.MAX_VALUE);
                        timeSelectCombo.setValue(Long.MAX_VALUE);
                    }
                }
            }

            this.pathDatesList.add(LocalDate.now());
            if (overrideTimestamp == null) {
                if (!stampSet.isEmpty()) {
                    enableTimeCombo(true);
                    for (Integer thisStamp : stampSet) {
                        Long fullTime = null;
                        Date stampDate;
                        LocalDate stampInstant = null;
                        try {
                            fullTime = stampDb.getPosition(thisStamp).getTime();
                            stampDate = new Date(fullTime);
                            stampInstant = stampDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        Calendar cal = Calendar.getInstance();
                        cal.setTime(new Date(fullTime));
                        cal.set(Calendar.MILLISECOND, 0); //Strip milliseconds
                        Long truncTime = cal.getTimeInMillis();

                        this.pathDatesList.add(stampInstant); //Build DatePicker
                        times.add(truncTime); //This can probably go, we don't populate hashmap like this at initialization
                        timeSelectCombo.getItems().add(truncTime);

                        if (truncTimeToFullTimeMap.containsKey(truncTime)) { //Build Truncated Time to Full Time HashMap
                            //If truncTimeToFullTimeMap has this key, is the value the newest time in milliseconds?
                            if (new Date(truncTimeToFullTimeMap.get(truncTime)).before(new Date(fullTime))) {
                                truncTimeToFullTimeMap.put(truncTime, fullTime);
                            }
                        } else {
                            truncTimeToFullTimeMap.put(truncTime, fullTime);
                        }
                    }
                } else {
                    //               disableTimeCombo(true);
                    //                  timeSelectCombo.getItems().add(Long.MAX_VALUE);
                    timeSelectCombo.setValue(Long.MAX_VALUE);
                    enableTimeCombo(true);
                    //               logger.error("Could not retreive any Stamps");
                }
            }
        }
    } catch (Exception e) {
        logger.error("Error setting the default Time Dropdown");
        e.printStackTrace();
    }
}

From source file:org.apache.hadoop.yarn.server.applicationhistoryservice.timeline.HBaseTimelineStore.java

@Override
public TimelineEvents getEntityTimelines(String entityType, SortedSet<String> entityIds, Long limit,
        Long windowStart, Long windowEnd, Set<String> eventTypes) throws IOException {
    TimelineEvents events = new TimelineEvents();
    if (entityIds == null || entityIds.isEmpty()) {
        return events;
    }/* w w w .j a  va2 s  .c  om*/
    // create a lexicographically-ordered map from start time to entities
    Map<byte[], List<EntityIdentifier>> startTimeMap = new TreeMap<byte[], List<EntityIdentifier>>(
            new Comparator<byte[]>() {
                @Override
                public int compare(byte[] o1, byte[] o2) {
                    return WritableComparator.compareBytes(o1, 0, o1.length, o2, 0, o2.length);
                }
            });

    if (windowEnd == null) {
        windowEnd = Long.MAX_VALUE;
    }
    if (limit == null) {
        limit = DEFAULT_LIMIT;
    }

    HTableInterface table = getTable(ENTITY_TABLE);
    try {
        // look up start times for the specified entities
        // skip entities with no start time
        for (String entityId : entityIds) {
            byte[] startTime = getStartTime(entityId, entityType, null, null);
            if (startTime != null) {
                List<EntityIdentifier> entities = startTimeMap.get(startTime);
                if (entities == null) {
                    entities = new ArrayList<EntityIdentifier>();
                    startTimeMap.put(startTime, entities);
                }
                entities.add(new EntityIdentifier(entityId, entityType));
            }
        }
        for (Entry<byte[], List<EntityIdentifier>> entry : startTimeMap.entrySet()) {
            // look up the events matching the given parameters (limit,
            // start time, end time, event types) for entities whose start times
            // were found and add the entities to the return list
            byte[] revStartTime = entry.getKey();
            for (EntityIdentifier entityIdentifier : entry.getValue()) {
                EventsOfOneEntity entity = new EventsOfOneEntity();
                entity.setEntityId(entityIdentifier.getId());
                entity.setEntityType(entityType);
                events.addEvent(entity);

                byte[] entityRow = HBaseTimelineStoreUtil.createEntityRow(entityIdentifier.getId(), entityType,
                        revStartTime);
                Scan scan = new Scan(entityRow, entityRow);
                scan.addFamily(EVENTS_COLUMN);
                scan.setFilter(new ColumnRangeFilter(writeReverseOrderedLong(windowEnd), true,
                        windowStart == null ? null : writeReverseOrderedLong(windowStart), false));

                ResultScanner rs = table.getScanner(scan);
                for (Result result = rs.next(); result != null; result = rs.next()) {
                    for (Cell cell : result.rawCells()) {
                        TimelineEvent event = HBaseTimelineStoreUtil.getEvent(cell.getQualifierArray(),
                                cell.getQualifierOffset(), cell.getQualifierLength(), cell.getValueArray(),
                                cell.getValueOffset(), cell.getValueLength());
                        if (eventTypes == null || eventTypes.contains(event.getEventType())) {
                            entity.addEvent(event);
                        }
                        if (entity.getEvents().size() >= limit) {
                            break;
                        }
                    }
                    if (entity.getEvents().size() >= limit) {
                        break;
                    }
                }
                rs.close();
            }
        }
    } finally {
        IOUtils.cleanup(LOG, table);
    }
    return events;

}

From source file:org.wrml.runtime.rest.ApiNavigator.java

/**
 * Determine which resource(s) match the requested resource id.
 * <p/>/*  w  w  w .j  a v  a 2s  . co m*/
 * Note: This needs to be as fast as possible because it is used during client request handling.
 */
private SortedSet<ResourceMatchResult> match(final URI uri) {

    ApiNavigator.LOG.debug("Attempting match on URI {}", new Object[] { uri });

    if (uri == null) {
        ApiNavigator.LOG.error("3 This ApiNavigator cannot locate a resource with a *null* identifier.");
        throw new ApiNavigatorException("This ApiNavigator cannot locate a resource with a *null* identifier.",
                null, this);

    }

    final URI apiUri = getApiUri();

    final String requestUriString = uri.toString();
    final String apiUriString = apiUri.toString();

    if (!requestUriString.startsWith(apiUriString)) {
        ApiNavigator.LOG.error("4 This ApiNavigator has charted \"" + apiUri
                + "\", which does not manage the specified resource (" + uri + ")");
        throw new ApiNavigatorException(
                "This ApiNavigator has charted \"" + apiUri
                        + "\", which does not manage the specified resource (" + uri + ")",
                null, this, Status.NOT_FOUND);
    }

    final String path = requestUriString.substring(apiUriString.length());

    final SortedSet<ResourceMatchResult> results = matchPath(path);

    if (results == null || results.isEmpty() || results.size() == 1) {
        return results;
    }

    int resultsTiedForFirst = 0;
    final int highestScore = results.first().getScore();
    for (final ResourceMatchResult result : results) {
        final int score = result.getScore();
        if (score == highestScore) {
            resultsTiedForFirst++;
        } else {
            break;
        }
    }

    // TODO there's no differentiation here; either a lot of logic missing, or a lot of unnecessary logic
    if (resultsTiedForFirst == 1) {
        return results;
    }

    return results;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.department.PublicDepartmentSiteDA.java

private void setupTeachersAreas(HttpServletRequest request, Department department) {

    SortedSet<Unit> areas = new TreeSet<Unit>(Unit.COMPARATOR_BY_NAME_AND_ID);
    SortedSet<Teacher> teachersNoArea = new TreeSet<Teacher>(Teacher.TEACHER_COMPARATOR_BY_CATEGORY_AND_NUMBER);
    Map<String, SortedSet<Teacher>> teachers = new Hashtable<String, SortedSet<Teacher>>();

    for (Teacher teacher : department.getAllCurrentTeachers()) {
        Unit area = teacher.getCurrentSectionOrScientificArea();

        if (area != null) {
            areas.add(area);/*from w  w w .j  a  va2  s .  com*/
            addListTeacher(teachers, area.getExternalId().toString(), teacher);
        } else {
            teachersNoArea.add(teacher);
        }
    }

    if (areas.isEmpty()) {
        request.setAttribute("ignoreAreas", true);
    }

    request.setAttribute("areas", areas);
    request.setAttribute("teachers", teachers);
    request.setAttribute("teachersNoArea", teachersNoArea);
}

From source file:de.interactive_instruments.ShapeChange.Model.EA.EADocument.java

private void saveDiagrams(AtomicInteger imgIdCounter, String imgIdPrefix, java.io.File targetFolder,
        String relPathWithTargetFolder, PackageInfo pi) {

    if (!targetFolder.exists()) {
        targetFolder.mkdir();//from w w  w.  jav  a  2 s. co  m
    }

    java.io.File pi_folder = new java.io.File(targetFolder, escapeFileName(pi.name()));

    if (!pi_folder.mkdir()) {
        result.addWarning(null, 32, pi_folder.getAbsolutePath());
    }

    String newRelPathWithTargetFolder = relPathWithTargetFolder + "/" + escapeFileName(pi.name());

    Project projectInterface = repository.GetProjectInterface();

    PackageInfoEA piEa = fPackageById.get(pi.id());

    List<Diagram> diagramList = getDiagramsOfPackage(piEa);

    String packageDiagramRegex = options.parameter("packageDiagramRegex");
    if (packageDiagramRegex == null) {
        packageDiagramRegex = Options.IMAGE_INCLUSION_PACKAGE_REGEX;
    }
    String classDiagramRegex = options.parameter("classDiagramRegex");
    if (classDiagramRegex == null) {
        classDiagramRegex = Options.IMAGE_INCLUSION_CLASS_REGEX;
    }

    String elementNameKeyForMatching = Options.ELEMENT_NAME_KEY_FOR_DIAGRAM_MATCHING;
    String regexForModelElement;

    for (Diagram d : diagramList) {

        String imgId = imgIdPrefix + imgIdCounter.incrementAndGet();
        String imgFileName = escapeFileName(imgId + ".jpg");
        String imgName = d.GetName();

        java.io.File img = new java.io.File(pi_folder, imgFileName);

        String relPathToFile = newRelPathWithTargetFolder + "/" + imgFileName;

        String type = d.GetType();

        /*
         * before saving the diagram, ensure that it is relevant for at
         * least one model element
         */
        boolean relevantDiagram = false;

        if (type.equalsIgnoreCase("Package")) {

            regexForModelElement = packageDiagramRegex.replaceAll(elementNameKeyForMatching, pi.name());
            if (imgName.matches(regexForModelElement)) {
                relevantDiagram = true;
            }

        } else if (type.equalsIgnoreCase("Logical")) {

            regexForModelElement = packageDiagramRegex.replaceAll(elementNameKeyForMatching, pi.name());
            if (imgName.matches(regexForModelElement)) {
                relevantDiagram = true;
            }

            SortedSet<ClassInfo> clTmp = this.classes(pi);

            if (clTmp == null || clTmp.isEmpty()) {

                // no classes in package, thus the logical diagram cannot be
                // relevant

            } else if (relevantDiagram) {
                // we have already established that this is a relevant diagram

            } else {

                for (ClassInfo ci : clTmp) {

                    // only process classes from this package
                    if (ci.pkg() == pi) {

                        regexForModelElement = classDiagramRegex.replaceAll(elementNameKeyForMatching,
                                ci.name());
                        if (imgName.matches(regexForModelElement)) {
                            relevantDiagram = true;
                            // we established that this is a relevant diagram
                            break;
                        }
                    }
                }
            }
        } else {
            // unsupported diagram type -> irrelevant
        }

        if (!relevantDiagram) {
            continue;
        }

        repository.OpenDiagram(d.GetDiagramID());
        projectInterface.SaveDiagramImageToFile(img.getAbsolutePath());
        repository.CloseDiagram(d.GetDiagramID());

        BufferedImage bimg;
        int width = 400;
        int height = 400;

        try {

            bimg = ImageIO.read(img);
            width = bimg.getWidth();
            height = bimg.getHeight();

        } catch (IOException e) {
            result.addError(null, 33, imgName, pi.name());
            e.printStackTrace(System.err);
            continue;
        }

        ImageMetadata imgMeta = new ImageMetadata(imgId, imgName, img, relPathToFile, width, height);

        if (type.equalsIgnoreCase("Package")) {

            // we already checked that the diagram is relevant for this
            // package
            addDiagramToPackage(pi, imgMeta);

        } else if (type.equalsIgnoreCase("Logical")) {

            regexForModelElement = packageDiagramRegex.replaceAll(elementNameKeyForMatching, pi.name());
            if (imgName.matches(regexForModelElement)) {
                addDiagramToPackage(pi, imgMeta);
            }

            SortedSet<ClassInfo> clTmp = this.classes(pi);

            if (clTmp == null || clTmp.isEmpty()) {

                continue;

            } else {

                for (ClassInfo ci : clTmp) {

                    // only process classes from this package
                    if (ci.pkg() == pi) {

                        regexForModelElement = classDiagramRegex.replaceAll(elementNameKeyForMatching,
                                ci.name());
                        if (imgName.matches(regexForModelElement)) {
                            addDiagramToClass(ci, imgMeta);
                        }

                    }
                }
            }
        } else {
            // unsupported diagram type - irrelevant
        }
    }

    SortedSet<PackageInfo> children = pi.containedPackages();

    if (children != null) {

        for (PackageInfo piChild : children) {

            if (piChild.targetNamespace().equals(pi.targetNamespace())) {
                saveDiagrams(imgIdCounter, imgIdPrefix, pi_folder, newRelPathWithTargetFolder, piChild);
            }
        }
    }
}

From source file:org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer.java

private void storeStatement(final Statement statement) throws IOException {
    Objects.requireNonNull(mtbw,//from   w  w w.ja v  a  2  s .  com
            "Freetext indexer attempting to store, but setMultiTableBatchWriter() was not set.");

    // if the predicate list is empty, accept all predicates.
    // Otherwise, make sure the predicate is on the "valid" list
    final boolean isValidPredicate = validPredicates.isEmpty()
            || validPredicates.contains(statement.getPredicate());

    if (isValidPredicate && (statement.getObject() instanceof Literal)) {

        // Get the tokens
        final String text = statement.getObject().stringValue().toLowerCase();
        final SortedSet<String> tokens = tokenizer.tokenize(text);

        if (!tokens.isEmpty()) {
            // Get Document Data
            final String docContent = StatementSerializer.writeStatement(statement);

            final String docId = Md5Hash.md5Base64(docContent);

            // Setup partition
            final Text partition = genPartition(docContent.hashCode(), docTableNumPartitions);

            final Mutation docTableMut = new Mutation(partition);
            final List<Mutation> termTableMutations = new ArrayList<Mutation>();

            final Text docIdText = new Text(docId);

            // Store the Document Data
            docTableMut.put(ColumnPrefixes.DOCS_CF_PREFIX, docIdText,
                    new Value(docContent.getBytes(Charsets.UTF_8)));

            // index the statement parts
            docTableMut.put(ColumnPrefixes.getSubjColFam(statement), docIdText, EMPTY_VALUE);
            docTableMut.put(ColumnPrefixes.getPredColFam(statement), docIdText, EMPTY_VALUE);
            docTableMut.put(ColumnPrefixes.getObjColFam(statement), docIdText, EMPTY_VALUE);
            docTableMut.put(ColumnPrefixes.getContextColFam(statement), docIdText, EMPTY_VALUE);

            // index the statement terms
            for (final String token : tokens) {
                // tie the token to the document
                docTableMut.put(ColumnPrefixes.getTermColFam(token), docIdText, EMPTY_VALUE);

                // store the term in the term table (useful for wildcard searches)
                termTableMutations.add(createEmptyPutMutation(ColumnPrefixes.getTermListColFam(token)));
                termTableMutations.add(createEmptyPutMutation(ColumnPrefixes.getRevTermListColFam(token)));
            }

            // write the mutations
            try {
                docTableBw.addMutation(docTableMut);
                termTableBw.addMutations(termTableMutations);
            } catch (final MutationsRejectedException e) {
                logger.error("error adding mutation", e);
                throw new IOException(e);
            }

        }

    }
}

From source file:org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer.java

private void deleteStatement(final Statement statement) throws IOException {
    Objects.requireNonNull(mtbw,/*  w w w  .j a v  a 2 s .c  o m*/
            "Freetext indexer attempting to delete, but setMultiTableBatchWriter() was not set.");

    // if the predicate list is empty, accept all predicates.
    // Otherwise, make sure the predicate is on the "valid" list
    final boolean isValidPredicate = validPredicates.isEmpty()
            || validPredicates.contains(statement.getPredicate());

    if (isValidPredicate && (statement.getObject() instanceof Literal)) {

        // Get the tokens
        final String text = statement.getObject().stringValue().toLowerCase();
        final SortedSet<String> tokens = tokenizer.tokenize(text);

        if (!tokens.isEmpty()) {
            // Get Document Data
            final String docContent = StatementSerializer.writeStatement(statement);

            final String docId = Md5Hash.md5Base64(docContent);

            // Setup partition
            final Text partition = genPartition(docContent.hashCode(), docTableNumPartitions);

            final Mutation docTableMut = new Mutation(partition);
            final List<Mutation> termTableMutations = new ArrayList<Mutation>();

            final Text docIdText = new Text(docId);

            // Delete the Document Data
            docTableMut.putDelete(ColumnPrefixes.DOCS_CF_PREFIX, docIdText);

            // Delete the statement parts in index
            docTableMut.putDelete(ColumnPrefixes.getSubjColFam(statement), docIdText);
            docTableMut.putDelete(ColumnPrefixes.getPredColFam(statement), docIdText);
            docTableMut.putDelete(ColumnPrefixes.getObjColFam(statement), docIdText);
            docTableMut.putDelete(ColumnPrefixes.getContextColFam(statement), docIdText);

            // Delete the statement terms in index
            for (final String token : tokens) {
                if (IS_TERM_TABLE_TOKEN_DELETION_ENABLED) {
                    final int rowId = Integer.parseInt(partition.toString());
                    final boolean doesTermExistInOtherDocs = doesTermExistInOtherDocs(token, rowId, docIdText);
                    // Only delete the term from the term table if it doesn't appear in other docs
                    if (!doesTermExistInOtherDocs) {
                        // Delete the term in the term table
                        termTableMutations
                                .add(createEmptyPutDeleteMutation(ColumnPrefixes.getTermListColFam(token)));
                        termTableMutations
                                .add(createEmptyPutDeleteMutation(ColumnPrefixes.getRevTermListColFam(token)));
                    }
                }

                // Un-tie the token to the document
                docTableMut.putDelete(ColumnPrefixes.getTermColFam(token), docIdText);
            }

            // write the mutations
            try {
                docTableBw.addMutation(docTableMut);
                termTableBw.addMutations(termTableMutations);
            } catch (final MutationsRejectedException e) {
                logger.error("error adding mutation", e);
                throw new IOException(e);
            }

        }
    }
}

From source file:org.voltdb.sysprocs.UpdateApplicationCatalog.java

/**
 * Use EE stats to get the row counts for all tables in this partition.
 * Check the provided list of tables that need to be empty against actual
 * row counts. If any of them aren't empty, stop the catalog update and
 * return the pre-provided error message that corresponds to the non-empty
 * tables.//from w ww  . ja  v  a  2s .c  om
 *
 * @param tablesThatMustBeEmpty List of table names that must be empty.
 * @param reasonsForEmptyTables Error messages to return if that table isn't
 * empty.
 * @param context
 */
protected void checkForNonEmptyTables(String[] tablesThatMustBeEmpty, String[] reasonsForEmptyTables,
        SystemProcedureExecutionContext context) {
    assert (tablesThatMustBeEmpty != null);
    // no work to do if no tables need to be empty
    if (tablesThatMustBeEmpty.length == 0) {
        return;
    }
    assert (reasonsForEmptyTables != null);
    assert (reasonsForEmptyTables.length == tablesThatMustBeEmpty.length);

    // fetch the id of the tables that must be empty from the
    //  current catalog (not the new one).
    CatalogMap<Table> tables = context.getDatabase().getTables();
    int[] tableIds = new int[tablesThatMustBeEmpty.length];
    int i = 0;
    for (String tableName : tablesThatMustBeEmpty) {
        Table table = tables.get(tableName);
        if (table == null) {
            String msg = String.format("@UpdateApplicationCatalog was checking to see if table %s was empty, "
                    + "presumably as part of a schema change, and it failed to find the table "
                    + "in the current catalog context.", tableName);
            throw new SpecifiedException(ClientResponse.UNEXPECTED_FAILURE, msg);
        }
        tableIds[i++] = table.getRelativeIndex();
    }

    // get the table stats for these tables from the EE
    final VoltTable[] s1 = context.getSiteProcedureConnection().getStats(StatsSelector.TABLE, tableIds, false,
            getTransactionTime().getTime());
    if ((s1 == null) || (s1.length == 0)) {
        String tableNames = StringUtils.join(tablesThatMustBeEmpty, ", ");
        String msg = String.format("@UpdateApplicationCatalog was checking to see if tables (%s) were empty ,"
                + "presumably as part of a schema change, but failed to get the row counts "
                + "from the native storage engine.", tableNames);
        throw new SpecifiedException(ClientResponse.UNEXPECTED_FAILURE, msg);
    }
    VoltTable stats = s1[0];
    SortedSet<String> nonEmptyTables = new TreeSet<String>();

    // find all empty tables
    while (stats.advanceRow()) {
        long tupleCount = stats.getLong("TUPLE_COUNT");
        String tableName = stats.getString("TABLE_NAME");
        if (tupleCount > 0 && !"StreamedTable".equals(stats.getString("TABLE_TYPE"))) {
            nonEmptyTables.add(tableName);
        }
    }

    // return an error containing the names of all non-empty tables
    // via the propagated reasons why each needs to be empty
    if (!nonEmptyTables.isEmpty()) {
        String msg = "Unable to make requested schema change:\n";
        for (i = 0; i < tablesThatMustBeEmpty.length; ++i) {
            if (nonEmptyTables.contains(tablesThatMustBeEmpty[i])) {
                msg += reasonsForEmptyTables[i] + "\n";
            }
        }
        throw new SpecifiedException(ClientResponse.GRACEFUL_FAILURE, msg);
    }
}