Skip to content

Commit

Permalink
Move createUniquenessConstraint procedure to community
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen authored and MishaDemianenko committed Jun 9, 2018
1 parent 323849e commit 5eca23a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 18 deletions.
Expand Up @@ -236,6 +236,21 @@ public Stream<SchemaIndexInfo> createIndex(
} }
} }


@Description( "Create a unique property constraint with index backed by specified index provider " +
"(for example: CALL db.createUniquePropertyConstraint(\":Person(name)\", \"lucene+native-2.0\")) - " +
"YIELD index, providerName, status" )
@Procedure( name = "db.createUniquePropertyConstraint", mode = SCHEMA )
public Stream<BuiltInProcedures.SchemaIndexInfo> createUniquePropertyConstraint(
@Name( "index" ) String index,
@Name( "providerName" ) String providerName )
throws ProcedureException
{
try ( IndexProcedures indexProcedures = indexProcedures() )
{
return indexProcedures.createUniquePropertyConstraint( index, providerName );
}
}

@Description( "Get node from explicit index. Replaces `START n=node:nodes(key = 'A')`" ) @Description( "Get node from explicit index. Replaces `START n=node:nodes(key = 'A')`" )
@Procedure( name = "db.index.explicit.seekNodes", mode = READ ) @Procedure( name = "db.index.explicit.seekNodes", mode = READ )
public Stream<NodeResult> nodeManualIndexSeek( @Name( "indexName" ) String explicitIndexName, public Stream<NodeResult> nodeManualIndexSeek( @Name( "indexName" ) String explicitIndexName,
Expand Down
Expand Up @@ -327,6 +327,12 @@ public void shouldListCorrectBuiltinProcedures() throws Throwable
record( "db.createIndex", record( "db.createIndex",
"db.createIndex(index :: STRING?, providerName :: STRING?) :: (index :: STRING?, providerName :: STRING?, status :: STRING?)", "db.createIndex(index :: STRING?, providerName :: STRING?) :: (index :: STRING?, providerName :: STRING?, status :: STRING?)",
"Create a schema index with specified index provider (for example: CALL db.createIndex(\":Person(name)\", \"lucene+native-2.0\")) - " + "Create a schema index with specified index provider (for example: CALL db.createIndex(\":Person(name)\", \"lucene+native-2.0\")) - " +
"YIELD index, providerName, status", "SCHEMA" ),
record( "db.createUniquePropertyConstraint",
"db.createUniquePropertyConstraint(index :: STRING?, providerName :: STRING?) :: " +
"(index :: STRING?, providerName :: STRING?, status :: STRING?)",
"Create a unique property constraint with index backed by specified index provider " +
"(for example: CALL db.createUniquePropertyConstraint(\":Person(name)\", \"lucene+native-2.0\")) - " +
"YIELD index, providerName, status", "SCHEMA" ) "YIELD index, providerName, status", "SCHEMA" )
) ); ) );
} }
Expand Down
Expand Up @@ -266,7 +266,13 @@ public void listProcedures() throws Throwable
"Create a schema index with specified index provider (for example: CALL db.createIndex(\":Person(name)\", \"lucene+native-2.0\")) - " + "Create a schema index with specified index provider (for example: CALL db.createIndex(\":Person(name)\", \"lucene+native-2.0\")) - " +
"YIELD index, providerName, status", "YIELD index, providerName, status",
"SCHEMA" "SCHEMA"
} ) } ),
equalTo( new Object[]{"db.createUniquePropertyConstraint",
"db.createUniquePropertyConstraint(index :: STRING?, providerName :: STRING?) :: " +
"(index :: STRING?, providerName :: STRING?, status :: STRING?)",
"Create a unique property constraint with index backed by specified index provider " +
"(for example: CALL db.createUniquePropertyConstraint(\":Person(name)\", \"lucene+native-2.0\")) - " +
"YIELD index, providerName, status", "SCHEMA"} )
) ); ) );
commit(); commit();
} }
Expand Down
Expand Up @@ -21,8 +21,11 @@


import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;


import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.StringJoiner; import java.util.StringJoiner;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;


Expand Down Expand Up @@ -56,8 +59,18 @@
import static org.neo4j.graphdb.factory.GraphDatabaseSettings.SchemaIndex.NATIVE10; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.SchemaIndex.NATIVE10;
import static org.neo4j.values.storable.Values.stringValue; import static org.neo4j.values.storable.Values.stringValue;


@RunWith( Parameterized.class )
public class CreateIndexProcedureIT extends KernelIntegrationTest public class CreateIndexProcedureIT extends KernelIntegrationTest
{ {
@Parameterized.Parameters( name = "{1}")
public static Collection<Object[]> parameters()
{
return Arrays.asList(
new Object[]{ true, "createIndex", "index created" }
new Object[]{ false, "createUniquePropertyConstraint", "uniqueness constraint online" },
);
}

@Test @Test
public void createIndexWithGivenProvider() throws KernelException public void createIndexWithGivenProvider() throws KernelException
{ {
Expand Down
Expand Up @@ -43,21 +43,6 @@ public class EnterpriseBuiltInProcedures
@Context @Context
public DependencyResolver resolver; public DependencyResolver resolver;


@Description( "Create a unique property constraint with index backed by specified index provider " +
"(for example: CALL db.createUniquePropertyConstraint(\":Person(name)\", \"lucene+native-2.0\")) - " +
"YIELD index, providerName, status" )
@Procedure( name = "db.createUniquePropertyConstraint", mode = SCHEMA )
public Stream<BuiltInProcedures.SchemaIndexInfo> createUniquePropertyConstraint(
@Name( "index" ) String index,
@Name( "providerName" ) String providerName )
throws ProcedureException
{
try ( IndexProcedures indexProcedures = indexProcedures() )
{
return indexProcedures.createUniquePropertyConstraint( index, providerName );
}
}

@Description( "Create a node key constraint with index backed by specified index provider " + @Description( "Create a node key constraint with index backed by specified index provider " +
"(for example: CALL db.createNodeKey(\":Person(name)\", \"lucene+native-2.0\")) - " + "(for example: CALL db.createNodeKey(\":Person(name)\", \"lucene+native-2.0\")) - " +
"YIELD index, providerName, status" ) "YIELD index, providerName, status" )
Expand Down
Expand Up @@ -51,8 +51,7 @@ public class EnterpriseCreateIndexProcedureIT extends CreateIndexProcedureIT
public static Collection<Object[]> parameters() public static Collection<Object[]> parameters()
{ {
return Arrays.asList( return Arrays.asList(
new Object[]{ false, "createUniquePropertyConstraint", "uniqueness constraint online" }, (Object[][]) new Object[]{true, "createNodeKey", "node key constraint online"}
new Object[]{ true, "createNodeKey", "node key constraint online" }
); );
} }


Expand Down

0 comments on commit 5eca23a

Please sign in to comment.