Skip to content

Commit

Permalink
Removes RecordCursor entirely
Browse files Browse the repository at this point in the history
Since it was no longer used on main execution paths,
just remaining in some tests and very few odd places
which could easily be changed to use the current default
way of reading records, which is getting a PageCursor
  • Loading branch information
tinwelint committed Jul 2, 2018
1 parent 3382a96 commit cb05246
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 620 deletions.
Expand Up @@ -20,7 +20,6 @@
package org.neo4j.kernel.impl.newapi;

import java.util.Iterator;
import java.util.function.IntPredicate;
import java.util.regex.Pattern;

import org.neo4j.internal.kernel.api.PropertyCursor;
Expand Down Expand Up @@ -132,7 +131,6 @@ private boolean innerNext()
}
}

IntPredicate predicate = propertyKey -> propertiesState != null && propertiesState.isPropertyChangedOrRemoved( propertyKey );
while ( storeCursor.next() )
{
boolean skip = propertiesState != null && propertiesState.isPropertyChangedOrRemoved( storeCursor.propertyKey() );
Expand Down
Expand Up @@ -376,7 +376,10 @@ public void close()
{
assert !closed;
closeSchemaResources();
commandCreationContext.close();
if ( commandCreationContext != null )
{
commandCreationContext.close();
}
closed = true;
}

Expand Down
Expand Up @@ -25,7 +25,8 @@
import java.nio.file.OpenOption;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.neo4j.graphdb.config.Setting;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
Expand Down Expand Up @@ -1046,7 +1047,7 @@ public void getRecordByCursor( long id, RECORD record, RecordLoad mode, PageCurs
}
}

void readIntoRecord( long id, RECORD record, RecordLoad mode, PageCursor cursor ) throws IOException
private void readIntoRecord( long id, RECORD record, RecordLoad mode, PageCursor cursor ) throws IOException
{
// Mark the record with this id regardless of whether or not we load the contents of it.
// This is done in this method since there are multiple call sites and they all want the id
Expand Down Expand Up @@ -1177,9 +1178,14 @@ public <EXCEPTION extends Exception> void scanAllRecords( Visitor<RECORD,EXCEPTI
}

@Override
public Collection<RECORD> getRecords( long firstId, RecordLoad mode )
public List<RECORD> getRecords( long firstId, RecordLoad mode )
{
Collection<RECORD> records = new ArrayList<>();
if ( Record.NULL_REFERENCE.is( firstId ) )
{
return Collections.emptyList();
}

List<RECORD> records = new ArrayList<>();
long id = firstId;
try ( PageCursor cursor = openPageCursorForReading( firstId ) )
{
Expand All @@ -1188,23 +1194,15 @@ public Collection<RECORD> getRecords( long firstId, RecordLoad mode )
{
record = newRecord();
getRecordByCursor( id, record, mode, cursor );
if ( record.inUse() )
{
records.add( record );
}
// Even unused records gets added and returned
records.add( record );
id = getNextRecordReference( record );
}
while ( record.inUse() && !Record.NULL_REFERENCE.is( id ) );
while ( !Record.NULL_REFERENCE.is( id ) );
}
return records;
}

@Override
public RecordCursor<RECORD> newRecordCursor( final RECORD record )
{
return new StoreRecordCursor<>( record, this );
}

private void verifyAfterNotRead( RECORD record, RecordLoad mode )
{
record.clear();
Expand Down
Expand Up @@ -59,12 +59,6 @@ public static Long readOwnerFromDynamicLabelsRecord( DynamicRecord record )
return bits.getLong( requiredBits );
}

public RecordCursor<DynamicRecord> newLabelCursor()
{
return dynamicLabelStore.newRecordCursor( dynamicLabelStore.newRecord() ).acquire( getNumberOfReservedLowIds(),
RecordLoad.NORMAL );
}

public NodeStore(
File fileName,
Config config,
Expand Down
Expand Up @@ -19,8 +19,6 @@
*/
package org.neo4j.kernel.impl.store;

import org.eclipse.collections.api.map.primitive.LongObjectMap;

import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
Expand All @@ -31,7 +29,6 @@
import java.util.List;
import java.util.function.ToIntFunction;

import org.neo4j.cursor.Cursor;
import org.neo4j.helpers.collection.Iterables;
import org.neo4j.helpers.collection.Pair;
import org.neo4j.io.pagecache.PageCache;
Expand Down Expand Up @@ -270,19 +267,14 @@ public void ensureHeavy( PropertyBlock block )

PropertyType type = block.getType();
RecordStore<DynamicRecord> dynamicStore = dynamicStoreForValueType( type );
if ( dynamicStore == null )
{
return;
}

try ( Cursor<DynamicRecord> dynamicRecords = dynamicStore.newRecordCursor( dynamicStore.newRecord() )
.acquire( block.getSingleValueLong(), NORMAL ) )
if ( dynamicStore != null )
{
while ( dynamicRecords.next() )
List<DynamicRecord> dynamicRecords = dynamicStore.getRecords( block.getSingleValueLong(), NORMAL );
for ( DynamicRecord dynamicRecord : dynamicRecords )
{
dynamicRecords.get().setType( type.intValue() );
block.addValueRecord( dynamicRecords.get().clone() );
dynamicRecord.setType( type.intValue() );
}
block.setValueRecords( dynamicRecords );
}
}

Expand All @@ -301,14 +293,12 @@ public Value getValue( PropertyBlock propertyBlock )
return propertyBlock.getType().value( propertyBlock, this );
}

public static void allocateStringRecords( Collection<DynamicRecord> target, byte[] chars,
DynamicRecordAllocator allocator )
private static void allocateStringRecords( Collection<DynamicRecord> target, byte[] chars, DynamicRecordAllocator allocator )
{
AbstractDynamicStore.allocateRecordsFromBytes( target, chars, allocator );
}

public static void allocateArrayRecords( Collection<DynamicRecord> target, Object array,
DynamicRecordAllocator allocator, boolean allowStorePoints )
private static void allocateArrayRecords( Collection<DynamicRecord> target, Object array, DynamicRecordAllocator allocator, boolean allowStorePoints )
{
DynamicArrayStore.allocateRecords( target, array, allocator, allowStorePoints );
}
Expand Down Expand Up @@ -655,26 +645,26 @@ public static String decodeString( byte[] byteArray )
return UTF8.decode( byteArray );
}

public String getStringFor( PropertyBlock propertyBlock )
String getStringFor( PropertyBlock propertyBlock )
{
ensureHeavy( propertyBlock );
return getStringFor( propertyBlock.getValueRecords() );
}

public String getStringFor( Collection<DynamicRecord> dynamicRecords )
private String getStringFor( Collection<DynamicRecord> dynamicRecords )
{
Pair<byte[], byte[]> source = stringStore.readFullByteArray( dynamicRecords, PropertyType.STRING );
// A string doesn't have a header in the data array
return decodeString( source.other() );
}

public Value getArrayFor( PropertyBlock propertyBlock )
Value getArrayFor( PropertyBlock propertyBlock )
{
ensureHeavy( propertyBlock );
return getArrayFor( propertyBlock.getValueRecords() );
}

public Value getArrayFor( Iterable<DynamicRecord> records )
private Value getArrayFor( Iterable<DynamicRecord> records )
{
return getRightArray( arrayStore.readFullByteArray( records, PropertyType.ARRAY ) );
}
Expand All @@ -699,24 +689,6 @@ public Collection<PropertyRecord> getPropertyRecordChain( long firstRecordId )
return toReturn;
}

public Collection<PropertyRecord> getPropertyRecordChain( long firstRecordId,
LongObjectMap<PropertyRecord> propertyLookup )
{
long nextProp = firstRecordId;
List<PropertyRecord> toReturn = new ArrayList<>();
while ( nextProp != Record.NO_NEXT_PROPERTY.intValue() )
{
PropertyRecord propRecord = propertyLookup.get( nextProp );
if ( propRecord == null )
{
getRecord( nextProp, propRecord = newRecord(), RecordLoad.NORMAL );
}
toReturn.add( propRecord );
nextProp = propRecord.getNextProp();
}
return toReturn;
}

@Override
public PropertyRecord newRecord()
{
Expand Down

This file was deleted.

0 comments on commit cb05246

Please sign in to comment.