private long[] modificationData( int min, int max ) { int count = random.intBetween( min, max ); long[] data = new long[count * 2]; for ( int i = 0, c = 0; i < count; i++ ) { data[c++] = random.intBetween( 0, keyRange ); // key data[c++] = random.intBetween( 0, keyRange ); // value } return data; }
private List<Labels> randomData() { List<Labels> labels = new ArrayList<>(); int labelCount = random.intBetween( 30, 100 ); int labelId = 0; for ( int i = 0; i < labelCount; i++ ) { labelId += random.intBetween( 1, 20 ); int nodeCount = random.intBetween( 20, 100 ); long[] nodeIds = new long[nodeCount]; long nodeId = 0; for ( int j = 0; j < nodeCount; j++ ) { nodeId += random.intBetween( 1, 100 ); nodeIds[j] = nodeId; } labels.add( labels( labelId, nodeIds ) ); } return labels; }
private List<Action> generateLoad() { List<Action> actions = new LinkedList<>(); boolean hasCheckPoint = false; for ( int i = 0; i < loadCountTransactions; i++ ) { Action action = randomAction( true ); actions.add( action ); if ( action == CHECKPOINT ) { hasCheckPoint = true; } } // Guarantee that there's at least one check point, i.e. if there's none then append one at the end if ( !hasCheckPoint ) { actions.add( CHECKPOINT ); } // Guarantee that there are at least some non-checkpoint actions after last checkpoint if ( actions.get( actions.size() - 1 ) == CHECKPOINT ) { int additional = random.intBetween( 1, 10 ); for ( int i = 0; i < additional; i++ ) { actions.add( randomAction( false ) ); } } return actions; }
@Override protected TestLayout<MutableLong,MutableLong> getLayout( RandomRule random ) { return longLayout().withKeyPadding( random.intBetween( 0, 10 ) ).build(); } }
Object dynamicValue( int keySizeLimit, int wiggleRoom ) { int lowLimit = lowLimit( keySizeLimit, wiggleRoom, singleArrayEntrySize ); int highLimit = highLimit( keySizeLimit, wiggleRoom, singleArrayEntrySize ); return dynamicValue( random.intBetween( lowLimit, highLimit ) ); }
private Page randomPage( int corruptionPercent, MutableInt totalNumberOfCorruptions ) { int numberOfCorruptions = 0; boolean internal = randomRule.nextBoolean(); if ( randomRule.nextInt( 100 ) < corruptionPercent ) { int maxCorruptions = internal ? possibleCorruptionsInInternal.size() : possibleCorruptionsInLeaf.size(); numberOfCorruptions = randomRule.intBetween( 1, maxCorruptions ); totalNumberOfCorruptions.add( numberOfCorruptions ); } return internal ? randomInternal( numberOfCorruptions ) : randomLeaf( numberOfCorruptions ); }
@Override protected TestLayout<MutableLong,MutableLong> getLayout( RandomRule random ) { return longLayout().withKeyPadding( random.intBetween( 0, 10 ) ).build(); } }
@Override protected TestLayout<MutableLong,MutableLong> getLayout( RandomRule random ) { return longLayout().withKeyPadding( random.intBetween( 0, 10 ) ).build(); }
private void writeTransactions( int transactionCount, int minTransactionSize, int maxTransactionSize ) throws IOException { FlushablePositionAwareChannel channel = logFile.getWriter(); TransactionLogWriter writer = new TransactionLogWriter( new LogEntryWriter( channel ) ); for ( int i = 0; i < transactionCount; i++ ) { writer.append( tx( random.intBetween( minTransactionSize, maxTransactionSize ) ), ++txId ); } channel.prepareForFlush().flush(); // Don't close the channel, LogFile owns it }
private void appendCorruptedTransaction() throws IOException { FlushablePositionAwareChannel channel = logFile.getWriter(); TransactionLogWriter writer = new TransactionLogWriter( new CorruptedLogEntryWriter( channel ) ); writer.append( tx( random.intBetween( 100, 1000 ) ), ++txId ); }
@Test void shouldFillRandomGaps() { // given int numberOfRanges = random.intBetween( 50, 100 ); int[] ranges = new int[numberOfRanges]; for ( int rangeId = 0; rangeId < numberOfRanges; rangeId++ ) { ranges[rangeId] = random.nextInt( 1 << RANGE_SIZE ); } GapFreeAllEntriesLabelScanReader reader = newGapFreeAllEntriesLabelScanReader( ranges ); // when Iterator<NodeLabelRange> iterator = reader.iterator(); // then assertRanges( iterator, ranges ); }
int count = random.intBetween( 5, 10 ); for ( int k = 0; k < count; k++ ) int count = random.intBetween( 5, 20 ); for ( int k = 0; k < count && !acquired.isEmpty(); k++ )
int transactionSize = random.intBetween( 1, 30 ); try ( Transaction tx = db.beginTx() )
int numberOfCrashesDuringRecovery = random.intBetween( 0, 3 ); for ( int i = 0; i < numberOfCrashesDuringRecovery; i++ ) GBPTree<KEY,VALUE> index = createIndex( pageCache, file ) ) int numberOfActionsToRecoverBeforeCrashing = random.intBetween( 1, recoveryActions.size() ); recover( recoveryActions.subList( 0, numberOfActionsToRecoverBeforeCrashing ), index );
produceRandomNodePropertyAndLabelUpdates( db, random.intBetween( 20, 40 ), label, key1, key2 ); checkPoint( db ); Map<Long,Collection<IndexEntryUpdate<?>>> updatesAtLastCheckPoint = updateCapturingIndexProvider.snapshot(); produceRandomNodePropertyAndLabelUpdates( db, random.intBetween( 40, 100 ), label, key1, key2 );
int transactionSize = random.intBetween( 1, 30 ); try ( Transaction tx = db.beginTx() )