/** * convert external thrift BlockletMinMaxIndex to BlockletMinMaxIndex of carbon metadata */ public static org.apache.carbondata.core.metadata.blocklet.index.BlockletMinMaxIndex convertExternalMinMaxIndex(BlockletMinMaxIndex minMaxIndex) { if (minMaxIndex == null) { return null; } List<Boolean> isMinMaxSet = null; if (minMaxIndex.isSetMin_max_presence()) { isMinMaxSet = minMaxIndex.getMin_max_presence(); } else { Boolean[] minMaxFlag = new Boolean[minMaxIndex.getMax_values().size()]; Arrays.fill(minMaxFlag, true); isMinMaxSet = Arrays.asList(minMaxFlag); } return new org.apache.carbondata.core.metadata.blocklet.index.BlockletMinMaxIndex( minMaxIndex.getMin_values(), minMaxIndex.getMax_values(), isMinMaxSet); }
/** * convert BlockletMinMaxIndex of carbon metadata to external thrift BlockletMinMaxIndex */ public static BlockletMinMaxIndex convertMinMaxIndex( org.apache.carbondata.core.metadata.blocklet.index.BlockletMinMaxIndex minMaxIndex) { if (minMaxIndex == null) { return null; } BlockletMinMaxIndex blockletMinMaxIndex = new BlockletMinMaxIndex(); for (int i = 0; i < minMaxIndex.getMaxValues().length; i++) { blockletMinMaxIndex.addToMax_values(ByteBuffer.wrap(minMaxIndex.getMaxValues()[i])); blockletMinMaxIndex.addToMin_values(ByteBuffer.wrap(minMaxIndex.getMinValues()[i])); blockletMinMaxIndex.addToMin_max_presence(minMaxIndex.getIsMinMaxSet()[i]); } return blockletMinMaxIndex; }
public void setFieldValue(_Fields field, Object value) { switch (field) { case MIN_VALUES: if (value == null) { unsetMin_values(); } else { setMin_values((List<ByteBuffer>)value); } break; case MAX_VALUES: if (value == null) { unsetMax_values(); } else { setMax_values((List<ByteBuffer>)value); } break; case MIN_MAX_PRESENCE: if (value == null) { unsetMin_max_presence(); } else { setMin_max_presence((List<Boolean>)value); } break; } }
public Object getFieldValue(_Fields field) { switch (field) { case MIN_VALUES: return getMin_values(); case MAX_VALUES: return getMax_values(); case MIN_MAX_PRESENCE: return getMin_max_presence(); } throw new IllegalStateException(); }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case MIN_VALUES: return isSetMin_values(); case MAX_VALUES: return isSetMax_values(); case MIN_MAX_PRESENCE: return isSetMin_max_presence(); } throw new IllegalStateException(); }
MeasureRawColumnChunk getMeasureRawColumnChunk(FileReader fileReader, int columnIndex, long offset, int dataLength, ByteBuffer buffer, DataChunk3 dataChunk) { // creating a raw chunks instance and filling all the details MeasureRawColumnChunk rawColumnChunk = new MeasureRawColumnChunk(columnIndex, buffer, offset, dataLength, this); int numberOfPages = dataChunk.getPage_length().size(); byte[][] maxValueOfEachPage = new byte[numberOfPages][]; byte[][] minValueOfEachPage = new byte[numberOfPages][]; int[] eachPageLength = new int[numberOfPages]; for (int i = 0; i < minValueOfEachPage.length; i++) { maxValueOfEachPage[i] = dataChunk.getData_chunk_list().get(i).getMin_max().getMax_values().get(0).array(); minValueOfEachPage[i] = dataChunk.getData_chunk_list().get(i).getMin_max().getMin_values().get(0).array(); eachPageLength[i] = dataChunk.getData_chunk_list().get(i).getNumberOfRowsInpage(); } rawColumnChunk.setDataChunkV3(dataChunk); rawColumnChunk.setFileReader(fileReader); rawColumnChunk.setPagesCount(dataChunk.getPage_length().size()); rawColumnChunk.setMaxValues(maxValueOfEachPage); rawColumnChunk.setMinValues(minValueOfEachPage); rawColumnChunk.setRowCount(eachPageLength); rawColumnChunk.setOffsets(ArrayUtils .toPrimitive(dataChunk.page_offset.toArray(new Integer[dataChunk.page_offset.size()]))); return rawColumnChunk; }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, BlockletIndex struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.min_max_index = new BlockletMinMaxIndex(); struct.min_max_index.read(iprot); struct.setMin_max_indexIsSet(true); } if (incoming.get(1)) { struct.b_tree_index = new BlockletBTreeIndex(); struct.b_tree_index.read(iprot); struct.setB_tree_indexIsSet(true); } } }
public static BlockletIndex getBlockletIndex(EncodedBlocklet encodedBlocklet, List<CarbonMeasure> carbonMeasureList) { BlockletMinMaxIndex blockletMinMaxIndex = new BlockletMinMaxIndex(); blockletMinMaxIndex.addToMax_values(ByteBuffer.wrap(max)); blockletMinMaxIndex.addToMin_values(ByteBuffer.wrap(min)); blockletMinMaxIndex.addToMax_values(ByteBuffer.wrap(max)); blockletMinMaxIndex.addToMin_values(ByteBuffer.wrap(min));
public BlockletMinMaxIndex deepCopy() { return new BlockletMinMaxIndex(this); }
public void write(org.apache.thrift.protocol.TProtocol oprot, BlockletMinMaxIndex struct) throws org.apache.thrift.TException { struct.validate(); if (struct.isSetMin_max_presence()) { oprot.writeFieldBegin(MIN_MAX_PRESENCE_FIELD_DESC);
if (isSetMin_max_presence()) { if (!first) sb.append(", "); sb.append("min_max_presence:");
blockletMinMaxIndex.setMin_max_presence(min_max_presence); return min_max_presence;
index.b_tree_index.getEnd_key()); BlockletMinMaxIndex minMaxIndex = new BlockletMinMaxIndex(index.getMin_max_index().getMin_values(), index.getMin_max_index().getMax_values(), index.getMin_max_index().getMin_max_presence()); org.apache.carbondata.core.metadata.blocklet.index.BlockletIndex bIndex = new org.apache.carbondata.core.metadata.blocklet.index.BlockletIndex(bTreeIndex,
/** * Performs a deep copy on <i>other</i>. */ public BlockletMinMaxIndex(BlockletMinMaxIndex other) { if (other.isSetMin_values()) { List<ByteBuffer> __this__min_values = new ArrayList<ByteBuffer>(other.min_values); this.min_values = __this__min_values; } if (other.isSetMax_values()) { List<ByteBuffer> __this__max_values = new ArrayList<ByteBuffer>(other.max_values); this.max_values = __this__max_values; } if (other.isSetMin_max_presence()) { List<Boolean> __this__min_max_presence = new ArrayList<Boolean>(other.min_max_presence); this.min_max_presence = __this__min_max_presence; } }
case 1: // MIN_MAX_INDEX if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.min_max_index = new BlockletMinMaxIndex(); struct.min_max_index.read(iprot); struct.setMin_max_indexIsSet(true); } else {
/** * Performs a deep copy on <i>other</i>. */ public BlockletIndex(BlockletIndex other) { if (other.isSetMin_max_index()) { this.min_max_index = new BlockletMinMaxIndex(other.min_max_index); } if (other.isSetB_tree_index()) { this.b_tree_index = new BlockletBTreeIndex(other.b_tree_index); } }
if (struct.isSetMin_max_presence()) { optionals.set(0); if (struct.isSetMin_max_presence()) {
/** * Below method will be used to convert the blocklet index of thrift to * wrapper * * @param blockletIndexThrift * @return blocklet index wrapper */ protected BlockletIndex getBlockletIndex( org.apache.carbondata.format.BlockletIndex blockletIndexThrift) { org.apache.carbondata.format.BlockletBTreeIndex btreeIndex = blockletIndexThrift.getB_tree_index(); org.apache.carbondata.format.BlockletMinMaxIndex minMaxIndex = blockletIndexThrift.getMin_max_index(); List<Boolean> isMinMaxSet = null; // Below logic is added to handle backward compatibility if (minMaxIndex.isSetMin_max_presence()) { isMinMaxSet = minMaxIndex.getMin_max_presence(); } else { Boolean[] minMaxFlag = new Boolean[minMaxIndex.getMax_values().size()]; Arrays.fill(minMaxFlag, true); isMinMaxSet = Arrays.asList(minMaxFlag); } return new BlockletIndex( new BlockletBTreeIndex(btreeIndex.getStart_key(), btreeIndex.getEnd_key()), new BlockletMinMaxIndex(minMaxIndex.getMin_values(), minMaxIndex.getMax_values(), isMinMaxSet)); }
@Override public int hashCode() { List<Object> list = new ArrayList<Object>(); boolean present_min_values = true && (isSetMin_values()); list.add(present_min_values); if (present_min_values) list.add(min_values); boolean present_max_values = true && (isSetMax_values()); list.add(present_max_values); if (present_max_values) list.add(max_values); boolean present_min_max_presence = true && (isSetMin_max_presence()); list.add(present_min_max_presence); if (present_min_max_presence) list.add(min_max_presence); return list.hashCode(); }
private BlockletMinMaxIndex buildMinMaxIndex(ColumnPage inputPage, List<Encoding> encoders) { BlockletMinMaxIndex index = new BlockletMinMaxIndex(); ByteBuffer max; ByteBuffer min; if (CarbonUtil.isEncodedWithMeta(encoders) && inputPage.getColumnSpec().getColumnType() == ColumnType.PLAIN_VALUE) { max = ByteBuffer.wrap(DataTypeUtil .getMinMaxBytesBasedOnDataTypeForNoDictionaryColumn(inputPage.getStatistics().getMax(), inputPage.getDataType())); min = ByteBuffer.wrap(DataTypeUtil .getMinMaxBytesBasedOnDataTypeForNoDictionaryColumn(inputPage.getStatistics().getMin(), inputPage.getDataType())); } else { byte[] bytes = CarbonUtil.getValueAsBytes(inputPage.getDataType(), inputPage.getStatistics().getMax()); max = ByteBuffer.wrap(bytes); min = ByteBuffer.wrap( CarbonUtil.getValueAsBytes(inputPage.getDataType(), inputPage.getStatistics().getMin())); } index.addToMax_values(max); index.addToMin_values(min); index.addToMin_max_presence(inputPage.getStatistics().writeMinMax()); return index; }