diff --git a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/sql/avatica/MSQDruidMeta.java b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/sql/avatica/MSQDruidMeta.java index a3333979c83..9f32008b1aa 100644 --- a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/sql/avatica/MSQDruidMeta.java +++ b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/sql/avatica/MSQDruidMeta.java @@ -86,7 +86,7 @@ public class MSQDruidMeta extends DruidMeta } try { String str = objectMapper - .writer(new DruidPrettyPrinter()) + .writerWithDefaultPrettyPrinter() .writeValueAsString(payload.getStages()); str = str.replaceAll(taskId, ""); DruidHook.dispatch(DruidHook.MSQ_PLAN, str); diff --git a/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.exec.MSQQuidemTest/msq1.iq b/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.exec.MSQQuidemTest/msq1.iq index 62e6743d799..619c3e62baa 100644 --- a/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.exec.MSQQuidemTest/msq1.iq +++ b/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.exec.MSQQuidemTest/msq1.iq @@ -40,23 +40,39 @@ order by 1; "type" : "inputNumber", "inputNumber" : 0 }, - "intervals" : {"type" : "intervals","intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ]}, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, "filter" : { "type" : "inType", "column" : "cityName", "matchValueType" : "STRING", "sortedValues" : [ "Aarhus", "New York" ] }, - "granularity" : {"type" : "all"}, - "dimensions" : [ {"type" : "default","dimension" : "cityName","outputName" : "d0","outputType" : "STRING"} ], + "granularity" : { + "type" : "all" + }, + "dimensions" : [ { + "type" : "default", + "dimension" : "cityName", + "outputName" : "d0", + "outputType" : "STRING" + } ], "aggregations" : [ { "type" : "filtered", - "aggregator" : {"type" : "count","name" : "a0"}, + "aggregator" : { + "type" : "count", + "name" : "a0" + }, "filter" : { "type" : "and", "fields" : [ { "type" : "not", - "field" : {"type" : "null","column" : "channel"} + "field" : { + "type" : "null", + "column" : "channel" + } }, { "type" : "range", "column" : "delta", @@ -66,19 +82,33 @@ order by 1; } ] }, "name" : "a0" - }, {"type" : "count","name" : "a1"} ], - "limitSpec" : {"type" : "NoopLimitSpec"}, + }, { + "type" : "count", + "name" : "a1" + } ], + "limitSpec" : { + "type" : "NoopLimitSpec" + }, "context" : { "__user" : null, "finalize" : true, "maxParseExceptions" : 0, "plannerStrategy" : "DECOUPLED", - "sqlQueryId" : "1a672bac-af09-4c2b-b7fb-3dec3bf248f5", + "sqlQueryId" : "d192187f-8ad1-458d-919e-b07a084156e9", "sqlStringifyArrays" : false } } }, - "signature" : [ {"name" : "d0","type" : "STRING"}, {"name" : "a0","type" : "LONG"}, {"name" : "a1","type" : "LONG"} ], + "signature" : [ { + "name" : "d0", + "type" : "STRING" + }, { + "name" : "a0", + "type" : "LONG" + }, { + "name" : "a1", + "type" : "LONG" + } ], "shuffleSpec" : { "type" : "maxCount", "clusterBy" : { @@ -97,8 +127,8 @@ order by 1; "partitionCount" : 1, "shuffle" : "globalSort", "output" : "localStorage", - "startTime" : "2024-07-24T17:13:03.981Z", - "duration" : 692, + "startTime" : "2024-07-24T17:16:24.473Z", + "duration" : 612, "sort" : true }, { "stageNumber" : 1, @@ -116,23 +146,39 @@ order by 1; "type" : "inputNumber", "inputNumber" : 0 }, - "intervals" : {"type" : "intervals","intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ]}, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, "filter" : { "type" : "inType", "column" : "cityName", "matchValueType" : "STRING", "sortedValues" : [ "Aarhus", "New York" ] }, - "granularity" : {"type" : "all"}, - "dimensions" : [ {"type" : "default","dimension" : "cityName","outputName" : "d0","outputType" : "STRING"} ], + "granularity" : { + "type" : "all" + }, + "dimensions" : [ { + "type" : "default", + "dimension" : "cityName", + "outputName" : "d0", + "outputType" : "STRING" + } ], "aggregations" : [ { "type" : "filtered", - "aggregator" : {"type" : "count","name" : "a0"}, + "aggregator" : { + "type" : "count", + "name" : "a0" + }, "filter" : { "type" : "and", "fields" : [ { "type" : "not", - "field" : {"type" : "null","column" : "channel"} + "field" : { + "type" : "null", + "column" : "channel" + } }, { "type" : "range", "column" : "delta", @@ -142,26 +188,40 @@ order by 1; } ] }, "name" : "a0" - }, {"type" : "count","name" : "a1"} ], - "limitSpec" : {"type" : "NoopLimitSpec"}, + }, { + "type" : "count", + "name" : "a1" + } ], + "limitSpec" : { + "type" : "NoopLimitSpec" + }, "context" : { "__user" : null, "finalize" : true, "maxParseExceptions" : 0, "plannerStrategy" : "DECOUPLED", - "sqlQueryId" : "1a672bac-af09-4c2b-b7fb-3dec3bf248f5", + "sqlQueryId" : "d192187f-8ad1-458d-919e-b07a084156e9", "sqlStringifyArrays" : false } } }, - "signature" : [ {"name" : "d0","type" : "STRING"}, {"name" : "a0","type" : "LONG"}, {"name" : "a1","type" : "LONG"} ], + "signature" : [ { + "name" : "d0", + "type" : "STRING" + }, { + "name" : "a0", + "type" : "LONG" + }, { + "name" : "a1", + "type" : "LONG" + } ], "maxWorkerCount" : 1 }, "phase" : "FINISHED", "workerCount" : 1, "partitionCount" : 1, "output" : "localStorage", - "startTime" : "2024-07-24T17:13:04.672Z", + "startTime" : "2024-07-24T17:16:25.085Z", "duration" : 2 } ] !msqPlan diff --git a/processing/src/main/java/org/apache/druid/java/util/common/granularity/AllGranularity.java b/processing/src/main/java/org/apache/druid/java/util/common/granularity/AllGranularity.java index 25a5d338b6d..c7028cec2d5 100644 --- a/processing/src/main/java/org/apache/druid/java/util/common/granularity/AllGranularity.java +++ b/processing/src/main/java/org/apache/druid/java/util/common/granularity/AllGranularity.java @@ -21,7 +21,6 @@ package org.apache.druid.java.util.common.granularity; import com.google.common.collect.ImmutableList; import org.apache.druid.java.util.common.DateTimes; -import org.apache.druid.sql.avatica.DruidPrettyPrinter.Inline; import org.joda.time.DateTime; import org.joda.time.Interval; import org.joda.time.format.DateTimeFormatter; @@ -29,7 +28,6 @@ import org.joda.time.format.DateTimeFormatter; /** * AllGranularty buckets everything into a single bucket */ -@Inline public class AllGranularity extends Granularity { /** diff --git a/processing/src/main/java/org/apache/druid/query/TableDataSource.java b/processing/src/main/java/org/apache/druid/query/TableDataSource.java index a286bbc9748..fe9cf46e37b 100644 --- a/processing/src/main/java/org/apache/druid/query/TableDataSource.java +++ b/processing/src/main/java/org/apache/druid/query/TableDataSource.java @@ -26,7 +26,6 @@ import com.google.common.base.Preconditions; import org.apache.druid.java.util.common.IAE; import org.apache.druid.query.planning.DataSourceAnalysis; import org.apache.druid.segment.SegmentReference; -import org.apache.druid.sql.avatica.DruidPrettyPrinter.Inline; import java.util.Collections; import java.util.List; @@ -36,7 +35,6 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.function.Function; @JsonTypeName("table") -@Inline public class TableDataSource implements DataSource { private final String name; diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/CountAggregatorFactory.java b/processing/src/main/java/org/apache/druid/query/aggregation/CountAggregatorFactory.java index 96d6e713151..7089789f90a 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/CountAggregatorFactory.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/CountAggregatorFactory.java @@ -27,7 +27,6 @@ import org.apache.druid.segment.ColumnInspector; import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.segment.column.ColumnType; import org.apache.druid.segment.vector.VectorColumnSelectorFactory; -import org.apache.druid.sql.avatica.DruidPrettyPrinter.Inline; import javax.annotation.Nullable; import java.util.Comparator; @@ -35,7 +34,6 @@ import java.util.List; /** */ -@Inline public class CountAggregatorFactory extends AggregatorFactory { private final String name; diff --git a/processing/src/main/java/org/apache/druid/query/dimension/DefaultDimensionSpec.java b/processing/src/main/java/org/apache/druid/query/dimension/DefaultDimensionSpec.java index 15268a4f012..5f613e59642 100644 --- a/processing/src/main/java/org/apache/druid/query/dimension/DefaultDimensionSpec.java +++ b/processing/src/main/java/org/apache/druid/query/dimension/DefaultDimensionSpec.java @@ -27,7 +27,6 @@ import org.apache.druid.segment.DimensionSelector; import org.apache.druid.segment.column.ColumnType; import org.apache.druid.segment.vector.MultiValueDimensionVectorSelector; import org.apache.druid.segment.vector.SingleValueDimensionVectorSelector; -import org.apache.druid.sql.avatica.DruidPrettyPrinter.Inline; import javax.annotation.Nullable; import java.util.Objects; @@ -35,7 +34,6 @@ import java.util.Objects; /** * */ -@Inline public class DefaultDimensionSpec implements DimensionSpec { public static DefaultDimensionSpec of(String dimensionName) diff --git a/processing/src/main/java/org/apache/druid/query/filter/NullFilter.java b/processing/src/main/java/org/apache/druid/query/filter/NullFilter.java index 6e7ece31753..cc2bdd2cf63 100644 --- a/processing/src/main/java/org/apache/druid/query/filter/NullFilter.java +++ b/processing/src/main/java/org/apache/druid/query/filter/NullFilter.java @@ -43,14 +43,12 @@ import org.apache.druid.segment.index.BitmapColumnIndex; import org.apache.druid.segment.index.semantic.DruidPredicateIndexes; import org.apache.druid.segment.index.semantic.NullValueIndex; import org.apache.druid.segment.vector.VectorColumnSelectorFactory; -import org.apache.druid.sql.avatica.DruidPrettyPrinter.Inline; import javax.annotation.Nullable; import java.util.Map; import java.util.Objects; import java.util.Set; -@Inline public class NullFilter extends AbstractOptimizableDimFilter implements Filter { public static NullFilter forColumn(String column) diff --git a/processing/src/main/java/org/apache/druid/query/groupby/orderby/NoopLimitSpec.java b/processing/src/main/java/org/apache/druid/query/groupby/orderby/NoopLimitSpec.java index 94d430c73b4..cc5de903a53 100644 --- a/processing/src/main/java/org/apache/druid/query/groupby/orderby/NoopLimitSpec.java +++ b/processing/src/main/java/org/apache/druid/query/groupby/orderby/NoopLimitSpec.java @@ -25,14 +25,12 @@ import com.google.common.base.Functions; import org.apache.druid.java.util.common.guava.Sequence; import org.apache.druid.query.groupby.GroupByQuery; import org.apache.druid.query.groupby.ResultRow; -import org.apache.druid.sql.avatica.DruidPrettyPrinter.Inline; import java.util.Set; /** * */ -@Inline public final class NoopLimitSpec implements LimitSpec { private static final byte CACHE_KEY = 0x0; diff --git a/processing/src/main/java/org/apache/druid/query/spec/MultipleIntervalSegmentSpec.java b/processing/src/main/java/org/apache/druid/query/spec/MultipleIntervalSegmentSpec.java index bfa8c82d379..7afcd2e1324 100644 --- a/processing/src/main/java/org/apache/druid/query/spec/MultipleIntervalSegmentSpec.java +++ b/processing/src/main/java/org/apache/druid/query/spec/MultipleIntervalSegmentSpec.java @@ -25,7 +25,6 @@ import org.apache.druid.java.util.common.JodaUtils; import org.apache.druid.query.Query; import org.apache.druid.query.QueryRunner; import org.apache.druid.query.QuerySegmentWalker; -import org.apache.druid.sql.avatica.DruidPrettyPrinter.Inline; import org.joda.time.Interval; import java.util.List; @@ -33,7 +32,6 @@ import java.util.Objects; /** */ -@Inline public class MultipleIntervalSegmentSpec implements QuerySegmentSpec { private final List intervals; diff --git a/processing/src/main/java/org/apache/druid/segment/column/ColumnSignature.java b/processing/src/main/java/org/apache/druid/segment/column/ColumnSignature.java index ec8d67bcc87..2ea9f960606 100644 --- a/processing/src/main/java/org/apache/druid/segment/column/ColumnSignature.java +++ b/processing/src/main/java/org/apache/druid/segment/column/ColumnSignature.java @@ -23,7 +23,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.druid.java.util.common.IAE; -import org.apache.druid.sql.avatica.DruidPrettyPrinter; import javax.annotation.Nullable; @@ -33,8 +32,7 @@ import javax.annotation.Nullable; * Package-private since it is not intended to be used outside that narrow use case. In other cases where passing * around information about column types is important, use {@link ColumnType} instead. */ -@DruidPrettyPrinter.Inline -public /*FIXME*/ class ColumnSignature +class ColumnSignature { private final String name; diff --git a/processing/src/main/java/org/apache/druid/sql/avatica/DruidPrettyPrinter.java b/processing/src/main/java/org/apache/druid/sql/avatica/DruidPrettyPrinter.java deleted file mode 100644 index 564351395de..00000000000 --- a/processing/src/main/java/org/apache/druid/sql/avatica/DruidPrettyPrinter.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.druid.sql.avatica; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonStreamContext; -import com.fasterxml.jackson.core.util.DefaultIndenter; -import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; - -import java.io.IOException; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Druid specific pretty printer which makes it more readable. - */ -public class DruidPrettyPrinter extends DefaultPrettyPrinter -{ - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.TYPE}) - public static @interface Inline - { - } - - private static final long serialVersionUID = 1L; - private boolean currentIndent = true; - - @Override - public DefaultPrettyPrinter createInstance() - { - return new DruidPrettyPrinter(); - } - - public DruidPrettyPrinter() - { - _objectIndenter = new DruidIndenter(this::shouldIndent); - } - - public boolean shouldIndent(JsonStreamContext ctx) - { - return currentIndent ; - } - - @Override - public void writeStartObject(JsonGenerator g) throws IOException - { - currentIndent = shouldIndentObject(g.getOutputContext()); - super.writeStartObject(g); - } - @Override - public void writeEndObject(JsonGenerator g, int nrOfEntries) throws IOException - { - super.writeEndObject(g, nrOfEntries); - currentIndent = true; - } - - public boolean shouldIndentObject(JsonStreamContext ctx) - { - Object value = ctx.getCurrentValue(); - Object annotation = value.getClass().getAnnotation(Inline.class); - if (annotation != null) { - return false; - } - return true; - } - - static class DruidIndenter implements Indenter - { - private static final Indenter DEFAULT_INDENTER = DefaultIndenter.SYSTEM_LINEFEED_INSTANCE; - - private java.util.function.Predicate predicate; - - public DruidIndenter(java.util.function.Predicate predicate) - { - this.predicate = predicate; - } - - @Override - public void writeIndentation(JsonGenerator g, int level) throws IOException - { - if (predicate.test(g.getOutputContext()) || level < -11) { - DEFAULT_INDENTER.writeIndentation(g, level); - } - } - - @Override - public boolean isInline() - { - return false; - } - } - -} diff --git a/processing/src/main/java/org/apache/druid/sql/avatica/DruidPrettyPrinterTest.java b/processing/src/main/java/org/apache/druid/sql/avatica/DruidPrettyPrinterTest.java deleted file mode 100644 index 828154204fd..00000000000 --- a/processing/src/main/java/org/apache/druid/sql/avatica/DruidPrettyPrinterTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.druid.sql.avatica; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectWriter; -import org.apache.druid.jackson.DefaultObjectMapper; -import org.apache.druid.query.groupby.orderby.LimitSpec; -import org.apache.druid.query.groupby.orderby.NoopLimitSpec; -import org.apache.druid.segment.column.ColumnType; -import org.apache.druid.segment.column.RowSignature; -import org.junit.Test; - -import java.util.List; - -public class DruidPrettyPrinterTest -{ - static class TwoInlined - { - @JsonProperty - final LimitSpec limitSpec = NoopLimitSpec.INSTANCE; - @JsonProperty - final LimitSpec limitSpec2 = NoopLimitSpec.INSTANCE; - } - - @Test - public void prettyPrintTwoInlined() throws Exception - { - ObjectMapper om = new DefaultObjectMapper(); - ObjectWriter w = om.writer(new DruidPrettyPrinter()); - - String s = w.writeValueAsString(new TwoInlined()); - System.out.println(s); - - } - - - static class SampleClass - { - @JsonProperty - final RowSignature rowSignature; - @JsonProperty - final LimitSpec limitSpec; - @JsonProperty - final LimitSpec limitSpec2; - - public SampleClass(RowSignature rs, LimitSpec ls) - { - this.rowSignature = rs; - this.limitSpec = ls; - this.limitSpec2 = ls; - } - } - -@Test - public void prettyPrint1() throws Exception - { - - ObjectMapper om = new DefaultObjectMapper(); - ObjectWriter w = om.writer(new DruidPrettyPrinter()); - - final RowSignature.Builder builder = RowSignature.builder() - .add("s", ColumnType.STRING) - .add("d", ColumnType.DOUBLE) - .add("d1", ColumnType.LONG); - - List cs = builder.build().asColumnSignatures(); - - String s = w.writeValueAsString(new SampleClass(builder.build(), NoopLimitSpec.INSTANCE)); - System.out.println(s); - - } - -} diff --git a/quidem-it/src/main/java/org/apache/druid/quidem/A11.java b/quidem-it/src/main/java/org/apache/druid/quidem/A11.java deleted file mode 100644 index e5ab2dcee39..00000000000 --- a/quidem-it/src/main/java/org/apache/druid/quidem/A11.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.druid.quidem; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.util.DefaultIndenter; -import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; -import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectWriter; -import com.fasterxml.jackson.databind.introspect.AnnotatedMember; -import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; -import org.apache.druid.msq.indexing.report.MSQResultsReport.ColumnAndType; -import org.apache.druid.segment.column.ColumnSignature; -import org.apache.druid.segment.column.ColumnType; -import org.apache.druid.segment.column.RowSignature; -import org.junit.Test; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -public class A11 -{ - static class CustomCollapedIntender implements DefaultPrettyPrinter.Indenter - { - boolean isInside = false; - - @Override - public boolean isInline() - { - return false;// getDelegate().isInline(); - } - - private DefaultPrettyPrinter.Indenter getDelegate() - { - if (isInside) { - return new DefaultPrettyPrinter.NopIndenter(); - } else { - return DefaultIndenter.SYSTEM_LINEFEED_INSTANCE; - - } - } - - @Override - public void writeIndentation(JsonGenerator g, int level) throws IOException - { - if (isX(g)) { - } - isInside = isX(g); - if (isInside) { - int asd = 1; - } - getDelegate().writeIndentation(g, level); - } - - private boolean isX(JsonGenerator g) - { - Object v = g.getCurrentValue(); - -// return v instanceof ColumnSignature; - return false; - // return v instanceof RowSignature; - // return g.getCurrentValue() instanceof List; - - } - - } - - static class aa extends DefaultPrettyPrinter - { - - public aa() - { - super(); - _objectIndenter = new CustomCollapedIntender(); - } - - @Override - public DefaultPrettyPrinter createInstance() - { - return new aa(); - } - - // @Override - // public void writeObjectEntrySeparator(JsonGenerator g) throws IOException - // { - // g.writeRaw(_separators.getObjectEntrySeparator()); - // _objectIndenter.writeIndentation(g, _nesting); - // } - - @Override - public void writeStartArray(JsonGenerator g) throws IOException - { - Object cv = g.getCurrentValue(); - if (isX(g)) { - g.setPrettyPrinter(new MinimalPrettyPrinter()); - } - super.writeStartArray(g); - - } - - @Override - public void writeObjectEntrySeparator(JsonGenerator g) throws IOException - { - - super.writeObjectEntrySeparator(g); - } - - @Override - public void writeStartObject(JsonGenerator g) throws IOException - { - super.writeStartObject(g); - } - - public void writeEndObject1(JsonGenerator g, int nrOfEntries) throws IOException - { - Indenter old = _objectIndenter; - if (isX(g)) { - _objectIndenter = DefaultIndenter.SYSTEM_LINEFEED_INSTANCE; - } - super.writeEndObject(g, nrOfEntries); - if (isX(g)) { - _objectIndenter = old; - } - } - - private boolean isX(JsonGenerator g) - { - Object v = g.getCurrentValue(); - return v instanceof ColumnSignature; - // return g.getCurrentValue() instanceof List; - - } - - @Override - public void writeEndArray(JsonGenerator g, int nrOfValues) throws IOException - { - Object cv = g.getCurrentValue(); - super.writeEndArray(g, nrOfValues); - - } - } - - static class Asd - { - @JsonProperty - int asd = 11; - @JsonProperty - RowSignature rs; - @JsonProperty - ColumnAndType or = new ColumnAndType("Asd", ColumnType.DOUBLE); - - Asd() - { - rs = RowSignature.builder() - .add("s", ColumnType.STRING) - .add("d", ColumnType.DOUBLE) - .add("d1", ColumnType.LONG) - .build(); - asd = 1111; - } - } - - @Test - public void sdf() throws JsonProcessingException - { - ObjectMapper om = new ObjectMapper(); - om.setAnnotationIntrospector(new JacksonAnnotationIntrospector() - { - @Override - public boolean hasIgnoreMarker(final AnnotatedMember m) - { - List exclusions = Arrays.asList("asd"); - return exclusions.contains(m.getName()) || super.hasIgnoreMarker(m); - } - }); - ObjectWriter w = om.writer(new DefaultPrettyPrinter().withObjectIndenter(new CustomCollapedIntender())); - - final RowSignature.Builder builder = RowSignature.builder() - .add("s", ColumnType.STRING) - .add("d", ColumnType.DOUBLE) - .add("d1", ColumnType.LONG); - - List cs = builder.build().asColumnSignatures(); - - // String s = w.writeValueAsString(builder.build()); - String s = w.writeValueAsString(new Asd()); - System.out.println(s); - - } - -} diff --git a/quidem-it/src/main/java/org/apache/druid/quidem/A12.java b/quidem-it/src/main/java/org/apache/druid/quidem/A12.java deleted file mode 100644 index be4dd6ae98f..00000000000 --- a/quidem-it/src/main/java/org/apache/druid/quidem/A12.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.druid.quidem; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.util.DefaultIndenter; -import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; -import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectWriter; -import org.apache.druid.msq.indexing.report.MSQResultsReport.ColumnAndType; -import org.apache.druid.segment.column.ColumnSignature; -import org.apache.druid.segment.column.ColumnType; -import org.apache.druid.segment.column.RowSignature; -import org.junit.Test; - -import java.io.IOException; -import java.util.List; - -public class A12 -{ - static class MyIntender implements DefaultPrettyPrinter.Indenter - { - boolean isInside = false; - - @Override - public boolean isInline() - { - return getDelegate().isInline(); - } - - private DefaultPrettyPrinter.Indenter getDelegate() - { - if (isInside) { - return DefaultPrettyPrinter.NopIndenter.instance; - } else { - return DefaultIndenter.SYSTEM_LINEFEED_INSTANCE; - } - } - - @Override - public void writeIndentation(JsonGenerator g, int level) throws IOException - { - if (isX(g)) { - } - isInside = isX(g); - if (isInside) { - int asd = 1; - } - getDelegate().writeIndentation(g, level); - } - - private boolean isX(JsonGenerator g) - { - Object v = g.getCurrentValue(); - - return v instanceof ColumnSignature; - // return false; - // return v instanceof RowSignature; - // return g.getCurrentValue() instanceof List; - - } - - } - - static class aa extends DefaultPrettyPrinter - { - - public aa() - { - super(); - _objectIndenter = new MyIntender(); - } - - @Override - public DefaultPrettyPrinter createInstance() - { - return new aa(); - } - - // @Override - // public void writeObjectEntrySeparator(JsonGenerator g) throws IOException - // { - // g.writeRaw(_separators.getObjectEntrySeparator()); - // _objectIndenter.writeIndentation(g, _nesting); - // } - - @Override - public void writeStartArray(JsonGenerator g) throws IOException - { - Object cv = g.getCurrentValue(); - if (isX(g)) { - g.setPrettyPrinter(new MinimalPrettyPrinter()); - } - super.writeStartArray(g); - - } - - @Override - public void writeObjectEntrySeparator(JsonGenerator g) throws IOException - { - - super.writeObjectEntrySeparator(g); - } - - @Override - public void writeStartObject(JsonGenerator g) throws IOException - { - super.writeStartObject(g); - } - - public void writeEndObject1(JsonGenerator g, int nrOfEntries) throws IOException - { - Indenter old = _objectIndenter; - if(isX(g)) - { - _objectIndenter=DefaultIndenter.SYSTEM_LINEFEED_INSTANCE; - } - super.writeEndObject(g, nrOfEntries); - if(isX(g)) - { - _objectIndenter=old; - } - } - - private boolean isX(JsonGenerator g) - { - Object v = g.getCurrentValue(); - return v instanceof ColumnSignature; - // return g.getCurrentValue() instanceof List; - - } - - @Override - public void writeEndArray(JsonGenerator g, int nrOfValues) throws IOException - { - Object cv = g.getCurrentValue(); - super.writeEndArray(g, nrOfValues); - - } - } - - static class Asd - { - @JsonProperty - int asd = 11; - @JsonProperty - RowSignature rs; - @JsonProperty - ColumnAndType or = new ColumnAndType("Asd", ColumnType.DOUBLE); - - Asd() - { - rs = RowSignature.builder() - .add("s", ColumnType.STRING) - .add("d", ColumnType.DOUBLE) - .add("d1", ColumnType.LONG) - .build(); - asd = 1111; - } - } - - @Test - public void sdf() throws JsonProcessingException - { - ObjectMapper om = new ObjectMapper(); - ObjectWriter w = om.writer(new aa()); - - final RowSignature.Builder builder = RowSignature.builder() - .add("s", ColumnType.STRING) - .add("d", ColumnType.DOUBLE) - .add("d1", ColumnType.LONG); - - List cs = builder.build().asColumnSignatures(); - - // String s = w.writeValueAsString(builder.build()); - String s = w.writeValueAsString(new Asd()); - System.out.println(s); - - } - -}