mirror of https://github.com/apache/druid.git
Remove AbstractIndex (#14388)
The class apparently only exists to add a toString() method to Indexes, which basically just crashes any debugger on any meaningfully sized index. It's a pointless abstract class that basically only causes pain.
This commit is contained in:
parent
ff577a69a5
commit
87149d5975
|
@ -1,73 +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.segment;
|
||||
|
||||
import org.apache.druid.java.util.common.Intervals;
|
||||
import org.apache.druid.java.util.common.granularity.Granularities;
|
||||
import org.apache.druid.segment.column.ColumnHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class AbstractIndex
|
||||
{
|
||||
public abstract List<String> getColumnNames();
|
||||
|
||||
public abstract StorageAdapter toStorageAdapter();
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
List<String> columnNames = new ArrayList<>();
|
||||
columnNames.add(ColumnHolder.TIME_COLUMN_NAME);
|
||||
columnNames.addAll(getColumnNames());
|
||||
|
||||
return toStorageAdapter()
|
||||
.makeCursors(
|
||||
null,
|
||||
Intervals.ETERNITY,
|
||||
VirtualColumns.EMPTY,
|
||||
Granularities.ALL,
|
||||
false,
|
||||
null
|
||||
)
|
||||
.accumulate(new StringBuilder(), (sb, cursor) -> {
|
||||
ColumnSelectorFactory columnSelectorFactory = cursor.getColumnSelectorFactory();
|
||||
List<ColumnValueSelector> selectors =
|
||||
columnNames.stream().map(columnSelectorFactory::makeColumnValueSelector).collect(Collectors.toList());
|
||||
while (!cursor.isDone()) {
|
||||
sb.append('[');
|
||||
for (int i = 0; i < selectors.size(); i++) {
|
||||
sb.append(columnNames.get(i)).append('=');
|
||||
ColumnValueSelector selector = selectors.get(i);
|
||||
Object columnValue = selector.getObject();
|
||||
sb.append(columnValue);
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.setLength(sb.length() - 2);
|
||||
sb.append("]\n");
|
||||
cursor.advance();
|
||||
}
|
||||
sb.append("\n");
|
||||
return sb;
|
||||
}).toString();
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ import java.util.Map;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class SimpleQueryableIndex extends AbstractIndex implements QueryableIndex
|
||||
public class SimpleQueryableIndex implements QueryableIndex
|
||||
{
|
||||
private final Interval dataInterval;
|
||||
private final List<String> columnNames;
|
||||
|
@ -100,12 +100,6 @@ public class SimpleQueryableIndex extends AbstractIndex implements QueryableInde
|
|||
return columnNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageAdapter toStorageAdapter()
|
||||
{
|
||||
return new QueryableIndexStorageAdapter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Indexed<String> getAvailableDimensions()
|
||||
{
|
||||
|
|
|
@ -214,19 +214,4 @@ public class FixedIndexed<T> implements Indexed<T>
|
|||
inspector.visit("typeStrategy", typeStrategy);
|
||||
inspector.visit("comparator", comparator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder("FixedIndexed[");
|
||||
if (size() > 0) {
|
||||
for (int i = 0; i < size(); i++) {
|
||||
T value = get(i);
|
||||
sb.append(value).append(',').append(' ');
|
||||
}
|
||||
sb.setLength(sb.length() - 2);
|
||||
}
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -454,21 +454,6 @@ public class GenericIndexed<T> implements CloseableIndexed<T>, Serializer
|
|||
inspector.visit("strategy", strategy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder("GenericIndexed[");
|
||||
if (size() > 0) {
|
||||
for (int i = 0; i < size(); i++) {
|
||||
T value = get(i);
|
||||
sb.append(value).append(',').append(' ');
|
||||
}
|
||||
sb.setLength(sb.length() - 2);
|
||||
}
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Single-threaded view.
|
||||
*/
|
||||
|
|
|
@ -48,7 +48,6 @@ import org.apache.druid.query.aggregation.AggregatorFactory;
|
|||
import org.apache.druid.query.aggregation.PostAggregator;
|
||||
import org.apache.druid.query.dimension.DimensionSpec;
|
||||
import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector;
|
||||
import org.apache.druid.segment.AbstractIndex;
|
||||
import org.apache.druid.segment.ColumnInspector;
|
||||
import org.apache.druid.segment.ColumnSelectorFactory;
|
||||
import org.apache.druid.segment.ColumnValueSelector;
|
||||
|
@ -66,7 +65,6 @@ import org.apache.druid.segment.NilColumnValueSelector;
|
|||
import org.apache.druid.segment.ObjectColumnSelector;
|
||||
import org.apache.druid.segment.RowAdapters;
|
||||
import org.apache.druid.segment.RowBasedColumnSelectorFactory;
|
||||
import org.apache.druid.segment.StorageAdapter;
|
||||
import org.apache.druid.segment.VirtualColumns;
|
||||
import org.apache.druid.segment.column.CapabilitiesBasedFormat;
|
||||
import org.apache.druid.segment.column.ColumnCapabilities;
|
||||
|
@ -104,7 +102,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public abstract class IncrementalIndex extends AbstractIndex implements Iterable<Row>, Closeable, ColumnInspector
|
||||
public abstract class IncrementalIndex implements Iterable<Row>, Closeable, ColumnInspector
|
||||
{
|
||||
/**
|
||||
* Column selector used at ingestion time for inputs to aggregators.
|
||||
|
@ -921,7 +919,6 @@ public abstract class IncrementalIndex extends AbstractIndex implements Iterable
|
|||
return ImmutableList.copyOf(metricDescs.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getColumnNames()
|
||||
{
|
||||
List<String> columnNames = new ArrayList<>(getDimensionNames());
|
||||
|
@ -929,12 +926,6 @@ public abstract class IncrementalIndex extends AbstractIndex implements Iterable
|
|||
return columnNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageAdapter toStorageAdapter()
|
||||
{
|
||||
return new IncrementalIndexStorageAdapter(this);
|
||||
}
|
||||
|
||||
public Metadata getMetadata()
|
||||
{
|
||||
return metadata;
|
||||
|
|
Loading…
Reference in New Issue