本文整理了Java中org.neo4j.kernel.impl.store.NodeStore.nextId()
方法的一些代码示例,展示了NodeStore.nextId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NodeStore.nextId()
方法的具体详情如下:
包路径:org.neo4j.kernel.impl.store.NodeStore
类名称:NodeStore
方法名:nextId
暂无
代码示例来源:origin: neo4j/neo4j
@Override
public long createNode( Map<String, Object> properties, Label... labels )
{
return internalCreateNode( nodeStore.nextId(), properties, labels );
}
代码示例来源:origin: neo4j/neo4j
private long nextId( Class<?> clazz )
{
NeoStores neoStores = ds.getDependencyResolver()
.resolveDependency( RecordStorageEngine.class ).testAccessNeoStores();
if ( clazz.equals( PropertyKeyTokenRecord.class ) )
{
return neoStores.getPropertyKeyTokenStore().nextId();
}
if ( clazz.equals( RelationshipType.class ) )
{
return neoStores.getRelationshipTypeTokenStore().nextId();
}
if ( clazz.equals( Node.class ) )
{
return neoStores.getNodeStore().nextId();
}
if ( clazz.equals( Relationship.class ) )
{
return neoStores.getRelationshipStore().nextId();
}
throw new IllegalArgumentException( clazz.getName() );
}
代码示例来源:origin: neo4j/neo4j
NodeStore nodeStore = neoStores.getNodeStore();
long[] nodes = { // allocate ids
nodeStore.nextId(), nodeStore.nextId(), nodeStore.nextId(), nodeStore.nextId(), nodeStore.nextId(),
nodeStore.nextId(), nodeStore.nextId(),};
代码示例来源:origin: neo4j/neo4j
for ( int i = 0; i < highestId; i++ )
assertThat( store.nextId(), is( (long) i ) );
record.setId( i );
store.updateRecord( record );
nextIds.add( store.nextId() ); // 2
nextIds.add( store.nextId() ); // 3
nextIds.add( store.nextId() ); // 5
nextIds.add( store.nextId() ); // 7
nextIds.add( store.nextId() ); // 51
assertThat( nextIds, contains( 2L, 3L, 5L, 7L, 50L ) );
store.close();
代码示例来源:origin: neo4j/neo4j
private long[] createRelationships( NeoStores neoStores, TransactionRecordState tx, long nodeId, int type,
Direction direction, int count )
{
long[] result = new long[count];
for ( int i = 0; i < count; i++ )
{
long otherNodeId = neoStores.getNodeStore().nextId();
tx.nodeCreate( otherNodeId );
long first = direction == OUTGOING ? nodeId : otherNodeId;
long other = direction == INCOMING ? nodeId : otherNodeId;
long relId = neoStores.getRelationshipStore().nextId();
result[i] = relId;
tx.relCreate( relId, type, first, other );
}
return result;
}
代码示例来源:origin: neo4j/neo4j
private TransactionToApply createNodeAndProperty( int progress ) throws Exception
{
TransactionState txState = new TxState();
long nodeId = nodeIds.nextId();
txState.nodeDoCreate( nodeId );
txState.nodeDoAddLabel( descriptor.getLabelId(), nodeId );
txState.nodeDoAddProperty( nodeId, descriptor.getPropertyId(), propertyValue( id, progress ) );
Collection<StorageCommand> commands = new ArrayList<>();
try ( StorageReader statement = storageEngine.newReader() )
{
storageEngine.createCommands( commands, txState, statement, null, 0, NO_DECORATION );
}
return tx( commands );
}
代码示例来源:origin: neo4j/neo4j
private TransactionRecordState nodeWithDynamicLabelRecord( NeoStores store, AtomicLong nodeId,
AtomicLong dynamicLabelRecordId )
{
TransactionRecordState recordState = newTransactionRecordState( store );
nodeId.set( store.getNodeStore().nextId() );
int[] labelIds = new int[20];
for ( int i = 0; i < labelIds.length; i++ )
{
int labelId = (int) store.getLabelTokenStore().nextId();
recordState.createLabelToken( "Label" + i, labelId );
labelIds[i] = labelId;
}
recordState.nodeCreate( nodeId.get() );
for ( int labelId : labelIds )
{
recordState.addLabelToNode( labelId, nodeId.get() );
}
// Extract the dynamic label record id (which is also a verification that we allocated one)
NodeRecord node = Iterables.single( recordChangeSet.getNodeRecords().changes() ).forReadingData();
dynamicLabelRecordId.set( Iterables.single( node.getDynamicLabelRecords() ).getId() );
return recordState;
}
代码示例来源:origin: neo4j/neo4j
for ( int i = 0; i < highestId; i++ )
assertThat( store.nextId(), is( (long) i ) );
record.setId( i );
store.updateRecord( record );
nextIds.add( store.nextId() ); // recordsPerPage - 2
nextIds.add( store.nextId() ); // recordsPerPage - 1
nextIds.add( store.nextId() ); // recordsPerPage * 3 (we didn't use this id in the create-look above)
assertThat( nextIds, contains( recordsPerPage - 2L, recordsPerPage - 1L, recordsPerPage * 3L ) );
store.close();
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldTellNodeInUse() throws Exception
{
// Given
EphemeralFileSystemAbstraction fs = efs.get();
NodeStore store = newNodeStore( fs );
long exists = store.nextId();
store.updateRecord( new NodeRecord( exists, false, 10, 20, true ) );
long deleted = store.nextId();
store.updateRecord( new NodeRecord( deleted, false, 10, 20, true ) );
store.updateRecord( new NodeRecord( deleted, false, 10, 20, false ) );
// When & then
assertTrue( store.isInUse( exists ) );
assertFalse( store.isInUse( deleted ) );
assertFalse( store.isInUse( nodeStore.recordFormat.getMaxId() ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldMaintainCorrectDataWhenDeletingFromDenseNodeWithOneType() throws Exception
{
// GIVEN a node with a total of denseNodeThreshold-1 relationships
NeoStores neoStores = neoStoresRule.builder()
.with( GraphDatabaseSettings.dense_node_threshold.name(), "13" ).build();
TransactionRecordState tx = newTransactionRecordState( neoStores );
int nodeId = (int) neoStores.getNodeStore().nextId();
int typeA = 0;
tx.nodeCreate( nodeId );
tx.createRelationshipTypeToken( "A", typeA );
long[] relationshipsCreated = createRelationships( neoStores, tx, nodeId, typeA, INCOMING, 15 );
//WHEN
tx.relDelete( relationshipsCreated[0] );
// THEN the node should have been converted into a dense node
assertDenseRelationshipCounts( recordChangeSet, nodeId, typeA, 0, 14 );
}
代码示例来源:origin: neo4j/neo4j
long nodeId = neoStores.getNodeStore().nextId();
long otherNode1Id = neoStores.getNodeStore().nextId();
long otherNode2Id = neoStores.getNodeStore().nextId();
TransactionRecordState recordState = newTransactionRecordState( neoStores );
recordState.nodeCreate( nodeId );
long otherNodeId = neoStores.getNodeStore().nextId();
recordState.nodeCreate( otherNodeId );
recordState.relCreate( neoStores.getRelationshipStore().nextId(), type5, nodeId, otherNodeId );
long otherNodeId = neoStores.getNodeStore().nextId();
recordState.nodeCreate( otherNodeId );
recordState.relCreate( neoStores.getRelationshipStore().nextId(), type15, nodeId, otherNodeId );
代码示例来源:origin: neo4j/neo4j
long startingId = nodeStore.nextId();
long nodeId = startingId;
for ( int i = 0; i < iterations; i++ )
record.setInUse( true );
nodeStore.updateRecord( record );
nodeId = nodeStore.nextId();
代码示例来源:origin: neo4j/neo4j
.with( GraphDatabaseSettings.dense_node_threshold.name(), "10" ).build();
TransactionRecordState tx = newTransactionRecordState( neoStores );
long nodeId = neoStores.getNodeStore().nextId();
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldConvertToDenseNodeRepresentationWhenHittingThresholdWithTheSameTypeSameDirection()
throws Exception
{
// GIVEN a node with a total of denseNodeThreshold-1 relationships
NeoStores neoStores = neoStoresRule.builder()
.with( GraphDatabaseSettings.dense_node_threshold.name(), "8" ).build();
TransactionRecordState tx = newTransactionRecordState( neoStores );
long nodeId = neoStores.getNodeStore().nextId();
int typeA = 0;
tx.nodeCreate( nodeId );
tx.createRelationshipTypeToken( "A", typeA );
createRelationships( neoStores, tx, nodeId, typeA, OUTGOING, 8 );
// here we're at the edge
assertFalse( recordChangeSet.getNodeRecords().getOrLoad( nodeId, null ).forReadingData().isDense() );
// WHEN creating the relationship that pushes us over the threshold
createRelationships( neoStores, tx, nodeId, typeA, OUTGOING, 1 );
// THEN the node should have been converted into a dense node
assertTrue( recordChangeSet.getNodeRecords().getOrLoad( nodeId, null ).forReadingData().isDense() );
assertDenseRelationshipCounts( recordChangeSet, nodeId, typeA, 9, 0 );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldConvertToDenseNodeRepresentationWhenHittingThresholdWithTheSameTypeDifferentDirection()
throws Exception
{
// GIVEN a node with a total of denseNodeThreshold-1 relationships
NeoStores neoStores = neoStoresRule.builder()
.with( GraphDatabaseSettings.dense_node_threshold.name(), "49" ).build();
TransactionRecordState tx = newTransactionRecordState( neoStores );
long nodeId = neoStores.getNodeStore().nextId();
int typeA = 0;
tx.nodeCreate( nodeId );
tx.createRelationshipTypeToken( "A", typeA );
createRelationships( neoStores, tx, nodeId, typeA, OUTGOING, 24 );
createRelationships( neoStores, tx, nodeId, typeA, INCOMING, 25 );
// here we're at the edge
assertFalse( recordChangeSet.getNodeRecords().getOrLoad( nodeId, null ).forReadingData().isDense() );
// WHEN creating the relationship that pushes us over the threshold
createRelationships( neoStores, tx, nodeId, typeA, INCOMING, 1 );
// THEN the node should have been converted into a dense node
assertTrue( recordChangeSet.getNodeRecords().getOrLoad( nodeId, null ).forReadingData().isDense() );
assertDenseRelationshipCounts( recordChangeSet, nodeId, typeA, 24, 26 );
}
代码示例来源:origin: neo4j/neo4j
private Ids createNode( DataImporter.Monitor monitor, NeoStores neoStores, int propertyCount, int labelCount )
{
PropertyStore propertyStore = neoStores.getPropertyStore();
RecordAccess<PropertyRecord,PrimitiveRecord> propertyRecordAccess =
new DirectRecordAccess<>( propertyStore, new Loaders( neoStores ).propertyLoader() );
NodeStore nodeStore = neoStores.getNodeStore();
NodeRecord nodeRecord = nodeStore.newRecord();
nodeRecord.setId( nodeStore.nextId() );
nodeRecord.setInUse( true );
NodeLabelsField.parseLabelsField( nodeRecord ).put( labelIds( labelCount ), nodeStore, nodeStore.getDynamicLabelStore() );
long nextProp = new PropertyCreator( propertyStore, new PropertyTraverser() )
.createPropertyChain( nodeRecord, properties( propertyStore, propertyCount ), propertyRecordAccess );
nodeRecord.setNextProp( nextProp );
nodeStore.updateRecord( nodeRecord );
PropertyRecord[] propertyRecords = extractPropertyRecords( propertyRecordAccess, nextProp );
propertyRecordAccess.close();
monitor.nodesImported( 1 );
monitor.propertiesImported( propertyCount );
return new Ids( nodeRecord, propertyRecords );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldSetCorrectHighIdWhenApplyingExternalTransactions() throws Exception
{
// WHEN recovering a transaction that creates some data
long nodeId = neoStores.getNodeStore().nextId();
long relationshipId = neoStores.getRelationshipStore().nextId();
int type = 1;
applyExternalTransaction( 1,
new NodeCommand( new NodeRecord( nodeId ), inUse( created( new NodeRecord( nodeId ) ) ) ),
new RelationshipCommand( null,
inUse( created( with( new RelationshipRecord( relationshipId ), nodeId, nodeId, type ) ) ) ) );
// and when, later on, recovering a transaction deleting some of those
applyExternalTransaction( 2,
new NodeCommand( inUse( created( new NodeRecord( nodeId ) ) ), new NodeRecord( nodeId ) ),
new RelationshipCommand( null, new RelationshipRecord( relationshipId ) ) );
// THEN that should be possible and the high ids should be correct, i.e. highest applied + 1
assertEquals( nodeId + 1, neoStores.getNodeStore().getHighId() );
assertEquals( relationshipId + 1, neoStores.getRelationshipStore().getHighId() );
}
代码示例来源:origin: neo4j/neo4j
.with( GraphDatabaseSettings.dense_node_threshold.name(), "50" ).build();
TransactionRecordState tx = newTransactionRecordState( neoStores );
long nodeId = neoStores.getNodeStore().nextId();
int typeA = 0;
int typeB = 1;
代码示例来源:origin: neo4j/neo4j
.with( GraphDatabaseSettings.dense_node_threshold.name(), "1" ).build();
TransactionRecordState tx = newTransactionRecordState( neoStores );
long nodeId = neoStores.getNodeStore().nextId();
int typeA = 0;
int typeB = 12;
代码示例来源:origin: org.neo4j/neo4j-kernel
@Override
public long createNode( Map<String, Object> properties, Label... labels )
{
return internalCreateNode( nodeStore.nextId(), properties, labels );
}
内容来源于网络,如有侵权,请联系作者删除!