Package org.voltdb.types

Examples of org.voltdb.types.TimestampType


        if (trace.val)
            LOG.trace("newOrder(W_ID=" + warehouse_id + ") -> [" +
                      "local_warehouses=" + local_warehouses + ", " +
                      "remote_warehouses=" + remote_warehouses + "]");

        TimestampType now = clock.getDateTime();
        client.callNewOrder(rollback, config.noop, warehouse_id, generateDistrict(), generateCID(),
                            now, item_id, supply_w_id, quantity);
    }
View Full Code Here


        // frame 6: settling the trade
        Calendar cal = Calendar.getInstance();
        cal.setTime(trade_dts);
        cal.add(Calendar.DATE, 2); // the settlement is due in two days
       
        TimestampType due_date = new TimestampType(cal.getTime());
        double se_amount;
       
        if (type_is_sell == 1) {
            se_amount = (trade_qty * trade_price) - charge - comm_amount;
        }
View Full Code Here

        // Insert a submitted followed by canceled record into TRADE_HISTORY,
        // mark
        // the trade canceled and delete the pending trade
        while (results[0].advanceRow()) {
            long tr_trade_id = results[0].getLong(0);
            TimestampType now = new TimestampType();

            voltQueueSQL(insertTradeHistory, tr_trade_id, now, submitted_id);
            voltQueueSQL(updateTrade, canceled_id, now, tr_trade_id);
            voltQueueSQL(insertTradeHistory, tr_trade_id, now, canceled_id);
        } // WHILE
        voltQueueSQL(deleteTradeRequest);
        voltExecuteSQL();

        // Find submitted trades, change the status to canceled and insert a
        // canceled record into TRADE_HISTORY
        voltQueueSQL(selectTrade, start_trade_id, submitted_id);
        results = voltExecuteSQL();

        while (results[0].advanceRow()) {
            long trade_id = results[0].getLong(0);
            TimestampType now = new TimestampType();

            // Mark the trade as canceled, and record the time
            voltQueueSQL(updateTrade, canceled_id, now, trade_id);
            voltQueueSQL(insertTradeHistory, trade_id, now, canceled_id);
        } // WHILE
View Full Code Here

           
            for (int year = 0; year < TPCEConstants.dailyMarketYears; year++) {
                cal.set(Calendar.YEAR, TPCEConstants.dailyMarketBaseYear + year);
                for (int month = 0; month < 12; month++) {
                    cal.set(Calendar.MONTH, month);
                    TimestampType t = new TimestampType(cal.getTime());
                    voltQueueSQL(updateDailyMarket, vol_incr, symbol, t);
                }
            }
            // EXCHANGE
        } else if (table_name.equals("EXCHANGE")) {
            // Other than the table_name, no additional
            // parameters are used when the table_name is EXCHANGE.
            // There are only four rows in the EXCHANGE table. Every
            // row will have its EX_DESC updated. If EX_DESC does not
            // already end with "LAST UPDATED " and a date and time,
            // that string will be appended to EX_DESC. Otherwise the
            // date and time at the end of EX_DESC will be updated
            // to the current date and time.

            // PAVLO (2010-06-15)
            // The substring replacement functions from the spec isn't
            // supported, so we are just going
            // to pull down all the exchange descriptions and update one at a
            // time
            voltQueueSQL(selectExchange);
            VoltTable[] results = voltExecuteSQL();

            final TimestampType now = new TimestampType();
            final String last_updated = " LAST UPDATED ";
            while (results[0].advanceRow()) {
                long ex_id = results[0].getLong(0);
                String ex_desc = results[0].getString(1);

                // Update the Last Update timestamp
                if (ex_desc.contains(last_updated)) {
                    int start_idx = ex_desc.indexOf(last_updated) + last_updated.length();
                    ex_desc = ex_desc.substring(0, start_idx) + now;
                    // Add the Last Updated string + timestamp
                } else {
                    ex_desc += last_updated + now;
                }
                voltQueueSQL(updateExchange, ex_desc, ex_id);
            } // WHILE

            // FINANCIAL
        } else if (table_name.equals("FINANCIAL")) {
            // Update the FINANCIAL table for a company identified by
            // co_id. That company's FI_QTR_START_DATEs will be
            // updated to the second of the month or to the first of
            // the month if the dates were already the second of the
            // month.

            // PAVLO (2010-06-15)
            // Again, the date substring tricks in the spec aren't supported, so
            // we'll pull
            // down the data and make the decision on what to do here
            voltQueueSQL(selectFinancial, co_id);
            VoltTable[] results = voltExecuteSQL();
            assert (results[0].advanceRow());

            TimestampType orig_start_timestamp = results[0].getTimestampAsTimestamp(0);
            Date qtr_start_date = orig_start_timestamp.asApproximateJavaDate();
            Calendar c = Calendar.getInstance();
            c.setTime(qtr_start_date);
            int qtr_start_day = c.get(Calendar.DAY_OF_MONTH);
            long delta = DAY_MICROSECONDS;

            // Decrement by one day
            if (qtr_start_day != 1)
                delta *= -1;

            TimestampType new_start_date = new TimestampType(orig_start_timestamp.getTime() + delta);
            voltQueueSQL(updateFinancial, new_start_date, co_id);

            // NEWS_ITEM
        } else if (table_name.equals("NEWS_ITEM")) {
            // Update the news items for a specified company.
            // Change the NI_DTS by 1 day.

            voltQueueSQL(selectNewsXref, co_id);
            VoltTable[] results = voltExecuteSQL();
            while (results[0].advanceRow()) {
                long ni_id = results[0].getLong(0);
                TimestampType ni_dts = results[0].getTimestampAsTimestamp(1);
               
                voltQueueSQL(updateNewsItem, ni_dts.getTime() + DAY_MICROSECONDS, ni_id);
             } // WHILE

            // SECURITY
        } else if (table_name.equals("SECURITY")) {
            // Update a security identified symbol, increment
            // S_EXCH_DATE by 1 day.

            voltQueueSQL(selectSecurity, symbol);
            VoltTable[] results = voltExecuteSQL();
            assert (results[0].advanceRow());

            TimestampType exch_date = results[0].getTimestampAsTimestamp(0);
            assert (exch_date != null);
            exch_date = new TimestampType(exch_date.getTime() + DAY_MICROSECONDS);

            voltQueueSQL(updateSecurity, exch_date, symbol);

            // TAXRATE
        } else if (table_name.equals("TAXRATE")) {
View Full Code Here

            // --------------------------------
            // TIMESTAMP
            // --------------------------------
            case TIMESTAMP: {
                int timestamp = rand.nextInt(VoltTypeUtil.DATE_STOP - VoltTypeUtil.DATE_START) + VoltTypeUtil.DATE_START;
                ret = new TimestampType(Long.valueOf(timestamp * 1000));
                break;
            }
            // --------------------------------
            // INVALID
            // --------------------------------
View Full Code Here

                        last_ex = ex;
                    }
                    if (date != null) break;
                } // FOR
                if (date == null) throw last_ex;
                ret = new TimestampType((date.getTime() * 1000) + usecs);
                break;
            }
            // --------------------------------
            // BOOLEAN
            // --------------------------------
View Full Code Here

            }
            // --------------------------------
            // TIMESTAMP
            // --------------------------------
            case TIMESTAMP: {
                TimestampType valArray[] = new TimestampType[objArray.length];
                for (int i = 0; i < objArray.length; i++) {
                    valArray[i] = (TimestampType)objArray[i];
                } // FOR
                ret = valArray;
                break;
View Full Code Here

       
        // frame 4: inserting the trade
        double comm_amount = (comm_rate / 100) * trade_qty * requested_price;
        String exec_name = exec_f_name + " " + exec_l_name;
        int is_cash = (type_is_margin == 1) ? 0 : 1;
        TimestampType now_dts = new TimestampType();
       
        voltQueueSQL(insertTrade, trade_id, now_dts, status_id, trade_type_id, is_cash,
                symbol, trade_qty, requested_price, acct_id, exec_name, null, charge_amount,
                comm_amount, 0, is_lifo);
       
View Full Code Here

                assert (MathUtil.equals(this.best_cost, cost2, 2, 0.2)) : cost2 + " == " + this.best_cost + "\n" + PartitionPlan.createFromCatalog(info.catalogContext.database) + "\n"
                        + this.costmodel.getLastDebugMessage();
            }

            // Save checkpoint
            this.last_checkpoint = new TimestampType();
            if (this.checkpoint != null) {
                this.save(this.checkpoint);
                LOG.info("Saved Round #" + this.restart_ctr + " checkpoint to '" + this.checkpoint.getAbsolutePath() + "'");
            }
View Full Code Here

        // we want time in seconds here; plus work days have only 8 hours in them
        meeSec.init(generator.getInitTradeDays() * 8 * 3600, null, null, 0);
        double price = meeSec.calculatePrice(counter, 0).getDollars();
       
        tuple[0] = secHandler.createSymbol(counter, 15); // lt_s_symb; because of CHAR(15) in the schema
        tuple[1] = new TimestampType(tradeDate); // lt_dts
        tuple[2] = price; // lt_price
        tuple[3] = price; // lt_open_price
        tuple[4] = 0; // lt_volume
       
        counter++;
View Full Code Here

TOP

Related Classes of org.voltdb.types.TimestampType

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.