Class SchemasUtils
- java.lang.Object
-
- org.apache.beam.examples.complete.datatokenization.utils.SchemasUtils
-
public class SchemasUtils extends java.lang.ObjectTheSchemasUtilsClass to read JSON based schema. Is there available to read from file or from string. Currently supported local File System and GCS.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEADLETTER_SCHEMA
-
Constructor Summary
Constructors Constructor Description SchemasUtils(java.lang.String schema)SchemasUtils(java.lang.String path, java.nio.charset.Charset encoding)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.beam.sdk.schemas.SchemagetBeamSchema()com.google.api.services.bigquery.model.TableSchemagetBigQuerySchema()static java.lang.StringgetGcsFileAsString(java.lang.String filePath)Reads a file from GCS and returns it as a string.java.lang.StringgetJsonBeamSchema()static byte[]readGcsFile(java.lang.String gcsFilePath)Method to read a schema file from GCS and return the file contents as a string.
-
-
-
Field Detail
-
DEADLETTER_SCHEMA
public static final java.lang.String DEADLETTER_SCHEMA
- See Also:
- Constant Field Values
-
-
Method Detail
-
getBigQuerySchema
public com.google.api.services.bigquery.model.TableSchema getBigQuerySchema()
-
readGcsFile
public static byte[] readGcsFile(java.lang.String gcsFilePath) throws java.io.IOExceptionMethod to read a schema file from GCS and return the file contents as a string.- Parameters:
gcsFilePath- path to file in GCS in format "gs://your-bucket/path/to/file"- Returns:
- byte array with file contents
- Throws:
java.io.IOException- thrown if not able to read file
-
getBeamSchema
public org.apache.beam.sdk.schemas.Schema getBeamSchema()
-
getJsonBeamSchema
public java.lang.String getJsonBeamSchema()
-
getGcsFileAsString
public static java.lang.String getGcsFileAsString(java.lang.String filePath)
Reads a file from GCS and returns it as a string.- Parameters:
filePath- path to file in GCS- Returns:
- contents of the file as a string
- Throws:
java.io.IOException- thrown if not able to read file
-
-