Search in sources :

Example 46 with Encoding

use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalColumnSchemaForTimestampDatatype.

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

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

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

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

        @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 47 with Encoding

use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.

the class RestructureUtilTest method testToGetUpdatedQueryDimension.

@Test
public void testToGetUpdatedQueryDimension() {
    BlockExecutionInfo blockExecutionInfo = new BlockExecutionInfo();
    List<Encoding> encodingList = new ArrayList<Encoding>();
    encodingList.add(Encoding.DICTIONARY);
    ColumnSchema columnSchema1 = new ColumnSchema();
    columnSchema1.setColumnName("Id");
    columnSchema1.setColumnUniqueId(UUID.randomUUID().toString());
    columnSchema1.setEncodingList(encodingList);
    ColumnSchema columnSchema2 = new ColumnSchema();
    columnSchema2.setColumnName("Name");
    columnSchema2.setColumnUniqueId(UUID.randomUUID().toString());
    columnSchema2.setEncodingList(encodingList);
    ColumnSchema columnSchema3 = new ColumnSchema();
    columnSchema3.setColumnName("Age");
    columnSchema3.setColumnUniqueId(UUID.randomUUID().toString());
    columnSchema3.setEncodingList(encodingList);
    ColumnSchema columnSchema4 = new ColumnSchema();
    columnSchema4.setColumnName("Salary");
    columnSchema4.setColumnUniqueId(UUID.randomUUID().toString());
    columnSchema4.setEncodingList(encodingList);
    ColumnSchema columnSchema5 = new ColumnSchema();
    columnSchema5.setColumnName("Address");
    columnSchema5.setColumnUniqueId(UUID.randomUUID().toString());
    columnSchema5.setEncodingList(encodingList);
    CarbonDimension tableBlockDimension1 = new CarbonDimension(columnSchema1, 1, 1, 1, 1);
    CarbonDimension tableBlockDimension2 = new CarbonDimension(columnSchema2, 5, 5, 5, 5);
    List<CarbonDimension> tableBlockDimensions = Arrays.asList(tableBlockDimension1, tableBlockDimension2);
    CarbonDimension tableComplexDimension1 = new CarbonDimension(columnSchema3, 4, 4, 4, 4);
    CarbonDimension tableComplexDimension2 = new CarbonDimension(columnSchema4, 2, 2, 2, 2);
    List<CarbonDimension> tableComplexDimensions = Arrays.asList(tableComplexDimension1, tableComplexDimension2);
    QueryDimension queryDimension1 = new QueryDimension("Id");
    queryDimension1.setDimension(tableBlockDimension1);
    QueryDimension queryDimension2 = new QueryDimension("Name");
    queryDimension2.setDimension(tableComplexDimension2);
    QueryDimension queryDimension3 = new QueryDimension("Address");
    queryDimension3.setDimension(new CarbonDimension(columnSchema5, 3, 3, 3, 3));
    List<QueryDimension> queryDimensions = Arrays.asList(queryDimension1, queryDimension2, queryDimension3);
    List<QueryDimension> result = null;
    result = RestructureUtil.createDimensionInfoAndGetCurrentBlockQueryDimension(blockExecutionInfo, queryDimensions, tableBlockDimensions, tableComplexDimensions);
    List<CarbonDimension> resultDimension = new ArrayList<>(result.size());
    for (QueryDimension queryDimension : result) {
        resultDimension.add(queryDimension.getDimension());
    }
    assertThat(resultDimension, is(equalTo(Arrays.asList(queryDimension1.getDimension(), queryDimension2.getDimension()))));
}
Also used : ArrayList(java.util.ArrayList) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) BlockExecutionInfo(org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo) QueryDimension(org.apache.carbondata.core.scan.model.QueryDimension) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) Test(org.junit.Test)

Example 48 with Encoding

use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalColumnSchemaForDecimalDatatype.

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

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

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

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

        @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 49 with Encoding

use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method testFromExternalToWrapperColumnSchemaEncodingNullCase.

@Test
public void testFromExternalToWrapperColumnSchemaEncodingNullCase() {
    final List<org.apache.carbondata.format.Encoding> encoders = new ArrayList<org.apache.carbondata.format.Encoding>();
    encoders.add(org.apache.carbondata.format.Encoding.INVERTED_INDEX);
    encoders.add(null);
    List<Encoding> encodings = new ArrayList<>();
    encodings.add(Encoding.INVERTED_INDEX);
    encodings.add(null);
    final org.apache.carbondata.format.ColumnSchema thriftColSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.STRING, "columnName", "1", true, encoders, true);
    thriftColumnSchema.setSchemaOrdinal(1);
    new MockUp<org.apache.carbondata.format.ColumnSchema>() {

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

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

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

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

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

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

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

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

        @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";
        }
    };
    ColumnSchema actualResult = thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColSchema);
    assertEquals("columnName", actualResult.getColumnName());
}
Also used : ArrayList(java.util.ArrayList) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) MockUp(mockit.MockUp) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 50 with Encoding

use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalColumnSchema.

@Test
public void testFromWrapperToExternalColumnSchema() {
    ColumnSchema wrapperColumnSchema = new ColumnSchema();
    new MockUp<ColumnSchema>() {

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

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

        @Mock
        public DataType getDataType() {
            return DataType.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";
        }
    };
    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)

Aggregations

Encoding (org.apache.carbondata.core.metadata.encoder.Encoding)58 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)56 ArrayList (java.util.ArrayList)45 Test (org.junit.Test)24 MockUp (mockit.MockUp)19 SchemaEvolution (org.apache.carbondata.core.metadata.schema.SchemaEvolution)5 HashMap (java.util.HashMap)4 SchemaEvolutionEntry (org.apache.carbondata.core.metadata.schema.SchemaEvolutionEntry)4 TableSchema (org.apache.carbondata.core.metadata.schema.table.TableSchema)4 Map (java.util.Map)3 TableInfo (org.apache.carbondata.core.metadata.schema.table.TableInfo)3 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)3 QueryDimension (org.apache.carbondata.core.scan.model.QueryDimension)3 AbstractDictionaryCacheTest (org.apache.carbondata.core.cache.dictionary.AbstractDictionaryCacheTest)2 IndexKey (org.apache.carbondata.core.datastore.IndexKey)2 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)2 FileFactory (org.apache.carbondata.core.datastore.impl.FileFactory)2 ValueEncoderMeta (org.apache.carbondata.core.metadata.ValueEncoderMeta)2 DataChunk (org.apache.carbondata.core.metadata.blocklet.datachunk.DataChunk)2 SchemaConverter (org.apache.carbondata.core.metadata.converter.SchemaConverter)2