本文整理了Java中org.neo4j.kernel.impl.store.NodeStore.newRecord()
方法的一些代码示例,展示了NodeStore.newRecord()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NodeStore.newRecord()
方法的具体详情如下:
包路径:org.neo4j.kernel.impl.store.NodeStore
类名称:NodeStore
方法名:newRecord
暂无
代码示例来源:origin: neo4j/neo4j
private NodeRecord loadNode( long nodeId )
{
if ( nodeRecord == null )
{
nodeRecord = nodeStore.newRecord();
}
nodeStore.getRecord( nodeId, nodeRecord, RecordLoad.NORMAL );
return nodeRecord;
}
代码示例来源:origin: neo4j/neo4j
public NodeImporter( BatchingNeoStores stores, IdMapper idMapper, Monitor monitor )
{
super( stores, monitor );
this.labelTokenRepository = stores.getLabelRepository();
this.idMapper = idMapper;
this.nodeStore = stores.getNodeStore();
this.nodeRecord = nodeStore.newRecord();
this.nodeIds = new BatchingIdGetter( nodeStore );
this.idPropertyStore = stores.getTemporaryPropertyStore();
this.idPropertyRecord = idPropertyStore.newRecord();
nodeRecord.setInUse( true );
}
代码示例来源:origin: neo4j/neo4j
@Override
public Value getNodePropertyValue( long nodeId, int propertyKeyId )
{
NodeRecord nodeRecord = nodeStore.newRecord();
if ( nodeStore.getRecord( nodeId, nodeRecord, FORCE ).inUse() )
{
SpecificValueVisitor visitor = new SpecificValueVisitor( propertyKeyId );
try
{
if ( visitPropertyRecordChain( nodeRecord.getNextProp(), visitor ) )
{
return visitor.foundPropertyValue;
}
}
catch ( CircularPropertyRecordChainException e )
{
// If we discover a circular reference and still haven't found the property then we won't find it.
// There are other places where this circular reference will be logged as an inconsistency,
// so simply catch this exception here and let this method return NO_VALUE below.
}
}
return Values.NO_VALUE;
}
代码示例来源:origin: neo4j/neo4j
@Test
void scanForHighIdOnlyOnceWhenProcessCache()
{
NeoStores neoStores = mock( NeoStores.class, Mockito.RETURNS_MOCKS );
NodeStore nodeStore = mock( NodeStore.class );
NodeRecord nodeRecord = mock( NodeRecord.class );
StoreProcessor storeProcessor = mock( StoreProcessor.class );
when( neoStores.getNodeStore() ).thenReturn( nodeStore );
when( nodeStore.getHighId() ).thenReturn( 10L );
when( nodeStore.getRecord( anyLong(), any( NodeRecord.class ), any( RecordLoad.class ) ) ).thenReturn( nodeRecord );
when( nodeStore.newRecord() ).thenReturn( nodeRecord );
StoreAccess storeAccess = new StoreAccess( neoStores );
storeAccess.initialize();
CacheTask.CheckNextRel cacheTask = new CacheTask.CheckNextRel( Stage.SEQUENTIAL_FORWARD, new DefaultCacheAccess( Counts.NONE, 1 ),
storeAccess, storeProcessor );
cacheTask.processCache();
verify( nodeStore, times( 1 ) ).getHighId();
}
}
代码示例来源:origin: neo4j/neo4j
@Before
public void setUp()
{
NodeRecord nodeRecord = getNodeRecord();
when( labelScanStore.allNodeLabelRanges()).thenReturn( nodeLabelRanges );
when( neoStores.getCounts() ).thenReturn( countStore );
when( neoStores.getNodeStore() ).thenReturn( nodeStore );
when( nodeStore.newRecord() ).thenReturn( nodeRecord );
doAnswer( invocation ->
{
NodeRecord record = invocation.getArgument( 1 );
record.initialize( true, 1L, false, 1L, 0L );
record.setId( invocation.getArgument( 0 ) );
return null;
} ).when( nodeStore ).getRecordByCursor( anyLong(), any( NodeRecord.class ), any( RecordLoad.class ), any( PageCursor.class ) );
doAnswer( invocation ->
{
NodeRecord record = invocation.getArgument( 0 );
record.initialize( true, 1L, false, 1L, 0L );
record.setId( record.getId() + 1 );
return null;
} ).when( nodeStore ).nextRecordByCursor( any( NodeRecord.class ), any( RecordLoad.class ), any( PageCursor.class ) );
}
代码示例来源:origin: neo4j/neo4j
private <RECEIVER extends PropertyReceiver> void nodeLoadProperties( long nodeId, RECEIVER receiver )
{
NodeRecord nodeRecord = nodeStore.getRecord( nodeId, nodeStore.newRecord(), NORMAL );
loadProperties( nodeRecord.getNextProp(), receiver );
}
代码示例来源:origin: neo4j/neo4j
@Override
public Value getNodePropertyValue( long nodeId, int propertyKeyId ) throws EntityNotFoundException
{
NodeRecord node = nodeStore.getRecord( nodeId, nodeStore.newRecord(), FORCE );
if ( !node.inUse() )
{
throw new EntityNotFoundException( EntityType.NODE, nodeId );
}
long firstPropertyId = node.getNextProp();
if ( firstPropertyId == Record.NO_NEXT_PROPERTY.intValue() )
{
return Values.NO_VALUE;
}
for ( PropertyRecord propertyRecord : propertyStore.getPropertyRecordChain( firstPropertyId ) )
{
PropertyBlock propertyBlock = propertyRecord.getPropertyBlock( propertyKeyId );
if ( propertyBlock != null )
{
return propertyBlock.newPropertyValue( propertyStore );
}
}
return Values.NO_VALUE;
}
代码示例来源:origin: neo4j/neo4j
NodeRecord inUseRecord = new NodeRecord( 42 );
inUseRecord.setInUse( true );
when( nodeStore.newRecord() ).thenReturn( emptyRecord );
when( nodeStore.getRecord( anyLong(), any( NodeRecord.class ), any( RecordLoad.class ) ) ).thenReturn( inUseRecord, inUseRecord, inUseRecord,
inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord );
代码示例来源:origin: neo4j/neo4j
@Override
protected void process( RelationshipGroupRecord[] batch, BatchSender sender )
{
for ( RelationshipGroupRecord group : batch )
{
if ( !group.inUse() )
{
continue;
}
long nodeId = group.getOwningNode();
if ( cache.getByte( nodeId, 0 ) == 0 )
{
cache.setByte( nodeId, 0, (byte) 1 );
NodeRecord nodeRecord = nodeStore.newRecord();
nodeStore.getRecordByCursor( nodeId, nodeRecord, NORMAL, nodeCursor );
nodeRecord.setNextRel( group.getId() );
nodeRecord.setDense( true );
current[cursor++] = nodeRecord;
if ( cursor == batchSize )
{
sender.send( current );
newBatch();
}
}
}
control.recycle( batch );
}
代码示例来源:origin: neo4j/neo4j
private void assertRelationshipGroupsInOrder( NeoStores neoStores, long nodeId, int... types )
{
NodeStore nodeStore = neoStores.getNodeStore();
NodeRecord node = nodeStore.getRecord( nodeId, nodeStore.newRecord(), NORMAL );
assertTrue( "Node should be dense, is " + node, node.isDense() );
long groupId = node.getNextRel();
int cursor = 0;
List<RelationshipGroupRecord> seen = new ArrayList<>();
while ( groupId != Record.NO_NEXT_RELATIONSHIP.intValue() )
{
RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore();
RelationshipGroupRecord group = relationshipGroupStore.getRecord( groupId,
relationshipGroupStore.newRecord(), NORMAL );
seen.add( group );
assertEquals( "Invalid type, seen groups so far " + seen, types[cursor++], group.getType() );
groupId = group.getNext();
}
assertEquals( "Not enough relationship group records found in chain for " + node, types.length, cursor );
}
代码示例来源:origin: neo4j/neo4j
if ( type == EntityType.NODE )
entity = nodeStore.getRecord( entityId, nodeStore.newRecord(), FORCE );
代码示例来源:origin: neo4j/neo4j
@Override
public EntityUpdates nodeAsUpdates( long nodeId )
{
NodeRecord node = nodeStore.getRecord( nodeId, nodeStore.newRecord(), FORCE );
if ( !node.inUse() )
{
return null;
}
long firstPropertyId = node.getNextProp();
if ( firstPropertyId == Record.NO_NEXT_PROPERTY.intValue() )
{
return null; // no properties => no updates (it's not going to be in any index)
}
long[] labels = parseLabelsField( node ).get( nodeStore );
if ( labels.length == 0 )
{
return null; // no labels => no updates (it's not going to be in any index)
}
EntityUpdates.Builder update = EntityUpdates.forEntity( nodeId ).withTokens( labels );
for ( PropertyRecord propertyRecord : propertyStore.getPropertyRecordChain( firstPropertyId ) )
{
for ( PropertyBlock property : propertyRecord )
{
Value value = property.getType().value( property, propertyStore );
update.added( property.getKeyIndexId(), value );
}
}
return update.build();
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldCombineProperFiveByteLabelField() throws Exception
{
// GIVEN
// -- a store
EphemeralFileSystemAbstraction fs = efs.get();
nodeStore = newNodeStore( fs );
// -- a record with the msb carrying a negative value
long nodeId = 0;
long labels = 0x8000000001L;
NodeRecord record =
new NodeRecord( nodeId, false, NO_NEXT_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue() );
record.setInUse( true );
record.setLabelField( labels, Collections.emptyList() );
nodeStore.updateRecord( record );
// WHEN
// -- reading that record back
NodeRecord readRecord = nodeStore.getRecord( nodeId, nodeStore.newRecord(), NORMAL );
// THEN
// -- the label field must be the same
assertEquals( labels, readRecord.getLabelField() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldNotCreateSameLabelTwiceOnSameNode()
{
// GIVEN
BatchInserter inserter = globalInserter;
// WHEN
long nodeId = inserter.createNode( map( "itemId", 1000L ), label( "Item" ),
label( "Item" ) );
// THEN
NodeStore nodeStore = getFlushedNeoStores( inserter ).getNodeStore();
NodeRecord node = nodeStore.getRecord( nodeId, nodeStore.newRecord(), NORMAL );
NodeLabels labels = NodeLabelsField.parseLabelsField( node );
long[] labelIds = labels.get( nodeStore );
assertEquals( 1, labelIds.length );
}
代码示例来源:origin: neo4j/neo4j
@Override
protected void process()
NodeRecord nodeRecord = nodeStore.newRecord();
PropertyRecord propertyRecord = propertyStore.newRecord();
try ( PageCursor cursor = nodeStore.openPageCursorForReading( 0 );
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldSortLabelIdsWhenGetOrCreate()
{
// GIVEN
BatchInserter inserter = globalInserter;
// WHEN
long nodeId = inserter.createNode( map( "Item", 123456789123L ), label( "AA" ),
label( "BB" ), label( "CC" ), label( "DD" ) );
inserter.setNodeLabels( nodeId, label( "CC" ), label( "AA" ),
label( "DD" ), label( "EE" ), label( "FF" ) );
// THEN
NodeStore nodeStore = getFlushedNeoStores( inserter ).getNodeStore();
NodeRecord node = nodeStore.getRecord( nodeId, nodeStore.newRecord(), RecordLoad.NORMAL );
NodeLabels labels = NodeLabelsField.parseLabelsField( node );
long[] labelIds = labels.get( nodeStore );
long[] sortedLabelIds = labelIds.clone();
Arrays.sort( sortedLabelIds );
assertArrayEquals( sortedLabelIds, labelIds );
}
代码示例来源:origin: neo4j/neo4j
@Before
public void setup()
{
neoStores = new StoreFactory( storage.directory().databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory( storage.fileSystem() ),
storage.pageCache(), storage.fileSystem(), NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ).openAllNeoStores( true );
creator = new PropertyCreator( neoStores.getPropertyStore(), new PropertyTraverser() );
owner = neoStores.getNodeStore().newRecord();
}
代码示例来源: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
NodeRecord record = stores.getNodeStore().newRecord();
record = stores.getNodeStore().getRecord( nodeId, record, RecordLoad.NORMAL );
long propId = record.getNextProp();
代码示例来源:origin: org.neo4j/neo4j-kernel
public NodeImporter( BatchingNeoStores stores, IdMapper idMapper, Monitor monitor )
{
super( stores, monitor );
this.labelTokenRepository = stores.getLabelRepository();
this.idMapper = idMapper;
this.nodeStore = stores.getNodeStore();
this.nodeRecord = nodeStore.newRecord();
this.nodeIds = new BatchingIdGetter( nodeStore );
this.idPropertyStore = stores.getTemporaryPropertyStore();
this.idPropertyRecord = idPropertyStore.newRecord();
nodeRecord.setInUse( true );
}
内容来源于网络,如有侵权,请联系作者删除!