Java Code Examples for org.apache.hadoop.hive.metastore.api.StorageDescriptor#getSortCols()
The following examples show how to use
org.apache.hadoop.hive.metastore.api.StorageDescriptor#getSortCols() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HiveMetaStoreBridge.java From atlas with Apache License 2.0 | 4 votes |
private AtlasEntity toStorageDescEntity(StorageDescriptor storageDesc, String tableQualifiedName, String sdQualifiedName, AtlasObjectId tableId ) throws AtlasHookException { AtlasEntity ret = new AtlasEntity(HiveDataTypes.HIVE_STORAGEDESC.getName()); ret.setRelationshipAttribute(ATTRIBUTE_TABLE, AtlasTypeUtil.getAtlasRelatedObjectId(tableId, RELATIONSHIP_HIVE_TABLE_STORAGE_DESC)); ret.setAttribute(ATTRIBUTE_QUALIFIED_NAME, sdQualifiedName); ret.setAttribute(ATTRIBUTE_PARAMETERS, storageDesc.getParameters()); ret.setAttribute(ATTRIBUTE_LOCATION, HdfsNameServiceResolver.getPathWithNameServiceID(storageDesc.getLocation())); ret.setAttribute(ATTRIBUTE_INPUT_FORMAT, storageDesc.getInputFormat()); ret.setAttribute(ATTRIBUTE_OUTPUT_FORMAT, storageDesc.getOutputFormat()); ret.setAttribute(ATTRIBUTE_COMPRESSED, storageDesc.isCompressed()); ret.setAttribute(ATTRIBUTE_NUM_BUCKETS, storageDesc.getNumBuckets()); ret.setAttribute(ATTRIBUTE_STORED_AS_SUB_DIRECTORIES, storageDesc.isStoredAsSubDirectories()); if (storageDesc.getBucketCols().size() > 0) { ret.setAttribute(ATTRIBUTE_BUCKET_COLS, storageDesc.getBucketCols()); } if (storageDesc.getSerdeInfo() != null) { SerDeInfo serdeInfo = storageDesc.getSerdeInfo(); LOG.debug("serdeInfo = {}", serdeInfo); // SkewedInfo skewedInfo = storageDesc.getSkewedInfo(); AtlasStruct serdeInfoStruct = new AtlasStruct(HiveDataTypes.HIVE_SERDE.getName()); serdeInfoStruct.setAttribute(ATTRIBUTE_NAME, serdeInfo.getName()); serdeInfoStruct.setAttribute(ATTRIBUTE_SERIALIZATION_LIB, serdeInfo.getSerializationLib()); serdeInfoStruct.setAttribute(ATTRIBUTE_PARAMETERS, serdeInfo.getParameters()); ret.setAttribute(ATTRIBUTE_SERDE_INFO, serdeInfoStruct); } if (CollectionUtils.isNotEmpty(storageDesc.getSortCols())) { List<AtlasStruct> sortColsStruct = new ArrayList<>(); for (Order sortcol : storageDesc.getSortCols()) { String hiveOrderName = HiveDataTypes.HIVE_ORDER.getName(); AtlasStruct colStruct = new AtlasStruct(hiveOrderName); colStruct.setAttribute("col", sortcol.getCol()); colStruct.setAttribute("order", sortcol.getOrder()); sortColsStruct.add(colStruct); } ret.setAttribute(ATTRIBUTE_SORT_COLS, sortColsStruct); } return ret; }
Example 2
Source File: HiveMetaStoreBridge.java From incubator-atlas with Apache License 2.0 | 4 votes |
public Referenceable fillStorageDesc(StorageDescriptor storageDesc, String tableQualifiedName, String sdQualifiedName, Id tableId) throws AtlasHookException { LOG.debug("Filling storage descriptor information for {}", storageDesc); Referenceable sdReferenceable = new Referenceable(HiveDataTypes.HIVE_STORAGEDESC.getName()); sdReferenceable.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, sdQualifiedName); SerDeInfo serdeInfo = storageDesc.getSerdeInfo(); LOG.debug("serdeInfo = {}", serdeInfo); // SkewedInfo skewedInfo = storageDesc.getSkewedInfo(); String serdeInfoName = HiveDataTypes.HIVE_SERDE.getName(); Struct serdeInfoStruct = new Struct(serdeInfoName); serdeInfoStruct.set(AtlasClient.NAME, serdeInfo.getName()); serdeInfoStruct.set("serializationLib", serdeInfo.getSerializationLib()); serdeInfoStruct.set(PARAMETERS, serdeInfo.getParameters()); sdReferenceable.set("serdeInfo", serdeInfoStruct); sdReferenceable.set(STORAGE_NUM_BUCKETS, storageDesc.getNumBuckets()); sdReferenceable .set(STORAGE_IS_STORED_AS_SUB_DIRS, storageDesc.isStoredAsSubDirectories()); List<Struct> sortColsStruct = new ArrayList<>(); for (Order sortcol : storageDesc.getSortCols()) { String hiveOrderName = HiveDataTypes.HIVE_ORDER.getName(); Struct colStruct = new Struct(hiveOrderName); colStruct.set("col", sortcol.getCol()); colStruct.set("order", sortcol.getOrder()); sortColsStruct.add(colStruct); } if (sortColsStruct.size() > 0) { sdReferenceable.set("sortCols", sortColsStruct); } sdReferenceable.set(LOCATION, storageDesc.getLocation()); sdReferenceable.set("inputFormat", storageDesc.getInputFormat()); sdReferenceable.set("outputFormat", storageDesc.getOutputFormat()); sdReferenceable.set("compressed", storageDesc.isCompressed()); if (storageDesc.getBucketCols().size() > 0) { sdReferenceable.set("bucketCols", storageDesc.getBucketCols()); } sdReferenceable.set(PARAMETERS, storageDesc.getParameters()); sdReferenceable.set("storedAsSubDirectories", storageDesc.isStoredAsSubDirectories()); sdReferenceable.set(TABLE, tableId); return sdReferenceable; }