private void initializeData() {
   for (int i = 0; i < batchState.getFields().size(); ++i) {
     for (int j = 0; j < batchState.getProject().getRecordsPerBatch(); ++j) {
       indexedData[i][j] = "";
     }
   }
 }
  private void builder() {

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;

    ArrayList<Field> fields = batchState.getFields();

    for (int i = 0; i < batchState.getFields().size(); ++i) {
      TextBox temp = new TextBox(i + 1);
      textBoxes.add(temp);

      gbc.gridy++;
      textBoxes.get(i).fieldTitle.setText(fields.get(i).getTitle() + " :");
      //			addListener(textBoxes.get(i));
      formText.add(textBoxes.get(i), gbc);

      gbc.gridy++;
      formText.add(new JPanel(), gbc);
    }
    for (int i = 0; i < batchState.getProject().getRecordsPerBatch(); ++i) {
      dlm.addElement(i + 1);
    }
    indexedData = new String[fields.size()][batchState.getProject().getRecordsPerBatch()];
    initializeData();
  }
 @Override
 public void setCell() {
   Cell cell = batchState.getCurrentCell();
   recordList.setSelectedIndex(cell.getRecordNum());
   textBoxes.get(cell.getFieldNum() - 1).text.requestFocus();
   for (int i = 0; i < batchState.getFields().size(); ++i) {
     String temp = indexedData[i][cell.getRecordNum()];
     textBoxes.get(i).text.setText(temp);
     boolean[][] check = batchState.getMisspelled();
     if (check[i][cell.getRecordNum()]) {
       textBoxes.get(i).text.setBackground(Color.RED);
     } else {
       textBoxes.get(i).text.setBackground(Color.WHITE);
     }
   }
 }
Пример #4
0
  public void addPicture(String url, int rh, int firsty, List<field> fields, int column, int row) {
    //		int firstx = fields.get(0).getXcoord();
    //		int xwidth = fields.get(0).getWidth();
    //
    //
    //		comp = new ImageComponent(url, rh, firsty, firstx, xwidth);
    //		add(comp, BorderLayout.CENTER);
    //		//add(slider, BorderLayout.SOUTH);
    //		revalidate();

    int x = fields.get(column - 1).getXcoord();
    int xwidth = fields.get(column - 1).getWidth();

    int y = firsty + (rh * row);

    comp = new ImageComponent(url, rh, y, x, xwidth, bs);

    if (!bs.highlight) {
      comp.updateHighlight(x, y, 0, 0);
    }

    comp.setScale(bs.getScale());
    add(comp);
    revalidate();
  }
Пример #5
0
  public void Zoom(boolean way) {
    if (way) {
      comp.setScale(comp.getScale() * 1.25);
    } else {
      comp.setScale(comp.getScale() * 0.75);
    }

    bs.setScale(comp.getScale());
  }
Пример #6
0
 public Object[][] getTableData(JTable table) {
   DefaultTableModel dtm = (DefaultTableModel) table.getModel();
   int nRow = dtm.getRowCount(), nCol = dtm.getColumnCount();
   Object[][] tableData = new Object[nRow][nCol];
   for (int i = 0; i < nRow; i++)
     for (int j = 0; j < nCol; j++) {
       if (dtm.getValueAt(i, j) == null) tableData[i][j] = " ";
       else tableData[i][j] = dtm.getValueAt(i, j);
     }
   batchState.setData(tableData);
   return tableData;
 }
Пример #7
0
  public void InvertPicture(
      String url, int rh, int firsty, List<field> fields, int column, int row, RescaleOp op) {
    int x = fields.get(column - 1).getXcoord();
    int xwidth = fields.get(column - 1).getWidth();

    int y = firsty + (rh * row);

    this.remove(comp);
    // System.out.print("inverting...");
    comp = new ImageComponent(url, rh, y, x, xwidth, bs, op);
    comp.setScale(bs.getScale());
    add(comp);
    revalidate();
  }
Пример #8
0
  @Override
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() == invertImage) {

      image = invertImage(image);
      midwin.updateImage(image);
    }

    if (e.getSource() == zoomOut) midwin.zoomOut();
    if (e.getSource() == zoomIn) midwin.zoomIn();

    if (e.getSource() == toggleHighlights) batchState.toggleHighlights();

    if (e.getSource() == submit) {
      if (!batchState.hasCurrentBatch()) {
        displayError();
      } else {
        JTable table = batchState.getTable();
        Object[][] data = getTableData(table);
        model.Image image = batchState.getImage();
        String recordValues = transferData(data);
        SubmitBatch_Params params =
            new SubmitBatch_Params(batchState.getUser(), batchState.getImage(), recordValues);
        ClientCommunicator c = new ClientCommunicator();
        try {
          SubmitBatch_Result result = c.SubmitBatch(params);
          if (result.isSuccess()) {
            batchState.clearDrawingComponent();
            batchState.enableDownload();
            batchState.clearBottom();
          }
        } catch (ClientException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
      }
    }
  }
Пример #9
0
  public TableEntry(BatchState bState) {
    bState.addListener(this);

    this.bState = bState;
  }
Пример #10
0
  /*
   * Execute a batch of homogeneous queries, i.e. all reads or all writes.
   */
  VoltTable[] executeSlowHomogeneousBatch(final List<QueuedSQL> batch, final boolean finalTask) {

    BatchState state =
        new BatchState(batch.size(), m_txnState, m_site.getCorrespondingSiteId(), finalTask);

    // iterate over all sql in the batch, filling out the above data structures
    for (int i = 0; i < batch.size(); ++i) {
      QueuedSQL queuedSQL = batch.get(i);

      assert (queuedSQL.stmt != null);

      // Figure out what is needed to resume the proc
      int collectorOutputDepId = m_txnState.getNextDependencyId();
      state.m_depsToResume[i] = collectorOutputDepId;

      // Build the set of params for the frags
      FastSerializer fs = new FastSerializer();
      try {
        fs.writeObject(queuedSQL.params);
      } catch (IOException e) {
        throw new RuntimeException(
            "Error serializing parameters for SQL statement: "
                + queuedSQL.stmt.getText()
                + " with params: "
                + queuedSQL.params.toJSONString(),
            e);
      }
      ByteBuffer params = fs.getBuffer();
      assert (params != null);

      // populate the actual lists of fragments and params
      if (queuedSQL.stmt.catStmt != null) {
        // Pre-planned query.

        int numFrags = queuedSQL.stmt.catStmt.getFragments().size();
        assert (numFrags > 0);
        assert (numFrags <= 2);

        /*
         * This numfrags == 1 code is for routing multi-partition reads of a
         * replicated table to the local site. This was a broken performance
         * optimization. see https://issues.voltdb.com/browse/ENG-1232.
         *
         * The problem is that the fragments for the replicated read are not correctly
         * interleaved with the distributed writes to the replicated table that might
         * be in the same batch of SQL statements. We do end up doing the replicated
         * read locally but we break up the batches in the face of mixed reads and
         * writes
         */
        Iterator<PlanFragment> fragmentIter = queuedSQL.stmt.catStmt.getFragments().iterator();
        if (numFrags == 1) {
          PlanFragment frag = fragmentIter.next();
          state.addFragment(i, frag, params);
        } else {
          // collector/aggregator pair (guaranteed above that numFrags==2 here)
          PlanFragment frag1 = fragmentIter.next();
          assert (frag1 != null);
          PlanFragment frag2 = fragmentIter.next();
          assert (frag2 != null);
          // frags with no deps are usually collector frags that go to all partitions
          // figure out which frag is which type
          if (frag1.getHasdependencies() == false) {
            state.addFragmentPair(i, frag1, frag2, params);
          } else {
            state.addFragmentPair(i, frag2, frag1, params);
          }
        }
      } else {
        /*
         * Unplanned custom query. Requires an attached plan.
         * Set up collector and dependent aggregator fragments.
         */
        SQLStmtPlan plan = queuedSQL.stmt.getPlan();
        assert (plan != null);
        byte[] collectorFragment = plan.getCollectorFragment();
        byte[] aggregatorFragment = plan.getAggregatorFragment();
        assert (aggregatorFragment != null);

        if (collectorFragment == null) {
          // Multi-partition/non-replicated with collector and aggregator.
          state.addCustomFragment(i, aggregatorFragment, params);
        } else {
          // Multi-partition/replicated with just an aggregator fragment.
          state.addCustomFragmentPair(i, collectorFragment, aggregatorFragment, params);
        }
      }
    }

    // instruct the dtxn what's needed to resume the proc
    m_txnState.setupProcedureResume(finalTask, state.m_depsToResume);

    // create all the local work for the transaction
    for (int i = 0; i < state.m_depsForLocalTask.length; i++) {
      if (state.m_depsForLocalTask[i] < 0) continue;
      state.m_localTask.addInputDepId(i, state.m_depsForLocalTask[i]);
    }

    // note: non-transactional work only helps us if it's final work
    m_txnState.createLocalFragmentWork(
        state.m_localTask, state.m_localFragsAreNonTransactional && finalTask);

    if (!state.m_distributedTask.isEmpty()) {
      m_txnState.createAllParticipatingFragmentWork(state.m_distributedTask);
    }

    // recursively call recursableRun and don't allow it to shutdown
    Map<Integer, List<VoltTable>> mapResults = m_site.recursableRun(m_txnState);

    assert (mapResults != null);
    assert (state.m_depsToResume != null);
    assert (state.m_depsToResume.length == batch.size());

    // build an array of answers, assuming one result per expected id
    for (int i = 0; i < batch.size(); i++) {
      List<VoltTable> matchingTablesForId = mapResults.get(state.m_depsToResume[i]);
      assert (matchingTablesForId != null);
      assert (matchingTablesForId.size() == 1);
      state.m_results[i] = matchingTablesForId.get(0);

      // get isReplicated flag from either the catalog statement or the plan,
      // depending on whether it's pre-planned or unplanned
      final SQLStmt stmt = batch.get(i).stmt;
      boolean isReplicated;
      if (stmt.catStmt != null) {
        isReplicated = stmt.catStmt.getReplicatedtabledml();
      } else {
        final SQLStmtPlan plan = stmt.getPlan();
        assert (plan != null);
        isReplicated = plan.isReplicatedTableDML();
      }

      // if replicated divide by the replication factor
      if (isReplicated) {
        long newVal = state.m_results[i].asScalarLong() / m_site.getReplicatedDMLDivisor();
        state.m_results[i] =
            new VoltTable(new VoltTable.ColumnInfo("modified_tuples", VoltType.BIGINT));
        state.m_results[i].addRow(newVal);
      }
    }

    return state.m_results;
  }
 /**
  * The state of the Spot fleet request.
  *
  * @param spotFleetRequestState The state of the Spot fleet request.
  * @see BatchState
  */
 public void setSpotFleetRequestState(BatchState spotFleetRequestState) {
   this.spotFleetRequestState = spotFleetRequestState.toString();
 }