Unnamed: 0
int64 0
6.7k
| func
stringlengths 12
89.6k
| target
bool 2
classes | project
stringlengths 45
151
|
|---|---|---|---|
6,400
|
public interface CacheLoader<T>
{
T load( long id ) throws EntityNotFoundException;
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_api_store_CacheLoader.java
|
6,401
|
public interface CacheUpdateListener
{
void newSize( Primitive entity, int size );
public static final CacheUpdateListener NO_UPDATES = new CacheUpdateListener()
{
@Override
public void newSize( Primitive entity, int size )
{
}
};
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_api_store_CacheUpdateListener.java
|
6,402
|
public interface StoreReadLayer
{
boolean nodeHasLabel( KernelStatement state, long nodeId, int labelId ) throws EntityNotFoundException;
PrimitiveIntIterator nodeGetLabels( KernelStatement state, long nodeId ) throws EntityNotFoundException;
Iterator<IndexDescriptor> indexesGetForLabel( KernelStatement state, int labelId );
Iterator<IndexDescriptor> indexesGetAll( KernelStatement state );
Iterator<IndexDescriptor> uniqueIndexesGetForLabel( KernelStatement state, int labelId );
Iterator<IndexDescriptor> uniqueIndexesGetAll( KernelStatement state );
Long indexGetOwningUniquenessConstraintId( KernelStatement state, IndexDescriptor index )
throws SchemaRuleNotFoundException;
long indexGetCommittedId( KernelStatement state, IndexDescriptor index, SchemaStorage.IndexRuleKind kind ) throws SchemaRuleNotFoundException;
IndexRule indexRule( IndexDescriptor index, SchemaStorage.IndexRuleKind kind );
PrimitiveLongIterator nodeGetPropertyKeys( KernelStatement state, long nodeId ) throws EntityNotFoundException;
Property nodeGetProperty( KernelStatement state, long nodeId, int propertyKeyId ) throws EntityNotFoundException;
Iterator<DefinedProperty> nodeGetAllProperties( KernelStatement state, long nodeId ) throws EntityNotFoundException;
PrimitiveLongIterator relationshipGetPropertyKeys( KernelStatement state, long relationshipId )
throws EntityNotFoundException;
Property relationshipGetProperty( KernelStatement state, long relationshipId, int propertyKeyId )
throws EntityNotFoundException;
Iterator<DefinedProperty> relationshipGetAllProperties( KernelStatement state, long nodeId )
throws EntityNotFoundException;
PrimitiveLongIterator graphGetPropertyKeys( KernelStatement state );
Property graphGetProperty( KernelStatement state, int propertyKeyId );
Iterator<DefinedProperty> graphGetAllProperties( KernelStatement state );
Iterator<UniquenessConstraint> constraintsGetForLabelAndPropertyKey(
KernelStatement state, int labelId, int propertyKeyId );
Iterator<UniquenessConstraint> constraintsGetForLabel( KernelStatement state, int labelId );
Iterator<UniquenessConstraint> constraintsGetAll( KernelStatement state );
PrimitiveLongIterator nodeGetUniqueFromIndexLookup( KernelStatement state, IndexDescriptor index,
Object value )
throws IndexNotFoundKernelException, IndexBrokenKernelException;
PrimitiveLongIterator nodesGetForLabel( KernelStatement state, int labelId );
PrimitiveLongIterator nodesGetFromIndexLookup( KernelStatement state, IndexDescriptor index, Object value )
throws IndexNotFoundKernelException;
IndexDescriptor indexesGetForLabelAndPropertyKey( KernelStatement state, int labelId, int propertyKey )
throws SchemaRuleNotFoundException;
InternalIndexState indexGetState( KernelStatement state, IndexDescriptor descriptor )
throws IndexNotFoundKernelException;
String indexGetFailure( Statement state, IndexDescriptor descriptor ) throws IndexNotFoundKernelException;
int labelGetForName( String labelName );
String labelGetName( int labelId ) throws LabelNotFoundKernelException;
int propertyKeyGetForName( String propertyKeyName );
int propertyKeyGetOrCreateForName( String propertyKeyName );
String propertyKeyGetName( int propertyKeyId ) throws PropertyKeyIdNotFoundKernelException;
Iterator<Token> propertyKeyGetAllTokens();
Iterator<Token> labelsGetAllTokens();
int relationshipTypeGetForName( String relationshipTypeName );
String relationshipTypeGetName( int relationshipTypeId ) throws RelationshipTypeIdNotFoundKernelException;
int labelGetOrCreateForName( String labelName ) throws TooManyLabelsException;
int relationshipTypeGetOrCreateForName( String relationshipTypeName );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_api_store_StoreReadLayer.java
|
6,403
|
public interface Loader<E>
{
/**
* Load the entity, or null if no entity exists.
*/
E loadById( long id );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_cache_AutoLoadingCache.java
|
6,404
|
public interface Cache<E extends EntityWithSizeObject>
{
/**
* Returns the name of the cache.
*
* @return name of the cache
*/
String getName();
/**
* Adds {@code element} to the cache. This operation is atomic and will not put the element into the cache
* if there were a previous element with the same {@link EntityWithSizeObject#getId() id}, but instead
* then return that element.
*
* @param value the element to cache.
*/
E put( E value );
/**
* Removes the element for <CODE>key</CODE> from cache and returns it. If
* the no element for <CODE>key</CODE> exists <CODE>null</CODE> is
* returned.
*
* @param key
* the key for the element
* @return the removed element or <CODE>null</CODE> if element didn't
* exist
*/
E remove( long key );
/**
* Returns the cached element for <CODE>key</CODE>. If the element isn't
* in cache <CODE>null</CODE> is returned.
*
* @param key
* the key for the element
* @return the cached element or <CODE>null</CODE> if element didn't exist
*/
E get( long key );
/**
* Removing all cached elements.
*/
void clear();
/**
* Returns the cache size. This number means different depending on cache type.
*
* @return cache size
*/
long size();
void putAll( Collection<E> values );
long hitCount();
long missCount();
void updateSize( E entity, int newSize );
void printStatistics();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_cache_Cache.java
|
6,405
|
public interface EntityWithSizeObject extends SizeOfObject
{
/**
* Id of this entity.
* @return the id of this entity.
*/
long getId();
/**
* Sets the size which was registered with the cache which this entity is in.
* @param size the size to store for future retrieval in {@link #getRegisteredSize()}.
*/
void setRegisteredSize( int size );
/**
* Returns the most recent registered size from {@link #setRegisteredSize(int)}.
* Called from the cache that this entity is in.
* @return the registered size of this entity.
*/
int getRegisteredSize();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_cache_EntityWithSizeObject.java
|
6,406
|
public interface Monitor {
void purged( long sizeBefore, long sizeAfter, int numberOfEntitiesPurged );
}
| false
|
enterprise_ha_src_main_java_org_neo4j_kernel_impl_cache_HighPerformanceCache.java
|
6,407
|
public interface ReferenceWithKey<KEY, VALUE>
{
interface Factory
{
<FK, FV> ReferenceWithKey<FK, FV> newReference( FK key, FV value, ReferenceQueue<? super FV> queue );
}
KEY key();
VALUE get();
void clear();
boolean enqueue();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_cache_ReferenceWithKey.java
|
6,408
|
interface Factory
{
<FK, FV> ReferenceWithKey<FK, FV> newReference( FK key, FV value, ReferenceQueue<? super FV> queue );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_cache_ReferenceWithKey.java
|
6,409
|
public interface SizeOfObject
{
/**
* @return the size in bytes of the state of this object including its object overhead (16b).
*/
int sizeOfObjectInBytesIncludingOverhead();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_cache_SizeOfObject.java
|
6,410
|
public interface CacheAccessBackDoor
{
void removeNodeFromCache( long nodeId );
void removeRelationshipFromCache( long id );
void removeRelationshipTypeFromCache( int id );
void removeGraphPropertiesFromCache();
void addSchemaRule( SchemaRule schemaRule );
void removeSchemaRuleFromCache( long id );
void addRelationshipTypeToken( Token type );
void addLabelToken( Token labelId );
void addPropertyKeyToken( Token index );
void applyLabelUpdates( Collection<NodeLabelUpdate> labelUpdates );
/**
* Patches the relationship chain loading parts of the start and end nodes of deleted relationships. This is
* a good idea to call when deleting relationships, otherwise the in memory representation of relationship chains
* may become damaged.
* This is not expected to remove the deleted relationship from the cache - use
* {@link #removeRelationshipFromCache(long)} for that purpose before calling this method.
*
* @param relId The relId of the relationship deleted
* @param firstNodeId The relId of the first node
* @param firstNodeNextRelId The next relationship relId of the first node in its relationship chain
* @param secondNodeId The relId of the second node
* @param secondNodeNextRelId The next relationship relId of the second node in its relationship chain
*/
void patchDeletedRelationshipNodes( long relId, long firstNodeId, long firstNodeNextRelId, long secondNodeId,
long secondNodeNextRelId );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_core_CacheAccessBackDoor.java
|
6,411
|
public interface Caches
{
void configure( CacheProvider cacheProvider, Config config );
Cache<NodeImpl> node();
Cache<RelationshipImpl> relationship();
void invalidate();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_core_Caches.java
|
6,412
|
public interface EntityFactory
{
Node newNodeProxyById( long id );
Relationship newRelationshipProxyById( long id );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_core_EntityFactory.java
|
6,413
|
public interface GraphProperties extends PropertyContainer
{
NodeManager getNodeManager();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_core_GraphProperties.java
|
6,414
|
public interface LastTxIdGetter
{
long getLastTxId();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_core_LastTxIdGetter.java
|
6,415
|
static enum LoadStatus
{
NOTHING( false, false ),
LOADED_END( true, false ),
LOADED_MORE( true, true );
private final boolean loaded;
private final boolean more;
private LoadStatus( boolean loaded, boolean more )
{
this.loaded = loaded;
this.more = more;
}
public boolean loaded()
{
return this.loaded;
}
public boolean hasMoreToLoad()
{
return this.more;
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_core_NodeImpl.java
|
6,416
|
public interface NodeLookup
{
NodeImpl lookup( long nodeId );
GraphDatabaseService getGraphDatabase();
NodeManager getNodeManager();
NodeImpl lookup( long nodeId, LockType lock );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_core_NodeProxy.java
|
6,417
|
public interface RelationshipLookups
{
Node newNodeProxy( long nodeId );
RelationshipImpl lookupRelationship(long relationshipId);
GraphDatabaseService getGraphDatabaseService();
NodeManager getNodeManager();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_core_RelationshipProxy.java
|
6,418
|
private interface DynamicRecordCounter
{
long count();
}
| false
|
community_kernel_src_test_java_org_neo4j_kernel_impl_core_TestLengthyArrayPacking.java
|
6,419
|
public interface TokenCreator
{
int getOrCreate( AbstractTransactionManager txManager, EntityIdGenerator idGenerator,
PersistenceManager persistence, String name );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_core_TokenCreator.java
|
6,420
|
public interface TransactionState
{
TransactionState NO_STATE = new NoTransactionState();
LockElement acquireWriteLock( Object resource );
LockElement acquireReadLock( Object resource );
ArrayMap<Integer, RelIdArray> getCowRelationshipAddMap( NodeImpl node );
RelIdArray getOrCreateCowRelationshipAddMap( NodeImpl node, int type );
ArrayMap<Integer, Collection<Long>> getCowRelationshipRemoveMap( NodeImpl node );
Collection<Long> getOrCreateCowRelationshipRemoveMap( NodeImpl node, int type );
void setFirstIds( long nodeId, long firstRel, long firstProp );
void commit();
void commitCows();
void rollback();
boolean hasLocks();
ArrayMap<Integer, DefinedProperty> getCowPropertyRemoveMap( Primitive primitive );
ArrayMap<Integer, DefinedProperty> getCowPropertyAddMap( Primitive primitive );
ArrayMap<Integer, DefinedProperty> getOrCreateCowPropertyAddMap( Primitive primitive );
ArrayMap<Integer, DefinedProperty> getOrCreateCowPropertyRemoveMap( Primitive primitive );
void createNode( long id );
void createRelationship( long id );
void deleteNode( long id );
void deleteRelationship( long id );
TransactionData getTransactionData();
boolean nodeIsDeleted( long nodeId );
boolean relationshipIsDeleted( long relationshpId );
boolean hasChanges();
RemoteTxHook getTxHook();
TxIdGenerator getTxIdGenerator();
Set<Long> getCreatedNodes();
Set<Long> getCreatedRelationships();
// Tech debt, this is here waiting for transaction state to move to the TxState class
Iterable<WritableTransactionState.CowNodeElement> getChangedNodes();
/**
* Below are two methods for getting and setting a {@link ResourceHolder}, i.e. a carrier of a
* {@link NeoStoreTransaction}. This is not a very good strategy. The reason it's here is that it's
* less contended to put and reach that instance in each {@link TransactionState} object, instead of
* in a shared map or similar in {@link PersistenceManager}.
*/
ResourceHolder getNeoStoreTransaction();
void setNeoStoreTransaction( ResourceHolder neoStoreTransaction );
/**
* A history of slave transactions and their cultural impact on Graph Databases.
*
*
* Acknowledgments
*
* I would like to thank both Mattias and Chris for their excellent input on this subject, without their eye
* witness accounts of the actual events, none of this would be possible.
*
*
* Chapter I
* Humble Beginnings
*
* Once upon a time, when a slave asked the master to perform an action, this used to imply something, a bond.
* The master recognized the slaves need for a transaction, and would implicitly create one. It was a time of peace
* and of reconciliation. Alas, this soon led to confusion as untrustworthy networks would cause master switches.
* A new master might receive a message intended for another, and would out of the kindness of his kernel create a
* new transaction for the slave. While a beautiful gesture, it shouldn't have done this because now it had tore
* transaction state into two transactions, a most vile abomination.
*
* So it was decided that the trust the masters had in their slaves must be revoked. Instead slaves had to
* explicitly ask the masters to create a transaction. All was now consistent - but now an additional network hop
* was required, and slaves begin transactions on the masters for the most simple of requests. Read only operations
* would suddenly pull updates. The universe was in disarray.
*
*
* Chapter II
* A hack
*
* Pulling updates on read operations is very bad, because it voids the databases contracts for when updates should
* be pulled, and makes read scaling perform very poorly. It was soon recognized that, while correct, the new
* regimen could not be allowed to stand. A hack was devised, whereupon the slave would wait to initialize the
* transaction on the master until the first write lock was required. A clear signal that a write was about to
* happen.
*
* This very hack is why the below methods exist.
*
*
* Chapter III
* A new dawn
*
* Once all Neo4j operations are contained in the Kernel component, the kernel will be able to get a clear view of
* all running transactions, and clear entry points for all running operations within those transactions. With that,
* a new rein of trust can be implemented. As soon as a slave sees a new master, it will be able to void all running
* transactions, and start new with the new master. This will allow a return to the days of implicit transactions,
* where network communication is done only just when it is needed, and removing the additional network hop.
*
* The End.
*
*/
boolean isRemotelyInitialized();
void markAsRemotelyInitialized();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_core_TransactionState.java
|
6,421
|
public interface Work<RESULT, FAILURE extends KernelException>
{
RESULT perform( Statement statement ) throws FAILURE;
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_core_Transactor.java
|
6,422
|
public interface TxEventSyncHookFactory
{
/**
* Creates a new {@link TransactionEventsSyncHook} instance of there
* are any registered {@link TransactionEventHandler}s, else {@code null}.
* @return a new {@link TransactionEventsSyncHook} or {@code null} if
* there were no registered {@link TransactionEventHandler}s.
*/
TransactionEventsSyncHook create();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_core_TxEventSyncHookFactory.java
|
6,423
|
public interface InternalSchemaActions
{
IndexDefinition createIndexDefinition( Label label, String propertyKey );
void dropIndexDefinitions( Label label, String propertyKey );
ConstraintDefinition createPropertyUniquenessConstraint( Label label, String propertyKey )
throws IllegalTokenNameException, TooManyLabelsException, CreateConstraintFailureException,
AlreadyConstrainedException, AlreadyIndexedException;
void dropPropertyUniquenessConstraint( Label label, String propertyKey );
String getUserMessage( KernelException e );
void assertInTransaction();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_coreapi_schema_InternalSchemaActions.java
|
6,424
|
private static enum RelTypes implements RelationshipType
{
TXEVENT
}
| false
|
community_kernel_src_test_java_org_neo4j_kernel_impl_event_TestTransactionEvents.java
|
6,425
|
public interface Dependencies
{
InternalAbstractGraphDatabase getDatabase();
IndexProviders getIndexProviders();
}
| false
|
community_kernel_src_test_java_org_neo4j_kernel_impl_index_DummyIndexExtensionFactory.java
|
6,426
|
public interface IndexXaConnection
{
void createIndex( Class<? extends PropertyContainer> entityType,
String indexName, Map<String, String> config );
boolean enlistResource( Transaction javaxTx )
throws SystemException, RollbackException;
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_index_IndexXaConnection.java
|
6,427
|
public interface LockService
{
enum LockType
{
READ_LOCK,
WRITE_LOCK
}
Lock acquireNodeLock( long nodeId, LockType type );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_locking_LockService.java
|
6,428
|
enum LockType
{
READ_LOCK,
WRITE_LOCK
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_locking_LockService.java
|
6,429
|
enum Benchmark
{
UNCONTENDED
{
@Override
void execute( Implementation impl )
{
int minThreads = Integer.getInteger( "minThreads", 1 );
int maxThreads = Integer.getInteger( "maxThreads", cores() * 2 );
int iterations = Integer.getInteger( "iterations", 100 );
int lockCount = Integer.getInteger( "lockCount", 100_000 );
for ( int threads = minThreads; threads <= maxThreads; threads++ )
{
System.out.printf( "=== %s / %s - %s threads ===%n", this, impl, threads );
executeUncontended( impl, threads, iterations, lockCount, false );
}
}
},
REENTRY
{
@Override
void execute( Implementation impl )
{
int minThreads = Integer.getInteger( "minThreads", 1 );
int maxThreads = Integer.getInteger( "maxThreads", cores() * 2 );
int iterations = Integer.getInteger( "iterations", 100 );
int lockCount = Integer.getInteger( "lockCount", 100_000 );
for ( int threads = minThreads; threads <= maxThreads; threads++ )
{
System.out.printf( "=== %s / %s - %s threads ===%n", this, impl, threads );
executeUncontended( impl, threads, iterations, lockCount, true );
}
}
},
HANDOVER
{
@Override
void execute( Implementation impl )
{
int minThreads = Integer.getInteger( "minThreads", 1 );
int maxThreads = Integer.getInteger( "maxThreads", cores() * 2 );
int iterations = Integer.getInteger( "iterations", 100 );
int lockCount = Integer.getInteger( "lockCount", 100_000 );
for ( int threads = minThreads; threads <= maxThreads; threads++ )
{
System.out.printf( "=== %s / %s - %s threads ===%n", this, impl, threads );
executeHandover( impl, threads, iterations, lockCount );
}
}
};
abstract void execute( Implementation impl );
}
| false
|
community_kernel_src_test_java_org_neo4j_kernel_impl_locking_LockServiceMicroBenchmark.java
|
6,430
|
enum Implementation
{
LOCK_MANAGER
{
@Override
LockService create()
{
return new AdaptedLockManager();
}
},
REENTRANT_LOCK_SERVICE
{
@Override
LockService create()
{
return new ReentrantLockService();
}
};
abstract LockService create();
}
| false
|
community_kernel_src_test_java_org_neo4j_kernel_impl_locking_LockServiceMicroBenchmark.java
|
6,431
|
public interface Task
{
void perform() throws Exception;
}
| false
|
community_kernel_src_test_java_org_neo4j_kernel_impl_locking_ThreadRepository.java
|
6,432
|
public interface ThreadInfo
{
StackTraceElement[] getStackTrace();
Object blocker();
Thread.State getState();
}
| false
|
community_kernel_src_test_java_org_neo4j_kernel_impl_locking_ThreadRepository.java
|
6,433
|
public interface BrickElementFactory
{
public static final BrickElementFactory DEFAULT = new BrickElementFactory()
{
@Override
public BrickElement create( int index )
{
return new BrickElement( index );
}
};
BrickElement create( int index );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_BrickElementFactory.java
|
6,434
|
public interface DynamicBlockSize
{
int getBlockSize();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_DynamicBlockSize.java
|
6,435
|
public interface DynamicRecordAllocator
{
int dataSize();
DynamicRecord nextUsedRecordOrNew( Iterator<DynamicRecord> recordsToUseFirst );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_DynamicRecordAllocator.java
|
6,436
|
public interface FileSystemAbstraction
{
StoreChannel open( File fileName, String mode ) throws IOException;
OutputStream openAsOutputStream( File fileName, boolean append ) throws IOException;
InputStream openAsInputStream( File fileName ) throws IOException;
Reader openAsReader( File fileName, String encoding ) throws IOException;
Writer openAsWriter( File fileName, String encoding, boolean append ) throws IOException;
FileLock tryLock( File fileName, StoreChannel channel ) throws IOException;
StoreChannel create( File fileName ) throws IOException;
boolean fileExists( File fileName );
boolean mkdir( File fileName );
void mkdirs( File fileName ) throws IOException;
long getFileSize( File fileName );
boolean deleteFile( File fileName );
void deleteRecursively( File directory ) throws IOException;
boolean renameFile( File from, File to ) throws IOException;
File[] listFiles( File directory );
boolean isDirectory( File file );
void moveToDirectory( File file, File toDirectory ) throws IOException;
void copyFile( File from, File to ) throws IOException;
void copyRecursively( File fromDirectory, File toDirectory ) throws IOException;
<K extends ThirdPartyFileSystem> K getOrCreateThirdPartyFileSystem( Class<K> clazz, Function<Class<K>, K> creator );
interface ThirdPartyFileSystem
{
void close();
void dumpToZip( ZipOutputStream zip, byte[] scratchPad ) throws IOException;
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_FileSystemAbstraction.java
|
6,437
|
interface ThirdPartyFileSystem
{
void close();
void dumpToZip( ZipOutputStream zip, byte[] scratchPad ) throws IOException;
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_FileSystemAbstraction.java
|
6,438
|
public interface IdGenerator
{
long nextId();
IdRange nextIdBatch( int size );
/**
* @param id the highest in use + 1
*/
void setHighId( long id );
long getHighId();
void freeId( long id );
/**
* Closes the id generator.
*/
void close();
long getNumberOfIdsInUse();
long getDefragCount();
void delete();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_IdGenerator.java
|
6,439
|
public interface IdSequence
{
long nextId();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_IdSequence.java
|
6,440
|
public enum LongerShortString
{
/**
* Binary coded decimal with punctuation.
*
* <pre>
* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F
* 0- 0 1 2 3 4 5 6 7 8 9 SP . - + , '
* </pre>
*/
NUMERICAL( 1, 4 )
{
@Override
int encTranslate( byte b )
{
if ( b >= '0' && b <= '9' ) return b - '0';
switch ( b )
{
// interm. encoded
case 0: return 0xA;
case 2: return 0xB;
case 3: return 0xC;
case 6: return 0xD;
case 7: return 0xE;
case 8: return 0xF;
default: throw cannotEncode( b );
}
}
@Override
int encPunctuation( byte b )
{
throw cannotEncode( b );
}
@Override
char decTranslate( byte codePoint )
{
if ( codePoint < 10 ) return (char) ( codePoint + '0' );
return decPunctuation( codePoint - 10 + 6 );
}
},
/**
* Binary coded decimal with punctuation.
*
* <pre>
* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F
* 0- 0 1 2 3 4 5 6 7 8 9 SP - : / + ,
* </pre>
*/
DATE( 2, 4 )
{
@Override
int encTranslate( byte b )
{
if ( b >= '0' && b <= '9' ) return b - '0';
switch ( b )
{
case 0: return 0xA;
case 3: return 0xB;
case 4: return 0xC;
case 5: return 0xD;
case 6: return 0xE;
case 7: return 0xF;
default: throw cannotEncode( b );
}
}
@Override
int encPunctuation( byte b )
{
throw cannotEncode( b );
}
@Override
char decTranslate( byte codePoint )
{
if ( codePoint < 0xA ) return (char) ( codePoint + '0' );
switch ( codePoint )
{
case 0xA: return ' ';
case 0xB: return '-';
case 0xC: return ':';
case 0xD: return '/';
case 0xE: return '+';
default: return ',';
}
}
},
/**
* Upper-case characters with punctuation.
*
* <pre>
* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F
* 0- SP A B C D E F G H I J K L M N O
* 1- P Q R S T U V W X Y Z _ . - : /
* </pre>
*/
UPPER( 3, 5 )
{
@Override
int encTranslate( byte b )
{
return super.encTranslate(b) - 0x40;
}
@Override
int encPunctuation( byte b )
{
return b == 0 ? 0x40 : b + 0x5a;
}
@Override
char decTranslate( byte codePoint )
{
if ( codePoint == 0 ) return ' ';
if ( codePoint <= 0x1A ) return (char) ( codePoint + 'A' - 1 );
return decPunctuation( codePoint - 0x1A );
}
},
/**
* Lower-case characters with punctuation.
*
* <pre>
* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F
* 0- SP a b c d e f g h i j k l m n o
* 1- p q r s t u v w x y z _ . - : /
* </pre>
*/
LOWER( 4, 5 )
{
@Override
int encTranslate( byte b )
{
return super.encTranslate(b) - 0x60;
}
@Override
int encPunctuation( byte b )
{
return b == 0 ? 0x60 : b + 0x7a;
}
@Override
char decTranslate( byte codePoint )
{
if ( codePoint == 0 ) return ' ';
if ( codePoint <= 0x1A ) return (char) ( codePoint + 'a' - 1 );
return decPunctuation( codePoint - 0x1A );
}
},
/**
* Lower-case characters with punctuation.
*
* <pre>
* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F
* 0- , a b c d e f g h i j k l m n o
* 1- p q r s t u v w x y z _ . - + @
* </pre>
*/
EMAIL( 5, 5 )
{
@Override
int encTranslate( byte b )
{
return super.encTranslate(b) - 0x60;
}
@Override
int encPunctuation( byte b )
{
int encOffset = 0x60;
if ( b == 7 ) return encOffset;
int offset = encOffset + 0x1B;
switch ( b )
{
case 1: return 0 + offset;
case 2: return 1 + offset;
case 3: return 2 + offset;
case 6: return 3 + offset;
case 9: return 4 + offset;
default: throw cannotEncode( b );
}
}
@Override
char decTranslate( byte codePoint )
{
if ( codePoint == 0 ) return ',';
if ( codePoint <= 0x1A ) return (char) ( codePoint + 'a' - 1 );
switch ( codePoint )
{
case 0x1E: return '+';
case 0x1F: return '@';
default: return decPunctuation( codePoint - 0x1A );
}
}
},
/**
* Lower-case characters, digits and punctuation and symbols.
*
* <pre>
* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F
* 0- SP a b c d e f g h i j k l m n o
* 1- p q r s t u v w x y z
* 2- 0 1 2 3 4 5 6 7 8 9 _ . - : / +
* 3- , ' @ | ; * ? & % # ( ) $ < > =
* </pre>
*/
URI( 6, 6 )
{
@Override
int encTranslate( byte b )
{
if ( b == 0 ) return 0; // space
if ( b >= 0x61 && b <= 0x7A ) return b - 0x60; // lower-case letters
if ( b >= 0x30 && b <= 0x39 ) return b - 0x10; // digits
if ( b >= 0x1 && b <= 0x16 ) return b + 0x29; // symbols
throw cannotEncode( b );
}
@Override
int encPunctuation( byte b )
{
// Handled by encTranslate
throw cannotEncode( b );
}
@Override
char decTranslate( byte codePoint )
{
if ( codePoint == 0 ) return ' ';
if ( codePoint <= 0x1A ) return (char) ( codePoint + 'a' - 1 );
if ( codePoint <= 0x29 ) return (char) (codePoint - 0x20 + '0');
if ( codePoint <= 0x2E ) return decPunctuation( codePoint - 0x29 );
return decPunctuation( codePoint - 0x2F + 9);
}
},
/**
* Alpha-numerical characters space and underscore.
*
* <pre>
* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F
* 0- SP A B C D E F G H I J K L M N O
* 1- P Q R S T U V W X Y Z 0 1 2 3 4
* 2- _ a b c d e f g h i j k l m n o
* 3- p q r s t u v w x y z 5 6 7 8 9
* </pre>
*/
ALPHANUM( 7, 6 )
{
@Override
char decTranslate( byte codePoint )
{
return EUROPEAN.decTranslate( (byte) ( codePoint + 0x40 ) );
}
@Override
int encTranslate( byte b )
{
// Punctuation is in the same places as European
if ( b < 0x20 ) return encPunctuation( b ); // Punctuation
// But the rest is transposed by 0x40
return EUROPEAN.encTranslate( b ) - 0x40;
}
@Override
int encPunctuation( byte b )
{
switch ( b )
{
case 0:
return 0x00; // SPACE
case 1:
return 0x20; // UNDERSCORE
default:
throw cannotEncode( b );
}
}
},
/**
* Alpha-numerical characters space and underscore.
*
* <pre>
* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F
* 0- SP A B C D E F G H I J K L M N O
* 1- P Q R S T U V W X Y Z _ . - : /
* 2- ; a b c d e f g h i j k l m n o
* 3- p q r s t u v w x y z + , ' @ |
* </pre>
*/
ALPHASYM( 8, 6 )
{
@Override
char decTranslate( byte codePoint )
{
if ( codePoint == 0x0 ) return ' ';
if ( codePoint <= 0x1A ) return (char)('A' + codePoint - 0x1);
if ( codePoint <= 0x1F ) return decPunctuation( codePoint - 0x1B + 1 );
if ( codePoint == 0x20 ) return ';';
if ( codePoint <= 0x3A ) return (char)('a' + codePoint - 0x21);
return decPunctuation( codePoint - 0x3B + 9 );
}
@Override
int encTranslate( byte b )
{
// Punctuation is in the same places as European
if ( b < 0x20 ) return encPunctuation( b ); // Punctuation
// But the rest is transposed by 0x40
// return EUROPEAN.encTranslate( b ) - 0x40;
return b - 0x40;
}
@Override
int encPunctuation( byte b )
{
switch ( b )
{
case 0x0: return 0x0;
case 0x1: return 0x1B;
case 0x2: return 0x1C;
case 0x3: return 0x1D;
case 0x4: return 0x1E;
case 0x5: return 0x1F;
case 0x6: return 0x3B;
case 0x7: return 0x3C;
case 0x8: return 0x3D;
case 0x9: return 0x3E;
case 0xA: return 0x3F;
case 0xB: return 0x20;
default: throw cannotEncode( b );
}
}
},
/**
* The most common European characters (latin-1 but with less punctuation).
*
* <pre>
* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F
* 0- À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
* 1- Ð Ñ Ò Ó Ô Õ Ö . Ø Ù Ú Û Ü Ý Þ ß
* 2- à á â ã ä å æ ç è é ê ë ì í î ï
* 3- ð ñ ò ó ô õ ö - ø ù ú û ü ý þ ÿ
* 4- SP A B C D E F G H I J K L M N O
* 5- P Q R S T U V W X Y Z 0 1 2 3 4
* 6- _ a b c d e f g h i j k l m n o
* 7- p q r s t u v w x y z 5 6 7 8 9
* </pre>
*/
EUROPEAN( 9, 7 )
{
@Override
char decTranslate( byte codePoint )
{
if ( codePoint < 0x40 )
{
if ( codePoint == 0x17 ) return '.';
if ( codePoint == 0x37 ) return '-';
return (char) ( codePoint + 0xC0 );
}
else
{
if ( codePoint == 0x40 ) return ' ';
if ( codePoint == 0x60 ) return '_';
if ( codePoint >= 0x5B && codePoint < 0x60 ) return (char) ( '0' + codePoint - 0x5B );
if ( codePoint >= 0x7B && codePoint < 0x80 ) return (char) ( '5' + codePoint - 0x7B );
return (char) codePoint;
}
}
@Override
int encPunctuation( byte b )
{
switch ( b )
{
case 0x00:
return 0x40; // SPACE
case 0x01:
return 0x60; // UNDERSCORE
case 0x02:
return 0x17; // DOT
case 0x03:
return 0x37; // DASH
case 0x07:
// TODO
return 0;
default:
throw cannotEncode( b );
}
}
},
// ENCODING_LATIN1 is 10th
/**
* Lower-case characters a-f and digits.
*
* <pre>
* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F
* 0- 0 1 2 3 4 5 6 7 8 9 a b c d e f
* </pre>
*/
LOWERHEX( 11, 4 )
{
@Override
int encTranslate( byte b )
{
if ( b >= '0' && b <= '9' ) return b - '0';
if ( b >= 'a' && b <= 'f' ) return b - 'a' + 10;
throw cannotEncode( b );
}
@Override
int encPunctuation( byte b )
{
throw cannotEncode( b );
}
@Override
char decTranslate( byte codePoint )
{
if ( codePoint < 10 ) return (char) ( codePoint + '0' );
return (char) ( codePoint + 'a' - 10 );
}
},
/**
* Upper-case characters A-F and digits.
*
* <pre>
* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F
* 0- 0 1 2 3 4 5 6 7 8 9 A B C D E F
* </pre>
*/
UPPERHEX( 12, 4 )
{
@Override
int encTranslate( byte b )
{
if ( b >= '0' && b <= '9' ) return b - '0';
if ( b >= 'A' && b <= 'F' ) return b - 'A' + 10;
throw cannotEncode( b );
}
@Override
int encPunctuation( byte b )
{
throw cannotEncode( b );
}
@Override
char decTranslate( byte codePoint )
{
if ( codePoint < 10 ) return (char) ( codePoint + '0' );
return (char) ( codePoint + 'A' - 10 );
}
};
public static final int REMOVE_LARGE_ENCODINGS_MASK = invertedBitMask( ALPHANUM, ALPHASYM, URI, EUROPEAN );
public static final LongerShortString[] ENCODINGS = values();
public static final int ENCODING_COUNT = ENCODINGS.length;
public static final int ALL_BIT_MASK = bitMask( LongerShortString.values() );
public static final int ENCODING_UTF8 = 0;
public static final int ENCODING_LATIN1 = 10;
final int encodingHeader;
final long mask;
final int step;
private LongerShortString( int encodingHeader, int step )
{
this.encodingHeader = encodingHeader;
this.mask = Bits.rightOverflowMask( step );
this.step = step;
}
int maxLength( int payloadSize )
{
// key-type-encoding-length
return ((payloadSize << 3)-24-4-4-6)/step;
}
final IllegalArgumentException cannotEncode( byte b )
{
return new IllegalArgumentException( "Cannot encode as " + this.name() + ": " + b );
}
/** Lookup table for decoding punctuation */
private static final char[] PUNCTUATION = {
' ', '_', '.', '-', ':', '/',
' ', '.', '-', '+', ',', '\'', '@', '|', ';', '*', '?', '&', '%', '#', '(', ')', '$', '<', '>', '=' };
final char decPunctuation( int code )
{
return PUNCTUATION[code];
}
int encTranslate( byte b )
{
if ( b < 0 ) return ( 0xFF & b ) - 0xC0; // European chars
if ( b < 0x20 ) return encPunctuation( b ); // Punctuation
if ( b >= '0' && b <= '4' ) return 0x5B + b - '0'; // Numbers
if ( b >= '5' && b <= '9' ) return 0x7B + b - '5'; // Numbers
return b; // Alphabetical
}
abstract int encPunctuation( byte b );
abstract char decTranslate( byte codePoint );
/**
* Encodes a short string.
*
* @param string the string to encode.
* @param target the property record to store the encoded string in
* @return <code>true</code> if the string could be encoded as a short
* string, <code>false</code> if it couldn't.
*/
/*
* Intermediate code table
* -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F
* 0- SP _ . - : / + , ' @ | ; * ? & %
* 1- # ( ) $ < > =
* 2-
* 3- 0 1 2 3 4 5 6 7 8 9
* 4- A B C D E F G H I J K L M N O
* 5- P Q R S T U V W X Y Z
* 6- a b c d e f g h i j k l m n o
* 7- p q r s t u v w x y z
* 8-
* 9-
* A-
* B-
* C- À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
* D- Ð Ñ Ò Ó Ô Õ Ö Ø Ù Ú Û Ü Ý Þ ß
* E- à á â ã ä å æ ç è é ê ë ì í î ï
* F- ð ñ ò ó ô õ ö ø ù ú û ü ý þ ÿ
*/
public static boolean encode( int keyId, String string,
PropertyBlock target, int payloadSize )
{
// NUMERICAL can carry most characters, so compare to that
int dataLength = string.length();
// We only use 6 bits for storing the string length
// TODO could be dealt with by having string length zero and go for null bytes,
// at least for LATIN1 (that's what the ShortString implementation initially did)
if ( dataLength > NUMERICAL.maxLength( payloadSize ) || dataLength > 63 )
{
return false; // Not handled by any encoding
}
// Allocate space for the intermediate representation
// (using the intermediate representation table above)
byte[] data = new byte[dataLength];
// Keep track of the possible encodings that can be used for the string
// 0 means none applies
int encodings = determineEncoding( string, data, dataLength, payloadSize );
if ( encodings != 0 && tryEncode( encodings, keyId, target, payloadSize, data, dataLength ) )
{
return true;
}
return encodeWithCharSet( keyId, string, target, payloadSize, dataLength );
}
private static boolean encodeWithCharSet(int keyId, String string, PropertyBlock target, int payloadSize, int stringLength)
{
int maxBytes = PropertyType.getPayloadSize();
if ( stringLength <= maxBytes - 5 )
{
if ( encodeLatin1( keyId, string, target ) ) return true;
if ( encodeUTF8( keyId, string, target, payloadSize ) ) return true;
}
return false;
}
private static boolean tryEncode( int encodings, int keyId, PropertyBlock target, int payloadSize, byte[] data, final int length )
{
// find encoders in order that are still selected and try to encode the data
for ( LongerShortString encoding : ENCODINGS )
{
if ( (encoding.bitMask() & encodings) == 0 )
{
continue;
}
if ( encoding.doEncode( keyId, data, target, payloadSize, length ) )
{
return true;
}
}
return false;
}
// inverted combined bit-mask for the encoders
static int invertedBitMask( LongerShortString... encoders )
{
return ~bitMask( encoders );
}
// combined bit-mask for the encoders
private static int bitMask( LongerShortString[] encoders )
{
int result = 0;
for ( LongerShortString encoder : encoders )
{
result |= encoder.bitMask();
}
return result;
}
// translation lookup for each ascii character
private static final int TRANSLATION_COUNT = 256;
// transformation for the char to byte according to the default translation table
private static final byte[] TRANSLATION = new byte[TRANSLATION_COUNT];
// mask for encoders that are not applicable for this character
private static final int[] REMOVE_MASK = new int[TRANSLATION_COUNT];
private static void setUp( char pos, int value, LongerShortString... removeEncodings )
{
TRANSLATION[pos] = (byte) value;
REMOVE_MASK[pos] = invertedBitMask( removeEncodings );
}
static
{
Arrays.fill( TRANSLATION, (byte) 0xFF );
Arrays.fill( REMOVE_MASK, invertedBitMask( ENCODINGS ) );
setUp( ' ', 0, EMAIL, LOWERHEX, UPPERHEX );
setUp( '_', 1, NUMERICAL, DATE, LOWERHEX, UPPERHEX );
setUp( '.', 2, DATE, ALPHANUM, LOWERHEX, UPPERHEX );
setUp( '-', 3, ALPHANUM, LOWERHEX, UPPERHEX );
setUp( ':', 4, ALPHANUM, NUMERICAL, EUROPEAN, EMAIL, LOWERHEX, UPPERHEX );
setUp( '/', 5, ALPHANUM, NUMERICAL, EUROPEAN, EMAIL, LOWERHEX, UPPERHEX );
setUp( '+', 6, UPPER, LOWER, ALPHANUM, EUROPEAN, LOWERHEX, UPPERHEX );
setUp( ',', 7, UPPER, LOWER, ALPHANUM, EUROPEAN, LOWERHEX, UPPERHEX );
setUp( '\'', 8, DATE, UPPER, LOWER, EMAIL, ALPHANUM, EUROPEAN, LOWERHEX, UPPERHEX );
setUp( '@', 9, NUMERICAL, DATE, UPPER, LOWER, ALPHANUM, EUROPEAN, LOWERHEX, UPPERHEX );
setUp( '|', 0xA, NUMERICAL, DATE, UPPER, LOWER, EMAIL, URI, ALPHANUM, EUROPEAN, LOWERHEX, UPPERHEX );
final LongerShortString[] retainUri = {NUMERICAL, DATE, UPPER, LOWER, EMAIL, ALPHANUM, ALPHASYM, EUROPEAN, LOWERHEX, UPPERHEX};
setUp( ';', 0xB, retainUri );
setUp( '*', 0xC, retainUri );
setUp( '?', 0xD, retainUri );
setUp( '&', 0xE, retainUri );
setUp( '%', 0xF, retainUri );
setUp( '#', 0x10, retainUri );
setUp( '(', 0x11, retainUri );
setUp( ')', 0x12, retainUri );
setUp( '$', 0x13, retainUri );
setUp( '<', 0x14, retainUri );
setUp( '>', 0x15, retainUri );
setUp( '=', 0x16, retainUri );
for ( char c = 'A'; c <= 'F'; c++ )
{
setUp( c, (byte) c, NUMERICAL, DATE, LOWER, EMAIL, URI, LOWERHEX );
}
for ( char c = 'G'; c <= 'Z'; c++ )
{
setUp( c, (byte) c, NUMERICAL, DATE, LOWER, EMAIL, URI, LOWERHEX, UPPERHEX );
}
for ( char c = 'a'; c <= 'f'; c++ )
{
setUp( c, (byte) c, NUMERICAL, DATE, UPPER, UPPERHEX );
}
for ( char c = 'g'; c <= 'z'; c++ )
{
setUp( c, (byte) c, NUMERICAL, DATE, UPPER, UPPERHEX, LOWERHEX );
}
for ( char c = '0'; c <= '9'; c++ )
{
setUp( c, (byte) c, UPPER, LOWER, EMAIL, ALPHASYM );
}
for ( char c = 'À'; c <= 'ÿ'; c++ )
{
if ( c != 0xD7 && c != 0xF7 )
{
setUp( c, (byte) c, NUMERICAL, DATE, UPPER, LOWER, EMAIL, URI, ALPHANUM, ALPHASYM, LOWERHEX, UPPERHEX );
}
}
}
private static int determineEncoding( String string, byte[] data, int length, int payloadSize )
{
if ( length == 0 )
{
return 0;
}
int encodings = ALL_BIT_MASK;
// filter out larger encodings in one go
if ( length > ALPHANUM.maxLength( payloadSize ) )
{
encodings &= REMOVE_LARGE_ENCODINGS_MASK;
}
for ( int i = 0; i < length; i++ )
{
char c = string.charAt( i );
// non ASCII chars not supported
if ( c >= TRANSLATION_COUNT )
{
return 0;
}
data[i] = TRANSLATION[c];
// remove not matching encoders
encodings &= REMOVE_MASK[c];
if ( encodings == 0 )
{
return 0;
}
}
return encodings;
}
int bitMask()
{
return 1 << ordinal();
}
private static void writeHeader( Bits bits, int keyId, int encoding, int stringLength )
{
// [][][][ lll,llle][eeee,tttt][kkkk,kkkk][kkkk,kkkk][kkkk,kkkk]
bits.put( keyId, 24 ).put( PropertyType.SHORT_STRING.intValue(), 4 ).put( encoding, 5 ).put( stringLength, 6 );
}
/**
* Decode a short string represented as a long[]
*
* @param block the value to decode to a short string.
* @return the decoded short string
*/
public static String decode( PropertyBlock block )
{
Bits bits = Bits.bitsFromLongs( copyOf( block.getValueBlocks(),
block.getValueBlocks().length ) );
long firstLong = bits.getLongs()[0];
if ( ( firstLong & 0xFFFFFF0FFFFFFFFFL ) == 0 ) return "";
bits.getInt( 24 ); // Get rid of the key
bits.getByte( 4 ); // Get rid of the type
int encoding = bits.getByte( 5 ); //(int) ( ( firstLong & 0xF00000000L ) >>> 32 );
int stringLength = bits.getByte( 6 ); //(int) ( ( firstLong & 0xFC000000L ) >>> 26 );
if ( encoding == ENCODING_UTF8 ) return decodeUTF8( bits, stringLength );
if ( encoding == ENCODING_LATIN1 ) return decodeLatin1( bits, stringLength );
LongerShortString table = getEncodingTable( encoding );
char[] result = new char[stringLength];
// encode shifts in the bytes with the first char at the MSB, therefore
// we must "unshift" in the reverse order
for ( int i = 0; i < stringLength; i++ )
{
byte codePoint = bits.getByte( table.step );
result[i] = table.decTranslate( codePoint );
}
return String.valueOf(result);
}
// lookup table by encoding header
// +2 because of ENCODING_LATIN1 gap and one based index
private final static LongerShortString[] ENCODINGS_BY_ENCODING = new LongerShortString[ENCODING_COUNT + 2];
static
{
for ( LongerShortString encoding : ENCODINGS )
{
ENCODINGS_BY_ENCODING[encoding.encodingHeader] = encoding;
}
}
private static LongerShortString getEncodingTable( int encodingHeader )
{
final LongerShortString encoding = ENCODINGS_BY_ENCODING[encodingHeader];
if (encoding==null) throw new IllegalArgumentException( "Invalid encoding '" + encoding + "'" );
return encoding;
}
private static Bits newBits( LongerShortString encoding, int length )
{
return Bits.bits(calculateNumberOfBlocksUsed( encoding, length ) << 3 ); //*8
}
private static Bits newBitsForStep8(int length)
{
return Bits.bits(calculateNumberOfBlocksUsedForStep8(length) << 3 ); //*8
}
private static boolean encodeLatin1( int keyId, String string, PropertyBlock target )
{
int length = string.length();
Bits bits = newBitsForStep8(length);
writeHeader( bits, keyId, ENCODING_LATIN1, length );
if ( !writeLatin1Characters( string, bits ) ) return false;
target.setValueBlocks( bits.getLongs() );
return true;
}
public static boolean writeLatin1Characters( String string, Bits bits )
{
int length = string.length();
for ( int i = 0; i < length; i++ )
{
char c = string.charAt( i );
if ( c < 0 || c >= 256 ) return false;
bits.put( c, 8 ); // Just the lower byte
}
return true;
}
private static boolean encodeUTF8( int keyId, String string,
PropertyBlock target, int payloadSize )
{
try
{
byte[] bytes = string.getBytes( "UTF-8" );
final int length = bytes.length;
if ( length > payloadSize-3/*key*/-2/*enc+len*/ ) return false;
Bits bits = newBitsForStep8(length);
writeHeader( bits, keyId, ENCODING_UTF8, length); // In this case it isn't the string length, but the number of bytes
for ( byte value : bytes )
{
bits.put( value );
}
target.setValueBlocks( bits.getLongs() );
return true;
}
catch ( UnsupportedEncodingException e )
{
throw new IllegalStateException( "All JVMs must support UTF-8", e );
}
}
private boolean doEncode(int keyId, byte[] data, PropertyBlock target,
int payloadSize, final int length)
{
if ( length > maxLength( payloadSize ) ) return false;
Bits bits = newBits( this, length);
writeHeader( bits, keyId, encodingHeader, length);
if (length >0) translateData(bits, data, length, step);
target.setValueBlocks( bits.getLongs() );
return true;
}
private void translateData(Bits bits, byte[] data, int length, final int step)
{
for (int i = 0; i < length; i++)
{
bits.put(encTranslate(data[i]), step);
}
}
private static String decodeLatin1( Bits bits, int stringLength )
{ // see decode
char[] result = new char[stringLength];
for ( int i = 0; i < stringLength; i++ )
{
result[i] = (char) bits.getShort( 8 );
}
return new String( result );
}
private static String decodeUTF8( Bits bits, int stringLength )
{
byte[] result = new byte[stringLength];
for ( int i = 0; i < stringLength; i++ )
{
result[i] = bits.getByte();
}
try
{
return new String( result, "UTF-8" );
}
catch ( UnsupportedEncodingException e )
{
throw new IllegalStateException( "All JVMs must support UTF-8", e );
}
}
public static int calculateNumberOfBlocksUsed( long firstBlock )
{
/*
* [ lll,llle][eeee,tttt][kkkk,kkkk][kkkk,kkkk][kkkk,kkkk]
*/
int encoding = (int) ( ( firstBlock & 0x1F0000000L ) >> 28 );
int length = (int) ( ( firstBlock & 0x7E00000000L ) >> 33 );
/*
Bits bits = Bits.bitsFromLongs( new long[] {firstBlock} );
bits.getInt( 24 ); // key
bits.getByte( 4 ); // type
int encoding = bits.getByte( 5 );
int length = bits.getByte( 6 );
*/
if (encoding==ENCODING_UTF8 || encoding == ENCODING_LATIN1) return calculateNumberOfBlocksUsedForStep8(length);
return calculateNumberOfBlocksUsed( getEncodingTable(encoding), length );
}
public static int calculateNumberOfBlocksUsedForStep8( int length )
{
return totalBits(length << 3); // * 8
}
public static int calculateNumberOfBlocksUsed( LongerShortString encoding, int length )
{
return totalBits(length * encoding.step);
}
private static int totalBits( int bitsForCharacters )
{
int bitsInTotal = 24 + 4 + 5 + 6 + bitsForCharacters;
return ((bitsInTotal - 1) >> 6) + 1; // /64
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_LongerShortString.java
|
6,441
|
public enum OperationType
{
READ, WRITE
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_OperationType.java
|
6,442
|
private static enum State
{
EMPTY
{
@Override
State transition( OperationType operationType, PersistenceRow persistenceRow )
{
switch ( operationType)
{
case READ:
persistenceRow.readFullWindow();
return CLEAN;
case WRITE:
return DIRTY;
default:
throw new IllegalStateException( "Unknown operation type: " + operationType );
}
}
},
CLEAN
{
@Override
State transition( OperationType operationType, PersistenceRow persistenceRow )
{
switch ( operationType)
{
case READ:
return CLEAN;
case WRITE:
return DIRTY;
default:
throw new IllegalStateException( "Unknown operation type: " + operationType );
}
}
},
DIRTY
{
@Override
State transition( OperationType operationType, PersistenceRow persistenceRow )
{
return DIRTY;
}
};
abstract State transition( OperationType operationType, PersistenceRow persistenceRow );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_PersistenceRow.java
|
6,443
|
public interface PersistenceWindow
{
/**
* Returns the underlying buffer to this persistence window. Since a window
* may hold many records this gives access to all these records in one buffer.
* Changes to the returned buffer are applied when calling {@link #force()}.
*
* @return the underlying buffer.
*/
Buffer getBuffer();
/**
* Returns the underlying buffer set at a specific record ({@code id}}.
* The id is the absolute record/block id of the whole underlying channel, which this
* window just provides its limited view of.
* Changes to the returned buffer are applied when calling {@link #force()}.
*
* @param id the record/block to offset the buffer to before returning it.
* @return the underlying buffer.
*/
Buffer getOffsettedBuffer( long id );
/**
* @return the record size for each record. A window can hold many records.
*/
int getRecordSize();
/**
* @return the current absolute record/block position of the first record
* in this window.
*/
long position();
/**
* @return the size of this window meaning the number of records/blocks it
* encapsulates.
*/
int size();
/**
* Force (write) changes to the underlying buffer returned from {@link #getBuffer()}
* and {@link #getOffsettedBuffer(long)}.
*/
void force();
/**
* Just closes the window without writing any potential changes made to it.
*/
void close();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_PersistenceWindow.java
|
6,444
|
@SuppressWarnings("UnnecessaryBoxing")
public enum PropertyType
{
BOOL( 1 )
{
@Override
public DefinedProperty readProperty( int propertyKeyId, PropertyBlock block, Provider<PropertyStore> store )
{
return Property.booleanProperty( propertyKeyId, getValue( block.getSingleValueLong() ) );
}
@Override
public Object getValue( PropertyBlock block, PropertyStore store )
{
return getValue( block.getSingleValueLong() );
}
private boolean getValue( long propBlock )
{
return ( propBlock & 0x1 ) == 1;
}
},
BYTE( 2 )
{
@Override
public DefinedProperty readProperty( int propertyKeyId, PropertyBlock block, Provider<PropertyStore> store )
{
return Property.byteProperty( propertyKeyId, block.getSingleValueByte() );
}
@Override
public Object getValue( PropertyBlock block, PropertyStore store )
{
return Byte.valueOf( block.getSingleValueByte() );
}
},
SHORT( 3 )
{
@Override
public DefinedProperty readProperty( int propertyKeyId, PropertyBlock block, Provider<PropertyStore> store )
{
return Property.shortProperty( propertyKeyId, block.getSingleValueShort() );
}
@Override
public Object getValue( PropertyBlock block, PropertyStore store )
{
return Short.valueOf( block.getSingleValueShort() );
}
},
CHAR( 4 )
{
@Override
public DefinedProperty readProperty( int propertyKeyId, PropertyBlock block, Provider<PropertyStore> store )
{
return Property.charProperty( propertyKeyId, (char) block.getSingleValueShort() );
}
@Override
public Object getValue( PropertyBlock block, PropertyStore store )
{
return Character.valueOf( (char) block.getSingleValueShort() );
}
},
INT( 5 )
{
@Override
public DefinedProperty readProperty( int propertyKeyId, PropertyBlock block, Provider<PropertyStore> store )
{
return Property.intProperty( propertyKeyId, block.getSingleValueInt() );
}
@Override
public Object getValue( PropertyBlock block, PropertyStore store )
{
return Integer.valueOf( block.getSingleValueInt() );
}
},
LONG( 6 )
{
@Override
public DefinedProperty readProperty( int propertyKeyId, PropertyBlock block, Provider<PropertyStore> store )
{
long firstBlock = block.getSingleValueBlock();
long value = valueIsInlined( firstBlock ) ? (block.getSingleValueLong() >>> 1) : block.getValueBlocks()[1];
return Property.longProperty( propertyKeyId, value );
}
@Override
public Object getValue( PropertyBlock block, PropertyStore store )
{
return Long.valueOf( getLongValue( block ) );
}
private long getLongValue( PropertyBlock block )
{
long firstBlock = block.getSingleValueBlock();
return valueIsInlined( firstBlock ) ? (block.getSingleValueLong() >>> 1) :
block.getValueBlocks()[1];
}
private boolean valueIsInlined( long firstBlock )
{
// [][][][][ i,tttt][kkkk,kkkk][kkkk,kkkk][kkkk,kkkk]
return (firstBlock & 0x10000000L) > 0;
}
@Override
public int calculateNumberOfBlocksUsed( long firstBlock )
{
return valueIsInlined( firstBlock ) ? 1 : 2;
}
},
FLOAT( 7 )
{
@Override
public DefinedProperty readProperty( int propertyKeyId, PropertyBlock block, Provider<PropertyStore> store )
{
return Property.floatProperty( propertyKeyId, Float.intBitsToFloat( block.getSingleValueInt() ) );
}
@Override
public Object getValue( PropertyBlock block, PropertyStore store )
{
return Float.valueOf( getValue( block.getSingleValueInt() ) );
}
private float getValue( int propBlock )
{
return Float.intBitsToFloat( propBlock );
}
},
DOUBLE( 8 )
{
@Override
public DefinedProperty readProperty( int propertyKeyId, PropertyBlock block, Provider<PropertyStore> store )
{
return Property.doubleProperty( propertyKeyId, Double.longBitsToDouble( block.getValueBlocks()[1] ) );
}
@Override
public Object getValue( PropertyBlock block, PropertyStore store )
{
return Double.valueOf( getValue( block.getValueBlocks()[1] ) );
}
private double getValue( long propBlock )
{
return Double.longBitsToDouble( propBlock );
}
@Override
public int calculateNumberOfBlocksUsed( long firstBlock )
{
return 2;
}
},
STRING( 9 )
{
@Override
public DefinedProperty readProperty( int propertyKeyId, final PropertyBlock block,
final Provider<PropertyStore> store )
{
return Property.lazyStringProperty(propertyKeyId, new Callable<String>()
{
@Override
public String call() throws Exception
{
return getValue( block, store.instance() );
}
});
}
@Override
public String getValue( PropertyBlock block, PropertyStore store )
{
if ( store == null )
{
return null;
}
return store.getStringFor( block );
}
@Override
byte[] readDynamicRecordHeader( byte[] recordBytes )
{
return EMPTY_BYTE_ARRAY;
}
},
ARRAY( 10 )
{
@Override
public DefinedProperty readProperty( int propertyKeyId, final PropertyBlock block, final Provider<PropertyStore> store )
{
return Property.lazyArrayProperty(propertyKeyId, new Callable<Object>()
{
@Override
public Object call() throws Exception
{
return getValue( block, store.instance() );
}
});
}
@Override
public Object getValue( PropertyBlock block, PropertyStore store )
{
if ( store == null )
{
return null;
}
return store.getArrayFor( block );
}
@Override
byte[] readDynamicRecordHeader( byte[] recordBytes )
{
byte itemType = recordBytes[0];
if ( itemType == STRING.byteValue() )
{
return headOf( recordBytes, DynamicArrayStore.STRING_HEADER_SIZE );
}
else if ( itemType <= DOUBLE.byteValue() )
{
return headOf( recordBytes, DynamicArrayStore.NUMBER_HEADER_SIZE );
}
throw new IllegalArgumentException( "Unknown array type " + itemType );
}
private byte[] headOf( byte[] bytes, int length )
{
return Arrays.copyOf( bytes, length );
}
},
SHORT_STRING( 11 )
{
@Override
public DefinedProperty readProperty( int propertyKeyId, PropertyBlock block, Provider<PropertyStore> store )
{
return Property.stringProperty( propertyKeyId, LongerShortString.decode( block ) );
}
@Override
public Object getValue( PropertyBlock block, PropertyStore store )
{
return LongerShortString.decode( block );
}
@Override
public int calculateNumberOfBlocksUsed( long firstBlock )
{
return LongerShortString.calculateNumberOfBlocksUsed( firstBlock );
}
},
SHORT_ARRAY( 12 )
{
@Override
public DefinedProperty readProperty( int propertyKeyId, PropertyBlock block, Provider<PropertyStore> store )
{
// TODO: Specialize per type
return Property.property( propertyKeyId, ShortArray.decode(block) );
}
@Override
public Object getValue( PropertyBlock block, PropertyStore store )
{
return ShortArray.decode( block );
}
@Override
public int calculateNumberOfBlocksUsed( long firstBlock )
{
return ShortArray.calculateNumberOfBlocksUsed( firstBlock );
}
};
private final int type;
// TODO In wait of a better place
private static int payloadSize = PropertyStore.DEFAULT_PAYLOAD_SIZE;
PropertyType( int type )
{
this.type = type;
}
/**
* Returns an int value representing the type.
*
* @return The int value for this property type
*/
public int intValue()
{
return type;
}
/**
* Returns a byte value representing the type. As long as there are
* < 128 PropertyTypes, this should be equal to intValue(). When this
* statement no longer holds, this method should be removed.
*
* @return The byte value for this property type
*/
public byte byteValue()
{
return (byte) type;
}
public abstract Object getValue( PropertyBlock block, PropertyStore store );
public abstract DefinedProperty readProperty( int propertyKeyId, PropertyBlock block, Provider<PropertyStore> store );
public static PropertyType getPropertyType( long propBlock, boolean nullOnIllegal )
{
// [][][][][ ,tttt][kkkk,kkkk][kkkk,kkkk][kkkk,kkkk]
int type = (int)((propBlock&0x000000000F000000L)>>24);
switch ( type )
{
case 1:
return BOOL;
case 2:
return BYTE;
case 3:
return SHORT;
case 4:
return CHAR;
case 5:
return INT;
case 6:
return LONG;
case 7:
return FLOAT;
case 8:
return DOUBLE;
case 9:
return STRING;
case 10:
return ARRAY;
case 11:
return SHORT_STRING;
case 12:
return SHORT_ARRAY;
default: if (nullOnIllegal)
{
return null;
}
throw new InvalidRecordException( "Unknown property type for type "
+ type );
}
}
// TODO In wait of a better place
public static int getPayloadSize()
{
return payloadSize;
}
// TODO In wait of a better place
public static int getPayloadSizeLongs()
{
return payloadSize >>> 3;
}
// TODO In wait of a better place
public static void setPayloadSize( int newPayloadSize )
{
if ( newPayloadSize%8 != 0 )
{
throw new RuntimeException( "Payload must be divisible by 8" );
}
payloadSize = newPayloadSize;
}
public int calculateNumberOfBlocksUsed( long firstBlock )
{
return 1;
}
byte[] readDynamicRecordHeader( byte[] recordBytes )
{
throw new UnsupportedOperationException();
}
public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_PropertyType.java
|
6,445
|
public enum Record
{
NOT_IN_USE( (byte) 0, 0 ),
IN_USE( (byte) 1, 1 ),
FIRST_IN_CHAIN( (byte) 2, 2 ),
RESERVED( (byte) -1, -1 ),
NO_NEXT_PROPERTY( (byte) -1, -1 ),
NO_PREVIOUS_PROPERTY( (byte) -1, -1 ),
NO_NEXT_RELATIONSHIP( (byte) -1, -1 ),
NO_PREV_RELATIONSHIP( (byte) -1, -1 ),
NOT_DIRECTED( (byte) 0, 0 ),
DIRECTED( (byte) 2, 2 ),
NO_NEXT_BLOCK( (byte) -1, -1 ),
NO_PREV_BLOCK( (byte) -1, -1 ),
NODE_PROPERTY( (byte) 0, 0 ),
REL_PROPERTY( (byte) 2, 2 );
private byte byteValue;
private int intValue;
Record( byte byteValue, int intValue )
{
this.byteValue = byteValue;
this.intValue = intValue;
}
/**
* Returns a byte value representation for this record type.
*
* @return The byte value for this record type
*/
public byte byteValue()
{
return byteValue;
}
/**
* Returns a int value representation for this record type.
*
* @return The int value for this record type
*/
public int intValue()
{
return intValue;
}
public boolean is( long value )
{
return value == intValue;
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_Record.java
|
6,446
|
enum RecordLoad
{
NORMAL, CHECK, FORCE
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_RecordLoad.java
|
6,447
|
public interface RecordSerializable
{
int length();
void serialize( ByteBuffer target );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_RecordSerializable.java
|
6,448
|
public interface RecordStore<R extends AbstractBaseRecord> extends IdSequence
{
File getStorageFileName();
WindowPoolStats getWindowPoolStats();
long getHighId();
long getHighestPossibleIdInUse();
R getRecord( long id );
Long getNextRecordReference( R record );
Collection<R> getRecords( long id );
void updateRecord( R record );
R forceGetRecord( long id );
R forceGetRaw( R record );
R forceGetRaw( long id );
void forceUpdateRecord( R record );
<FAILURE extends Exception> void accept( Processor<FAILURE> processor, R record ) throws FAILURE;
int getRecordSize();
int getRecordHeaderSize();
void close();
Predicate<AbstractBaseRecord> IN_USE = new Predicate<AbstractBaseRecord>()
{
@Override
public boolean accept( AbstractBaseRecord item )
{
return item.inUse();
}
};
@SuppressWarnings("unchecked")
abstract class Processor<FAILURE extends Exception>
{
// Have it volatile so that it can be stopped from a different thread.
private volatile boolean continueScanning = true;
public void stopScanning()
{
continueScanning = false;
}
public void processSchema( RecordStore<DynamicRecord> store, DynamicRecord schema ) throws FAILURE
{
processRecord( DynamicRecord.class, store, schema );
}
public void processNode( RecordStore<NodeRecord> store, NodeRecord node ) throws FAILURE
{
processRecord( NodeRecord.class, store, node );
}
public void processRelationship( RecordStore<RelationshipRecord> store, RelationshipRecord rel ) throws FAILURE
{
processRecord( RelationshipRecord.class, store, rel );
}
public void processProperty( RecordStore<PropertyRecord> store, PropertyRecord property ) throws FAILURE
{
processRecord( PropertyRecord.class, store, property );
}
public void processString( RecordStore<DynamicRecord> store, DynamicRecord string,
@SuppressWarnings( "deprecation") IdType idType ) throws FAILURE
{
processDynamic( store, string );
}
public void processArray( RecordStore<DynamicRecord> store, DynamicRecord array ) throws FAILURE
{
processDynamic( store, array );
}
public void processLabelArrayWithOwner( RecordStore<DynamicRecord> store, DynamicRecord labelArray )
throws FAILURE
{
processDynamic( store, labelArray );
}
protected void processDynamic( RecordStore<DynamicRecord> store, DynamicRecord record ) throws FAILURE
{
processRecord( DynamicRecord.class, store, record );
}
public void processRelationshipTypeToken( RecordStore<RelationshipTypeTokenRecord> store,
RelationshipTypeTokenRecord record ) throws FAILURE
{
processRecord( RelationshipTypeTokenRecord.class, store, record );
}
public void processPropertyKeyToken( RecordStore<PropertyKeyTokenRecord> store, PropertyKeyTokenRecord record ) throws FAILURE
{
processRecord( PropertyKeyTokenRecord.class, store, record );
}
public void processLabelToken( RecordStore<LabelTokenRecord> store, LabelTokenRecord record ) throws FAILURE
{
processRecord(LabelTokenRecord.class, store, record);
}
@SuppressWarnings("UnusedParameters")
protected <R extends AbstractBaseRecord> void processRecord( Class<R> type, RecordStore<R> store, R record ) throws FAILURE
{
throw new UnsupportedOperationException( this + " does not process "
+ type.getSimpleName().replace( "Record", "" ) + " records" );
}
@SafeVarargs
public final <R extends AbstractBaseRecord> Iterable<R> scan( final RecordStore<R> store,
final Predicate<? super R>... filters )
{
return new Iterable<R>()
{
@Override
public Iterator<R> iterator()
{
return new PrefetchingIterator<R>()
{
final PrimitiveLongIterator ids = new StoreIdIterator( store );
@Override
protected R fetchNextOrNull()
{
scan: while ( ids.hasNext() && continueScanning )
{
R record = getRecord( store, ids.next() );
for ( Predicate<? super R> filter : filters )
{
if ( !filter.accept( record ) ) continue scan;
}
return record;
}
return null;
}
};
}
};
}
protected <R extends AbstractBaseRecord> R getRecord( RecordStore<R> store, long id )
{
return store.forceGetRecord( id );
}
public static <R extends AbstractBaseRecord> Iterable<R> scanById( final RecordStore<R> store,
Iterable<Long> ids )
{
return new IterableWrapper<R, Long>( ids )
{
@Override
protected R underlyingObjectToObject( Long id )
{
return store.forceGetRecord( id );
}
};
}
public <R extends AbstractBaseRecord> void applyById( RecordStore<R> store, Iterable<Long> ids ) throws FAILURE
{
for ( R record : scanById( store, ids ) )
store.accept( this, record );
}
public <R extends AbstractBaseRecord> void applyFiltered( RecordStore<R> store, Predicate<? super R>... filters ) throws FAILURE
{
apply( store, ProgressListener.NONE, filters );
}
public <R extends AbstractBaseRecord> void applyFiltered( RecordStore<R> store, ProgressListener progressListener,
Predicate<? super R>... filters ) throws FAILURE
{
apply( store, progressListener, filters );
}
private <R extends AbstractBaseRecord> void apply( RecordStore<R> store, ProgressListener progressListener,
Predicate<? super R>... filters ) throws FAILURE
{
for ( R record : scan( store, filters ) )
{
store.accept( this, record );
progressListener.set( record.getLongId() );
}
progressListener.done();
}
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_RecordStore.java
|
6,449
|
public interface SchemaRule extends RecordSerializable
{
/**
* The persistence id for this rule.
*/
long getId();
/**
* @return id of label to which this schema rule has been attached
*/
int getLabel();
/**
* @return the kind of this schema rule
*/
Kind getKind();
public static enum Kind
{
INDEX_RULE( 1, IndexRule.class )
{
@Override
protected SchemaRule newRule( long id, int labelId, ByteBuffer buffer )
{
return IndexRule.readIndexRule( id, false, labelId, buffer );
}
},
CONSTRAINT_INDEX_RULE( 2, IndexRule.class )
{
@Override
protected SchemaRule newRule( long id, int labelId, ByteBuffer buffer )
{
return IndexRule.readIndexRule( id, true, labelId, buffer );
}
},
UNIQUENESS_CONSTRAINT( 3, UniquenessConstraintRule.class )
{
@Override
protected SchemaRule newRule( long id, int labelId, ByteBuffer buffer )
{
return UniquenessConstraintRule.readUniquenessConstraintRule( id, labelId, buffer );
}
};
private final byte id;
private final Class<? extends SchemaRule> ruleClass;
private Kind( int id, Class<? extends SchemaRule> ruleClass )
{
assert id > 0 : "Kind id 0 is reserved";
this.id = (byte) id;
this.ruleClass = ruleClass;
}
public Class<? extends SchemaRule> getRuleClass()
{
return this.ruleClass;
}
public byte id()
{
return this.id;
}
protected abstract SchemaRule newRule( long id, int labelId, ByteBuffer buffer );
public static SchemaRule deserialize( long id, ByteBuffer buffer ) throws MalformedSchemaRuleException
{
int labelId = buffer.getInt();
Kind kind = kindForId( buffer.get() );
try
{
SchemaRule rule = kind.newRule( id, labelId, buffer );
if ( null == rule )
{
throw new MalformedSchemaRuleException( null,
"Deserialized null schema rule for id %d with kind %s", id, kind.name() );
}
return rule;
}
catch ( Exception e )
{
throw new MalformedSchemaRuleException( e,
"Could not deserialize schema rule for id %d with kind %s", id, kind.name() );
}
}
public static Kind kindForId( byte id ) throws MalformedSchemaRuleException
{
switch ( id )
{
case 1: return INDEX_RULE;
case 2: return CONSTRAINT_INDEX_RULE;
case 3: return UNIQUENESS_CONSTRAINT;
default:
throw new MalformedSchemaRuleException( null, "Unknown kind id %d", id );
}
}
public boolean isIndex()
{
return ruleClass == IndexRule.class;
}
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_SchemaRule.java
|
6,450
|
public static enum Kind
{
INDEX_RULE( 1, IndexRule.class )
{
@Override
protected SchemaRule newRule( long id, int labelId, ByteBuffer buffer )
{
return IndexRule.readIndexRule( id, false, labelId, buffer );
}
},
CONSTRAINT_INDEX_RULE( 2, IndexRule.class )
{
@Override
protected SchemaRule newRule( long id, int labelId, ByteBuffer buffer )
{
return IndexRule.readIndexRule( id, true, labelId, buffer );
}
},
UNIQUENESS_CONSTRAINT( 3, UniquenessConstraintRule.class )
{
@Override
protected SchemaRule newRule( long id, int labelId, ByteBuffer buffer )
{
return UniquenessConstraintRule.readUniquenessConstraintRule( id, labelId, buffer );
}
};
private final byte id;
private final Class<? extends SchemaRule> ruleClass;
private Kind( int id, Class<? extends SchemaRule> ruleClass )
{
assert id > 0 : "Kind id 0 is reserved";
this.id = (byte) id;
this.ruleClass = ruleClass;
}
public Class<? extends SchemaRule> getRuleClass()
{
return this.ruleClass;
}
public byte id()
{
return this.id;
}
protected abstract SchemaRule newRule( long id, int labelId, ByteBuffer buffer );
public static SchemaRule deserialize( long id, ByteBuffer buffer ) throws MalformedSchemaRuleException
{
int labelId = buffer.getInt();
Kind kind = kindForId( buffer.get() );
try
{
SchemaRule rule = kind.newRule( id, labelId, buffer );
if ( null == rule )
{
throw new MalformedSchemaRuleException( null,
"Deserialized null schema rule for id %d with kind %s", id, kind.name() );
}
return rule;
}
catch ( Exception e )
{
throw new MalformedSchemaRuleException( e,
"Could not deserialize schema rule for id %d with kind %s", id, kind.name() );
}
}
public static Kind kindForId( byte id ) throws MalformedSchemaRuleException
{
switch ( id )
{
case 1: return INDEX_RULE;
case 2: return CONSTRAINT_INDEX_RULE;
case 3: return UNIQUENESS_CONSTRAINT;
default:
throw new MalformedSchemaRuleException( null, "Unknown kind id %d", id );
}
}
public boolean isIndex()
{
return ruleClass == IndexRule.class;
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_SchemaRule.java
|
6,451
|
public interface SchemaRuleAccess
{
SchemaRule loadSingleSchemaRule( long ruleId ) throws MalformedSchemaRuleException;
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_SchemaRuleAccess.java
|
6,452
|
public static enum IndexRuleKind
{
INDEX
{
@Override
public boolean isOfKind( IndexRule rule )
{
return !rule.isConstraintIndex();
}
},
CONSTRAINT
{
@Override
public boolean isOfKind( IndexRule rule )
{
return rule.isConstraintIndex();
}
},
ALL
{
@Override
public boolean isOfKind( IndexRule rule )
{
return true;
}
};
public abstract boolean isOfKind( IndexRule rule );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_SchemaStorage.java
|
6,453
|
public enum ShortArray
{
BOOLEAN( PropertyType.BOOL, 1, Boolean.class, boolean.class )
{
@Override
int getRequiredBits( Object array, int arrayLength )
{
return 1;
}
@Override
void writeAll( Object array, int length, int requiredBits, Bits result )
{
if ( isPrimitive( array ) )
{
for ( boolean value : (boolean[]) array )
{
result.put( value ? 1 : 0, 1 );
}
} else
{
for ( boolean value : (Boolean[]) array )
{
result.put( value ? 1 : 0, 1 );
}
}
}
@Override
Object createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
return EMPTY_BOOLEAN_ARRAY;
}
final boolean[] result = new boolean[length];
for ( int i = 0; i < length; i++ )
{
result[i] = bits.getByte( requiredBits ) != 0;
}
return result;
}
@Override
public Object createEmptyArray()
{
return EMPTY_BOOLEAN_ARRAY;
}
},
BYTE( PropertyType.BYTE, 8, Byte.class, byte.class )
{
int getRequiredBits( byte value )
{
long mask = 1L << maxBits - 1;
for ( int i = maxBits; i > 0; i--, mask >>= 1 )
{
if ( (mask & value) != 0 )
{
return i;
}
}
return 1;
}
@Override
int getRequiredBits( Object array, int arrayLength )
{
int highest = 1;
if ( isPrimitive( array ) )
{
for ( byte value : (byte[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
} else
{
for ( byte value : (Byte[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
}
return highest;
}
@Override
void writeAll( Object array, int length, int requiredBits, Bits result )
{
if ( isPrimitive( array ) )
{
for ( byte b : (byte[]) array )
{
result.put( b, requiredBits );
}
} else
{
for ( byte b : (Byte[]) array )
{
result.put( b, requiredBits );
}
}
}
@Override
Object createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
return EMPTY_BYTE_ARRAY;
}
final byte[] result = new byte[length];
for ( int i = 0; i < length; i++ )
{
result[i] = bits.getByte( requiredBits );
}
return result;
}
@Override
public Object createEmptyArray()
{
return EMPTY_BYTE_ARRAY;
}
},
SHORT( PropertyType.SHORT, 16, Short.class, short.class )
{
int getRequiredBits( short value )
{
long mask = 1L << maxBits - 1;
for ( int i = maxBits; i > 0; i--, mask >>= 1 )
{
if ( (mask & value) != 0 )
{
return i;
}
}
return 1;
}
@Override
int getRequiredBits( Object array, int arrayLength )
{
int highest = 1;
if ( isPrimitive( array ) )
{
for ( short value : (short[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
} else
{
for ( short value : (Short[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
}
return highest;
}
@Override
void writeAll( Object array, int length, int requiredBits, Bits result )
{
if ( isPrimitive( array ) )
{
for ( short value : (short[]) array )
{
result.put( value, requiredBits );
}
} else
{
for ( short value : (Short[]) array )
{
result.put( value, requiredBits );
}
}
}
@Override
Object createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
return EMPTY_SHORT_ARRAY;
}
final short[] result = new short[length];
for ( int i = 0; i < length; i++ )
{
result[i] = bits.getShort( requiredBits );
}
return result;
}
@Override
public Object createEmptyArray()
{
return EMPTY_SHORT_ARRAY;
}
},
CHAR( PropertyType.CHAR, 16, Character.class , char.class)
{
int getRequiredBits( char value )
{
long mask = 1L << maxBits - 1;
for ( int i = maxBits; i > 0; i--, mask >>= 1 )
{
if ( (mask & value) != 0 )
{
return i;
}
}
return 1;
}
@Override
int getRequiredBits( Object array, int arrayLength )
{
int highest = 1;
if ( isPrimitive( array ) )
{
for ( char value : (char[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
} else
{
for ( char value : (Character[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
}
return highest;
}
@Override
void writeAll( Object array, int length, int requiredBits, Bits result )
{
if ( isPrimitive( array ) )
{
for ( char value : (char[]) array )
{
result.put( value, requiredBits );
}
} else
{
for ( char value : (Character[]) array )
{
result.put( value, requiredBits );
}
}
}
@Override
Object createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
return EMPTY_CHAR_ARRAY;
}
final char[] result = new char[length];
for ( int i = 0; i < length; i++ )
{
result[i] = (char) bits.getShort( requiredBits );
}
return result;
}
@Override
public Object createEmptyArray()
{
return EMPTY_CHAR_ARRAY;
}
},
INT( PropertyType.INT, 32, Integer.class , int.class)
{
int getRequiredBits( int value )
{
long mask = 1L << maxBits - 1;
for ( int i = maxBits; i > 0; i--, mask >>= 1 )
{
if ( (mask & value) != 0 )
{
return i;
}
}
return 1;
}
@Override
int getRequiredBits( Object array, int arrayLength )
{
int highest = 1;
if ( isPrimitive( array ) )
{
for ( int value : (int[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
} else
{
for ( int value : (Integer[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
}
return highest;
}
@Override
void writeAll( Object array, int length, int requiredBits, Bits result )
{
if ( isPrimitive( array ) )
{
for ( int value : (int[]) array )
{
result.put( value, requiredBits );
}
} else
{
for ( int value : (Integer[]) array )
{
result.put( value, requiredBits );
}
}
}
@Override
Object createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
return EMPTY_INT_ARRAY;
}
final int[] result = new int[length];
for ( int i = 0; i < length; i++ )
{
result[i] = bits.getInt( requiredBits );
}
return result;
}
@Override
public Object createEmptyArray()
{
return EMPTY_INT_ARRAY;
}
},
LONG( PropertyType.LONG, 64, Long.class , long.class)
{
public int getRequiredBits( long value )
{
long mask = 1L << maxBits - 1;
for ( int i = maxBits; i > 0; i--, mask >>= 1 )
{
if ( (mask & value) != 0 )
{
return i;
}
}
return 1;
}
@Override
int getRequiredBits( Object array, int arrayLength )
{
int highest = 1;
if ( isPrimitive( array ) )
{
for ( long value : (long[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
} else
{
for ( long value : (Long[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
}
return highest;
}
@Override
void writeAll( Object array, int length, int requiredBits, Bits result )
{
if ( isPrimitive( array ) )
{
for ( long value : (long[]) array )
{
result.put( value, requiredBits );
}
} else
{
for ( long value : (Long[]) array )
{
result.put( value, requiredBits );
}
}
}
@Override
Object createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
return EMPTY_LONG_ARRAY;
}
final long[] result = new long[length];
for ( int i = 0; i < length; i++ )
{
result[i] = bits.getLong( requiredBits );
}
return result;
}
@Override
public Object createEmptyArray()
{
return EMPTY_LONG_ARRAY;
}
},
FLOAT( PropertyType.FLOAT, 32, Float.class ,float.class)
{
int getRequiredBits( float value )
{
int v = Float.floatToIntBits( value );
long mask = 1L << maxBits - 1;
for ( int i = maxBits; i > 0; i--, mask >>= 1 )
{
if ( (mask & v) != 0 )
{
return i;
}
}
return 1;
}
@Override
int getRequiredBits( Object array, int arrayLength )
{
int highest = 1;
if ( isPrimitive( array ) )
{
for ( float value : (float[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
} else
{
for ( float value : (Float[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
}
return highest;
}
@Override
void writeAll( Object array, int length, int requiredBits, Bits result )
{
if ( isPrimitive( array ) )
{
for ( float value : (float[]) array )
{
result.put( Float.floatToIntBits( value ), requiredBits );
}
} else
{
for ( float value : (Float[]) array )
{
result.put( Float.floatToIntBits( value ), requiredBits );
}
}
}
@Override
Object createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
return EMPTY_FLOAT_ARRAY;
}
final float[] result = new float[length];
for ( int i = 0; i < length; i++ )
{
result[i] = Float.intBitsToFloat( bits.getInt( requiredBits ) );
}
return result;
}
@Override
public Object createEmptyArray()
{
return EMPTY_FLOAT_ARRAY;
}
},
DOUBLE( PropertyType.DOUBLE, 64, Double.class, double.class )
{
int getRequiredBits( double value )
{
long v = Double.doubleToLongBits( value );
long mask = 1L << maxBits - 1;
for ( int i = maxBits; i > 0; i--, mask >>= 1 )
{
if ( (mask & v) != 0 )
{
return i;
}
}
return 1;
}
@Override
int getRequiredBits( Object array, int arrayLength )
{
int highest = 1;
if ( isPrimitive( array ) )
{
for ( double value : (double[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
} else
{
for ( double value : (Double[]) array )
{
highest = Math.max( getRequiredBits( value ), highest );
}
}
return highest;
}
@Override
void writeAll( Object array, int length, int requiredBits, Bits result )
{
if ( isPrimitive( array ) )
{
for ( double value : (double[]) array )
{
result.put( Double.doubleToLongBits( value ), requiredBits );
}
} else
{
for ( double value : (Double[]) array )
{
result.put( Double.doubleToLongBits( value ), requiredBits );
}
}
}
@Override
Object createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
return EMPTY_DOUBLE_ARRAY;
}
final double[] result = new double[length];
for ( int i = 0; i < length; i++ )
{
result[i] = Double.longBitsToDouble( bits.getLong( requiredBits ) );
}
return result;
}
@Override
public Object createEmptyArray()
{
return EMPTY_DOUBLE_ARRAY;
}
};
public static final boolean[] EMPTY_BOOLEAN_ARRAY = new boolean[0];
public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
public static final short[] EMPTY_SHORT_ARRAY = new short[0];
public static final char[] EMPTY_CHAR_ARRAY = new char[0];
public static final int[] EMPTY_INT_ARRAY = new int[0];
public static final long[] EMPTY_LONG_ARRAY = new long[0];
public static final float[] EMPTY_FLOAT_ARRAY = new float[0];
public static final double[] EMPTY_DOUBLE_ARRAY = new double[0];
private static boolean isPrimitive( Object array )
{
return array.getClass().getComponentType().isPrimitive();
}
private final static Map<Class, ShortArray> all = new IdentityHashMap<Class, ShortArray>( values().length * 2 );
static
{
for ( ShortArray shortArray : values() )
{
all.put( shortArray.primitiveClass, shortArray );
all.put( shortArray.boxedClass, shortArray );
}
}
final int maxBits;
private final Class<?> boxedClass;
private final Class<?> primitiveClass;
private final PropertyType type;
private ShortArray( PropertyType type, int maxBits, Class<?> boxedClass, Class<?> primitiveClass)
{
this.type = type;
this.maxBits = maxBits;
this.boxedClass = boxedClass;
this.primitiveClass = primitiveClass;
}
public int intValue()
{
return type.intValue();
}
abstract Object createArray(int length, Bits bits, int requiredBits);
public static boolean encode( int keyId, Object array,
PropertyBlock target, int payloadSizeInBytes )
{
/*
* If the array is huge, we don't have to check anything else.
* So do the length check first.
*/
int arrayLength = Array.getLength( array );
if ( arrayLength > 63 )/*because we only use 6 bits for length*/
{
return false;
}
ShortArray type = typeOf( array );
if ( type == null )
{
return false;
}
int requiredBits = type.calculateRequiredBitsForArray( array, arrayLength );
if ( !willFit( requiredBits, arrayLength, payloadSizeInBytes ) )
{
// Too big array
return false;
}
final int numberOfBytes = calculateNumberOfBlocksUsed( arrayLength, requiredBits ) * 8;
if ( Bits.requiredLongs( numberOfBytes ) > PropertyType.getPayloadSizeLongs() )
{
return false;
}
Bits result = Bits.bits( numberOfBytes );
// [][][ ,bbbb][bbll,llll][yyyy,tttt][kkkk,kkkk][kkkk,kkkk][kkkk,kkkk]
writeHeader( keyId, type, arrayLength, requiredBits, result );
type.writeAll( array, arrayLength, requiredBits, result );
target.setValueBlocks( result.getLongs() );
return true;
}
private static void writeHeader( int keyId, ShortArray type, int arrayLength, int requiredBits, Bits result )
{
result.put( keyId, 24 );
result.put( PropertyType.SHORT_ARRAY.intValue(), 4 );
result.put( type.type.intValue(), 4 );
result.put( arrayLength, 6 );
result.put( requiredBits, 6 );
}
public static Object decode( PropertyBlock block )
{
Bits bits = Bits.bitsFromLongs(Arrays.copyOf(block.getValueBlocks(), block.getValueBlocks().length));
// [][][ ,bbbb][bbll,llll][yyyy,tttt][kkkk,kkkk][kkkk,kkkk][kkkk,kkkk]
bits.getInt( 24 ); // Get rid of key
bits.getByte( 4 ); // Get rid of short array type
int typeId = bits.getByte( 4 );
int arrayLength = bits.getByte(6);
int requiredBits = bits.getByte( 6 );
/*
* So, it can be the case that values require 64 bits to store. However, you cannot encode this
* value with 6 bits. calculateRequiredBitsForArray never returns 0, because even for an array of
* all 0s one bit is required for every value. So when writing, we let it overflow and write out
* 0. When we are reading back, we just have to make sure that reading in 0 means 64.
*/
if ( requiredBits == 0 )
{
requiredBits = 64;
}
ShortArray type = typeOf( (byte)typeId );
return type.createArray(arrayLength, bits, requiredBits);
}
private static boolean willFit( int requiredBits, int arrayLength, int payloadSizeInBytes )
{
int totalBitsRequired = requiredBits*arrayLength;
int maxBits = payloadSizeInBytes * 8 - 24 - 4 - 4 - 6 - 6;
return totalBitsRequired <= maxBits;
}
public int calculateRequiredBitsForArray(Object array, int arrayLength)
{
if ( arrayLength == 0 )
{
return 0;
}
// return getRequiredBits(findBiggestValue(array, arrayLength));
return getRequiredBits(array, arrayLength);
}
public int getRequiredBits( long value )
{
int highest = 1;
long mask = 1;
for ( int i = 1; i <= maxBits; i++, mask <<= 1 )
{
if ( (mask & value) != 0 )
{
highest = i;
}
}
return highest;
}
abstract int getRequiredBits(Object array, int arrayLength);
public static ShortArray typeOf( byte typeId )
{
return ShortArray.values()[typeId-1];
}
public static ShortArray typeOf( Object array )
{
return ShortArray.all.get(array.getClass().getComponentType());
}
public static int calculateNumberOfBlocksUsed( long firstBlock )
{
Bits bits = Bits.bitsFromLongs( new long[] {firstBlock} );
// bbbb][bbll,llll][yyyy,tttt][kkkk,kkkk][kkkk,kkkk][kkkk,kkkk]
bits.getInt( 24 ); // Get rid of key
bits.getByte( 4 ); // Get rid of short array type
bits.getByte( 4 ); // Get rid of the type
int arrayLength = bits.getByte( 6 );
int requiredBits = bits.getByte( 6 );
if ( requiredBits == 0 )
{
requiredBits = 64;
}
return calculateNumberOfBlocksUsed( arrayLength, requiredBits );
}
public static int calculateNumberOfBlocksUsed( int arrayLength, int requiredBits )
{
int bitsForItems = arrayLength*requiredBits;
/*
* Key, Property Type (ARRAY), Array Type, Array Length, Bits Per Member, Data
*/
int totalBits = 24 + 4 + 4 + 6 + 6 + bitsForItems;
int result = ( totalBits - 1 ) / 64 + 1;
return result;
}
abstract void writeAll(Object array, int length, int requiredBits, Bits result);
public Object createEmptyArray()
{
return Array.newInstance( primitiveClass, 0 );
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_ShortArray.java
|
6,454
|
public interface Store
{
/**
* Returns the id of next free record.
*
* @return The id of the next free record
*/
long nextId();
String getTypeDescriptor();
long getHighestPossibleIdInUse();
long getNumberOfIdsInUse();
WindowPoolStats getWindowPoolStats();
void logIdUsage( StringLogger.LineLogger logger );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_Store.java
|
6,455
|
public interface StoreChannel
extends SeekableByteChannel, GatheringByteChannel, ScatteringByteChannel, InterruptibleChannel
{
/**
* Attempts to acquire an exclusive lock on this channel's file.
* @return A lock object representing the newly-acquired lock, or null if the lock could not be acquired.
* @throws IOException If an I/O error occurs.
* @throws java.nio.channels.ClosedChannelException if the channel is closed.
*/
FileLock tryLock() throws IOException;
int write( ByteBuffer src, long position ) throws IOException;
MappedByteBuffer map( FileChannel.MapMode mode, long position, long size ) throws IOException;
int read( ByteBuffer dst, long position ) throws IOException;
void force( boolean metaData ) throws IOException;
StoreChannel position( long newPosition ) throws IOException;
StoreChannel truncate( long size ) throws IOException;
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_StoreChannel.java
|
6,456
|
public static enum Charset
{
UNIFORM_ASCII
{
@Override
String randomString( int maxLen )
{
char[] chars = new char[random.nextInt( maxLen + 1 )];
for ( int i = 0; i < chars.length; i++ )
{
chars[i] = (char) ( 0x20 + random.nextInt( 94 ) );
}
return new String( chars );
}
},
SYMBOLS
{
@Override
String randomString( int maxLen )
{
char[] chars = new char[random.nextInt( maxLen + 1 )];
for ( int i = 0; i < chars.length; i++ )
{
chars[i] = SYMBOL_CHARS[random.nextInt( SYMBOL_CHARS.length )];
}
return new String( chars );
}
},
UNIFORM_LATIN
{
@Override
String randomString( int maxLen )
{
char[] chars = new char[random.nextInt( maxLen + 1 )];
for ( int i = 0; i < chars.length; i++ )
{
chars[i] = (char) ( 0x20 + random.nextInt( 0xC0 ) );
if ( chars[i] > 0x7f ) chars[i] += 0x20;
}
return new String( chars );
}
},
LONG
{
@Override
String randomString( int maxLen )
{
return Long.toString( random.nextLong() % ( (long) Math.pow( 10, maxLen ) ) );
}
},
INT
{
@Override
String randomString( int maxLen )
{
return Long.toString( random.nextInt() );
}
},
UNICODE
{
@Override
String randomString( int maxLen )
{
char[] chars = new char[random.nextInt( maxLen + 1 )];
for ( int i = 0; i < chars.length; i++ )
{
chars[i] = (char) ( 1 + random.nextInt( 0xD7FE ) );
}
return new String( chars );
}
},
;
static char[] SYMBOL_CHARS = new char[26 + 26 + 10 + 1];
static
{
SYMBOL_CHARS[0] = '_';
int i = 1;
for ( char c = '0'; c <= '9'; c++ )
{
SYMBOL_CHARS[i++] = c;
}
for ( char c = 'A'; c <= 'Z'; c++ )
{
SYMBOL_CHARS[i++] = c;
}
for ( char c = 'a'; c <= 'z'; c++ )
{
SYMBOL_CHARS[i++] = c;
}
}
abstract String randomString( int maxLen );
}
| false
|
community_kernel_src_test_java_org_neo4j_kernel_impl_nioneo_store_TestShortString.java
|
6,457
|
public interface NodeLabels
{
long[] get( NodeStore nodeStore );
long[] getIfLoaded();
Collection<DynamicRecord> put( long[] labelIds, NodeStore nodeStore );
Collection<DynamicRecord> add( long labelId, NodeStore nodeStore );
Collection<DynamicRecord> remove( long labelId, NodeStore nodeStore );
void ensureHeavy( NodeStore nodeStore );
boolean isInlined();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_labels_NodeLabels.java
|
6,458
|
public interface WindowPool
{
/**
* Acquires a windows for <CODE>position</CODE> and <CODE>operationType</CODE>
* locking the window preventing other threads from using it.
*
* @param position
* The position the needs to be encapsulated by the window
* @param operationType
* The type of operation (READ or WRITE)
* @return A locked window encapsulating the position
*/
PersistenceWindow acquire( long position, OperationType operationType );
/**
* Releases a window used for an operation back to the pool and unlocks it
* so other threads may use it.
*
* @param window
* The window to be released
*/
void release( PersistenceWindow window );
void flushAll();
void close();
WindowPoolStats getStats();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_windowpool_WindowPool.java
|
6,459
|
public interface WindowPoolFactory
{
WindowPool create( File storageFileName, int recordSize, StoreChannel fileChannel,
Config configuration, StringLogger log );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_store_windowpool_WindowPoolFactory.java
|
6,460
|
private interface DynamicRecordAdder<T>
{
void add( T target, DynamicRecord record );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_xa_Command.java
|
6,461
|
public enum Mode
{
CREATE,
UPDATE,
DELETE;
public static Mode fromRecordState( boolean created, boolean inUse )
{
if ( !inUse )
{
return DELETE;
}
if ( created )
{
return CREATE;
}
return UPDATE;
}
public static Mode fromRecordState( AbstractBaseRecord record )
{
return fromRecordState( record.isCreated(), record.inUse() );
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_xa_Command.java
|
6,462
|
public interface CommandRecordVisitor
{
void visitNode( NodeRecord record );
void visitRelationship( RelationshipRecord record );
void visitProperty( PropertyRecord record );
void visitRelationshipTypeToken( RelationshipTypeTokenRecord record );
void visitLabelToken( LabelTokenRecord record );
void visitPropertyKeyToken( PropertyKeyTokenRecord record );
void visitNeoStore( NeoStoreRecord record );
void visitSchemaRule( Collection<DynamicRecord> records );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_xa_CommandRecordVisitor.java
|
6,463
|
public interface NeoStoreProvider extends Thunk<NeoStore>
{
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_xa_NeoStoreProvider.java
|
6,464
|
public interface PropertyReceiver
{
void receive( DefinedProperty property, long propertyRecordId );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_xa_NeoStoreTransaction.java
|
6,465
|
private enum Diagnostics implements DiagnosticsExtractor<NeoStoreXaDataSource>
{
NEO_STORE_VERSIONS( "Store versions:" )
{
@Override
void dump( NeoStoreXaDataSource source, StringLogger.LineLogger log )
{
source.neoStore.logVersions( log );
}
},
NEO_STORE_ID_USAGE( "Id usage:" )
{
@Override
void dump( NeoStoreXaDataSource source, StringLogger.LineLogger log )
{
source.neoStore.logIdUsage( log );
}
},
PERSISTENCE_WINDOW_POOL_STATS( "Persistence Window Pool stats:" )
{
@Override
void dump( NeoStoreXaDataSource source, StringLogger.LineLogger log )
{
source.neoStore.logAllWindowPoolStats( log );
}
@Override
boolean applicable( DiagnosticsPhase phase )
{
return phase.isExplicitlyRequested();
}
};
private final String message;
private Diagnostics( String message )
{
this.message = message;
}
@Override
public void dumpDiagnostics( final NeoStoreXaDataSource source, DiagnosticsPhase phase, StringLogger log )
{
if ( applicable( phase ) )
{
log.logLongMessage( message, new Visitor<StringLogger.LineLogger, RuntimeException>()
{
@Override
public boolean visit( StringLogger.LineLogger logger )
{
dump( source, logger );
return false;
}
}, true );
}
}
boolean applicable( DiagnosticsPhase phase )
{
return phase.isInitialization() || phase.isExplicitlyRequested();
}
abstract void dump( NeoStoreXaDataSource source, StringLogger.LineLogger log );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_xa_NeoStoreXaDataSource.java
|
6,466
|
public interface PropertyRecordChange
{
PropertyRecord getBefore();
PropertyRecord getAfter();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_xa_PropertyRecordChange.java
|
6,467
|
public interface Loader<KEY,RECORD,ADDITIONAL>
{
RECORD newUnused( KEY key, ADDITIONAL additionalData );
RECORD load( KEY key, ADDITIONAL additionalData );
void ensureHeavy( RECORD record );
RECORD clone( RECORD record );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_nioneo_xa_RecordChanges.java
|
6,468
|
public interface EntityIdGenerator
{
long nextId( Class<?> clazz );
long getHighestPossibleIdInUse( Class<?> clazz );
long getNumberOfIdsInUse( Class<?> clazz );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_persistence_EntityIdGenerator.java
|
6,469
|
public interface PersistenceSource
{
/**
* Creates a resource connection to this persistence source.
* @param connection the {@link XaConnection} to use.
* @return a newly opened {@link NeoStoreTransaction} to this
* PersistenceSource
*/
NeoStoreTransaction createTransaction( XaConnection connection );
/**
* If the persistence source is responsible for id generation it must
* implement this method.
*
* @param clazz
* the data structure to get next free unique id for
* @return the next free unique id for <CODE>clazz</CODE>
*/
long nextId( Class<?> clazz );
long getHighestPossibleIdInUse( Class<?> clazz );
long getNumberOfIdsInUse( Class<?> clazz );
XaDataSource getXaDataSource();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_persistence_PersistenceSource.java
|
6,470
|
public enum StoreFile
{
NEO_STORE( "NeoStore", "" ),
NODE_STORE( "NodeStore", StoreFactory.NODE_STORE_NAME ),
NODE_LABEL_STORE( "NodeLabelStore", StoreFactory.NODE_LABELS_STORE_NAME, false ),
PROPERTY_STORE( "PropertyStore", StoreFactory.PROPERTY_STORE_NAME ),
PROPERTY_ARRAY_STORE( "ArrayPropertyStore", StoreFactory.PROPERTY_ARRAYS_STORE_NAME ),
PROPERTY_STRING_STORE( "StringPropertyStore", StoreFactory.PROPERTY_STRINGS_STORE_NAME ),
PROPERTY_INDEX_STORE( "PropertyIndexStore", StoreFactory.PROPERTY_KEY_TOKEN_STORE_NAME ),
PROPERTY_INDEX_KEYS_STORE( "StringPropertyStore", StoreFactory.PROPERTY_KEY_TOKEN_NAMES_STORE_NAME ),
RELATIONSHIP_STORE( "RelationshipStore", StoreFactory.RELATIONSHIP_STORE_NAME ),
RELATIONSHIP_TYPE_STORE( "RelationshipTypeStore", StoreFactory.RELATIONSHIP_TYPE_TOKEN_STORE_NAME ),
RELATIONSHIP_TYPE_NAMES_STORE( "StringPropertyStore", StoreFactory.RELATIONSHIP_TYPE_TOKEN_NAMES_STORE_NAME ),
LABEL_NAME_STORE( "LabelNameStore", StoreFactory.LABEL_TOKEN_STORE_NAME, false ),
LABEL_NAME_NAMES_STORE( "StringPropertyStore", StoreFactory.LABEL_TOKEN_NAMES_STORE_NAME, false ),
SCHEMA_STORE( "SchemaStore", StoreFactory.SCHEMA_STORE_NAME, false );
private final String typeDescriptor;
private final String storeFileNamePart;
private final boolean existsInBoth;
private StoreFile( String typeDescriptor, String storeFileNamePart )
{
this( typeDescriptor, storeFileNamePart, true );
}
private StoreFile( String typeDescriptor, String storeFileNamePart, boolean existsInBoth )
{
this.typeDescriptor = typeDescriptor;
this.storeFileNamePart = storeFileNamePart;
this.existsInBoth = existsInBoth;
}
public String legacyVersion()
{
return typeDescriptor + " " + LegacyStore.LEGACY_VERSION;
}
/**
* The first part of the version String.
*/
public String typeDescriptor()
{
return typeDescriptor;
}
public String storeFileName()
{
return NeoStore.DEFAULT_NAME + storeFileNamePart;
}
public String idFileName()
{
return storeFileName() + ".id";
}
public static Iterable<StoreFile> legacyStoreFiles()
{
Predicate<StoreFile> predicate = new Predicate<StoreFile>()
{
@Override
public boolean accept( StoreFile item )
{
return item.existsInBoth;
}
};
Iterable<StoreFile> storeFiles = currentStoreFiles();
return Iterables.filter( predicate, storeFiles );
}
public static Iterable<StoreFile> currentStoreFiles()
{
return Iterables.iterable( values() );
}
/**
* Moves a database's store files from one directory
* to another. Since it just renames files (the standard way of moving with
* JDK6) from and to must be on the same disk partition.
*
* @param fromDirectory The directory that hosts the database files.
* @param toDirectory The directory to move the database files to.
* @throws IOException If any of the move operations fail for any reason.
*/
public static void move( FileSystemAbstraction fs, File fromDirectory, File toDirectory,
Iterable<StoreFile> files ) throws IOException
{
// TODO: change the order that files are moved to handle failure conditions properly
for ( StoreFile storeFile : files )
{
moveFile( fs, storeFile.storeFileName(), fromDirectory, toDirectory );
moveFile( fs, storeFile.idFileName(), fromDirectory, toDirectory );
}
}
/**
* Moves a file from one directory to another, by a rename op.
* @param fs
*
* @param fileName The base filename of the file to move, not the complete
* path
* @param fromDirectory The directory currently containing filename
* @param toDirectory The directory to host filename - must be in the same
* disk partition as filename
* @throws IOException
*/
static void moveFile( FileSystemAbstraction fs, String fileName, File fromDirectory,
File toDirectory ) throws IOException
{
fs.moveToDirectory( new File( fromDirectory, fileName ), toDirectory );
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_storemigration_StoreFile.java
|
6,471
|
public static enum Outcome
{
ok( true ),
missingStoreFile( false ),
storeVersionNotFound( false ),
unexpectedUpgradingStoreVersion( false );
private final boolean success;
private Outcome( boolean success )
{
this.success = success;
}
public boolean isSuccessful()
{
return this.success;
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_storemigration_StoreVersionCheck.java
|
6,472
|
public interface UpgradeConfiguration
{
void checkConfigurationAllowsAutomaticUpgrade();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_storemigration_UpgradeConfiguration.java
|
6,473
|
public interface MigrationProgressMonitor
{
void started();
void percentComplete(int percent);
void finished();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_storemigration_monitoring_MigrationProgressMonitor.java
|
6,474
|
public interface DataSourceRegistrationListener
{
void registeredDataSource( XaDataSource ds );
void unregisteredDataSource( XaDataSource ds );
class Adapter implements DataSourceRegistrationListener
{
@Override
public void registeredDataSource( XaDataSource ds )
{
}
@Override
public void unregisteredDataSource( XaDataSource ds )
{
}
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_DataSourceRegistrationListener.java
|
6,475
|
private enum Labels implements Label
{
MY_LABEL;
}
| false
|
community_kernel_src_test_java_org_neo4j_kernel_impl_transaction_ExternalTransactionControlIT.java
|
6,476
|
public interface LockManager
{
/**
* Tries to acquire read lock on {@code resource} for a given
* transaction. If read lock can't be acquired the transaction will wait for
* the transaction until it can acquire it. If waiting leads to dead lock a
* {@link DeadlockDetectedException} will be thrown.
*
* @param resource the resource to lock
* @throws DeadlockDetectedException if a deadlock is detected, or prevented rather
* @throws IllegalResourceException if an illegal resource is supplied
*/
void getReadLock( Object resource, Transaction tx )
throws DeadlockDetectedException, IllegalResourceException;
/**
* Tries to acquire read lock on {@code resource} for a given
* transaction. If read lock can't be acquired {@code false} will be returned
* and no lock will have been acquired.
*
* @param resource the resource
* @throws IllegalResourceException if an illegal resource is supplied
*/
boolean tryReadLock( Object resource, Transaction tx )
throws IllegalResourceException;
/**
* Tries to acquire write lock on <CODE>resource</CODE> for a given
* transaction. If write lock can't be acquired the transaction will wait
* for the lock until it can acquire it. If waiting leads to dead lock a
* {@link DeadlockDetectedException} will be thrown.
*
* @param resource the resource
* @throws DeadlockDetectedException if a deadlock is detected, or prevented rather
* @throws IllegalResourceException if an illegal resource is supplied
*/
void getWriteLock( Object resource, Transaction tx )
throws DeadlockDetectedException, IllegalResourceException;
/**
* Tries to acquire write lock on {@code resource} for a given
* transaction. If write lock can't be acquired {@code false} will be returned
* and no lock will have been acquired.
*
* @param resource the resource
* @throws IllegalResourceException if an illegal resource is supplied
*/
boolean tryWriteLock( Object resource, Transaction tx )
throws IllegalResourceException;
/**
* Releases a read lock held by the given transaction on {@code resource}.
*
* @param resource the resource
* @throws IllegalResourceException if an illegal resource is supplied
* @throws LockNotFoundException if given transaction don't have read lock on the given {@code resource}.
*/
void releaseReadLock( Object resource, Transaction tx )
throws LockNotFoundException, IllegalResourceException;
/**
* Releases a write lock held by the given transaction on {@code resource}.
*
* @param resource the resource
* @throws IllegalResourceException if an illegal resource is supplied
* @throws LockNotFoundException if given transaction don't have read lock on the given {@code resource}.
*/
void releaseWriteLock( Object resource, Transaction tx )
throws LockNotFoundException, IllegalResourceException;
/**
* @return number of deadlocks that have been detected and prevented.
* @see #getWriteLock(Object, Transaction) and {@link #getReadLock(Object, Transaction)}.
*/
long getDetectedDeadlockCount();
/**
* Utility method for debugging. Dumps info to {@code logging} about txs having locks on resources.
*/
void dumpLocksOnResource( Object resource, Logging logging );
/**
* @return a {@link List} of all locks currently active.
*/
List<LockInfo> getAllLocks();
/**
* Returns info about locks that have been awaited for {@code minWaitTime} milliseconds.
* @param minWaitTime the threshold time in milliseconds for inclusion in the resulting {@link List}.
* @return locks that have been awaited for at least {@code minWaitTime} milliseconds.
*/
List<LockInfo> getAwaitedLocks( long minWaitTime );
/**
* Utility method for debugging. Dumps the resource allocation graph to {@code logging}.
*/
void dumpRagStack( Logging logging );
/**
* Utility method for debugging. Dumps info about each lock to {@code logging}.
*/
void dumpAllLocks( Logging logging );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_LockManager.java
|
6,477
|
public enum LockType
{
READ
{
@Override
public LockElement acquire( TransactionState state, Object resource )
{
return state.acquireReadLock( resource );
}
@Override
public void release( LockManager lockManager, Object resource, Transaction tx )
{
lockManager.releaseReadLock( resource, tx );
}
},
WRITE
{
@Override
public LockElement acquire( TransactionState state, Object resource )
{
return state.acquireWriteLock( resource );
}
@Override
public void release( LockManager lockManager, Object resource, Transaction tx )
{
lockManager.releaseWriteLock( resource, tx );
}
};
public abstract LockElement acquire( TransactionState state, Object resource );
public abstract void release( LockManager lockManager, Object resource, Transaction tx );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_LockType.java
|
6,478
|
public interface RemoteTxHook
{
void remotelyInitializeTransaction( int eventIdentifier, TransactionState state );
void remotelyFinishTransaction( int eventIdentifier, boolean success );
boolean freeIdsDuringRollback();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_RemoteTxHook.java
|
6,479
|
public interface TransactionIdFactory
{
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_TransactionIdFactory.java
|
6,480
|
public interface Monitor
{
void txStarted( Xid xid );
void txCommitted( Xid xid );
void txRolledBack( Xid xid );
void txManagerStopped();
public static class Adapter implements Monitor
{
@Override
public void txStarted( Xid xid )
{
}
@Override
public void txCommitted( Xid xid )
{
}
@Override
public void txRolledBack( Xid xid )
{
}
@Override
public void txManagerStopped()
{
}
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_TxManager.java
|
6,481
|
interface Seed
{
long nextRandomLong();
long nextSequenceId();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_XidImpl.java
|
6,482
|
public enum ForceMode
{
forced
{
@Override
public void force( LogBuffer buffer ) throws IOException
{
buffer.force();
}
},
unforced
{
@Override
public void force( LogBuffer buffer ) throws IOException
{
buffer.writeOut();
}
};
public abstract void force( LogBuffer buffer ) throws IOException;
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_ForceMode.java
|
6,483
|
public interface InjectedTransactionValidator
{
// This is used by the lucene data source, and some tests for convenience.
InjectedTransactionValidator ALLOW_ALL = new InjectedTransactionValidator(){
@Override
public void assertInjectionAllowed( long lastCommittedTxWhenTransactionStarted ) throws XAException
{
// Always ok.
}
};
void assertInjectionAllowed( long lastCommittedTxWhenTransactionStarted ) throws XAException;
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_InjectedTransactionValidator.java
|
6,484
|
public interface LogApplier
{
void apply( LogEntry entry ) throws IOException;
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_LogApplier.java
|
6,485
|
public interface LogBuffer
{
LogBuffer put( byte b ) throws IOException;
LogBuffer putShort( short b ) throws IOException;
LogBuffer putInt( int i ) throws IOException;
LogBuffer putLong( long l ) throws IOException;
LogBuffer putFloat( float f ) throws IOException;
LogBuffer putDouble( double d ) throws IOException;
LogBuffer put( byte[] bytes ) throws IOException;
LogBuffer put( char[] chars ) throws IOException;
/**
* Makes sure the data added to this buffer is written out to the underlying
* file. Makes sure that readers of the channel will see the content of the
* buffer up until the time of this call.
*
* @throws IOException if the data couldn't be written.
*/
void writeOut() throws IOException;
/**
* Makes sure the data added to this buffer is written out to the underlying
* file and forced. Same guarantees as writeOut() plus actually being
* written to disk.
*
* @throws IOException if the data couldn't be written.
*/
void force() throws IOException;
long getFileChannelPosition() throws IOException;
StoreChannel getFileChannel();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_LogBuffer.java
|
6,486
|
public interface LogBufferFactory
{
/**
* Create a new active log file (a file that will be picked up and used for recovery), and return
* a log buffer that allows writing to the file. The resulting file should contain any necessary
* headers and so on, and allow directly appending new transactions.
*
* @throws IllegalStateException if an active file already exists at the specified location
* @return LogBuffer that wraps the log file. Caller MUST call LogBuffer.getFileChannel.close() when done.
*/
LogBuffer createActiveLogFile( Config config, long prevCommittedId ) throws IllegalStateException, IOException;
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_LogBufferFactory.java
|
6,487
|
private interface LogEntryCollector
{
LogEntry collect( LogEntry entry, LogBuffer target ) throws IOException;
LogEntry.Start getLastStartEntry();
boolean hasInFutureQueue();
int getIdentifier();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_LogExtractor.java
|
6,488
|
public interface LogLoader
{
ReadableByteChannel getLogicalLogOrMyselfCommitted( long version, long position ) throws IOException;
long getHighestLogVersion();
File getFileName( long version );
/**
* @param version the log version to get first committed tx for.
* @return the first committed transaction id for the log with {@code version}.
* If that log doesn't exist {@code null} is returned.
*/
Long getFirstCommittedTxId( long version );
/**
* @return the first committed transaction id for the log with {@code version}.
* If that log doesn't exist {@code null} is returned.
*/
long getLastCommittedTxId();
/**
* @param version the log version to get first tx timestamp for.
* @return the timestamp for the start record for the first encountered transaction
* in the log {@code version}.
*/
Long getFirstStartRecordTimestamp( long version ) throws IOException;
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_LogExtractor.java
|
6,489
|
private interface Threshold
{
boolean reached( File file, long version, LogLoader source );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_LogPruneStrategies.java
|
6,490
|
public interface LogPruneStrategy
{
void prune( LogLoader source );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_LogPruneStrategy.java
|
6,491
|
public interface RecoveryVerifier
{
RecoveryVerifier ALWAYS_VALID = new RecoveryVerifier()
{
@Override
public boolean isValid( TransactionInfo txInfo )
{
return true;
}
};
/**
* Performs a check for the transaction which was just recovered to see if it's OK or not.
* The relevant information about the transaction is in {@code txInfo}. Typically,
* in a stand-alone environment there's no need to perform any additional checks since
* the 2PC protocol will guard for those cases. For a distributed environment it might
* be required.
*
* @param txInfo the {@link TransactionInfo} containing relevant information about the
* transaction which was recovered.
* @return {@code true} if the transaction verifies OK, otherwise {@code false}.
* Returning false will result in a {@link RecoveryVerificationException} being thrown
* from the recovery process.
*/
boolean isValid( TransactionInfo txInfo );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_RecoveryVerifier.java
|
6,492
|
public interface TransactionInterceptor extends CommandRecordVisitor
{
/**
* The main work method, supposed to be called by users when the whole
* required set of Commands has been met.
* The last operation in a normal completion scenario for this method
* must be calling complete() on the following member of the chain, if
* present.
*/
void complete();
/**
* Set, if available, the log start entry for this transaction. The
* implementation is not expected to act on it in any meaningful way
* but it is required to pass it on in the chain before throwing it
* out. Also, the implementation should not count on it being set
* during its lifetime - it is possible that it is not available.
*
* @param entry The start log entry for this transaction
*/
void setStartEntry( LogEntry.Start entry );
/**
* Set, if available, the log commit entry for this transaction. The
* implementation is not expected to act on it in any meaningful way
* but it is required to pass it on in the chain before throwing it
* out. Also, the implementation should not count on it being set
* during its lifetime - it is possible that it is not available.
*
* @param entry The commit log entry for this transaction
*/
void setCommitEntry( LogEntry.Commit entry );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_TransactionInterceptor.java
|
6,493
|
public interface TransactionMonitor
{
void transactionCommitted( Xid xid, boolean recovered );
void injectOnePhaseCommit( Xid xid );
void injectTwoPhaseCommit( Xid xid );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_TransactionMonitor.java
|
6,494
|
public interface Visitor
{
void visitStart( int localId, byte[] globalTransactionId, int masterId, int myId, long startTimestamp );
void visitPrepare( int localId, long prepareTimestamp );
void visitCommit( int localId, boolean twoPhase, long txId, long commitTimestamp );
void visitDone( int localId );
void visitUpdateNode( int localId, NodeRecord node );
void visitDeleteNode( int localId, long node );
void visitUpdateRelationship( int localId, RelationshipRecord node );
void visitDeleteRelationship( int localId, long node );
void visitUpdateProperty( int localId, PropertyRecord node );
void visitDeleteProperty( int localId, long node );
void visitUpdateRelationshipTypeToken( int localId, RelationshipTypeTokenRecord node );
void visitDeleteRelationshipTypeToken( int localId, int node );
void visitUpdateLabelToken( int localId, LabelTokenRecord node );
void visitDeleteLabelToken( int localId, int node );
void visitUpdatePropertyKeyToken( int localId, PropertyKeyTokenRecord node );
void visitDeletePropertyKeyToken( int localId, int node );
void visitUpdateNeoStore( int localId, NeoStoreRecord node );
void visitDeleteNeoStore( int localId, long node );
void visitDeleteSchemaRule( int localId, Collection<DynamicRecord> records, long id );
void visitUpdateSchemaRule( int localId, Collection<DynamicRecord> records );
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_TransactionReader.java
|
6,495
|
public interface TxIdGenerator
{
TxIdGenerator DEFAULT = new TxIdGenerator()
{
public long generate( XaDataSource dataSource, int identifier ) throws XAException
{
return dataSource.getLastCommittedTxId() + 1;
}
public int getCurrentMasterId()
{
return XaLogicalLog.MASTER_ID_REPRESENTING_NO_MASTER;
}
public int getMyId()
{
return XaLogicalLog.MASTER_ID_REPRESENTING_NO_MASTER;
}
@Override
public void committed( XaDataSource dataSource, int identifier, long txId, Integer externalAuthor )
{
}
};
/**
* Generates a transaction id to use for the committing transaction.
*
* @param dataSource {@link org.neo4j.kernel.impl.transaction.xaframework.XaDataSource} to commit.
* @param identifier temporary transaction identifier.
* @return transaction id to use to commit the next transaction for
* this {@code dataSource}.
*/
long generate( final XaDataSource dataSource, final int identifier ) throws XAException;
/**
* Hook which gets called when a transaction has been committed, but before
* returning from commit methods.
* @param dataSource {@link XaDataSource} which committed the transaction.
* @param identifier temporary identifier for the committed transaction.
* @param txId the transaction id used for this committed transaction.
* @param externalAuthorServerId if this transaction was authored by an
* external server exclude it as push target for this transaction.
* {@code null} means authored by this server.
*/
void committed( XaDataSource dataSource, int identifier, long txId, Integer externalAuthorServerId );
/**
* Returns the id of the current master. For single instance case it's
* {@code -1}, but in multi instance scenario it returns the id
* of the current master instance.
* @return id of the current master.
*/
int getCurrentMasterId();
/**
* Returns the id of my database instance. In a single instance scenario
* {@code -1} will be returned.
* @return my database instance id.
*/
int getMyId();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_TxIdGenerator.java
|
6,496
|
public interface XaConnection
{
/**
* Returns the <CODE>XAResource</CODE> held by this <CODE>XaConnection</CODE>.
*
* @return The resource associated with this connection
*/
XAResource getXaResource();
boolean enlistResource( Transaction javaxTx ) throws SystemException, RollbackException;
boolean delistResource( Transaction tx, int tmsuccess ) throws IllegalStateException, SystemException;
/**
* Destroys this connection and depending on <CODE>XAResource</CODE>
* implementation the work done on the resource will be rolled back, saved
* or committed (may also depend on transactional state).
* <p>
* This method is only valid to call once and there after it is illegal to
* invoke <CODE>getXaResource</CODE> or any other method that creates
* transactions or performs work using the <CODE>XAResource</CODE>.
*/
void destroy();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_XaConnection.java
|
6,497
|
public static enum State {
/**
* Old < b8 xaframework with no log rotation
*/
LEGACY_WITHOUT_LOG_ROTATION,
/**
* No .active file to tell us the state of
* affairs, and no legacy logical log file.
* TODO: Describe this state better.
*/
NO_ACTIVE_FILE,
/**
* Cleanly shut down log files.
*/
CLEAN,
/**
* Log 1 is currently active.
*/
LOG_1_ACTIVE,
/**
* Log 2 is currently active.
*/
LOG_2_ACTIVE,
/**
* Log 1 is active, but log 2 is also
* present.
*/
DUAL_LOGS_LOG_1_ACTIVE,
/**
* Log 2 is active, but log 1 is also
* present.
*/
DUAL_LOGS_LOG_2_ACTIVE
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_XaLogicalLogFiles.java
|
6,498
|
public interface XaResource extends XAResource
{
byte[] getBranchId();
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_transaction_xaframework_XaResource.java
|
6,499
|
public enum BranchCollisionPolicies implements BranchCollisionPolicy
{
/**
* @deprecated See {@link org.neo4j.graphdb.traversal.BranchCollisionPolicies}
*/
STANDARD;
@Override
public BranchCollisionDetector create( Evaluator evaluator )
{
return org.neo4j.graphdb.traversal.BranchCollisionPolicies.STANDARD.create( evaluator );
}
}
| false
|
community_kernel_src_main_java_org_neo4j_kernel_impl_traversal_BranchCollisionPolicies.java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.