Neo4j Community

org.neo4j.tooling.wrap
Class WrappedIndex<T extends PropertyContainer,I extends ReadableIndex<T>>

java.lang.Object
  extended by org.neo4j.tooling.wrap.WrappedIndex<T,I>
All Implemented Interfaces:
Index<T>, ReadableIndex<T>
Direct Known Subclasses:
WrappedIndex.WrappedNodeIndex, WrappedIndex.WrappedRelationshipIndex

public abstract class WrappedIndex<T extends PropertyContainer,I extends ReadableIndex<T>>
extends Object
implements Index<T>


Nested Class Summary
static class WrappedIndex.WrappedNodeIndex
           
static class WrappedIndex.WrappedRelationshipIndex
           
 
Method Summary
protected abstract  I actual()
           
 void add(T entity, String key, Object value)
          Adds a key/value pair for entity to the index.
 void delete()
          Clears the index and deletes the configuration associated with it.
 IndexHits<T> get(String key, Object value)
          Returns exact matches from this index, given the key/value pair.
 Class<T> getEntityType()
           
 GraphDatabaseService getGraphDatabase()
          Get the graph database that owns this index.
 String getName()
           
 boolean isWriteable()
          A ReadableIndex is possible to support mutating operations as well.
 T putIfAbsent(T entity, String key, Object value)
          Add the entity to this index for the given key/value pair if this particular key/value pair doesn't already exist.
 IndexHits<T> query(Object queryOrQueryObject)
          Returns matches from this index based on the supplied query object, which can be a query string or an implementation-specific query object.
 IndexHits<T> query(String key, Object queryOrQueryObject)
          Returns matches from this index based on the supplied key and query object, which can be a query string or an implementation-specific query object.
 void remove(T entity)
          Removes an entity from the index and all its key/value pairs which has been previously associated using Index.add(PropertyContainer, String, Object).
 void remove(T entity, String key)
          Removes key/value pairs for entity where key is key from the index.
 void remove(T entity, String key, Object value)
          Removes a key/value pair for entity from the index.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

actual

protected abstract I actual()

getGraphDatabase

public GraphDatabaseService getGraphDatabase()
Description copied from interface: ReadableIndex
Get the graph database that owns this index.

Specified by:
getGraphDatabase in interface ReadableIndex<T extends PropertyContainer>
Returns:
the graph database that owns this index.

toString

public String toString()
Overrides:
toString in class Object

getName

public String getName()
Specified by:
getName in interface ReadableIndex<T extends PropertyContainer>
Returns:
the name of the index, i.e. the name this index was created with.

getEntityType

public Class<T> getEntityType()
Specified by:
getEntityType in interface ReadableIndex<T extends PropertyContainer>
Returns:
the type of entities are managed by this index.

add

public void add(T entity,
                String key,
                Object value)
Description copied from interface: Index
Adds a key/value pair for entity to the index. If that key/value pair for the entity is already in the index it's up to the implementation to make it so that such an operation is idempotent.

Specified by:
add in interface Index<T extends PropertyContainer>
Parameters:
entity - the entity (i.e Node or Relationship) to associate the key/value pair with.
key - the key in the key/value pair to associate with the entity.
value - the value in the key/value pair to associate with the entity.

remove

public void remove(T entity,
                   String key,
                   Object value)
Description copied from interface: Index
Removes a key/value pair for entity from the index. If that key/value pair isn't associated with entity in this index this operation doesn't do anything.

Specified by:
remove in interface Index<T extends PropertyContainer>
Parameters:
entity - the entity (i.e Node or Relationship) to dissociate the key/value pair from.
key - the key in the key/value pair to dissociate from the entity.
value - the value in the key/value pair to dissociate from the entity.

remove

public void remove(T entity,
                   String key)
Description copied from interface: Index
Removes key/value pairs for entity where key is key from the index. Implementations can choose to not implement this method and should in that case throw UnsupportedOperationException.

Specified by:
remove in interface Index<T extends PropertyContainer>
Parameters:
entity - the entity (Node or Relationship) to remove the this index.

remove

public void remove(T entity)
Description copied from interface: Index
Removes an entity from the index and all its key/value pairs which has been previously associated using Index.add(PropertyContainer, String, Object). Implementations can choose to not implement this method and should in that case throw UnsupportedOperationException.

Specified by:
remove in interface Index<T extends PropertyContainer>
Parameters:
entity - the entity (Node or Relationship) to remove the this index.

delete

public void delete()
Description copied from interface: Index
Clears the index and deletes the configuration associated with it. After this it's invalid to call any other method on this index. However if the transaction which the delete operation was called in gets rolled back it again becomes ok to use this index.

Specified by:
delete in interface Index<T extends PropertyContainer>

get

public IndexHits<T> get(String key,
                        Object value)
Description copied from interface: ReadableIndex
Returns exact matches from this index, given the key/value pair. Matches will be for key/value pairs just as they were added by the #add(PropertyContainer, String, Object) method.

Specified by:
get in interface ReadableIndex<T extends PropertyContainer>
Parameters:
key - the key in the key/value pair to match.
value - the value in the key/value pair to match.
Returns:
the result wrapped in an IndexHits object. If the entire result set isn't looped through, IndexHits.close() must be called before disposing of the result.

query

public IndexHits<T> query(String key,
                          Object queryOrQueryObject)
Description copied from interface: ReadableIndex
Returns matches from this index based on the supplied key and query object, which can be a query string or an implementation-specific query object.

Specified by:
query in interface ReadableIndex<T extends PropertyContainer>
Parameters:
key - the key in this query.
queryOrQueryObject - the query for the key to match.
Returns:
the result wrapped in an IndexHits object. If the entire result set isn't looped through, IndexHits.close() must be called before disposing of the result.

query

public IndexHits<T> query(Object queryOrQueryObject)
Description copied from interface: ReadableIndex
Returns matches from this index based on the supplied query object, which can be a query string or an implementation-specific query object.

Specified by:
query in interface ReadableIndex<T extends PropertyContainer>
Parameters:
queryOrQueryObject - the query to match.
Returns:
the result wrapped in an IndexHits object. If the entire result set isn't looped through, IndexHits.close() must be called before disposing of the result.

isWriteable

public boolean isWriteable()
Description copied from interface: ReadableIndex
A ReadableIndex is possible to support mutating operations as well. This method returns true iff such operations are supported by the implementation.

Specified by:
isWriteable in interface ReadableIndex<T extends PropertyContainer>
Returns:
true iff mutating operations are supported.

putIfAbsent

public T putIfAbsent(T entity,
                     String key,
                     Object value)
Description copied from interface: Index
Add the entity to this index for the given key/value pair if this particular key/value pair doesn't already exist. This ensures that only one entity will be associated with the key/value pair even if multiple transactions are trying to add it at the same time. One of those transactions will win and add it while the others will block, waiting for the winning transaction to finish. If the winning transaction was successful these other transactions will return the associated entity instead of adding it. If it wasn't successful the waiting transactions will begin a new race to add it.

Specified by:
putIfAbsent in interface Index<T extends PropertyContainer>
Parameters:
entity - the entity (i.e Node or Relationship) to associate the key/value pair with.
key - the key in the key/value pair to associate with the entity.
value - the value in the key/value pair to associate with the entity.
Returns:
the previously indexed entity, or null if no entity was indexed before (and the specified entity was added to the index).

Neo4j Community

Copyright © 2002-2012 The Neo4j Graph Database Project. All Rights Reserved.