本文整理汇总了Java中org.apache.metamodel.schema.ColumnType.BINARY属性的典型用法代码示例。如果您正苦于以下问题:Java ColumnType.BINARY属性的具体用法?Java ColumnType.BINARY怎么用?Java ColumnType.BINARY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.metamodel.schema.ColumnType
的用法示例。
在下文中一共展示了ColumnType.BINARY属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
示例2: 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;
}
示例3: 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.");
}
示例4: testSerializeAndDeserialize
public void testSerializeAndDeserialize() throws Exception {
final Object map1 = buildMap(
"{'some_number':1234, 'gender':'M','address':{'city':'Copenhagen','country':'DK','additional_info':null}}");
final Object map2 =
buildMap("{'some_number':5678,'gender':'M','address':{'city':'Amsterdam','countries':['NL','IN']}}");
final SimpleTableDef tableDef = new SimpleTableDef("bar", new String[] { "id", "name", "details", "bytes" },
new ColumnType[] { ColumnType.INTEGER, ColumnType.VARCHAR, ColumnType.MAP, ColumnType.BINARY });
final Collection<Object[]> arrays = new ArrayList<>();
arrays.add(new Object[] { 1, "Kasper Sørensen", map1, new byte[] { (byte) -40, (byte) -2 } });
arrays.add(new Object[] { 2, "Ankit Kumar", map2, new byte[] { (byte) 1, (byte) 3, (byte) 3, (byte) 7 } });
final TableDataProvider<?> tableProvider = new ArrayTableDataProvider(tableDef, arrays);
final List<TableDataProvider<?>> tableProviders = new ArrayList<>();
tableProviders.add(tableProvider);
PojoDatastore datastore;
datastore = new PojoDatastore("foo", tableProviders);
final JaxbPojoDatastoreAdaptor adaptor = new JaxbPojoDatastoreAdaptor(new DataCleanerConfigurationImpl());
AbstractDatastoreType serializedDatastore = adaptor.createPojoDatastore(datastore, null, 20);
final DatastoreCatalogType serializedDatastoreCatalogType = new DatastoreCatalogType();
serializedDatastoreCatalogType.getJdbcDatastoreOrAccessDatastoreOrCsvDatastore().add(serializedDatastore);
Configuration serializedConfiguration = new Configuration();
serializedConfiguration.setDatastoreCatalog(serializedDatastoreCatalogType);
// serialize and deserialize
final JAXBContext jaxbContext = JAXBContext
.newInstance(ObjectFactory.class.getPackage().getName(), ObjectFactory.class.getClassLoader());
final File file = new File("target/JaxbPojoDatastoreAdaptorTest_serialize_and_deserialize.xml");
jaxbContext.createMarshaller().marshal(serializedConfiguration, file);
serializedConfiguration = (Configuration) jaxbContext.createUnmarshaller().unmarshal(file);
serializedDatastore =
serializedConfiguration.getDatastoreCatalog().getJdbcDatastoreOrAccessDatastoreOrCsvDatastore().get(0);
datastore = adaptor.read((PojoDatastoreType) serializedDatastore);
final UpdateableDatastoreConnection con = datastore.openConnection();
final DataSet ds = con.getDataContext().query().from("bar").select("id", "name", "details").execute();
assertTrue(ds.next());
assertTrue(ds.getRow().getValue(0) instanceof Integer);
assertEquals(1, ds.getRow().getValue(0));
assertTrue(ds.getRow().getValue(1) instanceof String);
assertEquals("Kasper Sørensen", ds.getRow().getValue(1));
assertTrue(ds.getRow().getValue(2) instanceof Map);
@SuppressWarnings("unchecked") final Map<String, ?> map3 = (Map<String, ?>) ds.getRow().getValue(2);
assertEquals("{some_number=1234, gender=M, address={city=Copenhagen, country=DK, additional_info=null}}",
map3.toString());
assertEquals(Integer.class, map3.get("some_number").getClass());
assertTrue(ds.next());
assertTrue(ds.getRow().getValue(0) instanceof Integer);
assertEquals(2, ds.getRow().getValue(0));
assertTrue(ds.getRow().getValue(1) instanceof String);
assertEquals("Ankit Kumar", ds.getRow().getValue(1));
assertTrue(ds.getRow().getValue(2) instanceof Map);
@SuppressWarnings("unchecked") final Map<String, ?> map4 = (Map<String, ?>) ds.getRow().getValue(2);
assertEquals("{some_number=5678, gender=M, address={city=Amsterdam, countries=[NL, IN]}}", map4.toString());
assertEquals(Integer.class, map3.get("some_number").getClass());
assertFalse(ds.next());
assertEquals(map1, map3);
assertEquals(map2, map4);
}
示例5: getAvailableColumnTypes
private ColumnType[] getAvailableColumnTypes() {
return new ColumnType[] { ColumnType.VARCHAR, ColumnType.DECIMAL, ColumnType.INTEGER, ColumnType.BOOLEAN,
ColumnType.DATE, ColumnType.TIME, ColumnType.TIMESTAMP, ColumnType.MAP, ColumnType.LIST,
ColumnType.BINARY };
}
示例6: testSerializeAndDeserialize
public void testSerializeAndDeserialize() throws Exception {
final Object map1 = buildMap("{'some_number':1234, 'gender':'M','address':{'city':'Copenhagen','country':'DK','additional_info':null}}");
final Object map2 = buildMap("{'some_number':5678,'gender':'M','address':{'city':'Amsterdam','countries':['NL','IN']}}");
SimpleTableDef tableDef = new SimpleTableDef("bar", new String[] { "id", "name", "details", "bytes" },
new ColumnType[] { ColumnType.INTEGER, ColumnType.VARCHAR, ColumnType.MAP, ColumnType.BINARY });
Collection<Object[]> arrays = new ArrayList<Object[]>();
arrays.add(new Object[] { 1, "Kasper Sørensen", map1, new byte[] { (byte) -40, (byte) -2 } });
arrays.add(new Object[] { 2, "Ankit Kumar", map2, new byte[] { (byte) 1, (byte) 3, (byte) 3, (byte) 7 } });
TableDataProvider<?> tableProvider = new ArrayTableDataProvider(tableDef, arrays);
List<TableDataProvider<?>> tableProviders = new ArrayList<TableDataProvider<?>>();
tableProviders.add(tableProvider);
PojoDatastore datastore;
datastore = new PojoDatastore("foo", tableProviders);
final JaxbPojoDatastoreAdaptor adaptor = new JaxbPojoDatastoreAdaptor();
AbstractDatastoreType serializedDatastore = adaptor.createPojoDatastore(datastore, null, 20);
DatastoreCatalogType serializedDatastoreCatalogType = new DatastoreCatalogType();
serializedDatastoreCatalogType.getJdbcDatastoreOrAccessDatastoreOrCsvDatastore().add(serializedDatastore);
Configuration serializedConfiguration = new Configuration();
serializedConfiguration.setDatastoreCatalog(serializedDatastoreCatalogType);
// serialize and deserialize
JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName(),
ObjectFactory.class.getClassLoader());
File file = new File("target/JaxbPojoDatastoreAdaptorTest_serialize_and_deserialize.xml");
jaxbContext.createMarshaller().marshal(serializedConfiguration, file);
serializedConfiguration = (Configuration) jaxbContext.createUnmarshaller().unmarshal(file);
serializedDatastore = serializedConfiguration.getDatastoreCatalog()
.getJdbcDatastoreOrAccessDatastoreOrCsvDatastore().get(0);
datastore = adaptor.read((PojoDatastoreType) serializedDatastore);
UpdateableDatastoreConnection con = datastore.openConnection();
DataSet ds = con.getDataContext().query().from("bar").select("id", "name", "details").execute();
assertTrue(ds.next());
assertTrue(ds.getRow().getValue(0) instanceof Integer);
assertEquals(1, ds.getRow().getValue(0));
assertTrue(ds.getRow().getValue(1) instanceof String);
assertEquals("Kasper Sørensen", ds.getRow().getValue(1));
assertTrue(ds.getRow().getValue(2) instanceof Map);
@SuppressWarnings("unchecked")
final Map<String, ?> map3 = (Map<String, ?>) ds.getRow().getValue(2);
assertEquals("{some_number=1234, gender=M, address={city=Copenhagen, country=DK, additional_info=null}}",
map3.toString());
assertEquals(Integer.class, map3.get("some_number").getClass());
assertTrue(ds.next());
assertTrue(ds.getRow().getValue(0) instanceof Integer);
assertEquals(2, ds.getRow().getValue(0));
assertTrue(ds.getRow().getValue(1) instanceof String);
assertEquals("Ankit Kumar", ds.getRow().getValue(1));
assertTrue(ds.getRow().getValue(2) instanceof Map);
@SuppressWarnings("unchecked")
final Map<String, ?> map4 = (Map<String, ?>) ds.getRow().getValue(2);
assertEquals("{some_number=5678, gender=M, address={city=Amsterdam, countries=[NL, IN]}}", map4.toString());
assertEquals(Integer.class, map3.get("some_number").getClass());
assertFalse(ds.next());
assertEquals(map1, map3);
assertEquals(map2, map4);
}
示例7: 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);
}