use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.
the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalColumnSchemaForStringDatatype.
@Test
public void testFromWrapperToExternalColumnSchemaForStringDatatype() {
org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.STRING, "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.STRING;
}
@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);
}
use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.
the class SegmentPropertiesTestUtil method getDimensionColumn10.
public static ColumnSchema getDimensionColumn10() {
ColumnSchema dimColumn = new ColumnSchema();
dimColumn.setColumnar(false);
dimColumn.setColumnName("IMEI10");
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);
dimColumn.setColumnGroup(1);
return dimColumn;
}
use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.
the class SegmentPropertiesTestUtil method getDimensionColumn2.
public static ColumnSchema getDimensionColumn2() {
ColumnSchema dimColumn = new ColumnSchema();
dimColumn.setColumnar(true);
dimColumn.setColumnName("IMEI1");
dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
dimColumn.setDataType(DataType.STRING);
dimColumn.setDimensionColumn(true);
List<Encoding> encodeList = new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
dimColumn.setEncodingList(encodeList);
dimColumn.setNumberOfChild(0);
return dimColumn;
}
use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.
the class ThriftWrapperSchemaConverterImpl method fromWrapperToExternalColumnSchema.
/* (non-Javadoc)
* convert from wrapper to external column schema
*/
@Override
public org.apache.carbondata.format.ColumnSchema fromWrapperToExternalColumnSchema(ColumnSchema wrapperColumnSchema) {
List<org.apache.carbondata.format.Encoding> encoders = new ArrayList<org.apache.carbondata.format.Encoding>();
for (Encoding encoder : wrapperColumnSchema.getEncodingList()) {
encoders.add(fromWrapperToExternalEncoding(encoder));
}
org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(fromWrapperToExternalDataType(wrapperColumnSchema.getDataType()), wrapperColumnSchema.getColumnName(), wrapperColumnSchema.getColumnUniqueId(), wrapperColumnSchema.isColumnar(), encoders, wrapperColumnSchema.isDimensionColumn());
thriftColumnSchema.setColumn_group_id(wrapperColumnSchema.getColumnGroupId());
thriftColumnSchema.setScale(wrapperColumnSchema.getScale());
thriftColumnSchema.setPrecision(wrapperColumnSchema.getPrecision());
thriftColumnSchema.setNum_child(wrapperColumnSchema.getNumberOfChild());
thriftColumnSchema.setDefault_value(wrapperColumnSchema.getDefaultValue());
thriftColumnSchema.setColumnProperties(wrapperColumnSchema.getColumnProperties());
thriftColumnSchema.setInvisible(wrapperColumnSchema.isInvisible());
thriftColumnSchema.setColumnReferenceId(wrapperColumnSchema.getColumnReferenceId());
thriftColumnSchema.setSchemaOrdinal(wrapperColumnSchema.getSchemaOrdinal());
if (wrapperColumnSchema.isSortColumn()) {
Map<String, String> properties = new HashMap<String, String>();
properties.put(CarbonCommonConstants.SORT_COLUMNS, "true");
thriftColumnSchema.setColumnProperties(properties);
}
return thriftColumnSchema;
}
use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.
the class FilterUtilTest method testPrepareDefaultStartIndexKey.
@Test
public void testPrepareDefaultStartIndexKey() throws KeyGenException {
List<ColumnSchema> columnsInTable = new ArrayList<>();
columnsInTable.add(columnSchema);
int[] columnCardinality = new int[] { 1, 2 };
new MockUp<ColumnSchema>() {
@Mock
public List<Encoding> getEncodingList() {
List<Encoding> encodingList = new ArrayList<>();
encodingList.add(Encoding.DICTIONARY);
return encodingList;
}
};
SegmentProperties segmentProperties = new SegmentProperties(columnsInTable, columnCardinality);
assertTrue(FilterUtil.prepareDefaultStartIndexKey(segmentProperties) instanceof IndexKey);
}
Aggregations