Search in sources :

Example 41 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalColumnSchemaForDatatypeNullCase.

@Test
public void testFromWrapperToExternalColumnSchemaForDatatypeNullCase() {
    org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.INT, "columnName", "1", true, encoders, true);
    thriftColumnSchema.setSchemaOrdinal(1);
    thriftColumnSchema.setAggregate_function("");
    new MockUp<ColumnSchema>() {

        @Mock
        public List<Encoding> getEncodingList() {
            return encodings;
        }

        @Mock
        public int getSchemaOrdinal() {
            return 1;
        }

        @Mock
        public DataType getDataType() {
            return DataTypes.INT;
        }

        @Mock
        public String getColumnName() {
            return "columnName";
        }

        @Mock
        public String getColumnUniqueId() {
            return "1";
        }

        @Mock
        public boolean isColumnar() {
            return true;
        }

        @Mock
        public boolean isDimensionColumn() {
            return true;
        }

        @Mock
        public int getColumnGroupId() {
            return 1;
        }

        @Mock
        public int getScale() {
            return 1;
        }

        @Mock
        public int getPrecision() {
            return 1;
        }

        @Mock
        public int getNumberOfChild() {
            return 1;
        }

        @Mock
        public byte[] getDefaultValue() {
            return new byte[] { 1, 2 };
        }

        @Mock
        public Map<String, String> getColumnProperties() {
            return columnPropertyMap;
        }

        @Mock
        public boolean isInvisible() {
            return true;
        }

        @Mock
        public String getColumnReferenceId() {
            return "1";
        }
    };
    ColumnSchema wrapperColumnSchema = new ColumnSchema();
    org.apache.carbondata.format.ColumnSchema actualResult = thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
    assertEquals(thriftColumnSchema, actualResult);
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) MockUp(mockit.MockUp) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) Test(org.junit.Test)

Example 42 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method testFromExternalToWrapperColumnSchemaForStructDatatype.

@Test
public void testFromExternalToWrapperColumnSchemaForStructDatatype() {
    org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.STRUCT, "columnName", "1", true, encoders, true);
    ColumnSchema actualResult = thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
    Boolean expectedResult = true;
    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Test(org.junit.Test)

Example 43 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method testFromExternalToWrapperColumnSchemaForArrayDatatype.

@Test
public void testFromExternalToWrapperColumnSchemaForArrayDatatype() {
    org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.ARRAY, "columnName", "1", true, encoders, true);
    ColumnSchema actualResult = thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
    Boolean expectedResult = true;
    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Test(org.junit.Test)

Example 44 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalSchemaEvolution.

@Test
public void testFromWrapperToExternalSchemaEvolution() {
    SchemaEvolution schemaEvolution = new SchemaEvolution();
    new MockUp<SchemaEvolutionEntry>() {

        @Mock
        public List<ColumnSchema> getAdded() {
            return columnSchemas;
        }

        @Mock
        public List<ColumnSchema> getRemoved() {
            return columnSchemas;
        }
    };
    new MockUp<ColumnSchema>() {

        @Mock
        public List<Encoding> getEncodingList() {
            return encodings;
        }

        @Mock
        public int getSchemaOrdinal() {
            return 1;
        }

        @Mock
        public DataType getDataType() {
            return DataTypes.BOOLEAN;
        }

        @Mock
        public String getColumnName() {
            return "columnName";
        }

        @Mock
        public String getColumnUniqueId() {
            return "1";
        }

        @Mock
        public boolean isColumnar() {
            return true;
        }

        @Mock
        public boolean isDimensionColumn() {
            return true;
        }

        @Mock
        public int getColumnGroupId() {
            return 1;
        }

        @Mock
        public int getScale() {
            return 1;
        }

        @Mock
        public int getPrecision() {
            return 1;
        }

        @Mock
        public int getNumberOfChild() {
            return 1;
        }

        @Mock
        public byte[] getDefaultValue() {
            return new byte[] { 1, 2 };
        }

        @Mock
        public Map<String, String> getColumnProperties() {
            return columnPropertyMap;
        }

        @Mock
        public boolean isInvisible() {
            return true;
        }

        @Mock
        public String getColumnReferenceId() {
            return "1";
        }
    };
    List<org.apache.carbondata.format.SchemaEvolutionEntry> thriftSchemaEvolutionEntries = new ArrayList<>();
    thriftSchemaEvolutionEntries.add(schemaEvolEntry);
    org.apache.carbondata.format.SchemaEvolution actualResult = thriftWrapperSchemaConverter.fromWrapperToExternalSchemaEvolution(schemaEvolution);
    org.apache.carbondata.format.SchemaEvolution expectedResult = new org.apache.carbondata.format.SchemaEvolution(thriftSchemaEvolutionEntries);
    assertEquals(expectedResult, actualResult);
}
Also used : ArrayList(java.util.ArrayList) SchemaEvolution(org.apache.carbondata.core.metadata.schema.SchemaEvolution) MockUp(mockit.MockUp) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) SchemaEvolutionEntry(org.apache.carbondata.core.metadata.schema.SchemaEvolutionEntry) Test(org.junit.Test)

Example 45 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method setUp.

@BeforeClass
public static void setUp() {
    thriftWrapperSchemaConverter = new ThriftWrapperSchemaConverterImpl();
    schemaEvolEntry = new org.apache.carbondata.format.SchemaEvolutionEntry();
    schemaEvolutionEntries = new ArrayList();
    schemaEvolutionEntries.add(new SchemaEvolutionEntry());
    columnSchemas = new ArrayList();
    columnSchemas.add(new ColumnSchema());
    encodings = new ArrayList<>();
    encodings.add(Encoding.INVERTED_INDEX);
    encodings.add(Encoding.DELTA);
    encodings.add(Encoding.BIT_PACKED);
    encodings.add(Encoding.DICTIONARY);
    encodings.add(Encoding.RLE);
    encodings.add(Encoding.DIRECT_DICTIONARY);
    encoders = new ArrayList<org.apache.carbondata.format.Encoding>();
    encoders.add(org.apache.carbondata.format.Encoding.INVERTED_INDEX);
    encoders.add(org.apache.carbondata.format.Encoding.DELTA);
    encoders.add(org.apache.carbondata.format.Encoding.BIT_PACKED);
    encoders.add(org.apache.carbondata.format.Encoding.DICTIONARY);
    encoders.add(org.apache.carbondata.format.Encoding.RLE);
    encoders.add(org.apache.carbondata.format.Encoding.DIRECT_DICTIONARY);
    columnPropertyMap = new HashMap<String, String>();
    columnPropertyMap.put("property", "value");
    thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.STRING, "columnName", "1", true, encoders, true);
    thriftColumnSchema.setSchemaOrdinal(1);
    thriftColumnSchema.setAggregate_function("");
    thriftColumnSchemas = new ArrayList<org.apache.carbondata.format.ColumnSchema>();
    thriftColumnSchemas.add(thriftColumnSchema);
    thriftSchemaEvolutionEntries = new ArrayList<>();
    thriftSchemaEvolutionEntries.add(schemaEvolEntry);
    schemaEvol = new org.apache.carbondata.format.SchemaEvolution(thriftSchemaEvolutionEntries);
    new MockUp<SchemaEvolution>() {

        @Mock
        public List<SchemaEvolutionEntry> getSchemaEvolutionEntryList() {
            return schemaEvolutionEntries;
        }
    };
    new MockUp<org.apache.carbondata.format.SchemaEvolutionEntry>() {

        @Mock
        public org.apache.carbondata.format.SchemaEvolutionEntry setAdded(List<org.apache.carbondata.format.ColumnSchema> added) {
            return schemaEvolEntry;
        }

        @Mock
        public org.apache.carbondata.format.SchemaEvolutionEntry setRemoved(List<org.apache.carbondata.format.ColumnSchema> removed) {
            return schemaEvolEntry;
        }

        @Mock
        public long getTime_stamp() {
            return 1112745600000L;
        }

        @Mock
        public List<org.apache.carbondata.format.ColumnSchema> getAdded() {
            return thriftColumnSchemas;
        }

        @Mock
        public List<org.apache.carbondata.format.ColumnSchema> getRemoved() {
            return thriftColumnSchemas;
        }
    };
    new MockUp<org.apache.carbondata.format.ColumnSchema>() {

        @Mock
        public org.apache.carbondata.format.ColumnSchema setColumn_group_id(int column_group_id) {
            return thriftColumnSchema;
        }

        @Mock
        public org.apache.carbondata.format.ColumnSchema setScale(int scale) {
            return thriftColumnSchema;
        }

        @Mock
        public org.apache.carbondata.format.ColumnSchema setPrecision(int precision) {
            return thriftColumnSchema;
        }

        @Mock
        public org.apache.carbondata.format.ColumnSchema setNum_child(int num_child) {
            return thriftColumnSchema;
        }

        @Mock
        public org.apache.carbondata.format.ColumnSchema setDefault_value(byte[] default_value) {
            return thriftColumnSchema;
        }

        @Mock
        public org.apache.carbondata.format.ColumnSchema setColumnProperties(Map<String, String> columnProperties) {
            return thriftColumnSchema;
        }

        @Mock
        public org.apache.carbondata.format.ColumnSchema setInvisible(boolean invisible) {
            return thriftColumnSchema;
        }

        @Mock
        public org.apache.carbondata.format.ColumnSchema setColumnReferenceId(String columnReferenceId) {
            return thriftColumnSchema;
        }

        @Mock
        public String getColumn_id() {
            return "1";
        }

        @Mock
        public String getColumn_name() {
            return "columnName";
        }

        @Mock
        public boolean isColumnar() {
            return true;
        }

        @Mock
        public boolean isDimension() {
            return true;
        }

        @Mock
        public List<org.apache.carbondata.format.Encoding> getEncoders() {
            return encoders;
        }

        @Mock
        public int getNum_child() {
            return 1;
        }

        @Mock
        public int getPrecision() {
            return 1;
        }

        @Mock
        public int getColumn_group_id() {
            return 1;
        }

        @Mock
        public int getScale() {
            return 1;
        }

        @Mock
        public byte[] getDefault_value() {
            return new byte[] { 1, 2 };
        }

        @Mock
        public String getAggregate_function() {
            return "";
        }

        @Mock
        public Map<String, String> getColumnProperties() {
            return columnPropertyMap;
        }

        @Mock
        public boolean isInvisible() {
            return true;
        }

        @Mock
        public String getColumnReferenceId() {
            return "1";
        }
    };
    final Map mapTableProperties = new HashMap<String, String>();
    tabSchema = new org.apache.carbondata.format.TableSchema();
    new MockUp<org.apache.carbondata.format.TableSchema>() {

        @Mock
        public org.apache.carbondata.format.TableSchema setTableProperties(Map<String, String> tableProperties) {
            return tabSchema;
        }

        @Mock
        public String getTable_id() {
            return "1";
        }

        @Mock
        public Map<String, String> getTableProperties() {
            return mapTableProperties;
        }

        @Mock
        public List<org.apache.carbondata.format.ColumnSchema> getTable_columns() {
            return thriftColumnSchemas;
        }

        @Mock
        public org.apache.carbondata.format.SchemaEvolution getSchema_evolution() {
            return schemaEvol;
        }
    };
    new MockUp<org.apache.carbondata.format.SchemaEvolution>() {

        @Mock
        public List<org.apache.carbondata.format.SchemaEvolutionEntry> getSchema_evolution_history() {
            return thriftSchemaEvolutionEntries;
        }
    };
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) MockUp(mockit.MockUp) SchemaEvolutionEntry(org.apache.carbondata.core.metadata.schema.SchemaEvolutionEntry) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) BeforeClass(org.junit.BeforeClass)

Aggregations

ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)164 ArrayList (java.util.ArrayList)80 Test (org.junit.Test)63 Encoding (org.apache.carbondata.core.metadata.encoder.Encoding)61 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)33 MockUp (mockit.MockUp)29 TableSchema (org.apache.carbondata.core.metadata.schema.table.TableSchema)14 DataFileFooter (org.apache.carbondata.core.metadata.blocklet.DataFileFooter)13 HashMap (java.util.HashMap)12 SchemaEvolutionEntry (org.apache.carbondata.core.metadata.schema.SchemaEvolutionEntry)11 TableInfo (org.apache.carbondata.core.metadata.schema.table.TableInfo)10 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)10 SchemaEvolution (org.apache.carbondata.core.metadata.schema.SchemaEvolution)9 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)8 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)8 Map (java.util.Map)7 SegmentInfo (org.apache.carbondata.core.metadata.blocklet.SegmentInfo)7 BlockletInfo (org.apache.carbondata.core.metadata.blocklet.BlockletInfo)6 BlockletIndex (org.apache.carbondata.core.metadata.blocklet.index.BlockletIndex)6 ThriftWrapperSchemaConverterImpl (org.apache.carbondata.core.metadata.converter.ThriftWrapperSchemaConverterImpl)6