Package prefuse.data

Examples of prefuse.data.Table$ColumnEntry


  }
 
  protected void addLegend() {
    SwimlanesStatePalette ssp = new SwimlanesStatePalette();
   
    Table shapes_table = new Table();
    shapes_table.addColumn(VisualItem.X,float.class);
    shapes_table.addColumn(VisualItem.Y,float.class);
   
    Table legend_labels_table = new Table();
    Table legend_squares_table = new Table();
    legend_labels_table.addColumn("label",String.class);
   
    // add labels
    int num_states = ssp.getNumStates();
    String [] state_names = ssp.getStates();
View Full Code Here


    // setup visualization
    this.viz = new Visualization();
    this.setupRenderer();
   
    // add table to visualization
    Table raw_data_tab = this.setupDataTable();
    MapReduceSwimlanes mrs = new MapReduceSwimlanes();
    mrs.populateTable_CollateReduces(raw_data_tab);
    mrs.groupByState();
    VisualTable maindatatable = mrs.addToVisualization(this.viz, maingroup);
       
View Full Code Here

      query = query + " and job_id like '"+ this.jobname +"'";
    }
    Macro mp = new Macro(start,end,query);
    query = mp.toString() + " order by start_time";
   
    Table rs_tab = null;   
    DatabaseDataSource dds;
    DefaultSQLDataHandler dh = new DefaultSQLDataHandler();

    log.debug("Query: " + query);
    // execute query
    try {
      dds = ConnectionFactory.getDatabaseConnection(dbw.getConnection());
      rs_tab = dds.getData(query);
    } catch (prefuse.data.io.DataIOException e) {
      System.err.println("prefuse data IO error: " + e);
      log.warn("prefuse data IO error: " + e);
      return null;
    } catch (SQLException e) {
      System.err.println("Error in SQL: " + e + " in statement: " + query);
      log.warn("Error in SQL: " + e + " in statement: " + query);
      return null;
    }
   
    HashMap<String, Integer> state_counts = new HashMap<String, Integer>();
    HashSet<String> states = new HashSet<String>();
    for (int i = 0; i < rs_tab.getRowCount(); i++) {
      String curr_state = rs_tab.getString(i, "state_name");
      states.add(curr_state);
      Integer cnt = state_counts.get(curr_state);
      if (cnt == null) {
        state_counts.put(curr_state, new Integer(1));
      } else {
        state_counts.remove(curr_state);
        state_counts.put(curr_state, new Integer(cnt.intValue()+1));
      }
    }
   
    log.info("Search complete: #cols: " + rs_tab.getColumnCount() + "; #rows: " + rs_tab.getRowCount());
   
    return rs_tab;
  }
View Full Code Here

     * @param field the column / data field name
     * @return the Tuple with the minimum data field value
     */
    public static Tuple min(TupleSet tuples, String field, Comparator cmp) {
        if ( tuples instanceof Table ) {
            Table table = (Table)tuples;
            ColumnMetadata md = table.getMetadata(field);
            return table.getTuple(md.getMinimumRow());
        } else {
            return min(tuples.tuples(), field, cmp);
        }
    }
View Full Code Here

     * @param field the column / data field name
     * @return the Tuple with the maximum data field value
     */
    public static Tuple max(TupleSet tuples, String field, Comparator cmp) {
        if ( tuples instanceof Table ) {
            Table table = (Table)tuples;
            ColumnMetadata md = table.getMetadata(field);
            return table.getTuple(md.getMaximumRow());
        } else {
            return max(tuples.tuples(), field, cmp);
        }
    }
View Full Code Here

     * @param field the column / data field name
     * @return the Tuple with the median data field value
     */
    public static Tuple median(TupleSet tuples, String field, Comparator cmp) {
        if ( tuples instanceof Table ) {
            Table table = (Table)tuples;
            ColumnMetadata md = table.getMetadata(field);
            return table.getTuple(md.getMedianRow());
        } else {
            return median(tuples.tuples(), field, cmp);
        }
    }
View Full Code Here

        byte[] data = CSV_DATA.getBytes();
        InputStream is = new ByteArrayInputStream(data);
       
        // parse data
        CSVTableReader ctr = new CSVTableReader();
        Table t = null;
        try {
            t = ctr.readTable(is);
        } catch ( DataIOException e ) {
            e.printStackTrace();
            fail("Data Read Exception");
        }
       
        boolean verbose = TestConfig.verbose();
       
        // text-dump
        if (verbose) System.out.println("-- Data Types -------------");
        for (int c = 0, idx = -1; c < t.getColumnCount(); ++c) {
            String name = t.getColumnType(c).getName();
            if ( (idx=name.lastIndexOf('.')) >= 0 )
                name = name.substring(idx+1);
            assertEquals(t.getColumnType(c), TYPES[c]);
            if (verbose) System.out.print(name + "\t");
        }
        if (verbose) System.out.println();
       
        if (verbose) System.out.println();
       
        if (verbose) System.out.println("-- Table Data -------------");
        for (int c = 0; c < t.getColumnCount(); ++c) {
            if (verbose) System.out.print(t.getColumnName(c) + "\t");
            assertEquals(t.getColumnName(c), HEADERS[c]);
        }
        if (verbose) System.out.println();
        for (int r = 0; r < t.getRowCount(); ++r) {
            for (int c = 0; c < t.getColumnCount(); ++c) {
                Object o = t.get(r, c);
                if (verbose) System.out.print(o + "\t");
                assertEquals(TABLE[c][r], o);
            }
            if (verbose) System.out.println();
        }
View Full Code Here

       
        //String query    = "SELECT gender, age, COUNT(*) FROM profiles GROUP BY gender,age";
       
        s_logger.info(TestConfig.memUse());
       
        Table t = null;
        try {
            DatabaseDataSource db = ConnectionFactory.getMySQLConnection(
                    host, database, user, password);
           
            s_logger.info(TestConfig.memUse());
           
            t = db.getData(t, query1, keyField);
            db.loadData(t, query2, keyField);
           
        } catch ( Exception e ) {
            e.printStackTrace();
            fail("Error connecting to database");
        }
       
        // text-dump
        StringBuffer sbuf = new StringBuffer('\n');
        sbuf.append("--[Table: ").append(t.getRowCount()).append(" rows, ")
            .append(t.getColumnCount()).append(" cols]--\n");
        for (int c = 0, idx = -1; c < t.getColumnCount(); ++c) {
            String name = t.getColumnType(c).getName();
            if ( (idx=name.lastIndexOf('.')) >= 0 )
                name = name.substring(idx+1);
            sbuf.append(c).append("\t").append(name).append("\t")
                .append(t.getColumnName(c)).append('\n');
        }
        sbuf.append('\n');
        sbuf.append(TestConfig.memUse()).append('\n');
        s_logger.info(sbuf.toString());
       
View Full Code Here

        byte[] data = TAB_DELIMITED_DATA.getBytes();
        InputStream is = new ByteArrayInputStream(data);
       
        // parse data
        TableReader ctr = new DelimitedTextTableReader();
        Table t = null;
        try {
            t = ctr.readTable(is);
        } catch ( DataIOException e ) {
            e.printStackTrace();
            fail("Data Read Exception");
        }
       
        boolean verbose = TestConfig.verbose();
       
        // text-dump
        if (verbose) System.out.println("** TAB DELIMITED DATA TEST **");
        if (verbose) System.out.println("-- Data Types -------------");
        for (int c = 0, idx = -1; c < t.getColumnCount(); ++c) {
            String name = t.getColumnType(c).getName();
            if ( (idx=name.lastIndexOf('.')) >= 0 )
                name = name.substring(idx+1);
            assertEquals(t.getColumnType(c), TYPES[c]);
            if (verbose) System.out.print(name + "\t");
        }
        if (verbose) System.out.println();
       
        if (verbose) System.out.println();
       
        if (verbose) System.out.println("-- Table Data -------------");
        for (int c = 0; c < t.getColumnCount(); ++c) {
            if (verbose) System.out.print(t.getColumnName(c) + "\t");
            assertEquals(t.getColumnName(c), HEADERS[c]);
        }
        if (verbose) System.out.println();
        for (int r = 0; r < t.getRowCount(); ++r) {
            for (int c = 0; c < t.getColumnCount(); ++c) {
                Object o = t.get(r, c);
                if (verbose) System.out.print(o + "\t");
                assertEquals(TABLE[c][r], o);
            }
            if (verbose) System.out.println();
        }
View Full Code Here

            return ts.tuples();
       
        // attempt to generate an optimized query plan
        Iterator iter = null;
        if ( ts instanceof Table ) {
            Table t = (Table)ts;
            IntIterator ii = getOptimizedIterator(t,p);
            if ( ii != null )
                iter = t.tuples(ii);
        }
       
        // optimization fails, scan the entire table
        if ( iter == null ) {
            iter = new FilterIterator(ts.tuples(), p);
View Full Code Here

TOP

Related Classes of prefuse.data.Table$ColumnEntry

Copyright © 2018 www.massapicom. 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.