github-advanced-security[bot] commented on code in PR #18521:
URL: https://github.com/apache/druid/pull/18521#discussion_r2345514928
##########
processing/src/main/java/org/apache/druid/segment/VirtualColumn.java:
##########
@@ -72,22 +77,51 @@
String getOutputName();
/**
- * Build a selector corresponding to this virtual column. Also provides the
name that the
- * virtual column was referenced with (through {@link
DimensionSpec#getDimension()}, which
- * is useful if this column uses dot notation. The virtual column is
expected to apply any
- * necessary decoration from the dimensionSpec.
+ * Build a selector corresponding to this virtual column.
+ *
+ * The virtual column is expected to apply any necessary {@link
DimensionSpec#decorate(DimensionSelector)} or
+ * {@link DimensionSpec#getExtractionFn()} from the dimensionSpec.
+ *
+ * @param dimensionSpec spec the column was referenced with. Also
provides the name that the
+ * virtual column was referenced with, which is
useful if this column uses dot notation.
+ * @param columnSelectorFactory object for fetching underlying selectors.
+ * @param columnSelector object for fetching underlying columns, if
available. Generally only available for
+ * regular segments.
+ * @param offset offset to use with underlying columns.
Available only if columnSelector is available.
*/
- DimensionSelector makeDimensionSelector(DimensionSpec dimensionSpec,
ColumnSelectorFactory factory);
+ default DimensionSelector makeDimensionSelector(
+ DimensionSpec dimensionSpec,
+ ColumnSelectorFactory columnSelectorFactory,
+ @Nullable ColumnSelector columnSelector,
+ @Nullable ReadableOffset offset
+ )
+ {
+ // Implementation for backwards compatibility with existing extensions.
+ if (columnSelector != null) {
+ final DimensionSelector selector = makeDimensionSelector(dimensionSpec,
columnSelector, offset);
Review Comment:
## Deprecated method or constructor invocation
Invoking [VirtualColumn.makeDimensionSelector](1) should be avoided because
it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10313)
##########
processing/src/main/java/org/apache/druid/segment/VirtualColumn.java:
##########
@@ -72,22 +77,51 @@
String getOutputName();
/**
- * Build a selector corresponding to this virtual column. Also provides the
name that the
- * virtual column was referenced with (through {@link
DimensionSpec#getDimension()}, which
- * is useful if this column uses dot notation. The virtual column is
expected to apply any
- * necessary decoration from the dimensionSpec.
+ * Build a selector corresponding to this virtual column.
+ *
+ * The virtual column is expected to apply any necessary {@link
DimensionSpec#decorate(DimensionSelector)} or
+ * {@link DimensionSpec#getExtractionFn()} from the dimensionSpec.
+ *
+ * @param dimensionSpec spec the column was referenced with. Also
provides the name that the
+ * virtual column was referenced with, which is
useful if this column uses dot notation.
+ * @param columnSelectorFactory object for fetching underlying selectors.
+ * @param columnSelector object for fetching underlying columns, if
available. Generally only available for
+ * regular segments.
+ * @param offset offset to use with underlying columns.
Available only if columnSelector is available.
*/
- DimensionSelector makeDimensionSelector(DimensionSpec dimensionSpec,
ColumnSelectorFactory factory);
+ default DimensionSelector makeDimensionSelector(
+ DimensionSpec dimensionSpec,
+ ColumnSelectorFactory columnSelectorFactory,
+ @Nullable ColumnSelector columnSelector,
+ @Nullable ReadableOffset offset
+ )
+ {
+ // Implementation for backwards compatibility with existing extensions.
+ if (columnSelector != null) {
+ final DimensionSelector selector = makeDimensionSelector(dimensionSpec,
columnSelector, offset);
+ if (selector != null) {
+ return selector;
+ }
+ }
+ return makeDimensionSelector(dimensionSpec, columnSelectorFactory);
Review Comment:
## Deprecated method or constructor invocation
Invoking [VirtualColumn.makeDimensionSelector](1) should be avoided because
it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10314)
##########
processing/src/main/java/org/apache/druid/segment/VirtualColumn.java:
##########
@@ -192,25 +303,50 @@
return null;
}
+ /**
+ * Build a selector corresponding to this virtual column.
+ *
+ * The virtual column is expected to apply any necessary {@link
DimensionSpec#decorate(DimensionSelector)} or
+ * {@link DimensionSpec#getExtractionFn()} from the dimensionSpec.
+ *
+ * @param columnName name the column was referenced with, which is
useful if this column uses dot notation.
+ * @param factory object for fetching underlying selectors.
+ * @param columnSelector object for fetching underlying columns, if
available. Generally only available for
+ * regular segments.
+ * @param offset offset to use with underlying columns. Available
only if columnSelector is available.
+ */
+ default VectorValueSelector makeVectorValueSelector(
+ String columnName,
+ VectorColumnSelectorFactory factory,
+ ColumnSelector columnSelector,
+ ReadableVectorOffset offset
+ )
+ {
+ // Implementation for backwards compatibility with existing extensions.
+ if (columnSelector != null) {
+ final VectorValueSelector selector =
+ makeVectorValueSelector(columnName, columnSelector, offset);
Review Comment:
## Deprecated method or constructor invocation
Invoking [VirtualColumn.makeVectorValueSelector](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10321)
##########
processing/src/main/java/org/apache/druid/segment/VirtualColumn.java:
##########
@@ -129,11 +190,40 @@
}
/**
- * Build a {@link SingleValueDimensionVectorSelector} corresponding to this
virtual column. Also provides the name
- * that the virtual column was referenced with (through {@link
DimensionSpec#getDimension()}, which is useful if this
- * column uses dot notation. The virtual column is expected to apply any
necessary decoration from the
- * {@link DimensionSpec}.
+ * Build a selector corresponding to this virtual column.
+ *
+ * The virtual column is expected to apply any necessary {@link
DimensionSpec#decorate(DimensionSelector)} or
+ * {@link DimensionSpec#getExtractionFn()} from the dimensionSpec.
+ *
+ * @param dimensionSpec spec the column was referenced with. Also provides
the name that the
+ * virtual column was referenced with, which is useful
if this column uses dot notation.
+ * @param factory object for fetching underlying selectors.
+ * @param columnSelector object for fetching underlying columns, if
available. Generally only available for
+ * regular segments.
+ * @param offset offset to use with underlying columns. Available
only if columnSelector is available.
*/
+ default SingleValueDimensionVectorSelector
makeSingleValueVectorDimensionSelector(
+ DimensionSpec dimensionSpec,
+ VectorColumnSelectorFactory factory,
+ ColumnSelector columnSelector,
+ ReadableVectorOffset offset
+ )
+ {
+ // Implementation for backwards compatibility with existing extensions.
+ if (columnSelector != null) {
+ final SingleValueDimensionVectorSelector selector =
+ makeSingleValueVectorDimensionSelector(dimensionSpec,
columnSelector, offset);
Review Comment:
## Deprecated method or constructor invocation
Invoking [VirtualColumn.makeSingleValueVectorDimensionSelector](1) should be
avoided because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10317)
##########
processing/src/main/java/org/apache/druid/segment/virtual/NestedFieldVirtualColumn.java:
##########
@@ -288,23 +300,35 @@
return null;
}
- return dimensionSpec.decorate(makeDimensionSelectorUndecorated(holder,
offset, dimensionSpec.getExtractionFn()));
+ return dimensionSpec.decorate(
+ makeDimensionSelectorUndecorated(
+ holder,
+ dimensionSpec.getExtractionFn(),
Review Comment:
## Deprecated method or constructor invocation
Invoking [DimensionSpec.getExtractionFn](1) should be avoided because it has
been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10325)
##########
processing/src/main/java/org/apache/druid/segment/VirtualColumn.java:
##########
@@ -192,25 +303,50 @@
return null;
}
+ /**
+ * Build a selector corresponding to this virtual column.
+ *
+ * The virtual column is expected to apply any necessary {@link
DimensionSpec#decorate(DimensionSelector)} or
+ * {@link DimensionSpec#getExtractionFn()} from the dimensionSpec.
+ *
+ * @param columnName name the column was referenced with, which is
useful if this column uses dot notation.
+ * @param factory object for fetching underlying selectors.
+ * @param columnSelector object for fetching underlying columns, if
available. Generally only available for
+ * regular segments.
+ * @param offset offset to use with underlying columns. Available
only if columnSelector is available.
+ */
+ default VectorValueSelector makeVectorValueSelector(
+ String columnName,
+ VectorColumnSelectorFactory factory,
+ ColumnSelector columnSelector,
+ ReadableVectorOffset offset
+ )
+ {
+ // Implementation for backwards compatibility with existing extensions.
+ if (columnSelector != null) {
+ final VectorValueSelector selector =
+ makeVectorValueSelector(columnName, columnSelector, offset);
+ if (selector != null) {
+ return selector;
+ }
+ }
+ return makeVectorValueSelector(columnName, factory);
Review Comment:
## Deprecated method or constructor invocation
Invoking [VirtualColumn.makeVectorValueSelector](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10322)
##########
processing/src/main/java/org/apache/druid/segment/VirtualColumn.java:
##########
@@ -99,20 +133,47 @@
}
/**
- * Build a {@link ColumnValueSelector} corresponding to this virtual column.
Also provides the name that the
- * virtual column was referenced with, which is useful if this column uses
dot notation.
+ * Builds a selector corresponding to this virtual column.
+ *
+ * @param columnName name the column was referenced with, which
is useful if this column uses dot notation.
+ * @param columnSelectorFactory object for fetching underlying selectors.
+ * @param columnSelector object for fetching underlying columns, if
available. Generally only available for
+ * regular segments.
+ * @param offset offset to use with underlying columns.
Available only if columnSelector is available.
*/
- ColumnValueSelector<?> makeColumnValueSelector(String columnName,
ColumnSelectorFactory factory);
+ default ColumnValueSelector<?> makeColumnValueSelector(
+ String columnName,
+ ColumnSelectorFactory columnSelectorFactory,
+ @Nullable ColumnSelector columnSelector,
+ @Nullable ReadableOffset offset
+ )
+ {
+ // Implementation for backwards compatibility with existing extensions.
+ if (columnSelector != null && offset != null) {
+ final ColumnValueSelector<?> selector =
makeColumnValueSelector(columnName, columnSelector, offset);
Review Comment:
## Deprecated method or constructor invocation
Invoking [VirtualColumn.makeColumnValueSelector](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10315)
##########
processing/src/main/java/org/apache/druid/segment/VirtualColumn.java:
##########
@@ -99,20 +133,47 @@
}
/**
- * Build a {@link ColumnValueSelector} corresponding to this virtual column.
Also provides the name that the
- * virtual column was referenced with, which is useful if this column uses
dot notation.
+ * Builds a selector corresponding to this virtual column.
+ *
+ * @param columnName name the column was referenced with, which
is useful if this column uses dot notation.
+ * @param columnSelectorFactory object for fetching underlying selectors.
+ * @param columnSelector object for fetching underlying columns, if
available. Generally only available for
+ * regular segments.
+ * @param offset offset to use with underlying columns.
Available only if columnSelector is available.
*/
- ColumnValueSelector<?> makeColumnValueSelector(String columnName,
ColumnSelectorFactory factory);
+ default ColumnValueSelector<?> makeColumnValueSelector(
+ String columnName,
+ ColumnSelectorFactory columnSelectorFactory,
+ @Nullable ColumnSelector columnSelector,
+ @Nullable ReadableOffset offset
+ )
+ {
+ // Implementation for backwards compatibility with existing extensions.
+ if (columnSelector != null && offset != null) {
+ final ColumnValueSelector<?> selector =
makeColumnValueSelector(columnName, columnSelector, offset);
+ if (selector != null) {
+ return selector;
+ }
+ }
+ return makeColumnValueSelector(columnName, columnSelectorFactory);
Review Comment:
## Deprecated method or constructor invocation
Invoking [VirtualColumn.makeColumnValueSelector](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10316)
##########
processing/src/main/java/org/apache/druid/query/search/UseIndexesStrategy.java:
##########
@@ -262,51 +268,30 @@
final QueryableIndex index = segment.as(QueryableIndex.class);
Preconditions.checkArgument(index != null, "Index should not be null");
- ColumnSelectorColumnIndexSelector indexSelector = new
ColumnSelectorColumnIndexSelector(
- index.getBitmapFactoryForDimensions(),
- query.getVirtualColumns(),
- new DeprecatedQueryableIndexColumnSelector(index)
- );
+ try (final Closer closer = Closer.create()) {
+ final ColumnIndexSelector indexSelector = new ColumnCache(index,
query.getVirtualColumns(), closer);
- final Object2IntRBTreeMap<SearchHit> retVal = new
Object2IntRBTreeMap<>(query.getSort().getComparator());
- retVal.defaultReturnValue(0);
+ final Object2IntRBTreeMap<SearchHit> retVal = new
Object2IntRBTreeMap<>(query.getSort().getComparator());
+ retVal.defaultReturnValue(0);
- final BitmapFactory bitmapFactory =
index.getBitmapFactoryForDimensions();
+ final BitmapFactory bitmapFactory =
index.getBitmapFactoryForDimensions();
- for (DimensionSpec dimension : dimsToSearch) {
+ for (DimensionSpec dimension : dimsToSearch) {
- final ColumnIndexSupplier indexSupplier =
indexSelector.getIndexSupplier(dimension.getDimension());
+ final ColumnIndexSupplier indexSupplier =
indexSelector.getIndexSupplier(dimension.getDimension());
- ExtractionFn extractionFn = dimension.getExtractionFn();
- if (extractionFn == null) {
- extractionFn = IdentityExtractionFn.getInstance();
- }
- // if indexSupplier is null here, it means the column is missing
- if (indexSupplier == null) {
- String dimVal = extractionFn.apply(null);
- if (!searchQuerySpec.accept(dimVal)) {
- continue;
- }
- ImmutableBitmap bitmap =
bitmapFactory.complement(bitmapFactory.makeEmptyImmutableBitmap(),
index.getNumRows());
- if (timeFilteredBitmap != null) {
- bitmap =
bitmapFactory.intersection(Arrays.asList(timeFilteredBitmap, bitmap));
- }
- if (!bitmap.isEmpty()) {
- retVal.addTo(new SearchHit(dimension.getOutputName(), dimVal),
bitmap.size());
- if (retVal.size() >= limit) {
- return retVal;
- }
+ ExtractionFn extractionFn = dimension.getExtractionFn();
Review Comment:
## Deprecated method or constructor invocation
Invoking [DimensionSpec.getExtractionFn](1) should be avoided because it has
been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10310)
##########
processing/src/main/java/org/apache/druid/segment/VirtualColumn.java:
##########
@@ -161,11 +247,40 @@
}
/**
- * Build a {@link MultiValueDimensionVectorSelector} corresponding to this
virtual column. Also provides
- * the name that the virtual column was referenced with (through {@link
DimensionSpec#getDimension()}, which is useful
- * if this column uses dot notation. The virtual column is expected to apply
any necessary decoration from the
- * {@link DimensionSpec}.
+ * Build a selector corresponding to this virtual column.
+ *
+ * The virtual column is expected to apply any necessary {@link
DimensionSpec#decorate(DimensionSelector)} or
+ * {@link DimensionSpec#getExtractionFn()} from the dimensionSpec.
+ *
+ * @param dimensionSpec spec the column was referenced with. Also provides
the name that the
+ * virtual column was referenced with, which is useful
if this column uses dot notation.
+ * @param factory object for fetching underlying selectors.
+ * @param columnSelector object for fetching underlying columns, if
available. Generally only available for
+ * regular segments.
+ * @param offset offset to use with underlying columns. Available
only if columnSelector is available.
*/
+ default MultiValueDimensionVectorSelector
makeMultiValueVectorDimensionSelector(
+ DimensionSpec dimensionSpec,
+ VectorColumnSelectorFactory factory,
+ ColumnSelector columnSelector,
+ ReadableVectorOffset offset
+ )
+ {
+ // Implementation for backwards compatibility with existing extensions.
+ if (columnSelector != null) {
+ final MultiValueDimensionVectorSelector selector =
+ makeMultiValueVectorDimensionSelector(dimensionSpec, columnSelector,
offset);
+ if (selector != null) {
+ return selector;
+ }
+ }
+ return makeMultiValueVectorDimensionSelector(dimensionSpec, factory);
Review Comment:
## Deprecated method or constructor invocation
Invoking [VirtualColumn.makeMultiValueVectorDimensionSelector](1) should be
avoided because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10320)
##########
processing/src/main/java/org/apache/druid/segment/VirtualColumn.java:
##########
@@ -129,11 +190,40 @@
}
/**
- * Build a {@link SingleValueDimensionVectorSelector} corresponding to this
virtual column. Also provides the name
- * that the virtual column was referenced with (through {@link
DimensionSpec#getDimension()}, which is useful if this
- * column uses dot notation. The virtual column is expected to apply any
necessary decoration from the
- * {@link DimensionSpec}.
+ * Build a selector corresponding to this virtual column.
+ *
+ * The virtual column is expected to apply any necessary {@link
DimensionSpec#decorate(DimensionSelector)} or
+ * {@link DimensionSpec#getExtractionFn()} from the dimensionSpec.
+ *
+ * @param dimensionSpec spec the column was referenced with. Also provides
the name that the
+ * virtual column was referenced with, which is useful
if this column uses dot notation.
+ * @param factory object for fetching underlying selectors.
+ * @param columnSelector object for fetching underlying columns, if
available. Generally only available for
+ * regular segments.
+ * @param offset offset to use with underlying columns. Available
only if columnSelector is available.
*/
+ default SingleValueDimensionVectorSelector
makeSingleValueVectorDimensionSelector(
+ DimensionSpec dimensionSpec,
+ VectorColumnSelectorFactory factory,
+ ColumnSelector columnSelector,
+ ReadableVectorOffset offset
+ )
+ {
+ // Implementation for backwards compatibility with existing extensions.
+ if (columnSelector != null) {
+ final SingleValueDimensionVectorSelector selector =
+ makeSingleValueVectorDimensionSelector(dimensionSpec,
columnSelector, offset);
+ if (selector != null) {
+ return selector;
+ }
+ }
+ return makeSingleValueVectorDimensionSelector(dimensionSpec, factory);
Review Comment:
## Deprecated method or constructor invocation
Invoking [VirtualColumn.makeSingleValueVectorDimensionSelector](1) should be
avoided because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10318)
##########
processing/src/main/java/org/apache/druid/segment/VirtualColumn.java:
##########
@@ -161,11 +247,40 @@
}
/**
- * Build a {@link MultiValueDimensionVectorSelector} corresponding to this
virtual column. Also provides
- * the name that the virtual column was referenced with (through {@link
DimensionSpec#getDimension()}, which is useful
- * if this column uses dot notation. The virtual column is expected to apply
any necessary decoration from the
- * {@link DimensionSpec}.
+ * Build a selector corresponding to this virtual column.
+ *
+ * The virtual column is expected to apply any necessary {@link
DimensionSpec#decorate(DimensionSelector)} or
+ * {@link DimensionSpec#getExtractionFn()} from the dimensionSpec.
+ *
+ * @param dimensionSpec spec the column was referenced with. Also provides
the name that the
+ * virtual column was referenced with, which is useful
if this column uses dot notation.
+ * @param factory object for fetching underlying selectors.
+ * @param columnSelector object for fetching underlying columns, if
available. Generally only available for
+ * regular segments.
+ * @param offset offset to use with underlying columns. Available
only if columnSelector is available.
*/
+ default MultiValueDimensionVectorSelector
makeMultiValueVectorDimensionSelector(
+ DimensionSpec dimensionSpec,
+ VectorColumnSelectorFactory factory,
+ ColumnSelector columnSelector,
+ ReadableVectorOffset offset
+ )
+ {
+ // Implementation for backwards compatibility with existing extensions.
+ if (columnSelector != null) {
+ final MultiValueDimensionVectorSelector selector =
+ makeMultiValueVectorDimensionSelector(dimensionSpec, columnSelector,
offset);
Review Comment:
## Deprecated method or constructor invocation
Invoking [VirtualColumn.makeMultiValueVectorDimensionSelector](1) should be
avoided because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10319)
##########
processing/src/main/java/org/apache/druid/segment/VirtualColumn.java:
##########
@@ -221,23 +357,49 @@
}
/**
- * Build a {@link VectorObjectSelector} corresponding to this virtual
column. Also provides the name that the
- * virtual column was referenced with, which is useful if this column uses
dot notation.
+ * Build a selector corresponding to this virtual column.
+ *
+ * The virtual column is expected to apply any necessary {@link
DimensionSpec#decorate(DimensionSelector)} or
+ * {@link DimensionSpec#getExtractionFn()} from the dimensionSpec.
+ *
+ * @param columnName name the column was referenced with, which is
useful if this column uses dot notation.
+ * @param factory object for fetching underlying selectors.
+ * @param columnSelector object for fetching underlying columns, if
available. Generally only available for
+ * regular segments.
+ * @param offset offset to use with underlying columns. Available
only if columnSelector is available.
+ */
+ default VectorObjectSelector makeVectorObjectSelector(
+ String columnName,
+ VectorColumnSelectorFactory factory,
+ ColumnSelector columnSelector,
+ ReadableVectorOffset offset
+ )
+ {
+ // Implementation for backwards compatibility with existing extensions.
+ if (columnSelector != null) {
+ final VectorObjectSelector selector =
+ makeVectorObjectSelector(columnName, columnSelector, offset);
+ if (selector != null) {
+ return selector;
+ }
+ }
+ return makeVectorObjectSelector(columnName, factory);
Review Comment:
## Deprecated method or constructor invocation
Invoking [VirtualColumn.makeVectorObjectSelector](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10324)
##########
processing/src/main/java/org/apache/druid/segment/VirtualColumn.java:
##########
@@ -221,23 +357,49 @@
}
/**
- * Build a {@link VectorObjectSelector} corresponding to this virtual
column. Also provides the name that the
- * virtual column was referenced with, which is useful if this column uses
dot notation.
+ * Build a selector corresponding to this virtual column.
+ *
+ * The virtual column is expected to apply any necessary {@link
DimensionSpec#decorate(DimensionSelector)} or
+ * {@link DimensionSpec#getExtractionFn()} from the dimensionSpec.
+ *
+ * @param columnName name the column was referenced with, which is
useful if this column uses dot notation.
+ * @param factory object for fetching underlying selectors.
+ * @param columnSelector object for fetching underlying columns, if
available. Generally only available for
+ * regular segments.
+ * @param offset offset to use with underlying columns. Available
only if columnSelector is available.
+ */
+ default VectorObjectSelector makeVectorObjectSelector(
+ String columnName,
+ VectorColumnSelectorFactory factory,
+ ColumnSelector columnSelector,
+ ReadableVectorOffset offset
+ )
+ {
+ // Implementation for backwards compatibility with existing extensions.
+ if (columnSelector != null) {
+ final VectorObjectSelector selector =
+ makeVectorObjectSelector(columnName, columnSelector, offset);
Review Comment:
## Deprecated method or constructor invocation
Invoking [VirtualColumn.makeVectorObjectSelector](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10323)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]