本文整理汇总了Java中org.voltdb.VoltTable.getColumnCount方法的典型用法代码示例。如果您正苦于以下问题:Java VoltTable.getColumnCount方法的具体用法?Java VoltTable.getColumnCount怎么用?Java VoltTable.getColumnCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.voltdb.VoltTable
的用法示例。
在下文中一共展示了VoltTable.getColumnCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCatalogTable
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* For a given VoltTable object, return the matching Table catalog object
* based on the column names.
*
* @param catalog_db
* @param voltTable
* @return
*/
public static Table getCatalogTable(Database catalog_db, VoltTable voltTable) {
int num_columns = voltTable.getColumnCount();
for (Table catalog_tbl : catalog_db.getTables()) {
if (num_columns == catalog_tbl.getColumns().size()) {
boolean match = true;
List<Column> catalog_cols = CatalogUtil.getSortedCatalogItems(catalog_tbl.getColumns(), "index");
for (int i = 0; i < num_columns; i++) {
if (!voltTable.getColumnName(i).equals(catalog_cols.get(i).getName())) {
match = false;
break;
}
} // FOR
if (match)
return (catalog_tbl);
}
} // FOR
return (null);
}
示例2: generateFlights
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* Populate FLIGHTS per benchmark spec
*/
void generateFlights() {
int fid = 0;
VoltTable flightTbl = initializeFlightDataTable();
Object row[] = new Object[flightTbl.getColumnCount()];
while (fid < kMaxFlights / m_scalefactor) {
int col = 0;
row[col++] = new Integer(fid++);
for (int j=0; j < 30; ++j) {
row[col++] = number(0, 1<<30);
}
assert (col == flightTbl.getColumnCount());
flightTbl.addRow(row);
if (flightTbl.getRowCount() >= kFlightBatchSize) {
System.err.printf("FLIGHTS: loading %d rows (fid %d of %d)\n",
flightTbl.getRowCount(), fid, (kMaxFlights / m_scalefactor));
loadTable("FLIGHTS", flightTbl);
flightTbl.clearRowData();
}
}
System.err.println("FLIGHTS: loading final " + flightTbl.getRowCount() + " rows.");
loadTable("FLIGHTS", flightTbl);
flightTbl.clearRowData();
}
示例3: compareTables
import org.voltdb.VoltTable; //导入方法依赖的package包/类
private void compareTables(VoltTable vt0, VoltTable vt1) {
assertEquals(vt0.getRowCount(), vt1.getRowCount());
assertEquals(vt0.getColumnCount(), vt1.getColumnCount());
assert(vt1.getColumnCount() > 0);
int rows = 0;
while (vt0.advanceRow() && vt1.advanceRow()) {
VoltTableRow row0 = vt0.fetchRow(vt0.getActiveRowIndex());
VoltTableRow row1 = vt1.fetchRow(vt1.getActiveRowIndex());
for (int i = 0; i < vt0.getColumnCount(); i++) {
// System.err.println(i + ": " + row1.get(i));
assertEquals(row0.get(i), row1.get(i));
} // FOR
rows++;
} // WHILE
assert(rows > 0);
}
示例4: needsConversion
import org.voltdb.VoltTable; //导入方法依赖的package包/类
public static Boolean needsConversion(VoltTable inputTable,
Table outputTableSchema) {
for (int ii = 0; ii < inputTable.getColumnCount(); ii++) {
final String name = inputTable.getColumnName(ii);
final VoltType type = inputTable.getColumnType(ii);
final Column column = outputTableSchema.getColumns().get(name);
if (column == null) {
return true;
}
if (column.getIndex() != ii) {
return true;
}
if (column.getType() != type.getValue()) {
return true;
}
}
return false;
}
示例5: csv
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* Dump out a VoltTable as a CSV to the given writer
* If the header flag is set to true, then the output will include
* the column names in the first row
* @param out
* @param vt
* @param write_header
*/
public static void csv(Writer out, VoltTable vt, boolean header) {
CSVWriter writer = new CSVWriter(out);
if (header) {
String cols[] = new String[vt.getColumnCount()];
for (int i = 0; i < cols.length; i++) {
cols[i] = vt.getColumnName(i);
} // FOR
writer.writeNext(cols);
}
vt.resetRowPosition();
while (vt.advanceRow()) {
String row[] = vt.getRowStringArray();
assert(row != null);
assert(row.length == vt.getColumnCount());
writer.writeNext(row);
} // WHILE
}
示例6: setOutput
import org.voltdb.VoltTable; //导入方法依赖的package包/类
public void setOutput(VoltTable...output) {
if (output == null || output.length == 0) return;
this.output = new Object[output.length][][];
this.output_types = new VoltType[output.length][];
for (int i = 0; i < this.output.length; i++) {
VoltTable vt = output[i];
if (vt == null) continue;
// TYPES
this.output_types[i] = new VoltType[vt.getColumnCount()];
for (int k = 0; k < this.output_types[i].length; k++) {
this.output_types[i][k] = vt.getColumnType(k);
} // FOR
// DATA
this.output[i] = new Object[vt.getRowCount()][vt.getColumnCount()];
int j = 0;
while (vt.advanceRow()) {
VoltTableRow row = vt.getRow();
for (int k = 0; k < this.output[i][j].length; k++) {
this.output[i][j][k] = row.get(k);
} // FOR (columns)
j++;
} // WHILE (rows)
} // FOR (tables)
}
示例7: extractColumnInfo
import org.voltdb.VoltTable; //导入方法依赖的package包/类
public static VoltTable.ColumnInfo[] extractColumnInfo(VoltTable vt) {
VoltTable.ColumnInfo cols[] = new VoltTable.ColumnInfo[vt.getColumnCount()];
for (int i = 0; i < cols.length; i++) {
cols[i] = new VoltTable.ColumnInfo(vt.getColumnName(i), vt.getColumnType(i));
} // FOR
return (cols);
}
示例8: loadTable
import org.voltdb.VoltTable; //导入方法依赖的package包/类
protected VoltTable loadTable(Client client) throws IOException, ProcCallException {
int num_partitions = this.getServerConfig().getPartitionCount();
int num_tuples = num_partitions * 10;
Database catalog_db = CatalogUtil.getDatabase(this.getCatalog());
Table catalog_tbl = catalog_db.getTables().get("TABLEC");
assertNotNull(catalog_tbl);
Random rand = new Random(0);
VoltTable vt = CatalogUtil.getVoltTable(catalog_tbl);
int col_cnt = vt.getColumnCount();
for (int i = 0; i < num_tuples; i++) {
Object row[] = new Object[col_cnt];
int col = 0;
row[col++] = i;
row[col++] = i % 5;
row[col++] = i % num_partitions;
for ( ; col < col_cnt; col++) {
int val = rand.nextInt(100);
row[col] = val;
} // FOR
vt.addRow(row);
} // FOR
ClientResponse cr = client.callProcedure("@LoadMultipartitionTable", catalog_tbl.getName(), vt);
assertEquals(Status.OK, cr.getStatus());
return (vt);
}
示例9: generateCustomers
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* Populate customers table per benchmark spec.
*/
void generateCustomers() {
int cid = 0;
VoltTable customerTbl = initializeCustomerDataTable();
Object row[] = new Object[customerTbl.getColumnCount()];
while (cid < kMaxCustomers / m_scalefactor) {
int col = 0;
row[col++] = new Integer(cid++);
for (int j=0; j < 20; ++j) {
row[col++] = astring(6,8);
}
for (int j=0; j < 20; ++j) {
row[col++] = number(0, 1<<30);
}
assert (col == customerTbl.getColumnCount());
customerTbl.addRow(row);
if (customerTbl.getRowCount() >= kCustomerBatchSize) {
System.err.printf("CUSTOMERS: loading %d rows (cid %d of %d)\n",
customerTbl.getRowCount(), cid, (kMaxCustomers / m_scalefactor));
loadTable("CUSTOMERS", customerTbl);
customerTbl.clearRowData();
}
}
System.err.println("CUSTOMERS: loading final " + customerTbl.getRowCount() + " rows.");
loadTable("CUSTOMERS", customerTbl);
customerTbl.clearRowData();
}
示例10: genAccessInfo
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* Populate Access_Info table per benchmark spec.
*/
void genAccessInfo(Table catalog_tbl) {
final VoltTable table = CatalogUtil.getVoltTable(catalog_tbl);
int[] arr = { 1, 2, 3, 4 };
int[] ai_types = TM1Util.subArr(arr, 1, 4);
long total = 0;
for (long s_id = 0; s_id < this.subscriberSize; s_id++) {
for (int ai_type : ai_types) {
Object row[] = new Object[table.getColumnCount()];
row[0] = s_id;
row[1] = ai_type;
row[2] = TM1Util.number(0, 255);
row[3] = TM1Util.number(0, 255);
row[4] = TM1Util.astring(3, 3);
row[5] = TM1Util.astring(5, 5);
table.addRow(row);
total++;
} // FOR
if (table.getRowCount() >= TM1Constants.BATCH_SIZE) {
if (d) LOG.debug(String.format("%s: %6d / %d",
TM1Constants.TABLENAME_ACCESS_INFO, total, ai_types.length * subscriberSize));
loadVoltTable(TM1Constants.TABLENAME_ACCESS_INFO, table);
table.clearRowData();
}
} // WHILE
if (table.getRowCount() > 0) {
if (d) LOG.debug(String.format("%s: %6d / %d",
TM1Constants.TABLENAME_ACCESS_INFO, total, ai_types.length * subscriberSize));
loadVoltTable(TM1Constants.TABLENAME_ACCESS_INFO, table);
table.clearRowData();
}
}
示例11: convertTable
import org.voltdb.VoltTable; //导入方法依赖的package包/类
public static VoltTable convertTable(VoltTable inputTable,
Table outputTableSchema)
throws VoltTypeException
{
VoltTable new_table =
CatalogUtil.getVoltTable(outputTableSchema);
Map<Integer, Integer> column_copy_index_map =
computeColumnCopyIndexMap(inputTable, new_table);
// Copy all the old tuples into the new table
while (inputTable.advanceRow())
{
Object[] coerced_values =
new Object[new_table.getColumnCount()];
for (int i = 0; i < new_table.getColumnCount(); i++)
{
if (column_copy_index_map.containsKey(i))
{
int orig_column_index = column_copy_index_map.get(i);
coerced_values[i] =
inputTable.get(orig_column_index,
inputTable.getColumnType(orig_column_index));
}
else
{
// otherwise if it's nullable, insert null,
Column catalog_column =
outputTableSchema.getColumns().
get(new_table.getColumnName(i));
VoltType default_type =
VoltType.get((byte)catalog_column.getDefaulttype());
if (default_type != VoltType.INVALID)
{
// if there is a default value for this table/column
// insert the default value
try
{
coerced_values[i] =
VoltTypeUtil.
getObjectFromString(default_type,
catalog_column.
getDefaultvalue());
}
catch (ParseException e)
{
String message = "Column: ";
message += new_table.getColumnName(i);
message += " has an unparseable default: ";
message += catalog_column.getDefaultvalue();
message += " for VoltType: ";
message += default_type.toString();
throw new VoltTypeException(message);
}
}
else if (catalog_column.getNullable())
{
coerced_values[i] = null;
}
else
{
throw new VoltTypeException("Column: " +
new_table.getColumnName(i) +
" has no default " +
"and null is not permitted");
}
}
}
new_table.addRow(coerced_values);
}
return new_table;
}
示例12: generateReservations
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* Populate RESERVATIONS per benchmark spec
*/
void generateReservations() {
// iterate through the flights.
// pick 70-90% of the 150 seats in the flight.
// pick a customer (who is not booked for this flight).
// create a reservation row.
// assign cids to fids in a deterministic way so
// that (cid, fid) pairs can be generated by the
// benchmark for the ChangeSeat procedure.
/* Creates a table of cids like this (using 6
* seats per aircraft, 10 total customers)
SEAT
1 2 3 4 5 6
FID
1 1 4 7 10 3 6
2 2 5 8 1 4 7
3 3 6 9 2 5 8
cid = f(fid,seat) = (maxfid * (seat -1) + fid) % maxcust
is in range to be on the flight.
(Actually, I think this gives a wrong answer (0 v. max) for
the maximum customer ID. 0 is an invalid cid so this can be
caught and fixed...)
*/
int maxcids = kMaxCustomers / m_scalefactor;
int maxfids = kMaxFlights / m_scalefactor;
int cid = 1;
int rid = 1;
VoltTable reservationTbl = initializeReservationDataTable();
Object row[] = new Object[reservationTbl.getColumnCount()];
for (int seatnum = 1; seatnum < 151; ++seatnum) {
for (int fid = 1; fid < maxfids + 1; ++fid) {
// always advance cid, even if seat is empty
cid = (cid++ % maxcids);
if (seatIsOccupied()) {
int col = 0;
row[col++] = new Integer(rid++);
row[col++] = new Integer(cid);
row[col++] = new Integer(fid);
row[col++] = new Integer(seatnum);
for (int j=0; j < 9; ++j) {
row[col++] = number(1, 1<<30);
}
reservationTbl.addRow(row);
if (reservationTbl.getRowCount() >= kReservationBatchSize) {
System.err.printf("RESERVATIONS: loading %d rows (fid %d of %d)\n",
reservationTbl.getRowCount(), fid, maxfids);
loadTable("RESERVATIONS", reservationTbl);
reservationTbl.clearRowData();
}
}
}
}
System.err.println("RESERVATIONS: loading final " + reservationTbl.getRowCount() + " rows.");
loadTable("RESERVATIONS", reservationTbl);
reservationTbl.clearRowData();
}
示例13: isUpdateResult
import org.voltdb.VoltTable; //导入方法依赖的package包/类
public static boolean isUpdateResult(VoltTable table)
{
return ((table.getColumnName(0).length() == 0 || table.getColumnName(0).equals("modified_tuples"))&& table.getRowCount() == 1 && table.getColumnCount() == 1 && table.getColumnType(0) == VoltType.BIGINT);
}
示例14: loadTable_ORDER_LINE
import org.voltdb.VoltTable; //导入方法依赖的package包/类
protected VoltTable loadTable_ORDER_LINE(Client client) throws IOException, ProcCallException {
int num_partitions = this.getServerConfig().getPartitionCount();
int num_tuples = num_partitions * 10;
Database catalog_db = CatalogUtil.getDatabase(this.getCatalog());
Table catalog_tbl = catalog_db.getTables().get("ORDER_LINE");
assertNotNull(catalog_tbl);
/*
CREATE TABLE ORDER_LINE (
OL_O_ID INTEGER DEFAULT '0' NOT NULL,
OL_D_ID TINYINT DEFAULT '0' NOT NULL,
OL_W_ID SMALLINT DEFAULT '0' NOT NULL,
OL_NUMBER INTEGER DEFAULT '0' NOT NULL,
OL_I_ID INTEGER DEFAULT NULL,
OL_SUPPLY_W_ID SMALLINT DEFAULT NULL,
OL_DELIVERY_D TIMESTAMP DEFAULT NULL,
OL_QUANTITY INTEGER DEFAULT NULL,
OL_AMOUNT FLOAT DEFAULT NULL,
OL_DIST_INFO VARCHAR(32) DEFAULT NULL,
PRIMARY KEY (OL_W_ID,OL_D_ID,OL_O_ID,OL_NUMBER),
CONSTRAINT OL_FKEY_O FOREIGN KEY (OL_O_ID, OL_D_ID, OL_W_ID) REFERENCES ORDERS (O_ID, O_D_ID, O_W_ID),
CONSTRAINT OL_FKEY_S FOREIGN KEY (OL_I_ID, OL_SUPPLY_W_ID) REFERENCES STOCK (S_I_ID, S_W_ID)
);
*/
Random rand = new Random(0);
VoltTable vt = CatalogUtil.getVoltTable(catalog_tbl);
int col_cnt = vt.getColumnCount();
for (int i = 0; i < num_tuples; i++) {
Object row[] = new Object[col_cnt];
int col = 0;
row[col++] = i;
row[col++] = i;
row[col++] = i;
row[col++] = rand.nextInt(10); // OL_NUMBER
col+=3; // disregard OL_I_ID,OL_SUPPLY_W_ID,OL_DELIVERY_D
row[col++] = i * 2;
row[col++] = 1.2 * i;
row[col++] = "null message";
assertEquals(col, 10);
vt.addRow(row);
} // FOR
ClientResponse cr = client.callProcedure("@LoadMultipartitionTable", catalog_tbl.getName(), vt);
assertEquals(Status.OK, cr.getStatus());
return (vt);
}
示例15: format
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* Pretty-printer for an array of VoltTables. This will reset
* each VoltTable's row position both before and after generating the
* formatted output
* @param results
* @return
*/
public static String format(VoltTable...results) {
StringBuilder sb = new StringBuilder();
final int num_results = results.length;
TableUtil.Format f = TableUtil.defaultTableFormat();
f.spacing_col = true;
f.trim_all = true;
f.delimiter_all = " | ";
// TABLE RESULTS
for (int result_idx = 0; result_idx < num_results; result_idx++) {
if (result_idx > 0) sb.append("\n\n");
VoltTable vt = results[result_idx];
vt.resetRowPosition();
String header[] = new String[vt.getColumnCount()];
for (int i = 0; i < header.length; i++) {
String colName = vt.getColumnName(i);
header[i] = (colName.isEmpty() ? "<empty>" : colName);
} // FOR
Object rows[][] = new Object[vt.getRowCount()][];
f.delimiter_rows = new String[rows.length];
for (int i = 0; i < rows.length; i++) {
rows[i] = new Object[header.length];
f.delimiter_rows[i] = "-";
boolean adv = vt.advanceRow();
assert(adv);
for (int j = 0; j < header.length; j++) {
rows[i][j] = vt.get(j);
if (vt.wasNull()) {
rows[i][j] = null;
}
} // FOR (cols)
} // FOR (rows)
sb.append(String.format("Result #%d / %d\n", result_idx+1, num_results));
String resultTable = TableUtil.table(f, header, rows);
resultTable = StringBoxUtil.box(resultTable,
StringBoxUtil.UNICODE_BOX_HORIZONTAL,
StringBoxUtil.UNICODE_BOX_VERTICAL,
null,
StringBoxUtil.UNICODE_BOX_CORNERS);
sb.append(StringUtil.prefix(resultTable, " "));
vt.resetRowPosition();
} // FOR
return (sb.toString());
}