本文整理汇总了Java中org.apache.metamodel.schema.ColumnType.DOUBLE属性的典型用法代码示例。如果您正苦于以下问题:Java ColumnType.DOUBLE属性的具体用法?Java ColumnType.DOUBLE怎么用?Java ColumnType.DOUBLE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.metamodel.schema.ColumnType
的用法示例。
在下文中一共展示了ColumnType.DOUBLE属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
private Object convert(String stringValue, ColumnType type) {
if (stringValue == null || stringValue.length() == 0) {
return null;
}
if (type == ColumnType.FLOAT) {
return Float.parseFloat(stringValue);
} else if (type == ColumnType.DOUBLE) {
return Double.parseDouble(stringValue);
} else if (type == ColumnType.DATE) {
try {
Date date = new SimpleDateFormat("yyyyMMdd").parse(stringValue);
return date;
} catch (ParseException e) {
throw new IllegalArgumentException(stringValue);
}
} else {
return stringValue;
}
}
示例2: getColumnType
private ColumnType getColumnType(ValueMetaInterface valueMeta) {
switch (valueMeta.getType()) {
case ValueMetaInterface.TYPE_STRING:
return ColumnType.VARCHAR;
case ValueMetaInterface.TYPE_INTEGER:
return ColumnType.INTEGER;
case ValueMetaInterface.TYPE_DATE:
return ColumnType.DATE;
case ValueMetaInterface.TYPE_BOOLEAN:
return ColumnType.BOOLEAN;
case ValueMetaInterface.TYPE_NUMBER:
return ColumnType.DOUBLE;
case ValueMetaInterface.TYPE_BINARY:
return ColumnType.BINARY;
case ValueMetaInterface.TYPE_BIGNUMBER:
return ColumnType.DECIMAL;
}
throw new RuntimeException("It is currently not possible to profile values of type: " + valueMeta.getTypeDesc());
}
示例3: rewriteColumnType
@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
if (columnType == ColumnType.BLOB) {
return "bytea";
}
if (columnType == ColumnType.BIT) {
return "BOOLEAN";
}
if (columnType == ColumnType.DOUBLE) {
return "double precision";
}
if (columnType == ColumnType.MAP) {
return "jsonb";
}
return super.rewriteColumnType(columnType, columnSize);
}
示例4: getColumnTypeFromElasticSearchType
public static ColumnType getColumnTypeFromElasticSearchType(final String metaDataFieldType) {
final ColumnType columnType;
if (metaDataFieldType.startsWith("date")) {
columnType = ColumnType.DATE;
} else if (metaDataFieldType.equals("long")) {
columnType = ColumnType.BIGINT;
} else if (metaDataFieldType.equals("string")) {
columnType = ColumnType.STRING;
} else if (metaDataFieldType.equals("float")) {
columnType = ColumnType.FLOAT;
} else if (metaDataFieldType.equals("boolean")) {
columnType = ColumnType.BOOLEAN;
} else if (metaDataFieldType.equals("double")) {
columnType = ColumnType.DOUBLE;
} else {
columnType = ColumnType.STRING;
}
return columnType;
}
示例5: rewriteColumnType
@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
if (columnType == ColumnType.DOUBLE) {
return "FLOAT";
}
if (columnType == ColumnType.BOOLEAN) {
return "BIT";
}
if (columnType.isLiteral() && columnSize == null) {
// SQL server provides the convenient MAX parameter. If not
// specified, the default size of e.g. a VARCHAR is 1!
return rewriteColumnTypeInternal(columnType.getName(), "MAX");
}
return super.rewriteColumnType(columnType, columnSize);
}
示例6: getType
/**
* Determines the best fitting type. For reference of ElasticSearch types,
* see
*
* <pre>
* http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html
* </pre>
*
*
* @param column
* @return
*/
private static String getType(Column column) {
String nativeType = column.getNativeType();
if (!Strings.isNullOrEmpty(nativeType)) {
return nativeType;
}
final ColumnType type = column.getType();
if (type == null) {
throw new IllegalStateException("No column type specified for '" + column.getName()
+ "' - cannot build ElasticSearch mapping without type.");
}
if (type.isLiteral()) {
return "text";
} else if (type == ColumnType.FLOAT) {
return "float";
} else if (type == ColumnType.DOUBLE || type == ColumnType.NUMERIC || type == ColumnType.NUMBER) {
return "double";
} else if (type == ColumnType.SMALLINT) {
return "short";
} else if (type == ColumnType.TINYINT) {
return "byte";
} else if (type == ColumnType.INTEGER) {
return "integer";
} else if (type == ColumnType.DATE || type == ColumnType.TIMESTAMP) {
return "date";
} else if (type == ColumnType.BINARY || type == ColumnType.VARBINARY) {
return "binary";
} else if (type == ColumnType.BOOLEAN || type == ColumnType.BIT) {
return "boolean";
} else if (type == ColumnType.MAP) {
return "object";
}
throw new UnsupportedOperationException("Unsupported column type '" + type.getName() + "' of column '" + column
.getName() + "' - cannot translate to an ElasticSearch type.");
}
示例7: toColumnType
protected static ColumnType toColumnType(FieldType type) {
switch (type) {
case _boolean:
return ColumnType.BOOLEAN;
case _int:
return ColumnType.INTEGER;
case _double:
case currency:
return ColumnType.DOUBLE;
case date:
return ColumnType.DATE;
case datetime:
return ColumnType.TIMESTAMP;
case time:
return ColumnType.TIME;
case string:
case email:
case url:
case phone:
case reference:
case textarea:
case encryptedstring:
case base64:
case id:
case picklist:
return ColumnType.VARCHAR;
default:
return ColumnType.OTHER;
}
}
示例8: testQuery
@Test
public void testQuery() throws Exception {
QueryResult qr = queryResult("/result/double-value.xml");
MutableColumn version = new MutableColumn("Version", ColumnType.DOUBLE);
SalesforceDataSet dataSet = new SalesforceDataSet(Collections.singletonList(version), qr, null);
List<Row> rows = dataSet.toRows();
assertEquals(5386.21, rows.get(0).getValue(version));
assertEquals(53.0, rows.get(1).getValue(version));
dataSet.close();
}
示例9: getMainSchema
@Override
protected Schema getMainSchema() throws MetaModelException {
DBF dbf = getDbf();
String schemaName = dbf.getName();
int separatorIndex = Math.max(schemaName.lastIndexOf('/'), schemaName.lastIndexOf('\\'));
if (separatorIndex != -1) {
schemaName = schemaName.substring(separatorIndex + 1);
}
MutableSchema schema = new MutableSchema(schemaName);
MutableTable table = new MutableTable(schemaName.substring(0, schemaName.length() - 4), TableType.TABLE, schema);
schema.addTable(table);
for (int i = 0; i < dbf.getFieldCount(); i++) {
try {
Field field = dbf.getField(i + 1);
MutableColumn column = new MutableColumn(field.getName());
ColumnType columnType = ColumnType.VARCHAR;
if (field instanceof FloatField) {
columnType = ColumnType.FLOAT;
} else if (field instanceof NumField) {
columnType = ColumnType.DOUBLE;
} else if (field instanceof CharField) {
columnType = ColumnType.CHAR;
} else if (field instanceof DateField) {
columnType = ColumnType.DATE;
} else if (field instanceof MemoField) {
columnType = ColumnType.VARCHAR;
} else if (field instanceof LogicalField) {
columnType = ColumnType.OTHER;
} else if (field instanceof PictureField) {
columnType = ColumnType.OTHER;
}
column.setType(columnType);
column.setTable(table);
column.setColumnNumber(i);
column.setNativeType("" + field.getType());
column.setColumnSize(field.getLength());
table.addColumn(column);
} catch (Exception e) {
throw new MetaModelException("Could not retrieve DBF field", e);
}
}
return schema;
}
示例10: testQuery
public void testQuery() throws Exception {
Schema schema = dc.getSchemaByName("METER.DBF");
Table table = schema.getTableByName("METER");
List<Column> columns = table.getColumns();
Query q = new Query().select(columns).from(table);
assertEquals(ColumnType.CHAR, q.getSelectClause().getItem(0)
.getColumn().getType());
assertEquals(ColumnType.CHAR, q.getSelectClause().getItem(6)
.getColumn().getType());
assertEquals(ColumnType.CHAR, q.getSelectClause().getItem(7)
.getColumn().getType());
assertEquals(ColumnType.CHAR, q.getSelectClause().getItem(8)
.getColumn().getType());
assertEquals(ColumnType.CHAR, q.getSelectClause().getItem(9)
.getColumn().getType());
assertEquals(ColumnType.DOUBLE, q.getSelectClause().getItem(30)
.getColumn().getType());
DataSet ds = dc.executeQuery(q);
assertTrue(ds.next());
// create a cross-locale string comparison of the date field
final String dateString;
{
Date date = DateUtils.get(2009, Month.AUGUST, 31);
dateString = date.toString();
}
assertEquals(
"Row[values=[0002, 0001, 0001, 0001, 0001, 0001, 21, 2008, -1, N, C, A, 0, 149627, A, "
+ dateString
+ ", E, NRC E1 , Electric , Cost , $ , , SimActual , Parkwood Hospital , Parkwood Hospital , Neuro Rehab Centre , 2893.26, 2180.46, 4541.75, 2894.24, 2981.31, 2702.11, 2733.67, 2733.67, 2597.37, 2850.39, 2914.74, 2951.58, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 12.0]]",
ds.getRow().toString());
assertEquals(Double.class, ds.getRow().getValue(30).getClass());
while (ds.next()) {
Row row = ds.getRow();
List<SelectItem> selectItems = row.getSelectItems();
for (int i = 0; i < selectItems.size(); i++) {
SelectItem selectItem = selectItems.get(i);
Column column = columns.get(i);
assertSame(selectItem.getColumn(), column);
Object selectItemValue = row.getValue(selectItem);
Object columnValue = row.getValue(column);
assertEquals(selectItemValue, columnValue);
assertNotNull(columnValue);
if (column.getType() == ColumnType.CHAR) {
assertTrue(columnValue instanceof Character
|| columnValue instanceof String);
} else if (column.getType() == ColumnType.FLOAT) {
assertTrue(columnValue instanceof Float);
} else if (column.getType() == ColumnType.DOUBLE) {
assertTrue(columnValue instanceof Double);
} else if (column.getType() == ColumnType.DATE) {
assertTrue(columnValue instanceof Date);
} else if (column.getType() == ColumnType.OTHER) {
System.out.println("other type: " + columnValue);
} else {
throw new MetaModelException(
"Value type not expected for Dbase data: " + column);
}
}
}
ds.close();
}
示例11: rewriteColumnType
@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
if (columnType == ColumnType.NUMBER || columnType == ColumnType.NUMERIC || columnType == ColumnType.DECIMAL) {
// as one of the only relational databases out there, Oracle has a
// NUMBER type. For this reason NUMBER would be replaced by the
// super-type's logic, but we handle it specifically here.
super.rewriteColumnTypeInternal("NUMBER", columnSize);
}
if (columnType == ColumnType.BOOLEAN || columnType == ColumnType.BIT) {
// Oracle has no boolean type, but recommends NUMBER(3) or CHAR(1).
// For consistency with most other databases who have either a
// boolean or a bit, we use the number variant because it's return
// values (0 or 1) can be converted the most easily back to a
// boolean.
return "NUMBER(3)";
}
if (columnType == ColumnType.DOUBLE) {
return "BINARY_DOUBLE";
}
if (columnType == ColumnType.FLOAT) {
return "BINARY_FLOAT";
}
if (columnType == ColumnType.BINARY || columnType == ColumnType.VARBINARY) {
return "RAW";
}
// following conversions based on
// http://docs.oracle.com/cd/B19306_01/gateways.102/b14270/apa.htm
if (columnType == ColumnType.TINYINT) {
return "NUMBER(3)";
}
if (columnType == ColumnType.SMALLINT) {
return "NUMBER(5)";
}
if (columnType == ColumnType.INTEGER) {
return "NUMBER(10)";
}
if (columnType == ColumnType.BIGINT) {
return "NUMBER(19)";
}
// Oracle has no "time only" data type but 'date' also includes time
if (columnType == ColumnType.TIME) {
super.rewriteColumnType(ColumnType.DATE, columnSize);
}
return super.rewriteColumnType(columnType, columnSize);
}
示例12: getColumnTypeFromMetaDataField
private static ColumnType getColumnTypeFromMetaDataField(DataType.Name metaDataName) {
switch (metaDataName) {
case BIGINT:
case COUNTER:
return ColumnType.BIGINT;
case BLOB:
return ColumnType.BLOB;
case BOOLEAN:
return ColumnType.BOOLEAN;
case DECIMAL:
return ColumnType.DECIMAL;
case DOUBLE:
return ColumnType.DOUBLE;
case FLOAT:
return ColumnType.FLOAT;
case INT:
return ColumnType.INTEGER;
case TEXT:
return ColumnType.STRING;
case TIMESTAMP:
return ColumnType.TIMESTAMP;
case UUID:
return ColumnType.UUID;
case VARCHAR:
return ColumnType.VARCHAR;
case VARINT:
return ColumnType.BIGINT;
case LIST:
return ColumnType.LIST;
case MAP:
return ColumnType.MAP;
case CUSTOM:
return ColumnType.OTHER;
case INET:
return ColumnType.INET;
case SET:
return ColumnType.SET;
default:
return ColumnType.STRING;
}
}
示例13: getExpectedColumnType
@Override
public ColumnType getExpectedColumnType(ColumnType type) {
return ColumnType.DOUBLE;
}