Example usage for java.util Vector size

List of usage examples for java.util Vector size

Introduction

In this page you can find the example usage for java.util Vector size.

Prototype

public synchronized int size() 

Source Link

Document

Returns the number of components in this vector.

Usage

From source file:edu.umn.cs.spatialHadoop.operations.Indexer.java

/***
 * Create a partitioner for a particular job
 * @param in//from  w ww.j  av  a 2 s .  c om
 * @param out
 * @param job
 * @param partitionerName
 * @return
 * @throws IOException
 */
public static Partitioner createPartitioner(Path[] ins, Path out, Configuration job, String partitionerName)
        throws IOException {
    try {
        Partitioner partitioner = null;
        Class<? extends Partitioner> partitionerClass = PartitionerClasses.get(partitionerName.toLowerCase());
        if (partitionerClass == null) {
            throw new RuntimeException("Unknown index type '" + partitionerName + "'");
        }
        boolean replicate = PartitionerReplicate.get(partitionerName.toLowerCase());
        job.setBoolean("replicate", replicate);
        partitioner = partitionerClass.newInstance();

        long t1 = System.currentTimeMillis();
        final Rectangle inMBR = (Rectangle) OperationsParams.getShape(job, "mbr");
        // Determine number of partitions
        long inSize = 0;
        for (Path in : ins) {
            inSize += FileUtil.getPathSize(in.getFileSystem(job), in);
        }
        long estimatedOutSize = (long) (inSize * (1.0 + job.getFloat(SpatialSite.INDEXING_OVERHEAD, 0.1f)));
        FileSystem outFS = out.getFileSystem(job);
        long outBlockSize = outFS.getDefaultBlockSize(out);
        int numPartitions = Math.max(1, (int) Math.ceil((float) estimatedOutSize / outBlockSize));
        LOG.info("Partitioning the space into " + numPartitions + " partitions");

        final Vector<Point> sample = new Vector<Point>();
        float sample_ratio = job.getFloat(SpatialSite.SAMPLE_RATIO, 0.01f);
        long sample_size = job.getLong(SpatialSite.SAMPLE_SIZE, 100 * 1024 * 1024);

        LOG.info("Reading a sample of " + (int) Math.round(sample_ratio * 100) + "%");
        ResultCollector<Point> resultCollector = new ResultCollector<Point>() {
            @Override
            public void collect(Point p) {
                sample.add(p.clone());
            }
        };
        OperationsParams params2 = new OperationsParams(job);
        params2.setFloat("ratio", sample_ratio);
        params2.setLong("size", sample_size);
        params2.setClass("outshape", Point.class, Shape.class);
        Sampler.sample(ins, resultCollector, params2);
        long t2 = System.currentTimeMillis();
        System.out.println("Total time for sampling in millis: " + (t2 - t1));
        LOG.info("Finished reading a sample of " + sample.size() + " records");

        partitioner.createFromPoints(inMBR, sample.toArray(new Point[sample.size()]), numPartitions);

        return partitioner;
    } catch (InstantiationException e) {
        e.printStackTrace();
        return null;
    } catch (IllegalAccessException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:it.classhidra.core.controller.wsController.java

public boolean performStream_Exit(Vector _streams, String id_action, i_action action_instance,
        HashMap wsParameters) throws bsControllerException, Exception, Throwable {
    for (int i = _streams.size() - 1; i > -1; i--) {
        info_stream iStream = (info_stream) _streams.get(i);
        i_stream currentStream = bsController.getAction_config().streamFactory(iStream.getName());
        if (currentStream != null) {
            currentStream.onPreExit(wsParameters);
            redirects currentStreamRedirect = currentStream.streamservice_exit(wsParameters);
            currentStream.onPostExit(currentStreamRedirect, wsParameters);
            if (currentStreamRedirect != null) {
                throw new bsControllerException(
                        "BLOCKED from EXIT stream:" + currentStream.get_infostream().getName(),
                        iStub.log_ERROR);
            }/*from  w w w  . ja  va2 s. com*/
        }
    }
    return true;
}

From source file:eu.apenet.dpt.standalone.gui.dateconversion.DateConversionRulesDialog.java

private void createDataConversionRulesList() {
    Vector<String> columnNames = new Vector<String>();
    columnNames.add(labels.getString("dateConversion.valueRead"));
    columnNames.add(labels.getString("dateConversion.valueConverted"));
    dm = new DefaultTableModel(xmlFilehandler.loadDataFromFile(FILENAME), columnNames);
    dm.addRow(new Vector<String>());
    dm.addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent e) {
            if (ruleTable.getEditingRow() != ruleTable.getRowCount() - 1
                    && (StringUtils.isEmpty((String) dm.getValueAt(ruleTable.getEditingRow(), 0))
                            && StringUtils.isEmpty((String) dm.getValueAt(ruleTable.getEditingRow(), 1)))) {
                dm.removeRow(ruleTable.getEditingRow());
            }//from  w ww.j  a va 2  s  . co  m
            if (ruleTable.getEditingRow() == ruleTable.getRowCount() - 1) {
                if (StringUtils.isNotEmpty((String) dm.getValueAt(ruleTable.getEditingRow(), 0))
                        && StringUtils.isNotEmpty((String) dm.getValueAt(ruleTable.getEditingRow(), 1))) {
                    dm.addRow(new Vector<String>());
                }
            }
            if (ruleTable.getEditingColumn() == 1) {
                if (StringUtils.isNotEmpty((String) dm.getValueAt(ruleTable.getEditingRow(), 1))
                        && !isCorrectDateFormat((String) dm.getValueAt(ruleTable.getEditingRow(), 1))) {
                    createOptionPaneForIsoDate(ruleTable.getEditingRow(), 1);
                }
            }
        }
    });

    ruleTable = new JTable(dm);
    oldModel = new DefaultTableModel(xmlFilehandler.loadDataFromFile(FILENAME), columnNames);

    JButton saveButton = new JButton(labels.getString("saveBtn"));
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (ruleTable.isEditing()) {
                ruleTable.getCellEditor().stopCellEditing();
            }
            Vector<Vector<String>> data = ((DefaultTableModel) ruleTable.getModel()).getDataVector();
            for (int i = 0; i < data.size() - 1; i++) {
                Vector<String> vector = data.elementAt(i);
                if (vector.elementAt(1) != null && !isCorrectDateFormat((String) vector.elementAt(1))) {
                    createOptionPaneForIsoDate(i, 1);
                }
            }
            xmlFilehandler.saveDataToFile(data, FILENAME);
            saveMessage.setText(MessageFormat.format(labels.getString("dateConversion.saveMsg"),
                    new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime())));
        }
    });

    JButton closeButton = new JButton(labels.getString("quit"));
    closeButton.addActionListener(new ActionListener() {
        // boolean cancel = true;

        public void actionPerformed(ActionEvent e) {
            /*System.out.println(Boolean.toString(oldModel.getRowCount() == (ruleTable.getModel().getRowCount() - 1)) + "<<" + oldModel.getRowCount() + ", " + (ruleTable.getModel().getRowCount() - 1));
            if (oldModel.getRowCount() != ruleTable.getModel().getRowCount() - 1) {
            cancel = showUnsavedChangesDialog();
            } else {
            for (int i = 0; i < (ruleTable.getModel().getRowCount() - 1); i++) {
                for (int j = 0; j <= 1; j++) {
                    System.out.println(oldModel.getValueAt(i, j) == ruleTable.getModel().getValueAt(i, j) + " >> " + oldModel.getValueAt(i, j) + ", " + ruleTable.getModel().getValueAt(i, j));
                    if (oldModel.getValueAt(i, j) != ruleTable.getModel().getValueAt(i, j)) {
                        cancel = showUnsavedChangesDialog();
                    }
                }
            }
            }
            if (cancel) {*/
            dispose();
            //  }
        }
    });

    JButton downloadButton = new JButton(labels.getString("downloadBtn"));
    downloadButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (ruleTable.isEditing()) {
                ruleTable.getCellEditor().stopCellEditing();
            }
            Vector<Vector<String>> data = ((DefaultTableModel) ruleTable.getModel()).getDataVector();
            File currentLocation = new File(retrieveFromDb.retrieveOpenLocation());
            JFileChooser fileChooser = new JFileChooser(currentLocation);
            fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
            fileChooser.setFileFilter(new FileNameExtensionFilter("XML file", "xml"));
            int returnedVal = fileChooser.showSaveDialog(getParent());

            if (returnedVal == JFileChooser.APPROVE_OPTION) {
                String fileName = fileChooser.getSelectedFile().toString();
                if (!fileName.endsWith(".xml")) {
                    fileName = fileName + ".xml";
                }
                xmlFilehandler.saveDataToFile(data, fileName);
                //additionally save data to standard file
                xmlFilehandler.saveDataToFile(data, FILENAME);
                saveMessage.setText(MessageFormat.format(labels.getString("dateConversion.saveMsg"),
                        new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime())));
            }
        }
    });

    JPanel contentPanel = new JPanel(new BorderLayout());
    contentPanel.add(new JScrollPane(ruleTable));
    saveMessage = new JLabel();
    contentPanel.add(saveMessage, BorderLayout.SOUTH);

    JPanel buttonPanel = new JPanel(new GridLayout(1, 3));
    buttonPanel.add(saveButton);
    buttonPanel.add(closeButton);
    buttonPanel.add(downloadButton);

    JPanel pane = new JPanel(new BorderLayout());
    pane.add(contentPanel, BorderLayout.PAGE_START);
    pane.add(buttonPanel, BorderLayout.PAGE_END);
    add(pane);
}

From source file:dao.CarryonSearchQuery.java

/**
 * This method lists all the results for the search text from directories
 * @param conn the connection/*from   w w  w.  j  a  va2s . c  o m*/
 * @param collabrumId the collabrumid
 * @return HashSet the set that has the list of moderators for these collabrums.
 * @throws BaseDaoException - when error occurs
 **/
public HashSet run(Connection conn, String sString) throws BaseDaoException {

    if ((RegexStrUtil.isNull(sString) || conn == null)) {
        return null;
    }

    StringBuffer sb = new StringBuffer(
            "select hdlogin.login, ownerid, entryid, carryontag.title as btitle, usertags, category, photos from hdlogin left join displayuser on hdlogin.loginid=displayuser.loginid left join carryontag on hdlogin.loginid=ownerid where category=1 and photos=1 and (");
    ArrayList columns = new ArrayList();
    columns.add("usertags");
    columns.add("carryontag.title");
    sb.append(sqlSearch.getConstraint(columns, sString));
    sb.append(")");

    logger.info("search query string" + sb.toString());

    try {
        PreparedStatement stmt = conn.prepareStatement(sb.toString());
        ResultSet rs = stmt.executeQuery();

        Vector columnNames = null;
        Photo photo = null;
        HashSet pendingSet = new HashSet();

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
        }

        while (rs.next()) {
            photo = (Photo) eop.newObject(DbConstants.PHOTO);
            for (int j = 0; j < columnNames.size(); j++) {
                photo.setValue((String) columnNames.elementAt(j),
                        (String) rs.getString((String) columnNames.elementAt(j)));
            }
            pendingSet.add(photo);
        }
        return pendingSet;
    } catch (Exception e) {
        throw new BaseDaoException("Error executing CarryonSearchQuery " + sb.toString(), e);
    }
}

From source file:com.vsquaresystem.safedeals.rawmarketprice.RawMarketPriceService.java

public Boolean checkExistingData() throws IOException {

    Boolean a = true;/* w w w .java2 s  .com*/
    Result result = new Result();
    result.response = "true";
    Vector checkCellVectorHolder = read();

    int excelSize = checkCellVectorHolder.size() - 1;

    List<RawMarketPrice> rs = rawMarketPriceDAL.getAll();
    JFrame parent = new JFrame();

    int listSize = rs.size();

    if (excelSize == listSize || excelSize > listSize) {

    } else {
        System.out.println("No selected");

    }
    return true;
}

From source file:dao.CarryonSearchBizAwareQuery.java

/**
 * This method lists all the results for the search text from carryontag
 * @param conn the connection//from   w ww.  jav  a 2 s .co  m
 * @param sString - search string
 * @param bid - bid
 * @return HashSet - result
 * @throws BaseDaoException - when error occurs
 **/
public HashSet run(Connection conn, String sString, String bid) throws BaseDaoException {

    if (RegexStrUtil.isNull(sString) || conn == null || RegexStrUtil.isNull(bid)) {
        return null;
    }

    StringBuffer sb = new StringBuffer(
            "select hdlogin.login, ownerid, entryid, title, usertags, hdlogin.bid, business.bsearch from business, hdlogin left join carryontag on hdlogin.loginid=ownerid where business.bid=hdlogin.bid and (");
    ArrayList columns = new ArrayList();
    columns.add("usertags");
    columns.add("title");
    sb.append(sqlSearch.getConstraint(columns, sString));
    sb.append(")");

    logger.info("search query string = " + sb.toString());

    try {
        PreparedStatement stmt = conn.prepareStatement(sb.toString());
        ResultSet rs = stmt.executeQuery();

        Vector columnNames = null;
        Photo photo = null;
        HashSet pendingSet = new HashSet();

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
        }

        while (rs.next()) {
            photo = (Photo) eop.newObject(DbConstants.PHOTO);
            for (int j = 0; j < columnNames.size(); j++) {
                photo.setValue((String) columnNames.elementAt(j),
                        (String) rs.getString((String) columnNames.elementAt(j)));
            }
            pendingSet.add(photo);
        }
        return pendingSet;
    } catch (Exception e) {
        throw new BaseDaoException("Error executing CarryonSearchBizAwareQuery " + sb.toString(), e);
    }
}

From source file:it.classhidra.core.controller.wsController.java

public boolean performStream_Enter(Vector _streams, String id_action, i_action action_instance,
        HashMap wsParameters) throws bsControllerException, Exception, Throwable {
    for (int i = 0; i < _streams.size(); i++) {
        info_stream iStream = (info_stream) _streams.get(i);
        i_stream currentStream = bsController.getAction_config().streamFactory(iStream.getName());
        if (currentStream != null) {
            currentStream.onPreEnter(wsParameters);
            redirects currentStreamRedirect = currentStream.streamservice_enter(wsParameters);
            currentStream.onPostEnter(currentStreamRedirect, wsParameters);
            if (currentStreamRedirect != null) {
                throw new bsControllerException(
                        "BLOCKED from ENTER stream:" + currentStream.get_infostream().getName(),
                        iStub.log_ERROR);
            }/*from w  w  w .  ja va  2  s . co  m*/
        }
    }
    return true;
}

From source file:edu.ku.brc.specify.datamodel.Appraisal.java

@Override
@Transient/*  w  w w  . j ava2  s  .c  om*/
public Integer getParentId() {
    if (accession != null) {
        parentTblId = Accession.getClassTableId();
        return accession.getId();
    }

    Vector<Object> ids = BasicSQLUtils.querySingleCol(
            "SELECT CollectionObjectID FROM collectionobject WHERE AppraisalID = " + appraisalId);
    if (ids.size() == 1) {
        parentTblId = CollectionObject.getClassTableId();
        return (Integer) ids.get(0);
    }
    parentTblId = null;
    return null;
}

From source file:dao.CollBlobSearchQuery.java

/**
 * This method lists all the results for the search text from directories
 * @param conn the connection// ww  w . j  a  va 2  s .  c o  m
 * @param collabrumId the collabrumid
 * @return HashSet the set that has the list of moderators for these collabrums.
 * @throws BaseDaoException - when error occurs
 **/
public HashSet run(Connection conn, String sString) throws BaseDaoException {

    if ((RegexStrUtil.isNull(sString) || conn == null)) {
        return null;
    }

    StringBuffer sb = new StringBuffer(
            "select blobtype, entrydate, collblob.collabrumid, collblob.entryid, btitle from collblob left join collblobtags on collblob.entryid=collblobtags.entryid where ");
    ArrayList columns = new ArrayList();
    columns.add("usertags");
    sb.append(sqlSearch.getConstraint(columns, sString));
    try {
        PreparedStatement stmt = conn.prepareStatement(sb.toString());
        ResultSet rs = stmt.executeQuery();
        Vector columnNames = null;
        Photo photo = null;
        HashSet pendingSet = new HashSet();

        if (rs != null) {
            columnNames = dbutils.getColumnNames(rs);
        }

        while (rs.next()) {
            photo = (Photo) eop.newObject(DbConstants.PHOTO);
            for (int j = 0; j < columnNames.size(); j++) {
                if (((String) (columnNames.elementAt(j))).equalsIgnoreCase(DbConstants.ENTRY_DATE)) {
                    try {
                        photo.setValue(DbConstants.ENTRY_DATE,
                                GlobalConst.dncalendar.getDisplayDate(rs.getTimestamp(DbConstants.ENTRY_DATE)));
                    } catch (ParseException e) {
                        throw new BaseDaoException("could not parse the date for entrydate in collabrum"
                                + rs.getTimestamp(DbConstants.ENTRY_DATE), e);
                    }
                } else {
                    photo.setValue((String) columnNames.elementAt(j),
                            (String) rs.getString((String) columnNames.elementAt(j)));
                }
            }
            pendingSet.add(photo);
        }
        return pendingSet;
    } catch (Exception e) {
        throw new BaseDaoException("Error occured while executing collblobsearch run query " + sb.toString(),
                e);
    }
}

From source file:de.nrw.hbz.regal.sync.Syncer.java

void pidl(String pidFile) {
    Vector<String> pids;

    pids = readPidlist(pidFile);//from www  .j  a v a 2 s.  co m
    int size = pids.size();
    for (int i = 0; i < size; i++) {
        try {
            logger.info((i + 1) + " / " + size);
            String pid = pids.get(i);

            String baseDir = downloader.download(pid, false);

            if (!downloader.hasUpdated()) {

                DigitalEntity dtlBean = builder.build(baseDir, pids.get(i));

                ingester.ingest(dtlBean);
                dtlBean = null;
                logger.info((i + 1) + "/" + size + " " + pid + " has been processed!\n");
            } else if (downloader.hasUpdated()) {

                DigitalEntity dtlBean = builder.build(baseDir, pids.get(i));
                ingester.ingest(dtlBean);
                dtlBean = null;
                logger.info((i + 1) + "/" + size + " " + pid + " has been updated!\n");
            }

        } catch (Exception e) {
            logger.error(e.toString(), e);
        }
    }

}