本文整理汇总了Java中org.voltdb.VoltTable.getColumnName方法的典型用法代码示例。如果您正苦于以下问题:Java VoltTable.getColumnName方法的具体用法?Java VoltTable.getColumnName怎么用?Java VoltTable.getColumnName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.voltdb.VoltTable
的用法示例。
在下文中一共展示了VoltTable.getColumnName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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
}
示例3: storeTableInMap
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* Store
*
* @param map
* @param vt
*/
public static void storeTableInMap(final Map<String, Object[]> map, final VoltTable vt) {
assert (vt != null);
assert (map != null);
int num_rows = vt.getRowCount();
while (vt.advanceRow()) {
int row_idx = vt.getActiveRowIndex();
for (int i = 0, cnt = vt.getColumnCount(); i < cnt; i++) {
String col_name = vt.getColumnName(i);
VoltType vtype = vt.getColumnType(i);
if (row_idx == 0) {
map.put(col_name, new Object[num_rows]);
}
map.get(col_name)[row_idx] = vt.get(col_name, vtype);
} // FOR
} // WHILE
}
示例4: 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);
}
示例5: 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;
}
示例6: 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());
}