Tabnine Logo
RecordStore
Code IndexAdd Tabnine to your IDE (free)

How to use
RecordStore
in
org.neo4j.kernel.impl.store

Best Java code snippets using org.neo4j.kernel.impl.store.RecordStore (Showing top 20 results out of 315)

origin: neo4j/neo4j

/**
 * Utility methods for reading records. These are not on the interface itself since it should be
 * an explicit choice when to create the record instances passed into it.
 * Also for mocking purposes it's less confusing and error prone having only a single method.
 */
static <R extends AbstractBaseRecord> R getRecord( RecordStore<R> store, long id, RecordLoad mode )
{
  R record = store.newRecord();
  store.getRecord( id, record, mode );
  return record;
}
origin: neo4j/neo4j

  public void warmUpCache()
  {
    int recordsPerPage = store.getRecordsPerPage();
    long id = 0;
    long half = store.getHighId() / 2;
    RECORD record = store.newRecord();
    while ( id < half )
    {
      store.getRecord( id, record, FORCE );
      id += recordsPerPage - 1;
    }
  }
}
origin: neo4j/neo4j

private static <RECORD extends AbstractBaseRecord> void migrate( RecordStore<RECORD> from, RecordStore<RECORD> to )
{
  to.setHighestPossibleIdInUse( from.getHighestPossibleIdInUse() );
  from.scanAllRecords( record ->
  {
    to.prepareForCommit( record );
    to.updateRecord( record );
    return false;
  } );
}
origin: neo4j/neo4j

  @Override
  protected long position()
  {
    return store.getHighId() * store.getRecordSize();
  }
}
origin: neo4j/neo4j

private static void breakTheChain( RecordStore<RelationshipRecord> relationshipStore )
{
  RelationshipRecord record = relationshipStore.getRecord( 10, relationshipStore.newRecord(), NORMAL );
  long relationshipTowardsEndOfChain = record.getFirstNode();
  while ( record.inUse() && !record.isFirstInFirstChain() )
  {
    record = relationshipStore.getRecord( relationshipTowardsEndOfChain, relationshipStore.newRecord(), FORCE );
    relationshipTowardsEndOfChain = record.getFirstPrevRel();
  }
  relationshipStore.updateRecord( new RelationshipRecord( relationshipTowardsEndOfChain, 0, 0, 0 ) );
}
origin: neo4j/neo4j

public static <RECORD extends AbstractBaseRecord> int numberOfRecordsInUse( RecordStore<RECORD> store )
{
  int inUse = 0;
  for ( long id = store.getNumberOfReservedLowIds(); id < store.getHighId(); id++ )
  {
    RECORD record = store.getRecord( id, store.newRecord(), RecordLoad.FORCE );
    if ( record.inUse() )
    {
      inUse++;
    }
  }
  return inUse;
}
origin: neo4j/neo4j

  private static <T extends AbstractBaseRecord> T[] readAllRecords( Class<T> type, RecordStore<T> store )
  {
    @SuppressWarnings( "unchecked" )
    T[] records = (T[]) Array.newInstance( type, (int) store.getHighId() );
    for ( int i = 0; i < records.length; i++ )
    {
      records[i] = store.getRecord( i, store.newRecord(), FORCE );
    }
    return records;
  }
}
origin: neo4j/neo4j

int relationshipTypeCount = 50;
RecordStore<RelationshipGroupRecord> groupStore = stores.getTemporaryRelationshipGroupStore();
RelationshipGroupRecord groupRecord = groupStore.newRecord();
RecordStore<NodeRecord> nodeStore = stores.getNodeStore();
NodeRecord nodeRecord = nodeStore.newRecord();
long cursor = 0;
for ( int typeId = relationshipTypeCount - 1; typeId >= 0; typeId-- )
    groupRecord.setId( groupStore.nextId() );
    groupStore.updateRecord( groupRecord );
      nodeStore.updateRecord( nodeRecord );
      nodeStore.setHighestPossibleIdInUse( nodeId );
origin: neo4j/neo4j

@Test
public void shouldReportRelationshipTypeInconsistencies() throws Exception
{
  // given
  StoreAccess access = fixture.directStoreAccess().nativeStores();
  RecordStore<RelationshipTypeTokenRecord> relTypeStore = access.getRelationshipTypeTokenStore();
  RelationshipTypeTokenRecord record = relTypeStore.getRecord( (int) relTypeStore.nextId(),
      relTypeStore.newRecord(), FORCE );
  record.setNameId( 20 );
  record.setInUse( true );
  relTypeStore.updateRecord( record );
  // when
  ConsistencySummaryStatistics stats = check();
  // then
  access.close();
  on( stats ).verify( RecordType.RELATIONSHIP_TYPE, 1 )
        .andThatsAllFolks();
}
origin: neo4j/neo4j

protected R getHeavy( S store, int id )
{
  R record = store.getRecord( id, store.newRecord(), NORMAL );
  store.ensureHeavy( record );
  return record;
}
origin: neo4j/neo4j

@Override
public R getRecord( long id, R target, RecordLoad mode ) throws InvalidRecordException
{
  return actual.getRecord( id, target, mode );
}
origin: neo4j/neo4j

@Override
public long getHighId()
{
  return actual.getHighId();
}
origin: neo4j/neo4j

private <RECORD extends AbstractBaseRecord> void createRecordIn( RecordStore<RECORD> store )
{
  RECORD record = store.newRecord();
  record.setId( store.nextId() );
  record.setInUse( true );
  if ( record instanceof PropertyRecord )
  {
    // Special hack for property store, since it's not enough to simply set a record as in use there
    PropertyBlock block = new PropertyBlock();
    ((PropertyStore)store).encodeValue( block, 0, Values.of( 10 ) );
    ((PropertyRecord) record).addPropertyBlock( block );
  }
  store.updateRecord( record );
}
origin: neo4j/neo4j

  private byte[] newRecordBuffer()
  {
    return new byte[schemaStore.getRecordSize() * 4];
  }
}
origin: neo4j/neo4j

@Override
public void updateRecord( R record )
{
  actual.updateRecord( record );
}
origin: stackoverflow.com

byte[] recData = null;
 int len;
 RecordStore rs = RecordStore.openRecordStore("StoryDataBase1", true);
 if (rs.getNumRecords() > 0) {
 recData = new byte[rs.getRecordSize(1)];
 len = rs.getRecord(1, recData, 0);
 String value = new String(recData, 0, len);
 if(value == null) {
 ....
 } else {
 ...
  }
 }
origin: neo4j/neo4j

static RecordIdIterator allInReversed( RecordStore<? extends AbstractBaseRecord> store,
    Configuration config )
{
  return backwards( store.getNumberOfReservedLowIds(), store.getHighId(), config );
}
origin: neo4j/neo4j

@SuppressWarnings( "unchecked" )
@Test
public void shouldProcessAllTheRecordsInAStore() throws Exception
{
  // given
  RecordStore<NodeRecord> nodeStore = stores.builder().build().getNodeStore();
  ConsistencyReport.Reporter reporter = mock( ConsistencyReport.Reporter.class );
  StoreProcessor processor = new StoreProcessor( CheckDecorator.NONE,
      reporter, Stage.SEQUENTIAL_FORWARD, CacheAccess.EMPTY );
  nodeStore.updateRecord( node( 0, false, 0, 0 ) );
  nodeStore.updateRecord( node( 1, false, 0, 0 ) );
  nodeStore.updateRecord( node( 2, false, 0, 0 ) );
  nodeStore.setHighestPossibleIdInUse( 2 );
  // when
  processor.applyFiltered( nodeStore );
  // then
  verify( reporter, times( 3 ) ).forNode( any( NodeRecord.class ), any( RecordCheck.class ) );
}
origin: neo4j/neo4j

@Override
public long nextId()
{
  return actual.nextId();
}
origin: neo4j/neo4j

boolean lastInChain = count == 0;
group.setId( nextId == -1 ? nextId = store.nextId() : nextId );
if ( !lastInChain )
  group.setNext( nextId = store.nextId() );
    store.prepareForCommit( batch[j] );
org.neo4j.kernel.impl.storeRecordStore

Javadoc

A store for #updateRecord(AbstractBaseRecord) and #getRecord(long,AbstractBaseRecord,RecordLoad) records. There are two ways of getting records, either one-by-one using #getRecord(long,AbstractBaseRecord,RecordLoad), passing in record retrieved from #newRecord(). This to make a conscious decision about who will create the record instance and in that process figure out ways to reduce number of record instances created.

The other way is to use #openPageCursorForReading(long) to open a cursor and use it to read records using #getRecordByCursor(long,AbstractBaseRecord,RecordLoad,PageCursor). A PageCursor can be ket open to read multiple records before closing it.

Most used methods

  • getRecord
    Utility methods for reading records. These are not on the interface itself since it should be an exp
  • getHighId
  • newRecord
  • updateRecord
    Updates this store with the contents of record at the record id AbstractBaseRecord#getId() by the re
  • getRecordSize
  • nextId
  • getRecordDataSize
  • setHighestPossibleIdInUse
    Sets highest id in use for this store. This is for when records are applied to this store where the
  • ensureHeavy
    For stores that have other stores coupled underneath, the "top level" record will have a flag saying
  • getNumberOfReservedLowIds
    Some stores may have meta data stored in the header of the store file. Since all records in a store
  • getRecordsPerPage
  • getStorageFile
  • getRecordsPerPage,
  • getStorageFile,
  • prepareForCommit,
  • accept,
  • addRecord,
  • close,
  • closeRecordStore,
  • deleteRecord,
  • enumerateRecords,
  • flush

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSupportFragmentManager (FragmentActivity)
  • setRequestProperty (URLConnection)
  • setContentView (Activity)
  • Kernel (java.awt.image)
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now