<commit_before>/**
 * Copyright (c) 2010-2012 "Neo Technology,"
 * Network Engine for Objects in Lund AB [http://neotechnology.com]
 *
 * This file is part of Neo4j.
 *
 * Neo4j is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.neo4j.gis.spatial.indexprovider;

import java.util.Collections;
import java.util.Map;

import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.index.Index;
import org.neo4j.graphdb.index.IndexImplementation;
import org.neo4j.graphdb.index.IndexManager;
import org.neo4j.graphdb.index.IndexProvider;
import org.neo4j.graphdb.index.RelationshipIndex;
import org.neo4j.helpers.Service;
import org.neo4j.helpers.collection.MapUtil;
import org.neo4j.kernel.KernelData;
import org.neo4j.kernel.KernelExtension;


@Service.Implementation( KernelExtension.class )
public class SpatialIndexProvider extends IndexProvider
{

    public static final String SERVICE_NAME = "spatial";
    public static final String GEOMETRY_TYPE = "geometry_type";

    public SpatialIndexProvider( )
    {
        super( SERVICE_NAME );        
    }

    @Override
    public IndexImplementation load(DependencyResolver dependencyResolver) throws Exception {
        return new SpatialIndexImplementation(dependencyResolver.resolveDependency(GraphDatabaseService.class));
    }

    private class SpatialIndexImplementation implements IndexImplementation {
    	
        private GraphDatabaseService db;

        public SpatialIndexImplementation(GraphDatabaseService db) {

            this.db = db;
        }

        @Override
        public String getDataSourceName() {
            return null;
        }

        @Override
        public Index<Node> nodeIndex(String indexName, Map<String, String> config) {
            return new LayerNodeIndex(indexName, db, config);
        }

        @Override
        public RelationshipIndex relationshipIndex(String indexName, Map<String, String> config) {
            throw new UnsupportedOperationException("Spatial relationship indexing is not supported at the moment. Please use the node index.");
        }

        @Override
        public Map<String, String> fillInDefaults(Map<String, String> config) {
            return config;
        }

        @Override
        public boolean configMatches(Map<String, String> stringStringMap, Map<String, String> stringStringMap1) {
            return false;
        }
    }
    
    public static final Map<String, String> SIMPLE_POINT_CONFIG =
            Collections.unmodifiableMap( MapUtil.stringMap(
                    IndexManager.PROVIDER, SERVICE_NAME, GEOMETRY_TYPE , LayerNodeIndex.POINT_PARAMETER, LayerNodeIndex.LAT_PROPERTY_KEY, "lat", LayerNodeIndex.LON_PROPERTY_KEY, "lon") );<commit_msg>datasource name is now: Config.DEFAULT_DATA_SOURCE_NAME<commit_after>/**
 * Copyright (c) 2010-2012 "<NAME>,"
 * Network Engine for Objects in Lund AB [http://neotechnology.com]
 *
 * This file is part of Neo4j.
 *
 * Neo4j is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.neo4j.gis.spatial.indexprovider;

import java.util.Collections;
import java.util.Map;

import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.index.Index;
import org.neo4j.graphdb.index.IndexImplementation;
import org.neo4j.graphdb.index.IndexManager;
import org.neo4j.graphdb.index.IndexProvider;
import org.neo4j.graphdb.index.RelationshipIndex;
import org.neo4j.helpers.Service;
import org.neo4j.helpers.collection.MapUtil;
import org.neo4j.kernel.Config;
import org.neo4j.kernel.KernelData;
import org.neo4j.kernel.KernelExtension;


@Service.Implementation( KernelExtension.class )
public class SpatialIndexProvider extends IndexProvider
{

    public static final String SERVICE_NAME = "spatial";
    public static final String GEOMETRY_TYPE = "geometry_type";

    public SpatialIndexProvider( )
    {
        super( SERVICE_NAME );        
    }

    @Override
    public IndexImplementation load(DependencyResolver dependencyResolver) throws Exception {
        return new SpatialIndexImplementation(dependencyResolver.resolveDependency(GraphDatabaseService.class));
    }

    private class SpatialIndexImplementation implements IndexImplementation {
    	
        private GraphDatabaseService db;

        public SpatialIndexImplementation(GraphDatabaseService db) {

            this.db = db;
        }

        @Override
        public String getDataSourceName() {
            return Config.DEFAULT_DATA_SOURCE_NAME;
        }

        @Override
        public Index<Node> nodeIndex(String indexName, Map<String, String> config) {
            return new LayerNodeIndex(indexName, db, config);
        }

        @Override
        public RelationshipIndex relationshipIndex(String indexName, Map<String, String> config) {
            throw new UnsupportedOperationException("Spatial relationship indexing is not supported at the moment. Please use the node index.");
        }

        @Override
        public Map<String, String> fillInDefaults(Map<String, String> config) {
            return config;
        }

        @Override
        public boolean configMatches(Map<String, String> stringStringMap, Map<String, String> stringStringMap1) {
            return false;
        }
    }
    
    public static final Map<String, String> SIMPLE_POINT_CONFIG =
            Collections.unmodifiableMap( MapUtil.stringMap(
                    IndexManager.PROVIDER, SERVICE_NAME, GEOMETRY_TYPE , LayerNodeIndex.POINT_PARAMETER, LayerNodeIndex.LAT_PROPERTY_KEY, "lat", LayerNodeIndex.LON_PROPERTY_KEY, "lon") );
{'fraction_non_alphanumeric': 0.07598784194528875, 'fraction_numerical': 0.007381676074685193, 'mean_word_length': 3.489928525016244, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2279230', 'n_tokens_mistral': 1915, 'n_tokens_neox': 1837, 'n_words': 557}