]> git.proxmox.com Git - ceph.git/blame - ceph/src/arrow/java/c/src/test/java/org/apache/arrow/c/FlagsTest.java
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / java / c / src / test / java / org / apache / arrow / c / FlagsTest.java
CommitLineData
1d09f67e
TL
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package org.apache.arrow.c;
19
20import static org.junit.jupiter.api.Assertions.assertEquals;
21
22import java.util.ArrayList;
23
24import org.apache.arrow.c.Flags;
25import org.apache.arrow.vector.types.pojo.ArrowType;
26import org.apache.arrow.vector.types.pojo.DictionaryEncoding;
27import org.apache.arrow.vector.types.pojo.Field;
28import org.apache.arrow.vector.types.pojo.FieldType;
29import org.junit.jupiter.api.Test;
30
31public class FlagsTest {
32 @Test
33 public void testForFieldNullableOrderedDict() {
34 FieldType fieldType = new FieldType(true, ArrowType.Binary.INSTANCE,
35 new DictionaryEncoding(123L, true, new ArrowType.Int(8, true)));
36
37 assertEquals(Flags.ARROW_FLAG_DICTIONARY_ORDERED | Flags.ARROW_FLAG_NULLABLE,
38 Flags.forField(new Field("Name", fieldType, new ArrayList<>())));
39 }
40
41 @Test
42 public void testForFieldOrderedDict() {
43 FieldType fieldType = new FieldType(false, ArrowType.Binary.INSTANCE,
44 new DictionaryEncoding(123L, true, new ArrowType.Int(8, true)));
45 assertEquals(Flags.ARROW_FLAG_DICTIONARY_ORDERED, Flags.forField(new Field("Name", fieldType, new ArrayList<>())));
46 }
47
48 @Test
49 public void testForFieldNullableDict() {
50 FieldType fieldType = new FieldType(true, ArrowType.Binary.INSTANCE,
51 new DictionaryEncoding(123L, false, new ArrowType.Int(8, true)));
52 assertEquals(Flags.ARROW_FLAG_NULLABLE, Flags.forField(new Field("Name", fieldType, new ArrayList<>())));
53 }
54
55 @Test
56 public void testForFieldNullable() {
57 FieldType fieldType = new FieldType(true, ArrowType.Binary.INSTANCE, null);
58 assertEquals(Flags.ARROW_FLAG_NULLABLE, Flags.forField(new Field("Name", fieldType, new ArrayList<>())));
59 }
60
61 @Test
62 public void testForFieldNullableOrderedSortedMap() {
63 ArrowType.Map type = new ArrowType.Map(true);
64 FieldType fieldType = new FieldType(true, type, new DictionaryEncoding(123L, true, new ArrowType.Int(8, true)));
65 assertEquals(Flags.ARROW_FLAG_DICTIONARY_ORDERED | Flags.ARROW_FLAG_NULLABLE | Flags.ARROW_FLAG_MAP_KEYS_SORTED,
66 Flags.forField(new Field("Name", fieldType, new ArrayList<>())));
67 }
68
69 @Test
70 public void testForFieldNullableOrderedMap() {
71 ArrowType.Map type = new ArrowType.Map(false);
72 FieldType fieldType = new FieldType(true, type, new DictionaryEncoding(123L, true, new ArrowType.Int(8, true)));
73 assertEquals(Flags.ARROW_FLAG_DICTIONARY_ORDERED | Flags.ARROW_FLAG_NULLABLE,
74 Flags.forField(new Field("Name", fieldType, new ArrayList<>())));
75 }
76}