org.kitesdk.data.Formats Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kite-data-core Show documentation
Show all versions of kite-data-core Show documentation
The Kite Data Core module provides simple, intuitive APIs for working with
datasets in the Hadoop Platform.
The newest version!
/**
* Copyright 2013 Cloudera Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kitesdk.data;
import static org.kitesdk.data.CompressionType.*;
/**
*
* Contains constant definitions for the standard {@link Format} instances
* supported by the library. {@link #AVRO} is the default format.
*
*
* @since 0.2.0
*/
public class Formats {
private Formats() {
}
/**
* AVRO: the
*
* Avro row-oriented format
*/
public static final Format AVRO = new Format("avro", Snappy,
new CompressionType[] { Uncompressed, Snappy, Deflate, Bzip2 });
/**
* PARQUET: the Parquet columnar format
*/
public static final Format PARQUET = new Format("parquet", Snappy,
new CompressionType[] { Uncompressed, Snappy, Deflate });
/**
* JSON: white-space separated json values (read-only).
*
* @since 0.18.0
*/
public static final Format JSON = new Format("json", Uncompressed,
new CompressionType[] { Uncompressed });
/**
* CSV: comma-separated values (read-only).
*
* @since 0.9.0
*/
public static final Format CSV = new Format("csv", Uncompressed,
new CompressionType[] { Uncompressed });
/**
* INPUTFORMAT: a mapreduce InputFormat (read-only).
*
* @since 0.18.0
*/
public static final Format INPUTFORMAT = new Format("inputformat", Uncompressed,
new CompressionType[] { Uncompressed });
/**
* Return a {@link Format} for the format name specified. If {@code formatName}
* is not a valid name, an IllegalArgumentException is thrown. Currently the
* formats avro
, csv
, and parquet
are supported. Format names are
* case sensitive.
*
* @since 0.9.0
* @return an appropriate instance of Format
* @throws IllegalArgumentException if {@code formatName} is not a valid format.
*/
public static Format fromString(String formatName) {
if (formatName.equals("avro")) {
return AVRO;
} else if (formatName.equals("parquet")) {
return PARQUET;
} else if (formatName.equals("json")) {
return JSON;
} else if (formatName.equals("csv")) {
return CSV;
} else if (formatName.equals("inputformat")) {
return INPUTFORMAT;
} else {
throw new IllegalArgumentException("Unknown format type: " + formatName);
}
}
}