Example usage for java.util List clear

List of usage examples for java.util List clear

Introduction

In this page you can find the example usage for java.util List clear.

Prototype

void clear();

Source Link

Document

Removes all of the elements from this list (optional operation).

Usage

From source file:adapters.BoxSeriesCollectionAdapter.java

/**
 * Modified Method: change label from serie to Cluster plus the number of instances in the cluster
 *
 * Creates a new <TT>BoxSeriesCollection</TT> instance with default
 *    parameters and given data series. The input parameter represents series
 *    of point sets.//  w  ww . j av  a 2s  .co  m
 *
 * @param data series of point sets.
 *
 *
 */
public BoxSeriesCollectionAdapter(double[]... data) {
    renderer = new BoxAndWhiskerRenderer();
    seriesCollection = new DefaultBoxAndWhiskerCategoryDataset();

    DefaultBoxAndWhiskerCategoryDataset tempSeriesCollection = (DefaultBoxAndWhiskerCategoryDataset) seriesCollection;

    for (int i = 0; i < data.length; i++) {
        if (data[i].length == 0)
            throw new IllegalArgumentException("Unable to render the plot. data[" + i + "] contains no row");
        final List<Double> list = new ArrayList<Double>();
        for (int j = 0; j < data[i].length - 1; j++)
            list.add(data[i][j]);

        // "i + 1" since the cluster label should start with 1 instead of 0
        tempSeriesCollection.add(list, 0, "[ " + data[i].length + " ]");
        list.clear();
    }
    ((BoxAndWhiskerRenderer) renderer).setMaximumBarWidth(BARWIDTH);
}

From source file:com.dell.asm.asmcore.asmmanager.app.rest.ConfigureTemplateService.java

@Override
public ServiceTemplate uploadTemplate(ServiceTemplateUploadRequest uploadRequest) {
    ServiceTemplate svc = null;//www  .j a v a 2 s  .  co m
    try {

        if (uploadRequest.getFileData() == null) {
            throw new LocalizedWebApplicationException(Response.Status.BAD_REQUEST,
                    AsmManagerMessages.noTemplateFile());
        }

        // encrypt
        if (uploadRequest.isUseEncPwdFromBackup()) {
            DatabaseBackupSettings databaseBackupSettings = getAlcmDatabaseService()
                    .getDatabaseBackupSettings();
            String encPassword = databaseBackupSettings.getEncryptionPassword();
            if (encPassword == null) {
                throw new LocalizedWebApplicationException(Response.Status.BAD_REQUEST,
                        AsmManagerMessages.noBackupPassword());
            }
            uploadRequest.setEncryptionPassword(encPassword);
        }

        try {
            svc = ServiceTemplateUtil.importTemplate(uploadRequest.getFileData(),
                    uploadRequest.getEncryptionPassword());
        } catch (Exception e) {
            logger.error(e);
            throw new LocalizedWebApplicationException(Response.Status.BAD_REQUEST,
                    AsmManagerMessages.badTemplateFile(e.getMessage()));
        }

        if (svc != null) {
            if (svc.getId() != null) {
                ServiceTemplateEntity serviceTemplateEntity = getServiceTemplateDAO()
                        .getTemplateById(svc.getId());
                if (serviceTemplateEntity != null) {
                    throw new LocalizedWebApplicationException(Response.Status.BAD_REQUEST,
                            AsmManagerMessages.uploadedServiceTemplateExists());
                }
            }

            if (uploadRequest.getDescription() != null)
                svc.setTemplateDescription(uploadRequest.getDescription());
            if (uploadRequest.getCategory() != null && uploadRequest.getCategory().length() > 0)
                svc.setCategory(uploadRequest.getCategory());
            if (uploadRequest.getTemplateName() != null)
                svc.setTemplateName(uploadRequest.getTemplateName());

            svc.setManageFirmware(uploadRequest.isManageFirmware());
            if (uploadRequest.isManageFirmware()) {
                if (uploadRequest.isUseDefaultCatalog()) {
                    svc.setUseDefaultCatalog(true);
                    svc.setFirmwareRepository(null);
                } else if (StringUtils.isNotBlank(uploadRequest.getFirmwarePackageId())) {
                    FirmwareRepositoryEntity firmwareRepositoryEntity = getFirmwareRepositoryDAO()
                            .get(uploadRequest.getFirmwarePackageId());
                    if (firmwareRepositoryEntity != null) {
                        svc.setFirmwareRepository(firmwareRepositoryEntity.getSimpleFirmwareRepository());
                    }
                }
            }
            if (uploadRequest.isManagePermissions()) {

                svc.setAllUsersAllowed(uploadRequest.isAllStandardUsers());
                Set<User> users = new HashSet<>();
                svc.setAssignedUsers(users);

                ProxyUtil.setProxyHeaders(getUserResourceProxy(), getServletRequest());

                List<String> fUser = new ArrayList<>();
                if (uploadRequest != null && uploadRequest.getAssignedUsers() != null) {
                    for (String userName : uploadRequest.getAssignedUsers()) {
                        fUser.clear();
                        fUser.add("eq,userName," + userName);
                        User[] lUsers = getUserResourceProxy().getUsers(fUser, null, null, null);
                        if (lUsers != null && lUsers.length == 1) {
                            users.add(lUsers[0]);
                        }
                    }
                }
            }

            addServiceTemplateConfiguration(svc);

            svc.setTemplateName(null);
            svc.setTemplateDescription(null);
            svc.setCategory(null);
            svc.setDraft(true);
            svc.setTemplateLocked(true);
            svc.setInConfiguration(true);

            ServiceTemplateUtil.stripPasswords(svc,
                    ServiceTemplateSettingIDs.SERVICE_TEMPLATE_PASSWORD_DEFAULT_TO_REMOVE);
        }

    } catch (LocalizedWebApplicationException e) {
        logger.error("LocalizedWebApplicationException while importing service template", e);
        throw e;
    } catch (Exception e) {
        logger.error("Exception while importing service template", e);
        throw new LocalizedWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR,
                AsmManagerMessages.internalError());
    }
    return svc;
}

From source file:com.jaeksoft.searchlib.learning.StandardLearner.java

private void fieldClassify(String fieldName, Float boost, String data,
        TreeMap<String, LearnerResultItem> targetMap) throws SearchLibException, IOException {
    AbstractSearchRequest searchRequest = (AbstractSearchRequest) learnerClient.getNewRequest(REQUEST_SEARCH);
    BooleanQuery booleanQuery = getBooleanQuery(fieldName, data);
    if (booleanQuery == null || booleanQuery.getClauses() == null || booleanQuery.getClauses().length == 0)
        return;//w  w  w.  j ava 2  s .  c om
    int start = 0;
    final int rows = 1000;
    List<String[]> termVectors = new ArrayList<String[]>(rows);
    List<String> stringIndexTerms = new ArrayList<String>(rows);
    for (;;) {
        termVectors.clear();
        stringIndexTerms.clear();
        searchRequest.setStart(start);
        searchRequest.setRows(rows);
        searchRequest.setBoostedComplexQuery(booleanQuery);
        ResultSearchSingle result = (ResultSearchSingle) learnerClient.request(searchRequest);
        if (result.getDocumentCount() == 0)
            break;
        int end = start + result.getDocumentCount();
        int[] docIds = ArrayUtils.subarray(ResultDocument.getDocIds(result.getDocs()), start, end);
        learnerClient.getIndex().putTermVectors(docIds, FIELD_SOURCE_TARGET, termVectors);
        learnerClient.getIndex().getStringIndex(FIELD_SOURCE_NAME).putTerms(docIds, stringIndexTerms);
        int i = -1;
        for (int pos = start; pos < end; pos++) {
            i++;
            String[] terms = termVectors.get(i);
            if (terms == null)
                continue;
            double docScore = result.getScore(pos);
            if (boost != null)
                docScore = docScore * boost;
            String name = stringIndexTerms.get(i);
            for (String value : terms) {
                if (value == null)
                    continue;
                LearnerResultItem learnerResultItem = targetMap.get(value);
                if (learnerResultItem == null) {
                    learnerResultItem = new LearnerResultItem(0, -1, value, null, 0, null);
                    targetMap.put(value, learnerResultItem);
                }
                learnerResultItem.addScoreInstance(docScore, 1, name);
            }
        }
        searchRequest.reset();
        start += rows;
    }
}

From source file:edu.ucuenca.authorsdisambiguation.nwd.NWD.java

public List<String> clean(List<String> ls) {
    List<String> al = ls;
    Set<String> hs = new HashSet<>();
    hs.addAll(al);//  w w w. ja  v  a2  s . com
    al.clear();
    al.addAll(hs);

    JsonArray asArray = Cache.getInstance().config.get("stopwords").getAsArray();

    for (JsonValue s : asArray) {
        al.remove(s.getAsString().value());
    }

    return al;
}

From source file:com.glaf.core.db.DbTableChecker.java

public void checkTables() {
    List<String> tables = DBUtils.getTables();
    TableDefinitionQuery query = new TableDefinitionQuery();

    List<TableDefinition> list = tableDefinitionService.getTableColumnsCount(query);
    Map<String, TableDefinition> tableMap = new java.util.HashMap<String, TableDefinition>();
    if (list != null && !list.isEmpty()) {
        for (TableDefinition t : list) {
            tableMap.put(t.getTableName().toLowerCase(), t);
        }//from  www.  j  av a2  s . co m
        list.clear();
    }

    if (tables != null && !tables.isEmpty()) {
        for (String tableName : tables) {
            String tbl = tableName;
            tableName = tableName.toLowerCase();
            if (tableName.startsWith("act_")) {
                continue;
            }
            if (tableName.startsWith("jbpm_")) {
                continue;
            }
            if (tableName.startsWith("tmp_")) {
                continue;
            }
            if (tableName.startsWith("temp_")) {
                continue;
            }
            if (tableName.startsWith("demo_")) {
                continue;
            }
            if (tableName.startsWith("wwv_")) {
                continue;
            }
            if (tableName.startsWith("aq_")) {
                continue;
            }
            if (tableName.startsWith("bsln_")) {
                continue;
            }
            if (tableName.startsWith("mgmt_")) {
                continue;
            }
            if (tableName.startsWith("ogis_")) {
                continue;
            }
            if (tableName.startsWith("ols_")) {
                continue;
            }
            if (tableName.startsWith("em_")) {
                continue;
            }
            if (tableName.startsWith("openls_")) {
                continue;
            }
            if (tableName.startsWith("mrac_")) {
                continue;
            }
            if (tableName.startsWith("orddcm_")) {
                continue;
            }
            if (tableName.startsWith("x_")) {
                continue;
            }
            if (tableName.startsWith("wlm_")) {
                continue;
            }
            if (tableName.startsWith("olap_")) {
                continue;
            }
            if (tableName.startsWith("ggs_")) {
                continue;
            }
            if (tableName.startsWith("jpage_")) {
                continue;
            }
            if (tableName.startsWith("ex_")) {
                continue;
            }
            if (tableName.startsWith("logmnrc_")) {
                continue;
            }
            if (tableName.startsWith("logmnrg_")) {
                continue;
            }
            if (tableName.startsWith("olap_")) {
                continue;
            }
            if (tableName.startsWith("sto_")) {
                continue;
            }
            if (tableName.startsWith("sdo_")) {
                continue;
            }
            if (tableName.startsWith("sys_iot_")) {
                continue;
            }
            if (tableName.indexOf("$") != -1) {
                continue;
            }
            if (tableName.indexOf("+") != -1) {
                continue;
            }
            if (tableName.indexOf("-") != -1) {
                continue;
            }
            if (tableName.indexOf("?") != -1) {
                continue;
            }
            if (tableName.indexOf("=") != -1) {
                continue;
            }
            if (tableMap.get(tableName) == null) {
                try {
                    List<ColumnDefinition> columns = DBUtils.getColumnDefinitions(tbl);
                    tableDefinitionService.saveSystemTable(tableName, columns);
                    logger.debug(tableName + " save ok");
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {
                TableDefinition table = tableMap.get(tableName);
                boolean success = false;
                int retry = 0;
                while (retry < 2 && !success) {
                    try {
                        retry++;
                        List<ColumnDefinition> columns = DBUtils.getColumnDefinitions(tbl);
                        if (table.getColumnQty() != columns.size()) {
                            tableDefinitionService.saveSystemTable(tableName, columns);
                            logger.debug(tableName + " save ok");
                        } else {
                            logger.debug(tableName + " check ok");
                        }
                        success = true;
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        }
        tables.clear();
    }

    list = null;
    tables = null;
}

From source file:hydrograph.ui.propertywindow.widgets.customwidgets.schema.GridRowLoader.java

/**
 * The method import schema rows from schema file into schema grid.
 * /*from   w  w w.j av  a 2s .  c om*/
 */
public List<GridRow> importGridRowsFromXML(ListenerHelper helper, Table table) {

    List<GridRow> schemaGridRowListToImport = null;

    ELTGridDetails gridDetails = (ELTGridDetails) helper.get(HelperType.SCHEMA_GRID);
    List<GridRow> grids = gridDetails.getGrids();
    grids.clear();
    try (InputStream xml = new FileInputStream(schemaFile);
            InputStream xsd = new FileInputStream(SCHEMA_CONFIG_XSD_PATH);) {
        if (StringUtils.isNotBlank(schemaFile.getPath())) {

            if (!schemaFile.getName().contains(".")) {
                logger.error(Messages.IMPORT_XML_IMPROPER_EXTENSION);
                throw new Exception(Messages.IMPORT_XML_IMPROPER_EXTENSION);
            }

            if (!(schemaFile.getPath().endsWith(".schema")) && !(schemaFile.getPath().endsWith(".xml"))) {
                logger.error(Messages.IMPORT_XML_INCORRECT_FILE);
                throw new Exception(Messages.IMPORT_XML_INCORRECT_FILE);
            }

            if (validateXML(xml, xsd)) {

                DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
                builderFactory.setExpandEntityReferences(false);
                builderFactory.setNamespaceAware(true);
                builderFactory.setFeature(Constants.DISALLOW_DOCTYPE_DECLARATION, true);

                DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder();
                Document document = documentBuilder.parse(schemaFile);

                JAXBContext jaxbContext = JAXBContext.newInstance(Schema.class);
                Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();

                Schema schema = (Schema) jaxbUnmarshaller.unmarshal(document);
                fields = schema.getFields();
                List<Field> fieldsList = fields.getField();
                GridRow gridRow = null;
                schemaGridRowListToImport = new ArrayList<GridRow>();

                if (Messages.GENERIC_GRID_ROW.equals(gridRowType)) {
                    for (Field field : fieldsList) {
                        addRowToList(gridDetails, grids, getBasicSchemaGridRow(field),
                                schemaGridRowListToImport);
                    }
                } else if (Messages.FIXEDWIDTH_GRID_ROW.equals(gridRowType)) {

                    for (Field field : fieldsList) {
                        addRowToList(gridDetails, grids, getFixedWidthGridRow(field),
                                schemaGridRowListToImport);
                    }
                } else if (Messages.GENERATE_RECORD_GRID_ROW.equals(gridRowType)) {
                    for (Field field : fieldsList) {
                        addRowToList(gridDetails, grids, getGenerateRecordGridRow(field),
                                schemaGridRowListToImport);
                    }
                } else if (Messages.XPATH_GRID_ROW.equals(gridRowType)) {
                    for (Field field : fieldsList) {
                        Text loopXPathData = null;
                        if (table.getData() != null
                                && Text.class.isAssignableFrom(table.getData().getClass())) {
                            loopXPathData = (Text) table.getData();
                        }
                        XPathGridRow xPathGridRow = new XPathGridRow();
                        populateCommonFields(xPathGridRow, field);
                        xPathGridRow.setXPath(field.getAbsoluteOrRelativeXpath());
                        if (loopXPathData != null && StringUtils.isNotBlank(loopXPathData.getText())) {
                            xPathGridRow.setAbsolutexPath(
                                    loopXPathData.getText() + Path.SEPARATOR + xPathGridRow.getXPath());
                        } else {
                            xPathGridRow.setAbsolutexPath(xPathGridRow.getXPath());
                        }
                        addRowToList(gridDetails, grids, xPathGridRow, schemaGridRowListToImport);
                    }
                } else if (Messages.MIXEDSCHEME_GRID_ROW.equals(gridRowType)) {
                    for (Field field : fieldsList) {
                        addRowToList(gridDetails, grids, getMixedSchemeGridRow(field),
                                schemaGridRowListToImport);
                    }
                }
            }
        } else {
            logger.error(Messages.EXPORT_XML_EMPTY_FILENAME);
            throw new Exception(Messages.EXPORT_XML_EMPTY_FILENAME);
        }
    } catch (JAXBException e1) {
        grids.clear();
        showMessageBox(Messages.IMPORT_XML_FORMAT_ERROR + " -\n" + e1.getMessage(), "Error", SWT.ERROR);
        logger.error(Messages.IMPORT_XML_FORMAT_ERROR);
        return null;
    } catch (DuplicateFieldException e1) {
        grids.clear();
        showMessageBox(e1.getMessage(), "Error", SWT.ERROR);
        logger.error(e1.getMessage());
        return null;
    } catch (Exception e) {
        grids.clear();
        showMessageBox(Messages.IMPORT_XML_ERROR + " -\n" + e.getMessage(), "Error", SWT.ERROR);
        logger.error(Messages.IMPORT_XML_ERROR);
        return null;
    }

    return schemaGridRowListToImport;
}

From source file:com.pureinfo.srm.reports.table.MyTabeleDataHelper.java

public static Map getRowMap(Class _contentClass, SQLCondition _condition, String _sGroupProp,
        String[] _caredValues) throws PureException {
    IContentMgr mgr = ArkContentHelper.getContentMgrOf(_contentClass);
    List params = new ArrayList();
    IObjects datas = null;/*  w  ww  .j  a va2s. c o  m*/
    IStatement query = null;
    Map row = null;
    try {
        String sCondion = "";
        if (_condition != null)
            sCondion = _condition.toSQL(params);
        String strSQL = "SELECT COUNT(*) AS _COUNT, {this." + _sGroupProp + "} FROM {this}"
                + (sCondion == null || sCondion.trim().length() < 1 ? "" : " WHERE ") + sCondion
                + " GROUP BY {this." + _sGroupProp + '}';
        query = mgr.createQuery(strSQL, 0);
        if (!params.isEmpty()) {
            query.setParameters(0, params);
        }
        datas = query.executeQuery();
        row = new HashMap(datas.getSize());
        do {
            DolphinObject data = datas.next();
            if (data == null) {
                break;
            }
            row.put(data.getProperty(_sGroupProp), data.getProperty("_COUNT"));
        } while (true);
    } finally {
        params.clear();
        DolphinHelper.clear(datas, query);
    }
    if (_caredValues != null) {
        int caredTotal = 0;
        int total = 0;
        for (Iterator iter = row.entrySet().iterator(); iter.hasNext();) {
            Map.Entry entry = (Map.Entry) iter.next();
            String sName = (String) entry.getKey();
            Number num = (Number) entry.getValue();
            if (ArrayUtils.contains(_caredValues, sName)) {
                caredTotal += num.intValue();
            }
            total += num.intValue();
        }
        row.put(OTHER, new Integer(total - caredTotal));
        row.put(TOTAL, new Integer(total));
    }
    return row;
}

From source file:es.pode.empaquetador.presentacion.avanzado.organizaciones.elementos.gestor.GestorElementosControllerImpl.java

public final void vaciarPortapapeles(ActionMapping mapping, VaciarPortapapelesForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    EmpaquetadorSession sesEmpa = this.getEmpaquetadorSession(request);

    List portapapeles = sesEmpa.getPortapapeles();
    if (portapapeles != null && portapapeles.size() > 0) {
        portapapeles.clear();
        sesEmpa.setPortapapeles(portapapeles);
        sesEmpa.setAccion(NORMAL);/*ww  w  . j  a v  a2s  .c o m*/
        sesEmpa.setModoPegar(false);
    } else {
        throw new ValidatorException(PORTAL_EMPAQUETADO_EXCEPTION_SESSION);
    }

}

From source file:edu.uci.ics.asterix.optimizer.rules.PushAggregateIntoGroupbyRule.java

private boolean pushSubplanAsAggIntoGby(Mutable<ILogicalOperator> subplanOpRef, GroupByOperator gbyOp,
        LogicalVariable varFromGroupAgg, Map<LogicalVariable, Integer> gbyAggVars,
        Map<LogicalVariable, GroupByOperator> gbyWithAgg, Map<LogicalVariable, Integer> gbyAggVarToPlanIndex,
        IOptimizationContext context) throws AlgebricksException {
    SubplanOperator subplan = (SubplanOperator) subplanOpRef.getValue();
    // only free var can be varFromGroupAgg
    HashSet<LogicalVariable> freeVars = new HashSet<LogicalVariable>();
    OperatorPropertiesUtil.getFreeVariablesInSubplans(subplan, freeVars);
    for (LogicalVariable vFree : freeVars) {
        if (!vFree.equals(varFromGroupAgg)) {
            return false;
        }/*from   w  w w. j a v a 2 s .c o  m*/
    }

    List<ILogicalPlan> plans = subplan.getNestedPlans();
    if (plans.size() > 1) {
        return false;
    }
    ILogicalPlan p = plans.get(0);
    if (p.getRoots().size() > 1) {
        return false;
    }
    Mutable<ILogicalOperator> opRef = p.getRoots().get(0);
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    if (op.getOperatorTag() != LogicalOperatorTag.AGGREGATE) {
        return false;
    }
    AggregateOperator aggInSubplanOp = (AggregateOperator) op;
    LogicalVariable unnestVar = null;
    boolean pushableNestedSubplan = false;
    while (op.getInputs().size() == 1) {
        opRef = op.getInputs().get(0);
        op = (AbstractLogicalOperator) opRef.getValue();
        switch (op.getOperatorTag()) {
        case ASSIGN: {
            break;
        }
        case UNNEST: {
            UnnestOperator unnest = (UnnestOperator) op;
            if (unnest.getPositionalVariable() != null) {
                // TODO currently subplan with both accumulating and running aggregate is not supported.
                return false;
            }
            ILogicalExpression expr = unnest.getExpressionRef().getValue();
            if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
                return false;
            }
            AbstractFunctionCallExpression fun = (AbstractFunctionCallExpression) expr;
            if (fun.getFunctionIdentifier() != AsterixBuiltinFunctions.SCAN_COLLECTION) {
                return false;
            }
            ILogicalExpression arg0 = fun.getArguments().get(0).getValue();
            if (arg0.getExpressionTag() != LogicalExpressionTag.VARIABLE) {
                return false;
            }
            VariableReferenceExpression varExpr = (VariableReferenceExpression) arg0;
            if (!varExpr.getVariableReference().equals(varFromGroupAgg)) {
                return false;
            }
            opRef = op.getInputs().get(0);
            op = (AbstractLogicalOperator) opRef.getValue();
            if (op.getOperatorTag() != LogicalOperatorTag.NESTEDTUPLESOURCE) {
                return false;
            }
            pushableNestedSubplan = true;
            unnestVar = unnest.getVariable();
            break;
        }
        default: {
            return false;
        }
        }
    }
    if (pushableNestedSubplan) {
        for (int i = 0; i < gbyOp.getNestedPlans().size(); i++) {
            Mutable<ILogicalOperator> gbyAggRef = gbyOp.getNestedPlans().get(i).getRoots().get(0);
            AggregateOperator gbyAgg = (AggregateOperator) gbyAggRef.getValue();
            Mutable<ILogicalOperator> gbyAggChildRef = gbyAgg.getInputs().get(0);
            OperatorManipulationUtil.substituteVarRec(aggInSubplanOp, unnestVar,
                    findListifiedVariable(gbyAgg, varFromGroupAgg), true, context);
            gbyAgg.getVariables().addAll(aggInSubplanOp.getVariables());
            gbyAgg.getExpressions().addAll(aggInSubplanOp.getExpressions());
            for (LogicalVariable v : aggInSubplanOp.getVariables()) {
                gbyWithAgg.put(v, gbyOp);
                gbyAggVars.put(v, 0);
                gbyAggVarToPlanIndex.put(v, i);
            }

            Mutable<ILogicalOperator> opRef1InSubplan = aggInSubplanOp.getInputs().get(0);
            if (opRef1InSubplan.getValue().getInputs().size() > 0) {
                Mutable<ILogicalOperator> opRef2InSubplan = opRef1InSubplan.getValue().getInputs().get(0);
                AbstractLogicalOperator op2InSubplan = (AbstractLogicalOperator) opRef2InSubplan.getValue();
                if (op2InSubplan.getOperatorTag() != LogicalOperatorTag.NESTEDTUPLESOURCE) {
                    List<Mutable<ILogicalOperator>> gbyInpList = gbyAgg.getInputs();
                    gbyInpList.clear();
                    gbyInpList.add(opRef1InSubplan);
                    while (true) {
                        opRef2InSubplan = opRef1InSubplan.getValue().getInputs().get(0);
                        op2InSubplan = (AbstractLogicalOperator) opRef2InSubplan.getValue();
                        if (op2InSubplan.getOperatorTag() == LogicalOperatorTag.UNNEST) {
                            List<Mutable<ILogicalOperator>> opInpList = opRef1InSubplan.getValue().getInputs();
                            opInpList.clear();
                            opInpList.add(gbyAggChildRef);
                            break;
                        }
                        opRef1InSubplan = opRef2InSubplan;
                        if (opRef1InSubplan.getValue().getInputs().size() == 0) {
                            throw new IllegalStateException(
                                    "PushAggregateIntoGroupbyRule: could not find UNNEST.");
                        }
                    }
                }
            }
            subplanOpRef.setValue(subplan.getInputs().get(0).getValue());
            OperatorPropertiesUtil.typeOpRec(gbyAggRef, context);
        }
        return true;
    } else {
        return false;
    }
}

From source file:net.sf.ehcache.distribution.RMIBootstrapCacheLoader.java

/**
 * Bootstraps the cache from a random CachePeer. Requests are done in chunks estimated at 5MB Serializable
 * size. This balances memory use on each end and network performance.
 * <p/>/*from w ww  .  j av  a 2s .c om*/
 * Bootstrapping requires the establishment of a cluster. This can be instantaneous for manually configued
 * clusters or may take a number of seconds for multicast ones. This method waits up to 11 seconds for a cluster
 * to form.
 *
 * @throws RemoteCacheException
 *          if anything goes wrong with the remote call
 */
public void doLoad(Ehcache cache) throws RemoteCacheException {

    List cachePeers = acquireCachePeers(cache);
    if (cachePeers == null || cachePeers.size() == 0) {
        LOG.debug("Empty list of cache peers for cache " + cache.getName()
                + ". No cache peer to bootstrap from.");
        return;
    }
    Random random = new Random();
    int randomPeerNumber = random.nextInt(cachePeers.size());
    CachePeer cachePeer = (CachePeer) cachePeers.get(randomPeerNumber);
    LOG.debug("Bootstrapping " + cache.getName() + " from " + cachePeer);

    try {

        //Estimate element size
        Element sampleElement = null;
        List keys = cachePeer.getKeys();
        for (int i = 0; i < keys.size(); i++) {
            Serializable key = (Serializable) keys.get(i);
            sampleElement = cachePeer.getQuiet(key);
            if (sampleElement != null && sampleElement.getSerializedSize() != 0) {
                break;
            }
        }
        if (sampleElement == null) {
            LOG.debug("All cache peer elements were either null or empty. Nothing to bootstrap from. Cache was "
                    + cache.getName() + ". Cache peer was " + cachePeer);
            return;
        }
        long size = sampleElement.getSerializedSize();
        int chunkSize = (int) (maximumChunkSizeBytes / size);

        List requestChunk = new ArrayList();
        for (int i = 0; i < keys.size(); i++) {
            Serializable serializable = (Serializable) keys.get(i);
            requestChunk.add(serializable);
            if (requestChunk.size() == chunkSize) {
                fetchAndPutElements(cache, requestChunk, cachePeer);
                requestChunk.clear();
            }
        }
        //get leftovers
        fetchAndPutElements(cache, requestChunk, cachePeer);
        LOG.debug("Bootstrap of " + cache.getName() + " from " + cachePeer + " finished. " + keys.size()
                + " keys requested.");
    } catch (Throwable t) {
        throw new RemoteCacheException("Error bootstrapping from remote peer. Message was: " + t.getMessage(),
                t);
    }
}