25using namespace Qt::StringLiterals;
29QString QgsAttributeIndexAlgorithm::name()
const
31 return u
"createattributeindex"_s;
34QString QgsAttributeIndexAlgorithm::displayName()
const
36 return QObject::tr(
"Create attribute index" );
39QStringList QgsAttributeIndexAlgorithm::tags()
const
41 return QObject::tr(
"table,attribute,index,create,vector" ).split(
',' );
44QString QgsAttributeIndexAlgorithm::group()
const
46 return QObject::tr(
"Vector general" );
49QString QgsAttributeIndexAlgorithm::groupId()
const
51 return u
"vectorgeneral"_s;
60QString QgsAttributeIndexAlgorithm::shortHelpString()
const
63 "This algorithm creates an index to speed up queries made against "
64 "a field in a table. Support for index creation is "
65 "dependent on the layer's data provider and the field type."
69QString QgsAttributeIndexAlgorithm::shortDescription()
const
71 return QObject::tr(
"Creates an index to speed up queries made against a field in a table." );
74QgsAttributeIndexAlgorithm *QgsAttributeIndexAlgorithm::createInstance()
const
76 return new QgsAttributeIndexAlgorithm();
79void QgsAttributeIndexAlgorithm::initAlgorithm(
const QVariantMap & )
89 QGS_MARK_ALGORITHM_SOURCE
91 QgsVectorLayer *layer = parameterAsVectorLayer( parameters, u
"INPUT"_s, context );
96 const QString field = parameterAsString( parameters, u
"FIELD"_s, context );
103 feedback->
pushInfo( QObject::tr(
"Can not create attribute index on %1" ).arg( field ) );
107 const int providerIndex = layer->fields().fieldOriginIndex( fieldIndex );
112 feedback->
pushInfo( QObject::tr(
"Could not create attribute index" ) );
117 feedback->
pushInfo( QObject::tr(
"Layer's data provider does not support creating attribute indexes" ) );
122 outputs.insert( u
"OUTPUT"_s, layer->id() );
@ Vector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ CreateAttributeIndex
Can create indexes on provider's fields.
QFlags< ProcessingAlgorithmFlag > ProcessingAlgorithmFlags
Flags indicating how and when an algorithm operates and should be exposed to users.
@ Provider
Field originates from the underlying data provider of the vector layer.
@ NoThreading
Algorithm is not thread safe and cannot be run in a background thread, e.g. for algorithms which mani...
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
virtual Qgis::ProcessingAlgorithmFlags flags() const
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
A vector layer output for processing algorithms.
A vector layer or feature source field parameter for processing algorithms.
A vector layer (with or without geometry) parameter for processing algorithms.
Base class for vector data providers.
virtual Q_INVOKABLE Qgis::VectorProviderCapabilities capabilities() const
Returns flags containing the supported capabilities.
virtual bool createAttributeIndex(int field)
Create an attribute index on the datasource.
QgsFields fields() const override=0
Returns the fields associated with this data provider.
Represents a vector layer which manages a vector based dataset.