Search in sources :

Example 41 with Encoding

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

the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalColumnSchemaForDoubleDatatype.

@Test
public void testFromWrapperToExternalColumnSchemaForDoubleDatatype() {
    org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.DOUBLE, "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.DOUBLE;
        }

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

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

the class CarbonTableTest method getColumnarDimensionColumn.

private ColumnSchema getColumnarDimensionColumn() {
    ColumnSchema dimColumn = new ColumnSchema();
    dimColumn.setColumnar(true);
    dimColumn.setColumnName("IMEI");
    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
    dimColumn.setDataType(DataType.STRING);
    dimColumn.setDimensionColumn(true);
    List<Encoding> encodeList = new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
    encodeList.add(Encoding.DICTIONARY);
    dimColumn.setEncodingList(encodeList);
    dimColumn.setNumberOfChild(0);
    return dimColumn;
}
Also used : ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding)

Example 43 with Encoding

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

the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalColumnSchemaForShortDatatype.

@Test
public void testFromWrapperToExternalColumnSchemaForShortDatatype() {
    org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.SHORT, "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.SHORT;
        }

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

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

the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalColumnSchemaWhenEncoderIsNull.

@Test
public void testFromWrapperToExternalColumnSchemaWhenEncoderIsNull() {
    final List<Encoding> encoding = new ArrayList<>();
    encoding.add(Encoding.INVERTED_INDEX);
    encoding.add(null);
    new MockUp<ColumnSchema>() {

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

        @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";
        }
    };
    List<Encoding> encodings = null;
    encodings = new ArrayList<>();
    encodings.add(Encoding.INVERTED_INDEX);
    encodings.add(null);
    List<org.apache.carbondata.format.Encoding> encoders = null;
    encoders = new ArrayList<org.apache.carbondata.format.Encoding>();
    encoders.add(org.apache.carbondata.format.Encoding.INVERTED_INDEX);
    encoders.add(null);
    org.apache.carbondata.format.ColumnSchema thriftColumnSchema = null;
    thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.STRING, "columnName", "1", true, encoders, true);
    thriftColumnSchema.setSchemaOrdinal(1);
    ColumnSchema wrapperColumnSchema = new ColumnSchema();
    org.apache.carbondata.format.ColumnSchema actualResult = thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
    assertEquals(thriftColumnSchema, actualResult);
}
Also used : ArrayList(java.util.ArrayList) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) MockUp(mockit.MockUp) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Test(org.junit.Test)

Example 45 with Encoding

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

the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalColumnSchemaForLongDatatype.

@Test
public void testFromWrapperToExternalColumnSchemaForLongDatatype() {
    org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.LONG, "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.LONG;
        }

        @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)

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