本文整理匯總了Java中org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat類的典型用法代碼示例。如果您正苦於以下問題:Java AvroContainerOutputFormat類的具體用法?Java AvroContainerOutputFormat怎麽用?Java AvroContainerOutputFormat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AvroContainerOutputFormat類屬於org.apache.hadoop.hive.ql.io.avro包,在下文中一共展示了AvroContainerOutputFormat類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGetTableAvro
import org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat; //導入依賴的package包/類
@Test
public void testGetTableAvro() {
final String databaseName = "testdb";
final String tableName = "testtable";
HiveTable.Builder builder = new HiveTable.Builder();
builder.withDbName(databaseName).withTableName(tableName);
State serdeProps = new State();
serdeProps.setProp("avro.schema.literal", "{\"type\": \"record\", \"name\": \"TestEvent\","
+ " \"namespace\": \"test.namespace\", \"fields\": [{\"name\":\"a\"," + " \"type\": \"int\"}]}");
builder.withSerdeProps(serdeProps);
HiveTable hiveTable = builder.build();
hiveTable.setInputFormat(AvroContainerInputFormat.class.getName());
hiveTable.setOutputFormat(AvroContainerOutputFormat.class.getName());
hiveTable.setSerDeType(AvroSerDe.class.getName());
Table table = HiveMetaStoreUtils.getTable(hiveTable);
Assert.assertEquals(table.getDbName(), databaseName);
Assert.assertEquals(table.getTableName(), tableName);
StorageDescriptor sd = table.getSd();
Assert.assertEquals(sd.getInputFormat(), AvroContainerInputFormat.class.getName());
Assert.assertEquals(sd.getOutputFormat(), AvroContainerOutputFormat.class.getName());
Assert.assertNotNull(sd.getSerdeInfo());
Assert.assertEquals(sd.getSerdeInfo().getSerializationLib(), AvroSerDe.class.getName());
List<FieldSchema> fields = sd.getCols();
Assert.assertTrue(fields != null && fields.size() == 1);
FieldSchema fieldA = fields.get(0);
Assert.assertEquals(fieldA.getName(), "a");
Assert.assertEquals(fieldA.getType(), "int");
}
示例2: testGetTableAvroInvalidSchema
import org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat; //導入依賴的package包/類
@Test
public void testGetTableAvroInvalidSchema() {
final String databaseName = "testdb";
final String tableName = "testtable";
HiveTable.Builder builder = new HiveTable.Builder();
builder.withDbName(databaseName).withTableName(tableName);
State serdeProps = new State();
serdeProps.setProp("avro.schema.literal", "invalid schema");
builder.withSerdeProps(serdeProps);
HiveTable hiveTable = builder.build();
hiveTable.setInputFormat(AvroContainerInputFormat.class.getName());
hiveTable.setOutputFormat(AvroContainerOutputFormat.class.getName());
hiveTable.setSerDeType(AvroSerDe.class.getName());
Table table = HiveMetaStoreUtils.getTable(hiveTable);
Assert.assertEquals(table.getDbName(), databaseName);
Assert.assertEquals(table.getTableName(), tableName);
StorageDescriptor sd = table.getSd();
Assert.assertEquals(sd.getInputFormat(), AvroContainerInputFormat.class.getName());
Assert.assertEquals(sd.getOutputFormat(), AvroContainerOutputFormat.class.getName());
Assert.assertNotNull(sd.getSerdeInfo());
Assert.assertEquals(sd.getSerdeInfo().getSerializationLib(), AvroSerDe.class.getName());
List<FieldSchema> fields = sd.getCols();
Assert.assertTrue(fields != null && fields.size() == 0);
}