Skip to content

Commit

Permalink
Restructuring API entry to fit usage model
Browse files Browse the repository at this point in the history
  • Loading branch information
thobe authored and fickludd committed Nov 9, 2017
1 parent b47090c commit f96bb81
Show file tree
Hide file tree
Showing 27 changed files with 501 additions and 204 deletions.
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2002-2017 "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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.internal.kernel.api;

import org.neo4j.values.storable.Value;

public interface ExplicitIndexRead
{
void nodeExplicitIndexLookup( NodeExplicitIndexCursor cursor, String index, String key, Value value );

void nodeExplicitIndexQuery( NodeExplicitIndexCursor cursor, String index, Object query );

void nodeExplicitIndexQuery( NodeExplicitIndexCursor cursor, String index, String key, Object query );

void relationshipExplicitIndexGet(
RelationshipExplicitIndexCursor cursor, String index, String key, Value value, long source, long target );

void relationshipExplicitIndexQuery(
RelationshipExplicitIndexCursor cursor, String index, Object query, long source, long target );

void relationshipExplicitIndexQuery(
RelationshipExplicitIndexCursor cursor, String index, String key, Object query, long source, long target );
}
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2002-2017 "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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.internal.kernel.api;

public interface ExplicitIndexWrite
{
}
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2002-2017 "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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.internal.kernel.api;

public interface Kernel
{
CursorFactory cursors();

Session beginSession( Permissions permissions );
}
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2002-2017 "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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.internal.kernel.api;

public interface Locks
{
}
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2002-2017 "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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.internal.kernel.api;

import java.util.Collections;
import java.util.EnumSet;

public final class Permissions
{
enum Grant
{
DATA_READ,
DATA_WRITE,
SCHEMA_READ,
SCHEMA_WRITE,
TOKEN_WRITE
}

private final EnumSet<Grant> grants;

Permissions( Grant... grants )
{
this.grants = EnumSet.noneOf( Grant.class );
Collections.addAll( this.grants, grants );
}

boolean permits( Grant grant )
{
return grants.contains( grant );
}
}
Expand Up @@ -19,8 +19,6 @@
*/ */
package org.neo4j.internal.kernel.api; package org.neo4j.internal.kernel.api;


import org.neo4j.values.storable.Value;

/** /**
* Defines the read operations of the Kernel API. * Defines the read operations of the Kernel API.
*/ */
Expand Down Expand Up @@ -119,6 +117,8 @@ public interface Read
*/ */
void relationshipProperties( long reference, PropertyCursor cursor ); void relationshipProperties( long reference, PropertyCursor cursor );


void graphProperties( PropertyCursor cursor );

// hints to the page cache about data we will be accessing in the future: // hints to the page cache about data we will be accessing in the future:


void futureNodeReferenceRead( long reference ); void futureNodeReferenceRead( long reference );
Expand All @@ -128,27 +128,4 @@ public interface Read
void futureNodePropertyReferenceRead( long reference ); void futureNodePropertyReferenceRead( long reference );


void futureRelationshipPropertyReferenceRead( long reference ); void futureRelationshipPropertyReferenceRead( long reference );

// TOKEN/meta operations

IndexReference index( int label, int... properties );

int nodeLabel( String name );

int propertyKey( String name );

void nodeExplicitIndexLookup( NodeExplicitIndexCursor cursor, String index, String key, Value value );

void nodeExplicitIndexQuery( NodeExplicitIndexCursor cursor, String index, Object query );

void nodeExplicitIndexQuery( NodeExplicitIndexCursor cursor, String index, String key, Object query );

void relationshipExplicitIndexGet(
RelationshipExplicitIndexCursor cursor, String index, String key, Value value, long source, long target );

void relationshipExplicitIndexQuery(
RelationshipExplicitIndexCursor cursor, String index, Object query, long source, long target );

void relationshipExplicitIndexQuery(
RelationshipExplicitIndexCursor cursor, String index, String key, Object query, long source, long target );
} }
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2002-2017 "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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.internal.kernel.api;

public interface SchemaRead
{
IndexReference index( int label, int... properties );
}
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2002-2017 "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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.internal.kernel.api;

public interface SchemaWrite
{
}
Expand Up @@ -19,16 +19,12 @@
*/ */
package org.neo4j.internal.kernel.api; package org.neo4j.internal.kernel.api;


/** public interface Session extends AutoCloseable
* Entry point for the Kernel API
*
* Usage pattern is under development
*/
public interface KernelAPI
{ {
Transaction beginTransaction(); Transaction beginTransaction();


CursorFactory cursors();

Token token(); Token token();

@Override
void close();
} }
Expand Up @@ -47,4 +47,8 @@ class SomeException extends Exception
void propertyKeyCreateForName( String propertyKeyName, int id ) throws SomeException; void propertyKeyCreateForName( String propertyKeyName, int id ) throws SomeException;


void relationshipTypeCreateForName( String relationshipTypeName, int id ) throws SomeException; void relationshipTypeCreateForName( String relationshipTypeName, int id ) throws SomeException;

int nodeLabel( String name );

int propertyKey( String name );
} }
Expand Up @@ -19,8 +19,25 @@
*/ */
package org.neo4j.internal.kernel.api; package org.neo4j.internal.kernel.api;


public interface Transaction extends Read, Write, AutoCloseable public interface Transaction
{ {
void success(); long READ_ONLY_TRANSACTION = 0;
void failure();
long commit();

void rollback();

Read dataRead();

Write dataWrite();

ExplicitIndexRead indexRead();

ExplicitIndexWrite indexWrite();

SchemaRead schemaRead();

SchemaWrite schemaWrite();

Locks locks();
} }
Expand Up @@ -38,18 +38,15 @@ public interface Write


void nodeRemoveLabel( long node, int nodeLabel ); void nodeRemoveLabel( long node, int nodeLabel );


// TODO: Define property value hierarchy Value nodeSetProperty( long node, int propertyKey, Value value );
// We will want a value type hierarchy to avoid passing objects around, which should be shared by all of Neo4j
// server. This can hold general logic such as equality, coercion, ordering and comparability. It also needs some
// visitor/writer functionality so we can break out large logic and eg. file formats.


// This method will become Value nodeRemoveProperty( long node, int propertyKey );
// void nodeSetProperty( long node, int propertyKey, Value value );
void nodeSetProperty( long node, int propertyKey, Object value );


void nodeRemoveProperty( long node, int propertyKey ); Value relationshipSetProperty( long relationship, int propertyKey, Value value );


void relationshipSetProperty( long relationship, int propertyKey, Value value ); Value relationshipRemoveProperty( long node, int propertyKey );


void relationshipRemoveProperty( long node, int propertyKey ); Value graphSetProperty( int propertyKey, Value value );

Value graphRemoveProperty( int propertyKey );
} }

0 comments on commit f96bb81

Please sign in to comment.