Index the feature table

@param force
true to force re-indexing
@return count
486318
public int index(boolean force) {
		int count = 0;
		if (force || !isIndexed()) {
			getOrCreateExtension();
			TableIndex tableIndex = getOrCreateTableIndex();
			createOrClearGeometryIndices();
			geoPackage.unindexGeometryIndexTable();
			count = indexTable(tableIndex);
			geoPackage.indexGeometryIndexTable();
		}
		return count;
	}
1148014
public long count(GeometryEnvelope envelope) {
		long count = 0;
		switch (getIndexedType()) {
		case GEOPACKAGE:
			count = featureTableIndex.count(envelope);
			break;
		case RTREE:
			count = rTreeIndexTableDao.count(envelope);
			break;
		default:
			count = manualFeatureQuery.count(envelope);
		}
		return count;
	}
438576
public static long count_filtered(nitro_service service, Long td, String filter) throws Exception{
		nstrafficdomain_bridgegroup_binding obj = new nstrafficdomain_bridgegroup_binding();
		obj.set_td(td);
		options option = new options();
		option.set_count(true);
		option.set_filter(filter);
		nstrafficdomain_bridgegroup_binding[] response = (nstrafficdomain_bridgegroup_binding[]) obj.getfiltered(service, option);
		if (response != null) {
			return response[0].__count;
		}
		return 0;
	}
734927
public int lookupIndex (long entry)
    {
        int ret = map.get(entry);
        if (ret <= 0 && !growthStopped) {
            numEntries++;
            ret = numEntries;
            map.put (entry, ret);
        }
        return ret - 1;	// feature id should be 0-based
    }
702748
private int clientIndexToTabIndex(final int clientIndex) {
		int childCount = getTotalTabs();
		int serverIndex = clientIndex;

		for (int i = 0; i <= serverIndex && i < childCount; i++) {
			if (!isTabVisible(i)) {
				serverIndex++;
			}
		}

		return serverIndex;
	}
552653
private void indexQuery(
      long index,
      long timestamp,
      RaftSession session,
      PrimitiveOperation operation,
      CompletableFuture<OperationResult> future) {
    // If the query index is greater than the session's last applied index, queue the request for handling once the
    // state machine is caught up.
    if (index > currentIndex) {
      log.trace("Registering query with index " + index + " > " + currentIndex);
      session.registerIndexQuery(index, () -> applyQuery(timestamp, session, operation, future));
    } else {
      applyQuery(timestamp, session, operation, future);
    }
  }
131526
def feature(self, index):
        
        if index < 0 or index >= self.num_features_:
            raise ValueError('Index %d out of range' %(index))
        return self.features_[index]
137121
public int indexOf(final OIdentifiable iElement) {
		if (delegate.isEmpty())
			return -1;

		final boolean prevConvert = delegate.isAutoConvertToRecord();
		if (prevConvert)
			delegate.setAutoConvertToRecord(false);

		final int pos = Collections.binarySearch(delegate, iElement);

		if (prevConvert)
			// RESET PREVIOUS SETTINGS
			delegate.setAutoConvertToRecord(true);

		return pos;
	}
723308
public List<FeatureTileLink> queryForFeatureTableName(
			String featureTableName) {
		List<FeatureTileLink> results = null;
		try {
			results = queryForEq(FeatureTileLink.COLUMN_FEATURE_TABLE_NAME,
					featureTableName);
		} catch (SQLException e) {
			throw new GeoPackageException(
					"Failed to query for Feature Tile Link objects by Feature Table Name: "
							+ featureTableName);
		}
		return results;
	}
95402
@Override
    public AtlasGraphIndex getGraphIndex(String indexName) {
        TitanGraphIndex index = management.getGraphIndex(indexName);
        return GraphDbObjectFactory.createGraphIndex(index);
    }
527166
private Map<Long, FeatureShape> getFeatureIds(Map<String, Map<Long, FeatureShape>> tables, String table) {

        Map<Long, FeatureShape> featureIds = tables.get(table);
        if (featureIds == null) {
            featureIds = new HashMap<>();
            tables.put(table, featureIds);
        }
        return featureIds;
    }
1356708
private function index($force = false)
    {
        if ($force || !$this->index)
        {
            $items = Eresus_CMS::getLegacyKernel()->db->
                select($this->table, '', '`position`', '`id`,`owner`');
            if ($items)
            {
                $this->index = array();
                foreach ($items as $item)
                {
                    $this->index[$item['owner']] []= $item['id'];
                }
            }
        }
    }
777549
public static QueryResult featureCollection2QueryResult( SimpleFeatureCollection featureCollection ) {
        List<AttributeDescriptor> attributeDescriptors = featureCollection.getSchema().getAttributeDescriptors();
        QueryResult queryResult = new QueryResult();
        int count = 0;
        for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) {
            if (!(attributeDescriptor instanceof GeometryDescriptor)) {
                String fieldName = attributeDescriptor.getLocalName();
                String type = attributeDescriptor.getType().getBinding().toString();
                queryResult.names.add(fieldName);
                queryResult.types.add(type);
                count++;
            }
        }

        SimpleFeatureIterator featureIterator = featureCollection.features();
        while( featureIterator.hasNext() ) {
            SimpleFeature f = featureIterator.next();

            Geometry geometry = (Geometry) f.getDefaultGeometry();
            queryResult.geometries.add(geometry);

            Object[] dataRow = new Object[count];
            int index = 0;
            for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) {
                if (!(attributeDescriptor instanceof GeometryDescriptor)) {
                    String fieldName = attributeDescriptor.getLocalName();
                    Object attribute = f.getAttribute(fieldName);
                    if (attribute == null) {
                        attribute = "";
                    }
                    dataRow[index++] = attribute;
                }
            }
            queryResult.data.add(dataRow);
        }

        return queryResult;
    }
235155
@Override
	public <T> EntitySequence getSequence(TableDefinition tableDef, Iterable<T> collection) {
		return getSequence(tableDef, collection, null, null);
	}
442342
@Override
    public Map<String, Object> count(String task) {
        MappingConfig config = rdbMapping.get(task);
        MappingConfig.DbMapping dbMapping = config.getDbMapping();
        String sql = "SELECT COUNT(1) AS cnt FROM " + SyncUtil.getDbTableName(dbMapping);
        Connection conn = null;
        Map<String, Object> res = new LinkedHashMap<>();
        try {
            conn = dataSource.getConnection();
            Util.sqlRS(conn, sql, rs -> {
                try {
                    if (rs.next()) {
                        Long rowCount = rs.getLong("cnt");
                        res.put("count", rowCount);
                    }
                } catch (SQLException e) {
                    logger.error(e.getMessage(), e);
                }
            });
        } catch (SQLException e) {
            logger.error(e.getMessage(), e);
        } finally {
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException e) {
                    logger.error(e.getMessage(), e);
                }
            }
        }
        res.put("targetTable", SyncUtil.getDbTableName(dbMapping));

        return res;
    }
431301
public int indexOf(E object, int from) {
        Object[] snapshot = elements;
        return indexOf(object, snapshot, from, snapshot.length);
    }
1119796
private int indexRows(TableIndex tableIndex, FeatureResultSet resultSet) {

		int count = -1;

		try {
			while ((progress == null || progress.isActive())
					&& resultSet.moveToNext()) {
				if (count < 0) {
					count++;
				}
				try {
					FeatureRow row = resultSet.getRow();
					boolean indexed = index(tableIndex, row.getId(),
							row.getGeometry());
					if (indexed) {
						count++;
					}
					if (progress != null) {
						progress.addProgress(1);
					}
				} catch (Exception e) {
					log.log(Level.SEVERE, "Failed to index feature. Table: "
							+ tableIndex.getTableName() + ", Position: "
							+ resultSet.getPosition(), e);
				}
			}
		} finally {
			resultSet.close();
		}

		return count;
	}