001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.marshall.parquet;
018
019import static java.lang.annotation.ElementType.*;
020import static java.lang.annotation.RetentionPolicy.*;
021
022import java.lang.annotation.*;
023
024import org.apache.juneau.marshall.*;
025
026/**
027 * Annotation for configuring Parquet serializer/parser on classes and methods.
028 *
029 * @see ParquetSerializer
030 * @see ParquetParser
031 */
032@Documented
033@Target({ TYPE, METHOD })
034@Retention(RUNTIME)
035@Inherited
036@Repeatable(ParquetConfigAnnotation.Array.class)
037@ContextApply({ ParquetConfigAnnotation.SerializerApply.class, ParquetConfigAnnotation.ParserApply.class })
038public @interface ParquetConfig {
039
040   /**
041    * Compression codec used when <b>writing</b> (<js>"UNCOMPRESSED"</js> or <js>"GZIP"</js>, case-insensitive).
042    *
043    * <p>
044    * Any other value fails fast with an {@link IllegalArgumentException} naming the bad value and the valid write
045    * codecs.  This includes unknown names (typos) and <js>"SNAPPY"</js>, which the parser can decode but the
046    * serializer cannot write.  The parser detects the codec from the file and ignores this setting.
047    */
048   String compressionCodec() default "";
049
050   /** Row group size in bytes. */
051   String rowGroupSize() default "";
052
053   /** Page size in bytes. */
054   String pageSize() default "";
055
056   /** Add bean types column. */
057   String addBeanTypes() default "";
058
059   /**
060    * Maximum allowed wire-declared length (in bytes) for a single Parquet page (compressed or
061    * uncompressed) when parsing.
062    *
063    * <p>
064    * Guards against malformed or adversarial input where a small file declares a huge per-page byte
065    * size. Default is <js>"268435456"</js> (256 MiB). A value of <js>"0"</js> or less disables the cap.
066    *
067    * @return The annotation value.
068    */
069   String maxLength() default "";
070
071   /**
072    * Maximum allowed wire-declared element count (file/row-group row counts, column-chunk value counts)
073    * when parsing.
074    *
075    * <p>
076    * Guards against malformed or adversarial input where a small footer declares a huge row or value
077    * count. Default is <js>"10000000"</js> (10 million). A value of <js>"0"</js> or less disables the cap.
078    *
079    * @return The annotation value.
080    */
081   String maxCount() default "";
082
083   /**
084    * Maximum allowed size (in bytes) of the whole Parquet input buffered into memory before parsing.
085    *
086    * <p>
087    * Guards against an oversized input being buffered unbounded into memory. Default is
088    * <js>"268435456"</js> (256 MiB). A value of <js>"0"</js> or less disables the cap.
089    *
090    * @return The annotation value.
091    */
092   String maxInputLength() default "";
093
094   /**
095    * Maximum allowed aggregate decompressed-byte total across every Parquet page read during a single
096    * parse.
097    *
098    * <p>
099    * Guards against a decompression bomb assembled from many pages that each individually pass the
100    * per-page {@link #maxLength()} cap. Default is <js>"67108864"</js> (64 MiB). A value of
101    * <js>"0"</js> or less disables the cap.
102    *
103    * @return The annotation value.
104    */
105   String maxDecompressedBytes() default "";
106
107   /** Rank for application order. */
108   int rank() default 0;
109}