本文整理汇总了Java中org.apache.metamodel.schema.ColumnType.STRING属性的典型用法代码示例。如果您正苦于以下问题:Java ColumnType.STRING属性的具体用法?Java ColumnType.STRING怎么用?Java ColumnType.STRING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.metamodel.schema.ColumnType
的用法示例。
在下文中一共展示了ColumnType.STRING属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: before
@Before
public void before() throws Exception {
loadConfiguration();
if (isConfigured()) {
final int timeout = 8 * 1000; // 8 seconds should be more than
// enough
httpClient = new StdHttpClient.Builder().socketTimeout(timeout).host(getHostname()).build();
// set up a simple database
couchDbInstance = new StdCouchDbInstance(httpClient);
final String databaseName = getDatabaseName();
if (couchDbInstance.getAllDatabases().contains(databaseName)) {
throw new IllegalStateException("Couch DB instance already has a database called " + databaseName);
}
connector = couchDbInstance.createConnector(databaseName, true);
final String[] columnNames = new String[] { "name", "gender", "age" };
final ColumnType[] columnTypes = new ColumnType[] { ColumnType.STRING, ColumnType.CHAR,
ColumnType.INTEGER };
predefinedTableDef = new SimpleTableDef(databaseName, columnNames, columnTypes);
}
}
示例2: rewriteColumnType
@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
if (columnType == ColumnType.INTEGER) {
return "INT";
}
if(columnType == ColumnType.STRING) {
return "STRING";
}
// Hive does not support VARCHAR without a width, nor VARCHAR(MAX).
// Returning max allowable column size instead.
if (columnType == ColumnType.VARCHAR && columnSize == null) {
return super.rewriteColumnType(columnType, 65535);
}
return super.rewriteColumnType(columnType, columnSize);
}
示例3: parse
/**
* Parses the ElasticSearch meta data info into an ElasticSearchMetaData
* object. This method makes much easier to create the ElasticSearch schema.
*
* @param metaDataInfo
* ElasticSearch mapping metadata in Map format
* @return An ElasticSearchMetaData object
*/
public static ElasticSearchMetaData parse(Map<String, ?> metaDataInfo) {
final String[] fieldNames = new String[metaDataInfo.size() + 1];
final ColumnType[] columnTypes = new ColumnType[metaDataInfo.size() + 1];
// add the document ID field (fixed)
fieldNames[0] = ElasticSearchUtils.FIELD_ID;
columnTypes[0] = ColumnType.STRING;
int i = 1;
for (Entry<String, ?> metaDataField : metaDataInfo.entrySet()) {
@SuppressWarnings("unchecked")
final Map<String, ?> fieldMetadata = (Map<String, ?>) metaDataField.getValue();
fieldNames[i] = metaDataField.getKey();
columnTypes[i] = getColumnTypeFromMetadataField(fieldMetadata);
i++;
}
return new ElasticSearchMetaData(fieldNames, columnTypes);
}
示例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: testCreateRowWithParsableDates
public void testCreateRowWithParsableDates() throws Exception {
SelectItem item1 = new SelectItem(new MutableColumn("value1", ColumnType.STRING));
SelectItem item2 = new SelectItem(new MutableColumn("value2", ColumnType.DATE));
List<SelectItem> selectItems1 = Arrays.asList(item1, item2);
String documentId = "doc1";
DataSetHeader header = new SimpleDataSetHeader(selectItems1);
Map<String, Object> values = new HashMap<>();
values.put("value1", "theValue");
values.put("value2", "2013-01-04T15:55:51.217+01:00");
Row row = ElasticSearchUtils.createRow(values, documentId, header);
Object stringValue = row.getValue(item1);
Object dateValue = row.getValue(item2);
assertTrue(stringValue instanceof String);
assertTrue(dateValue instanceof Date);
}
示例6: buildColumns
private List<Column> buildColumns(final List<String> columnNames) {
if (columnNames == null) {
return new ArrayList<>();
}
final CsvConfiguration configuration = _schema.getDataContext().getConfiguration();
final int columnNameLineNumber = configuration.getColumnNameLineNumber();
final boolean nullable = !configuration.isFailOnInconsistentRowLength();
final ColumnNamingStrategy columnNamingStrategy = configuration.getColumnNamingStrategy();
List<Column> columns = new ArrayList<>();
try (final ColumnNamingSession namingSession = columnNamingStrategy.startColumnNamingSession()) {
for (int i = 0; i < columnNames.size(); i++) {
final String intrinsicColumnName = columnNameLineNumber == CsvConfiguration.NO_COLUMN_NAME_LINE ? null
: columnNames.get(i);
final String columnName = namingSession.getNextColumnName(new ColumnNamingContextImpl(this,
intrinsicColumnName, i));
final Column column = new MutableColumn(columnName, ColumnType.STRING, this, i, null, null, nullable,
null, false, null);
columns.add(column);
}
}
return columns;
}
示例7: createDatastore
private Datastore createDatastore(final String name, final MongodbDatastoreType mongodbDatastoreType) {
final String hostname = getStringVariable("hostname", mongodbDatastoreType.getHostname());
final Integer port = getIntegerVariable("port", mongodbDatastoreType.getPort());
final String databaseName = getStringVariable("databaseName", mongodbDatastoreType.getDatabaseName());
final String username = getStringVariable("username", mongodbDatastoreType.getUsername());
final String password = getPasswordVariable("password", mongodbDatastoreType.getPassword());
final List<org.datacleaner.configuration.jaxb.MongodbDatastoreType.TableDef> tableDefList =
mongodbDatastoreType.getTableDef();
final SimpleTableDef[] tableDefs;
if (tableDefList.isEmpty()) {
tableDefs = null;
} else {
tableDefs = new SimpleTableDef[tableDefList.size()];
for (int i = 0; i < tableDefs.length; i++) {
final org.datacleaner.configuration.jaxb.MongodbDatastoreType.TableDef tableDef = tableDefList.get(i);
final String collectionName = tableDef.getCollection();
final List<org.datacleaner.configuration.jaxb.MongodbDatastoreType.TableDef.Property> propertyList =
tableDef.getProperty();
final String[] propertyNames = new String[propertyList.size()];
final ColumnType[] columnTypes = new ColumnType[propertyList.size()];
for (int j = 0; j < columnTypes.length; j++) {
final String propertyName = propertyList.get(j).getName();
final String propertyTypeName = propertyList.get(j).getType();
final ColumnType propertyType;
if (StringUtils.isNullOrEmpty(propertyTypeName)) {
propertyType = ColumnType.STRING;
} else {
propertyType = ColumnTypeImpl.valueOf(propertyTypeName);
}
propertyNames[j] = propertyName;
columnTypes[j] = propertyType;
}
tableDefs[i] = new SimpleTableDef(collectionName, propertyNames, columnTypes);
}
}
return new MongoDbDatastore(name, hostname, port, databaseName, username, password, tableDefs);
}
示例8: createDatastoreConnection
@Override
protected UsageAwareDatastoreConnection<HBaseDataContext> createDatastoreConnection() {
final HBaseConfiguration hBaseConfiguration =
new HBaseConfiguration("HBase", _zookeeperHostname, _zookeeperPort, _tableDefs, ColumnType.STRING);
final HBaseDataContext hBaseDataContext = new HBaseDataContext(hBaseConfiguration);
return new DatastoreConnectionImpl<>(hBaseDataContext, this);
}
示例9: createDatastoreConnection
@Override
protected UsageAwareDatastoreConnection<HBaseDataContext> createDatastoreConnection() {
final HBaseConfiguration hBaseConfiguration = new HBaseConfiguration("HBase", _zookeeperHostname,
_zookeeperPort, _tableDefs, ColumnType.STRING);
final HBaseDataContext hBaseDataContext = new HBaseDataContext(hBaseConfiguration);
final DatastoreConnectionImpl<HBaseDataContext> connection = new DatastoreConnectionImpl<HBaseDataContext>(
hBaseDataContext, this);
return connection;
}
示例10: rewriteColumnType
@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
if (columnType == ColumnType.STRING) {
// convert STRING to VARCHAR as the default SQL type for strings
return rewriteColumnType(ColumnType.VARCHAR, columnSize);
}
if (columnType == ColumnType.NUMBER) {
// convert NUMBER to FLOAT as the default SQL type for numbers
return rewriteColumnType(ColumnType.FLOAT, columnSize);
}
return super.rewriteColumnType(columnType, columnSize);
}
示例11: rewriteColumnType
@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
if (columnType == ColumnType.NUMERIC) {
return super.rewriteColumnType(ColumnType.DECIMAL, columnSize);
}
if (columnType.isLiteral() && columnSize == null) {
if (columnType == ColumnType.STRING || columnType == ColumnType.VARCHAR
|| columnType == ColumnType.NVARCHAR) {
// MySQL requires size to be specified, so instead we choose the
// text type
return "TEXT";
}
}
return super.rewriteColumnType(columnType, columnSize);
}
示例12: toColumnType
public static ColumnType toColumnType(String attributeName, String attributeType) {
if (attributeType == null) {
return null;
}
switch (attributeType) {
case "S":
return ColumnType.STRING;
case "N":
return ColumnType.NUMBER;
case "B":
return ColumnType.BINARY;
}
logger.warn("Unexpected attribute type '{}' for attribute: {}", attributeType, attributeName);
return null;
}
示例13: getColumnTypeFromMetadataField
private static ColumnType getColumnTypeFromMetadataField(Map<String, ?> fieldMetadata) {
final String metaDataFieldType = getMetaDataFieldTypeFromMetaDataField(fieldMetadata);
if (metaDataFieldType == null) {
return ColumnType.STRING;
}
return ElasticSearchUtils.getColumnTypeFromElasticSearchType(metaDataFieldType);
}
示例14: getExpectedColumnType
@Override
public ColumnType getExpectedColumnType(ColumnType type) {
if (type.isLiteral()) {
return type;
}
return ColumnType.STRING;
}
示例15: detectType
private ColumnType detectType() {
if (_columnTypes.isEmpty()) {
return ColumnType.OTHER;
}
if (_columnTypes.size() == 1) {
return _columnTypes.iterator().next();
}
boolean allStrings = true;
boolean allNumbers = true;
for (ColumnType type : _columnTypes) {
if (allStrings && !type.isLiteral()) {
allStrings = false;
} else if (allNumbers && !type.isNumber()) {
allNumbers = false;
}
}
if (allStrings) {
return ColumnType.STRING;
}
if (allNumbers) {
return ColumnType.NUMBER;
}
return ColumnType.OTHER;
}