idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
19,500 | public static Type newInstance ( int sqlType ) { switch ( sqlType ) { case ( java . sql . Types . INTEGER ) : return INTEGER ; case ( java . sql . Types . BIGINT ) : return BIGINT ; case ( java . sql . Types . DOUBLE ) : return DOUBLE ; case ( java . sql . Types . VARCHAR ) : return VARCHAR ; } throw new UnsupportedOperationException ( "Unspported SQL type: " + sqlType ) ; } | Constructs a new instance corresponding to the specified SQL type . |
19,501 | public Buffer pin ( BlockId blk ) { PinnedBuffer pinnedBuff = pinnedBuffers . get ( blk ) ; if ( pinnedBuff != null ) { pinnedBuff . pinnedCount ++ ; return pinnedBuff . buffer ; } if ( pinnedBuffers . size ( ) == BUFFER_POOL_SIZE ) throw new BufferAbortException ( ) ; try { Buffer buff ; long timestamp = System . currentTimeMillis ( ) ; boolean waitedBeforeGotBuffer = false ; buff = bufferPool . pin ( blk ) ; if ( buff == null ) { waitedBeforeGotBuffer = true ; synchronized ( bufferPool ) { waitingThreads . add ( Thread . currentThread ( ) ) ; while ( buff == null && ! waitingTooLong ( timestamp ) ) { bufferPool . wait ( MAX_TIME ) ; if ( waitingThreads . get ( 0 ) . equals ( Thread . currentThread ( ) ) ) buff = bufferPool . pin ( blk ) ; } waitingThreads . remove ( Thread . currentThread ( ) ) ; } } if ( buff == null ) { repin ( ) ; buff = pin ( blk ) ; } else { pinnedBuffers . put ( buff . block ( ) , new PinnedBuffer ( buff ) ) ; } if ( waitedBeforeGotBuffer ) { synchronized ( bufferPool ) { bufferPool . notifyAll ( ) ; } } return buff ; } catch ( InterruptedException e ) { throw new BufferAbortException ( ) ; } } | Pins a buffer to the specified block potentially waiting until a buffer becomes available . If no buffer becomes available within a fixed time period then repins all currently holding blocks . |
19,502 | public Buffer pinNew ( String fileName , PageFormatter fmtr ) { if ( pinnedBuffers . size ( ) == BUFFER_POOL_SIZE ) throw new BufferAbortException ( ) ; try { Buffer buff ; long timestamp = System . currentTimeMillis ( ) ; boolean waitedBeforeGotBuffer = false ; buff = bufferPool . pinNew ( fileName , fmtr ) ; if ( buff == null ) { waitedBeforeGotBuffer = true ; synchronized ( bufferPool ) { waitingThreads . add ( Thread . currentThread ( ) ) ; while ( buff == null && ! waitingTooLong ( timestamp ) ) { bufferPool . wait ( MAX_TIME ) ; if ( waitingThreads . get ( 0 ) . equals ( Thread . currentThread ( ) ) ) buff = bufferPool . pinNew ( fileName , fmtr ) ; } waitingThreads . remove ( Thread . currentThread ( ) ) ; } } if ( buff == null ) { repin ( ) ; buff = pinNew ( fileName , fmtr ) ; } else { pinnedBuffers . put ( buff . block ( ) , new PinnedBuffer ( buff ) ) ; } if ( waitedBeforeGotBuffer ) { synchronized ( bufferPool ) { bufferPool . notifyAll ( ) ; } } return buff ; } catch ( InterruptedException e ) { throw new BufferAbortException ( ) ; } } | Pins a buffer to a new block in the specified file potentially waiting until a buffer becomes available . If no buffer becomes available within a fixed time period then repins all currently holding blocks . |
19,503 | public void unpin ( Buffer buff ) { BlockId blk = buff . block ( ) ; PinnedBuffer pinnedBuff = pinnedBuffers . get ( blk ) ; if ( pinnedBuff != null ) { pinnedBuff . pinnedCount -- ; if ( pinnedBuff . pinnedCount == 0 ) { bufferPool . unpin ( buff ) ; pinnedBuffers . remove ( blk ) ; synchronized ( bufferPool ) { bufferPool . notifyAll ( ) ; } } } } | Unpins the specified buffer . If the buffer s pin count becomes 0 then the threads on the wait list are notified . |
19,504 | private void repin ( ) { if ( logger . isLoggable ( Level . WARNING ) ) logger . warning ( "Tx." + txNum + " is re-pinning all buffers" ) ; try { List < BlockId > blksToBeRepinned = new LinkedList < BlockId > ( ) ; Map < BlockId , Integer > pinCounts = new HashMap < BlockId , Integer > ( ) ; List < Buffer > buffersToBeUnpinned = new LinkedList < Buffer > ( ) ; for ( Entry < BlockId , PinnedBuffer > entry : pinnedBuffers . entrySet ( ) ) { blksToBeRepinned . add ( entry . getKey ( ) ) ; pinCounts . put ( entry . getKey ( ) , entry . getValue ( ) . pinnedCount ) ; buffersToBeUnpinned . add ( entry . getValue ( ) . buffer ) ; } for ( Buffer buf : buffersToBeUnpinned ) unpin ( buf ) ; synchronized ( bufferPool ) { bufferPool . wait ( MAX_TIME ) ; } for ( BlockId blk : blksToBeRepinned ) pin ( blk ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } } | Unpins all currently pinned buffers of the calling transaction and repins them . |
19,505 | public static Map < String , Integer > offsetMap ( Schema sch ) { int pos = 0 ; Map < String , Integer > offsetMap = new HashMap < String , Integer > ( ) ; for ( String fldname : sch . fields ( ) ) { offsetMap . put ( fldname , pos ) ; pos += Page . maxSize ( sch . type ( fldname ) ) ; } return offsetMap ; } | Returns the map of field name to offset of a specified schema . |
19,506 | public static int recordSize ( Schema sch ) { int pos = 0 ; for ( String fldname : sch . fields ( ) ) pos += Page . maxSize ( sch . type ( fldname ) ) ; return pos < MIN_REC_SIZE ? MIN_REC_SIZE : pos ; } | Returns the number of bytes required to store a record with the specified schema in disk . |
19,507 | public Constant getVal ( String fldName ) { int position = fieldPos ( fldName ) ; return getVal ( position , ti . schema ( ) . type ( fldName ) ) ; } | Returns the value stored in the specified field of this record . |
19,508 | public void setVal ( String fldName , Constant val ) { int position = fieldPos ( fldName ) ; setVal ( position , val ) ; } | Stores a value at the specified field of this record . |
19,509 | public void delete ( RecordId nextDeletedSlot ) { Constant flag = EMPTY_CONST ; setVal ( currentPos ( ) , flag ) ; setNextDeletedSlotId ( nextDeletedSlot ) ; } | Deletes the current record . Deletion is performed by marking the record as deleted and setting the content as a pointer points to next deleted slot . |
19,510 | public boolean insertIntoTheCurrentSlot ( ) { if ( ! getVal ( currentPos ( ) , INTEGER ) . equals ( EMPTY_CONST ) ) return false ; setVal ( currentPos ( ) , INUSE_CONST ) ; return true ; } | Marks the current slot as in - used . |
19,511 | public boolean insertIntoNextEmptySlot ( ) { boolean found = searchFor ( EMPTY ) ; if ( found ) { Constant flag = INUSE_CONST ; setVal ( currentPos ( ) , flag ) ; } return found ; } | Inserts a new blank record somewhere in the page . Return false if there were no available slots . |
19,512 | public RecordId insertIntoDeletedSlot ( ) { RecordId nds = getNextDeletedSlotId ( ) ; setNextDeletedSlotId ( new RecordId ( new BlockId ( "" , 0 ) , 0 ) ) ; Constant flag = INUSE_CONST ; setVal ( currentPos ( ) , flag ) ; return nds ; } | Inserts a new blank record into this deleted slot and return the record id of the next one . |
19,513 | public void runAllSlot ( ) { moveToId ( 0 ) ; System . out . println ( "== runAllSlot start at " + currentSlot + " ==" ) ; while ( isValidSlot ( ) ) { if ( currentSlot % 10 == 0 ) System . out . print ( currentSlot + ": " ) ; int flag = ( Integer ) getVal ( currentPos ( ) , INTEGER ) . asJavaVal ( ) ; System . out . print ( flag + " " ) ; if ( ( currentSlot + 1 ) % 10 == 0 ) System . out . println ( ) ; currentSlot ++ ; } System . out . println ( "== runAllSlot end at " + currentSlot + " ==" ) ; } | Print all Slot IN_USE or EMPTY for debugging |
19,514 | public synchronized void startCollecting ( ) { paused = false ; if ( thread != null ) return ; packages = new CountMap < String > ( MAX_PACKAGES ) ; selfMethods = new CountMap < String > ( MAX_METHODS ) ; stackMethods = new CountMap < String > ( MAX_METHODS ) ; lines = new CountMap < String > ( MAX_LINES ) ; total = 0 ; started = true ; thread = new Thread ( this ) ; thread . setName ( "Profiler" ) ; thread . setDaemon ( true ) ; thread . start ( ) ; } | Start collecting profiling data . |
19,515 | public synchronized void stopCollecting ( ) { started = false ; if ( thread != null ) { try { thread . join ( ) ; } catch ( InterruptedException e ) { } thread = null ; } } | Stop collecting . |
19,516 | public String getPackageCsv ( ) { stopCollecting ( ) ; StringBuilder buff = new StringBuilder ( ) ; buff . append ( "Package,Self" ) . append ( LINE_SEPARATOR ) ; for ( String k : new TreeSet < String > ( packages . keySet ( ) ) ) { int percent = 100 * packages . get ( k ) / Math . max ( total , 1 ) ; buff . append ( k ) . append ( "," ) . append ( percent ) . append ( LINE_SEPARATOR ) ; } return buff . toString ( ) ; } | Stop and obtain the self execution time of packages each as a row in CSV format . |
19,517 | public String getTopMethods ( int num ) { stopCollecting ( ) ; CountMap < String > selfms = new CountMap < String > ( selfMethods ) ; CountMap < String > stackms = new CountMap < String > ( stackMethods ) ; StringBuilder buff = new StringBuilder ( ) ; buff . append ( "Top methods over " ) . append ( time ) . append ( " ms (" ) . append ( pauseTime ) . append ( " ms paused), with " ) . append ( total ) . append ( " counts:" ) . append ( LINE_SEPARATOR ) ; buff . append ( "Rank\tSelf\tStack\tMethod" ) . append ( LINE_SEPARATOR ) ; for ( int i = 0 , n = 0 ; selfms . size ( ) > 0 && n < num ; i ++ ) { int highest = 0 ; List < Map . Entry < String , Integer > > bests = new ArrayList < Map . Entry < String , Integer > > ( ) ; for ( Map . Entry < String , Integer > el : selfms . entrySet ( ) ) { if ( el . getValue ( ) > highest ) { bests . clear ( ) ; bests . add ( el ) ; highest = el . getValue ( ) ; } else if ( el . getValue ( ) == highest ) { bests . add ( el ) ; } } for ( Map . Entry < String , Integer > e : bests ) { selfms . remove ( e . getKey ( ) ) ; int selfPercent = 100 * highest / Math . max ( total , 1 ) ; int stackPercent = 100 * stackms . remove ( e . getKey ( ) ) / Math . max ( total , 1 ) ; buff . append ( i + 1 ) . append ( "\t" ) . append ( selfPercent ) . append ( "%\t" ) . append ( stackPercent ) . append ( "%\t" ) . append ( e . getKey ( ) ) . append ( LINE_SEPARATOR ) ; n ++ ; } } return buff . toString ( ) ; } | Stop and obtain the top methods ordered by their self execution time . |
19,518 | public String getMethodCsv ( ) { stopCollecting ( ) ; StringBuilder buff = new StringBuilder ( ) ; buff . append ( "Method,Self" ) . append ( LINE_SEPARATOR ) ; for ( String k : new TreeSet < String > ( selfMethods . keySet ( ) ) ) { int percent = 100 * selfMethods . get ( k ) / Math . max ( total , 1 ) ; buff . append ( k ) . append ( "," ) . append ( percent ) . append ( LINE_SEPARATOR ) ; } return buff . toString ( ) ; } | Stop and obtain the self execution time of methods each as a row in CSV format . |
19,519 | public String getTopLines ( int num ) { stopCollecting ( ) ; CountMap < String > ls = new CountMap < String > ( lines ) ; StringBuilder buff = new StringBuilder ( ) ; buff . append ( "Top lines over " ) . append ( time ) . append ( " ms (" ) . append ( pauseTime ) . append ( " ms paused), with " ) . append ( total ) . append ( " counts:" ) . append ( LINE_SEPARATOR ) ; for ( int i = 0 , n = 0 ; ls . size ( ) > 0 && n < num ; i ++ ) { int highest = 0 ; List < Map . Entry < String , Integer > > bests = new ArrayList < Map . Entry < String , Integer > > ( ) ; for ( Map . Entry < String , Integer > el : ls . entrySet ( ) ) { if ( el . getValue ( ) > highest ) { bests . clear ( ) ; bests . add ( el ) ; highest = el . getValue ( ) ; } else if ( el . getValue ( ) == highest ) { bests . add ( el ) ; } } for ( Map . Entry < String , Integer > e : bests ) { ls . remove ( e . getKey ( ) ) ; int percent = 100 * highest / Math . max ( total , 1 ) ; buff . append ( "Rank: " ) . append ( i + 1 ) . append ( ", Self: " ) . append ( percent ) . append ( "%, Trace: " ) . append ( LINE_SEPARATOR ) . append ( e . getKey ( ) ) . append ( LINE_SEPARATOR ) ; n ++ ; } } return buff . toString ( ) ; } | Stop and obtain the top lines ordered by their execution time . |
19,520 | public void createIndex ( String idxName , String tblName , List < String > fldNames , IndexType idxType , Transaction tx ) { RecordFile rf = idxTi . open ( tx , true ) ; rf . insert ( ) ; rf . setVal ( ICAT_IDXNAME , new VarcharConstant ( idxName ) ) ; rf . setVal ( ICAT_TBLNAME , new VarcharConstant ( tblName ) ) ; rf . setVal ( ICAT_IDXTYPE , new IntegerConstant ( idxType . toInteger ( ) ) ) ; rf . close ( ) ; rf = keyTi . open ( tx , true ) ; for ( String fldName : fldNames ) { rf . insert ( ) ; rf . setVal ( KCAT_IDXNAME , new VarcharConstant ( idxName ) ) ; rf . setVal ( KCAT_KEYNAME , new VarcharConstant ( fldName ) ) ; rf . close ( ) ; } updateCache ( new IndexInfo ( idxName , tblName , fldNames , idxType ) ) ; } | Creates an index of the specified type for the specified field . A unique ID is assigned to this index and its information is stored in the idxcat table . |
19,521 | public List < IndexInfo > getIndexInfo ( String tblName , String fldName , Transaction tx ) { if ( ! loadedTables . contains ( tblName ) ) { readFromFile ( tblName , tx ) ; } Map < String , List < IndexInfo > > iiMap = iiMapByTblAndFlds . get ( tblName ) ; if ( iiMap == null ) return Collections . emptyList ( ) ; List < IndexInfo > iiList = iiMap . get ( fldName ) ; if ( iiList == null ) return Collections . emptyList ( ) ; return new LinkedList < IndexInfo > ( iiList ) ; } | Returns a map containing the index info for all indexes on the specified table . |
19,522 | public IndexInfo getIndexInfoByName ( String idxName , Transaction tx ) { IndexInfo ii = iiMapByIdxNames . get ( idxName ) ; if ( ii != null ) return ii ; String tblName = null ; List < String > fldNames = new LinkedList < String > ( ) ; IndexType idxType = null ; RecordFile rf = idxTi . open ( tx , true ) ; rf . beforeFirst ( ) ; while ( rf . next ( ) ) { if ( ( ( String ) rf . getVal ( ICAT_IDXNAME ) . asJavaVal ( ) ) . equals ( idxName ) ) { tblName = ( String ) rf . getVal ( ICAT_TBLNAME ) . asJavaVal ( ) ; int idxtypeVal = ( Integer ) rf . getVal ( ICAT_IDXTYPE ) . asJavaVal ( ) ; idxType = IndexType . fromInteger ( idxtypeVal ) ; break ; } } rf . close ( ) ; if ( tblName == null ) return null ; rf = keyTi . open ( tx , true ) ; rf . beforeFirst ( ) ; while ( rf . next ( ) ) { if ( ( ( String ) rf . getVal ( KCAT_IDXNAME ) . asJavaVal ( ) ) . equals ( idxName ) ) { fldNames . add ( ( String ) rf . getVal ( KCAT_KEYNAME ) . asJavaVal ( ) ) ; } } rf . close ( ) ; ii = new IndexInfo ( idxName , tblName , fldNames , idxType ) ; updateCache ( ii ) ; return ii ; } | Returns the requested index info object with the given index name . |
19,523 | public Index open ( Transaction tx ) { TableInfo ti = VanillaDb . catalogMgr ( ) . getTableInfo ( tblName , tx ) ; if ( ti == null ) throw new TableNotFoundException ( "table '" + tblName + "' is not defined in catalog." ) ; return Index . newInstance ( this , new SearchKeyType ( ti . schema ( ) , fldNames ) , tx ) ; } | Opens the index described by this object . |
19,524 | public Constant nextVal ( Type type ) { Constant val = pg . getVal ( currentPos , type ) ; currentPos += Page . size ( val ) ; return val ; } | Returns the next value of this log record . |
19,525 | public int getColumnType ( int column ) throws RemoteException { String fldname = getColumnName ( column ) ; return schema . type ( fldname ) . getSqlType ( ) ; } | Returns the type of the specified column . The method first finds the name of the field in that column and then looks up its type in the schema . |
19,526 | public int getColumnDisplaySize ( int column ) throws RemoteException { String fldname = getColumnName ( column ) ; Type fldtype = schema . type ( fldname ) ; if ( fldtype . isFixedSize ( ) ) return fldtype . maxSize ( ) * 8 / 5 ; return schema . type ( fldname ) . getArgument ( ) ; } | Returns the number of characters required to display the specified column . |
19,527 | public boolean next ( ) { if ( isLhsEmpty ) return false ; if ( idx . next ( ) ) { ts . moveToRecordId ( idx . getDataRecordId ( ) ) ; return true ; } else if ( ! ( isLhsEmpty = ! s . next ( ) ) ) { resetIndex ( ) ; return next ( ) ; } else return false ; } | Moves the scan to the next record . The method moves to the next index record if possible . Otherwise it moves to the next LHS record and the first index record . If there are no more LHS records the method returns false . |
19,528 | public Constant getVal ( String fldName ) { if ( ts . hasField ( fldName ) ) return ts . getVal ( fldName ) ; else return s . getVal ( fldName ) ; } | Returns the Constant value of the specified field . |
19,529 | public boolean hasField ( String fldName ) { return ts . hasField ( fldName ) || s . hasField ( fldName ) ; } | Returns true if the field is in the schema . |
19,530 | public void undo ( Transaction tx ) { LogSeqNum lsn = tx . recoveryMgr ( ) . logLogicalAbort ( this . txNum , this . lsn ) ; VanillaDb . logMgr ( ) . flush ( lsn ) ; } | Appends a Logical Abort Record to indicate the logical operation has be aborted |
19,531 | public Collection < String > getViewNamesByTable ( String tblName , Transaction tx ) { Collection < String > result = new LinkedList < String > ( ) ; TableInfo ti = tblMgr . getTableInfo ( VCAT , tx ) ; RecordFile rf = ti . open ( tx , true ) ; rf . beforeFirst ( ) ; while ( rf . next ( ) ) { Parser parser = new Parser ( ( String ) rf . getVal ( VCAT_VDEF ) . asJavaVal ( ) ) ; if ( parser . queryCommand ( ) . tables ( ) . contains ( tblName ) ) result . add ( ( String ) rf . getVal ( VCAT_VNAME ) . asJavaVal ( ) ) ; } rf . close ( ) ; return result ; } | We may have to come out a better method . |
19,532 | public boolean next ( ) { if ( ! moreGroups ) return false ; if ( aggFns != null ) for ( AggregationFn fn : aggFns ) fn . processFirst ( ss ) ; groupVal = new GroupValue ( ss , groupFlds ) ; while ( moreGroups = ss . next ( ) ) { GroupValue gv = new GroupValue ( ss , groupFlds ) ; if ( ! groupVal . equals ( gv ) ) break ; if ( aggFns != null ) for ( AggregationFn fn : aggFns ) fn . processNext ( ss ) ; } return true ; } | Moves to the next group . The key of the group is determined by the group values at the current record . The method repeatedly reads underlying records until it encounters a record having a different key . The aggregation functions are called for each record in the group . The values of the grouping fields for the group are saved . |
19,533 | public Constant getVal ( String fldname ) { if ( groupFlds . contains ( fldname ) ) return groupVal . getVal ( fldname ) ; if ( aggFns != null ) for ( AggregationFn fn : aggFns ) if ( fn . fieldName ( ) . equals ( fldname ) ) return fn . value ( ) ; throw new RuntimeException ( "field " + fldname + " not found." ) ; } | Gets the Constant value of the specified field . If the field is a group field then its value can be obtained from the saved group value . Otherwise the value is obtained from the appropriate aggregation function . |
19,534 | public boolean hasField ( String fldname ) { if ( groupFlds . contains ( fldname ) ) return true ; if ( aggFns != null ) for ( AggregationFn fn : aggFns ) if ( fn . fieldName ( ) . equals ( fldname ) ) return true ; return false ; } | Returns true if the specified field is either a grouping field or created by an aggregation function . |
19,535 | void flushAll ( ) { for ( Buffer buff : bufferPool ) { try { buff . getExternalLock ( ) . lock ( ) ; buff . flush ( ) ; } finally { buff . getExternalLock ( ) . unlock ( ) ; } } } | Flushes all dirty buffers . |
19,536 | Buffer pin ( BlockId blk ) { synchronized ( prepareAnchor ( blk ) ) { Buffer buff = findExistingBuffer ( blk ) ; if ( buff == null ) { int lastReplacedBuff = this . lastReplacedBuff ; int currBlk = ( lastReplacedBuff + 1 ) % bufferPool . length ; while ( currBlk != lastReplacedBuff ) { buff = bufferPool [ currBlk ] ; if ( buff . getExternalLock ( ) . tryLock ( ) ) { try { if ( ! buff . isPinned ( ) ) { this . lastReplacedBuff = currBlk ; BlockId oldBlk = buff . block ( ) ; if ( oldBlk != null ) blockMap . remove ( oldBlk ) ; buff . assignToBlock ( blk ) ; blockMap . put ( blk , buff ) ; if ( ! buff . isPinned ( ) ) numAvailable . decrementAndGet ( ) ; buff . pin ( ) ; return buff ; } } finally { buff . getExternalLock ( ) . unlock ( ) ; } } currBlk = ( currBlk + 1 ) % bufferPool . length ; } return null ; } else { buff . getExternalLock ( ) . lock ( ) ; try { if ( buff . block ( ) . equals ( blk ) ) { if ( ! buff . isPinned ( ) ) numAvailable . decrementAndGet ( ) ; buff . pin ( ) ; return buff ; } return pin ( blk ) ; } finally { buff . getExternalLock ( ) . unlock ( ) ; } } } } | Pins a buffer to the specified block . If there is already a buffer assigned to that block then that buffer is used ; otherwise an unpinned buffer from the pool is chosen . Returns a null value if there are no available buffers . |
19,537 | void unpin ( Buffer ... buffs ) { for ( Buffer buff : buffs ) { try { buff . getExternalLock ( ) . lock ( ) ; buff . unpin ( ) ; if ( ! buff . isPinned ( ) ) numAvailable . incrementAndGet ( ) ; } finally { buff . getExternalLock ( ) . unlock ( ) ; } } } | Unpins the specified buffers . |
19,538 | public static void initializeSystem ( Transaction tx ) { tx . recoveryMgr ( ) . recoverSystem ( tx ) ; tx . bufferMgr ( ) . flushAll ( ) ; VanillaDb . logMgr ( ) . removeAndCreateNewLog ( ) ; new StartRecord ( tx . getTransactionNumber ( ) ) . writeToLog ( ) ; } | Goes through the log rolling back all uncompleted transactions . Flushes all modified blocks . Finally writes a quiescent checkpoint record to the log and flush it . This method should be called only during system startup before user transactions begin . |
19,539 | public void onTxCommit ( Transaction tx ) { if ( ! tx . isReadOnly ( ) && enableLogging ) { LogSeqNum lsn = new CommitRecord ( txNum ) . writeToLog ( ) ; VanillaDb . logMgr ( ) . flush ( lsn ) ; } } | Writes a commit record to the log and then flushes the log record to disk . |
19,540 | public void onTxRollback ( Transaction tx ) { if ( ! tx . isReadOnly ( ) && enableLogging ) { rollback ( tx ) ; LogSeqNum lsn = new RollbackRecord ( txNum ) . writeToLog ( ) ; VanillaDb . logMgr ( ) . flush ( lsn ) ; } } | Does the roll back process writes a rollback record to the log and flushes the log record to disk . |
19,541 | public LogSeqNum logSetVal ( Buffer buff , int offset , Constant newVal ) { if ( enableLogging ) { BlockId blk = buff . block ( ) ; if ( isTempBlock ( blk ) ) return null ; return new SetValueRecord ( txNum , blk , offset , buff . getVal ( offset , newVal . getType ( ) ) , newVal ) . writeToLog ( ) ; } else return null ; } | Writes a set value record to the log . |
19,542 | public LogSeqNum logLogicalAbort ( long txNum , LogSeqNum undoNextLSN ) { if ( enableLogging ) { return new LogicalAbortRecord ( txNum , undoNextLSN ) . writeToLog ( ) ; } else return null ; } | Writes a logical abort record into the log . |
19,543 | public void delete ( SearchKey key , RecordId dataRecordId , boolean doLogicalLogging ) { if ( tx . isReadOnly ( ) ) throw new UnsupportedOperationException ( ) ; search ( new SearchRange ( key ) , SearchPurpose . DELETE ) ; if ( doLogicalLogging ) tx . recoveryMgr ( ) . logLogicalStart ( ) ; leaf . delete ( dataRecordId ) ; if ( doLogicalLogging ) tx . recoveryMgr ( ) . logIndexDeletionEnd ( ii . indexName ( ) , key , dataRecordId . block ( ) . number ( ) , dataRecordId . id ( ) ) ; } | Deletes the specified index record . The method first traverses the directory to find the leaf page containing that record ; then it deletes the record from the page . F |
19,544 | public void close ( ) { if ( leaf != null ) { leaf . close ( ) ; leaf = null ; } dirsMayBeUpdated = null ; } | Closes the index by closing its open leaf page if necessary . |
19,545 | public synchronized TableStatInfo getTableStatInfo ( TableInfo ti , Transaction tx ) { if ( isRefreshStatOn ) { Integer c = updateCounts . get ( ti . tableName ( ) ) ; if ( c != null && c > REFRESH_THRESHOLD ) VanillaDb . taskMgr ( ) . runTask ( new StatisticsRefreshTask ( tx , ti . tableName ( ) ) ) ; } TableStatInfo tsi = tableStats . get ( ti . tableName ( ) ) ; if ( tsi == null ) { tsi = calcTableStats ( ti , tx ) ; tableStats . put ( ti . tableName ( ) , tsi ) ; } return tsi ; } | Returns the statistical information about the specified table . |
19,546 | public boolean hasNext ( ) { if ( ! isForward ) { currentRec = currentRec - pointerSize ; isForward = true ; } return currentRec > 0 || blk . number ( ) > 0 ; } | Determines if the current log record is the earliest record in the log file . |
19,547 | public BasicLogRecord next ( ) { if ( ! isForward ) { currentRec = currentRec - pointerSize ; isForward = true ; } if ( currentRec == 0 ) moveToNextBlock ( ) ; currentRec = ( Integer ) pg . getVal ( currentRec , INTEGER ) . asJavaVal ( ) ; return new BasicLogRecord ( pg , new LogSeqNum ( blk . number ( ) , currentRec + pointerSize * 2 ) ) ; } | Moves to the next log record in reverse order . If the current log record is the earliest in its block then the method moves to the next oldest block and returns the log record from there . |
19,548 | private void moveToNextBlock ( ) { blk = new BlockId ( blk . fileName ( ) , blk . number ( ) - 1 ) ; pg . read ( blk ) ; currentRec = ( Integer ) pg . getVal ( LogMgr . LAST_POS , INTEGER ) . asJavaVal ( ) ; } | Moves to the next log block in reverse order and positions it after the last record in that block . |
19,549 | private void moveToPrevBlock ( ) { blk = new BlockId ( blk . fileName ( ) , blk . number ( ) + 1 ) ; pg . read ( blk ) ; currentRec = 0 + pointerSize ; } | Moves to the previous log block in reverse order and positions it after the last record in that block . |
19,550 | public Constant evaluate ( Record rec ) { return op . evaluate ( lhs , rhs , rec ) ; } | Evaluates the arithmetic expression by computing on the values from the record . |
19,551 | public boolean isApplicableTo ( Schema sch ) { return lhs . isApplicableTo ( sch ) && rhs . isApplicableTo ( sch ) ; } | Returns true if both expressions are in the specified schema . |
19,552 | public static void formatFileHeader ( String fileName , Transaction tx ) { tx . concurrencyMgr ( ) . modifyFile ( fileName ) ; if ( VanillaDb . fileMgr ( ) . size ( fileName ) == 0 ) { FileHeaderFormatter fhf = new FileHeaderFormatter ( ) ; Buffer buff = tx . bufferMgr ( ) . pinNew ( fileName , fhf ) ; tx . bufferMgr ( ) . unpin ( buff ) ; } } | Format the header of specified file . |
19,553 | public boolean next ( ) { if ( currentBlkNum == 0 && ! moveTo ( 1 ) ) return false ; while ( true ) { if ( rp . next ( ) ) return true ; if ( ! moveTo ( currentBlkNum + 1 ) ) return false ; } } | Moves to the next record . Returns false if there is no next record . |
19,554 | public void setVal ( String fldName , Constant val ) { if ( tx . isReadOnly ( ) && ! isTempTable ( ) ) throw new UnsupportedOperationException ( ) ; Type fldType = ti . schema ( ) . type ( fldName ) ; Constant v = val . castTo ( fldType ) ; if ( Page . size ( v ) > Page . maxSize ( fldType ) ) throw new SchemaIncompatibleException ( ) ; rp . setVal ( fldName , v ) ; } | Sets a value of the specified field in the current record . The type of the value must be equal to that of the specified field . |
19,555 | public void insert ( ) { if ( tx . isReadOnly ( ) && ! isTempTable ( ) ) throw new UnsupportedOperationException ( ) ; if ( ! isTempTable ( ) ) tx . concurrencyMgr ( ) . modifyFile ( fileName ) ; if ( fhp == null ) fhp = openHeaderForModification ( ) ; tx . recoveryMgr ( ) . logLogicalStart ( ) ; if ( fhp . hasDeletedSlots ( ) ) { moveToRecordId ( fhp . getLastDeletedSlot ( ) ) ; RecordId lds = rp . insertIntoDeletedSlot ( ) ; fhp . setLastDeletedSlot ( lds ) ; } else { if ( ! fhp . hasDataRecords ( ) ) { appendBlock ( ) ; moveTo ( 1 ) ; rp . insertIntoNextEmptySlot ( ) ; } else { RecordId tailSlot = fhp . getTailSolt ( ) ; moveToRecordId ( tailSlot ) ; while ( ! rp . insertIntoNextEmptySlot ( ) ) { if ( atLastBlock ( ) ) appendBlock ( ) ; moveTo ( currentBlkNum + 1 ) ; } } fhp . setTailSolt ( currentRecordId ( ) ) ; } RecordId insertedRid = currentRecordId ( ) ; tx . recoveryMgr ( ) . logRecordFileInsertionEnd ( ti . tableName ( ) , insertedRid . block ( ) . number ( ) , insertedRid . id ( ) ) ; closeHeader ( ) ; } | Inserts a new blank record somewhere in the file beginning at the current record . If the new record does not fit into an existing block then a new block is appended to the file . |
19,556 | public void insert ( RecordId rid ) { if ( tx . isReadOnly ( ) && ! isTempTable ( ) ) throw new UnsupportedOperationException ( ) ; if ( ! isTempTable ( ) ) tx . concurrencyMgr ( ) . modifyFile ( fileName ) ; if ( fhp == null ) fhp = openHeaderForModification ( ) ; tx . recoveryMgr ( ) . logLogicalStart ( ) ; moveToRecordId ( rid ) ; if ( ! rp . insertIntoTheCurrentSlot ( ) ) throw new RuntimeException ( "the specified slot: " + rid + " is in used" ) ; RecordId lastSlot = null ; RecordId currentSlot = fhp . getLastDeletedSlot ( ) ; while ( ! currentSlot . equals ( rid ) && currentSlot . block ( ) . number ( ) != FileHeaderPage . NO_SLOT_BLOCKID ) { moveToRecordId ( currentSlot ) ; lastSlot = currentSlot ; currentSlot = rp . getNextDeletedSlotId ( ) ; } if ( lastSlot == null ) { moveToRecordId ( currentSlot ) ; fhp . setLastDeletedSlot ( rp . getNextDeletedSlotId ( ) ) ; } else if ( currentSlot . block ( ) . number ( ) != FileHeaderPage . NO_SLOT_BLOCKID ) { moveToRecordId ( currentSlot ) ; RecordId nextSlot = rp . getNextDeletedSlotId ( ) ; moveToRecordId ( lastSlot ) ; rp . setNextDeletedSlotId ( nextSlot ) ; } tx . recoveryMgr ( ) . logRecordFileInsertionEnd ( ti . tableName ( ) , rid . block ( ) . number ( ) , rid . id ( ) ) ; closeHeader ( ) ; } | Inserts a record to a specified physical address . |
19,557 | public void moveToRecordId ( RecordId rid ) { moveTo ( rid . block ( ) . number ( ) ) ; rp . moveToId ( rid . id ( ) ) ; } | Positions the current record as indicated by the specified record ID . |
19,558 | public RecordId currentRecordId ( ) { int id = rp . currentId ( ) ; return new RecordId ( new BlockId ( fileName , currentBlkNum ) , id ) ; } | Returns the record ID of the current record . |
19,559 | public Operator operator ( String fldName ) { if ( lhs . isFieldName ( ) && lhs . asFieldName ( ) . equals ( fldName ) ) return op ; if ( rhs . isFieldName ( ) && rhs . asFieldName ( ) . equals ( fldName ) ) return op . complement ( ) ; return null ; } | Determines if this term is of the form F< ; OP> ; E where F is the specified field < ; OP> ; is an operator and E is an expression . If so the method returns < ; OP> ; . If not the method returns null . |
19,560 | public Constant oppositeConstant ( String fldName ) { if ( lhs . isFieldName ( ) && lhs . asFieldName ( ) . equals ( fldName ) && rhs . isConstant ( ) ) return rhs . asConstant ( ) ; if ( rhs . isFieldName ( ) && rhs . asFieldName ( ) . equals ( fldName ) && lhs . isConstant ( ) ) return lhs . asConstant ( ) ; return null ; } | Determines if this term is of the form F< ; OP> ; C where F is the specified field < ; OP> ; is an operator and C is some constant . If so the method returns C . If not the method returns null . |
19,561 | public String oppositeField ( String fldName ) { if ( lhs . isFieldName ( ) && lhs . asFieldName ( ) . equals ( fldName ) && rhs . isFieldName ( ) ) return rhs . asFieldName ( ) ; if ( rhs . isFieldName ( ) && rhs . asFieldName ( ) . equals ( fldName ) && lhs . isFieldName ( ) ) return lhs . asFieldName ( ) ; return null ; } | Determines if this term is of the form F1< ; OP> ; F2 where F1 is the specified field < ; OP> ; is an operator and F2 is another field . If so the method returns F2 . If not the method returns null . |
19,562 | public synchronized Hosts putAllInRandomOrder ( String domain , String [ ] ips ) { Random random = new Random ( ) ; int index = ( int ) ( random . nextLong ( ) % ips . length ) ; if ( index < 0 ) { index += ips . length ; } LinkedList < String > ipList = new LinkedList < String > ( ) ; for ( int i = 0 ; i < ips . length ; i ++ ) { ipList . add ( ips [ ( i + index ) % ips . length ] ) ; } hosts . put ( domain , ipList ) ; return this ; } | avoid many server visit first ip in same time . s |
19,563 | public static String [ ] getByInternalAPI ( ) { try { Class < ? > resolverConfiguration = Class . forName ( "sun.net.dns.ResolverConfiguration" ) ; Method open = resolverConfiguration . getMethod ( "open" ) ; Method getNameservers = resolverConfiguration . getMethod ( "nameservers" ) ; Object instance = open . invoke ( null ) ; List nameservers = ( List ) getNameservers . invoke ( instance ) ; if ( nameservers == null || nameservers . size ( ) == 0 ) { return null ; } String [ ] ret = new String [ nameservers . size ( ) ] ; int i = 0 ; for ( Object dns : nameservers ) { ret [ i ++ ] = ( String ) dns ; } return ret ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return null ; } | has 300s latency when system resolv change |
19,564 | public static IResolver defaultResolver ( ) { return new IResolver ( ) { public Record [ ] resolve ( Domain domain ) throws IOException { String [ ] addresses = defaultServer ( ) ; if ( addresses == null ) { throw new IOException ( "no dns server" ) ; } IResolver resolver = new Resolver ( InetAddress . getByName ( addresses [ 0 ] ) ) ; return resolver . resolve ( domain ) ; } } ; } | system ip would change |
19,565 | void writeAssocBean ( ) throws IOException { writingAssocBean = true ; origDestPackage = destPackage ; destPackage = destPackage + ".assoc" ; origShortName = shortName ; shortName = "Assoc" + shortName ; prepareAssocBeanImports ( ) ; writer = new Append ( createFileWriter ( ) ) ; writePackage ( ) ; writeImports ( ) ; writeClass ( ) ; writeFields ( ) ; writeConstructors ( ) ; writeClassEnd ( ) ; writer . close ( ) ; } | Write the type query assoc bean . |
19,566 | private void prepareAssocBeanImports ( ) { importTypes . remove ( DB ) ; importTypes . remove ( TQROOTBEAN ) ; importTypes . remove ( DATABASE ) ; importTypes . add ( TQASSOCBEAN ) ; if ( isEntity ( ) ) { importTypes . add ( TQPROPERTY ) ; importTypes . add ( origDestPackage + ".Q" + origShortName ) ; } Iterator < String > importsIterator = importTypes . iterator ( ) ; String checkImportStart = destPackage + ".QAssoc" ; while ( importsIterator . hasNext ( ) ) { String importType = importsIterator . next ( ) ; if ( importType . startsWith ( checkImportStart ) ) { importsIterator . remove ( ) ; } } } | Prepare the imports for writing assoc bean . |
19,567 | private void writeRootBeanConstructor ( ) throws IOException { writer . eol ( ) ; writer . append ( " /**" ) . eol ( ) ; writer . append ( " * Construct with a given Database." ) . eol ( ) ; writer . append ( " */" ) . eol ( ) ; writer . append ( " public Q%s(Database server) {" , shortName ) . eol ( ) ; writer . append ( " super(%s.class, server);" , shortName ) . eol ( ) ; writer . append ( " }" ) . eol ( ) ; writer . eol ( ) ; String name = ( dbName == null ) ? "default" : dbName ; writer . append ( " /**" ) . eol ( ) ; writer . append ( " * Construct using the %s Database." , name ) . eol ( ) ; writer . append ( " */" ) . eol ( ) ; writer . append ( " public Q%s() {" , shortName ) . eol ( ) ; if ( dbName == null ) { writer . append ( " super(%s.class);" , shortName ) . eol ( ) ; } else { writer . append ( " super(%s.class, DB.byName(\"%s\"));" , shortName , dbName ) . eol ( ) ; } writer . append ( " }" ) . eol ( ) ; writer . eol ( ) ; writer . append ( " /**" ) . eol ( ) ; writer . append ( " * Construct for Alias." ) . eol ( ) ; writer . append ( " */" ) . eol ( ) ; writer . append ( " private Q%s(boolean dummy) {" , shortName ) . eol ( ) ; writer . append ( " super(dummy);" ) . eol ( ) ; writer . append ( " }" ) . eol ( ) ; } | Write the constructors for root type query bean . |
19,568 | private void writeAssocBeanConstructor ( ) { writer . append ( " public Q%s(String name, R root) {" , shortName ) . eol ( ) ; writer . append ( " super(name, root);" ) . eol ( ) ; writer . append ( " }" ) . eol ( ) ; } | Write constructor for assoc type query bean . |
19,569 | private void writeFields ( ) throws IOException { for ( PropertyMeta property : properties ) { property . writeFieldDefn ( writer , shortName , writingAssocBean ) ; writer . eol ( ) ; } writer . eol ( ) ; } | Write all the fields . |
19,570 | private void writeClass ( ) { if ( writingAssocBean ) { writer . append ( "/**" ) . eol ( ) ; writer . append ( " * Association query bean for %s." , shortName ) . eol ( ) ; writer . append ( " * " ) . eol ( ) ; writer . append ( " * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS." ) . eol ( ) ; writer . append ( " */" ) . eol ( ) ; if ( processingContext . isGeneratedAvailable ( ) ) { writer . append ( AT_GENERATED ) . eol ( ) ; } writer . append ( AT_TYPEQUERYBEAN ) . eol ( ) ; writer . append ( "public class Q%s<R> extends TQAssocBean<%s,R> {" , shortName , origShortName ) . eol ( ) ; } else { writer . append ( "/**" ) . eol ( ) ; writer . append ( " * Query bean for %s." , shortName ) . eol ( ) ; writer . append ( " * " ) . eol ( ) ; writer . append ( " * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS." ) . eol ( ) ; writer . append ( " */" ) . eol ( ) ; if ( processingContext . isGeneratedAvailable ( ) ) { writer . append ( AT_GENERATED ) . eol ( ) ; } writer . append ( AT_TYPEQUERYBEAN ) . eol ( ) ; writer . append ( "public class Q%s extends TQRootBean<%1$s,Q%1$s> {" , shortName ) . eol ( ) ; } writer . eol ( ) ; } | Write the class definition . |
19,571 | private void writeImports ( ) { for ( String importType : importTypes ) { writer . append ( "import %s;" , importType ) . eol ( ) ; } writer . eol ( ) ; } | Write all the imports . |
19,572 | static String [ ] split ( String className ) { String [ ] result = new String [ 2 ] ; int startPos = className . lastIndexOf ( '.' ) ; if ( startPos == - 1 ) { result [ 1 ] = className ; return result ; } result [ 0 ] = className . substring ( 0 , startPos ) ; result [ 1 ] = className . substring ( startPos + 1 ) ; return result ; } | Split into package and class name . |
19,573 | static String shortName ( String className ) { int startPos = className . lastIndexOf ( '.' ) ; if ( startPos == - 1 ) { return className ; } return className . substring ( startPos + 1 ) ; } | Trim off package to return the simple class name . |
19,574 | Append append ( String format , Object ... args ) { return append ( String . format ( format , args ) ) ; } | Append content with formatted arguments . |
19,575 | < A extends Annotation > A findAnnotation ( TypeElement element , Class < A > anno ) { final A annotation = element . getAnnotation ( anno ) ; if ( annotation != null ) { return annotation ; } final TypeMirror typeMirror = element . getSuperclass ( ) ; if ( typeMirror . getKind ( ) == TypeKind . NONE ) { return null ; } final TypeElement element1 = ( TypeElement ) typeUtils . asElement ( typeMirror ) ; return findAnnotation ( element1 , anno ) ; } | Find the annotation searching the inheritance hierarchy . |
19,576 | private static boolean dbJsonField ( Element field ) { return ( field . getAnnotation ( DbJson . class ) != null || field . getAnnotation ( DbJsonB . class ) != null ) ; } | Return true if it is a DbJson field . |
19,577 | private PropertyType createPropertyTypeAssoc ( String fullName ) { String [ ] split = Split . split ( fullName ) ; String propertyName = "QAssoc" + split [ 1 ] ; String packageName = packageAppend ( split [ 0 ] , "query.assoc" ) ; return new PropertyTypeAssoc ( propertyName , packageName ) ; } | Create the QAssoc PropertyType . |
19,578 | private String packageAppend ( String origPackage , String suffix ) { if ( origPackage == null ) { return suffix ; } else { return origPackage + "." + suffix ; } } | Prepend the package to the suffix taking null into account . |
19,579 | JavaFileObject createWriter ( String factoryClassName , Element originatingElement ) throws IOException { return filer . createSourceFile ( factoryClassName , originatingElement ) ; } | Create a file writer for the given class name . |
19,580 | public static String printNode ( Node node , boolean prettyprint ) { StringWriter strw = new StringWriter ( ) ; new DOMWriter ( strw ) . setPrettyprint ( prettyprint ) . print ( node ) ; return strw . toString ( ) ; } | Print a node with explicit prettyprinting . The defaults for all other DOMWriter properties apply . |
19,581 | public static String resolve ( String normalized ) { StringBuilder builder = new StringBuilder ( ) ; int end = normalized . length ( ) ; int pos = normalized . indexOf ( '&' ) ; int last = 0 ; if ( pos == - 1 ) return normalized ; while ( pos != - 1 ) { String sub = normalized . subSequence ( last , pos ) . toString ( ) ; builder . append ( sub ) ; int peek = pos + 1 ; if ( peek == end ) throw MESSAGES . entityResolutionInvalidEntityReference ( normalized ) ; if ( normalized . charAt ( peek ) == '#' ) pos = resolveCharRef ( normalized , pos , builder ) ; else pos = resolveEntityRef ( normalized , pos , builder ) ; last = pos ; pos = normalized . indexOf ( '&' , pos ) ; } if ( last < end ) { String sub = normalized . subSequence ( last , end ) . toString ( ) ; builder . append ( sub ) ; } return builder . toString ( ) ; } | Transforms an XML normalized string by resolving all predefined character and entity references |
19,582 | private static void invokeMethod ( final Object instance , final Method method , final Object [ ] args ) { final boolean accessability = method . isAccessible ( ) ; try { method . setAccessible ( true ) ; method . invoke ( instance , args ) ; } catch ( Exception e ) { InjectionException . rethrow ( e ) ; } finally { method . setAccessible ( accessability ) ; } } | Invokes method on object with specified arguments . |
19,583 | private static void setField ( final Object instance , final Field field , final Object value ) { final boolean accessability = field . isAccessible ( ) ; try { field . setAccessible ( true ) ; field . set ( instance , value ) ; } catch ( Exception e ) { InjectionException . rethrow ( e ) ; } finally { field . setAccessible ( accessability ) ; } } | Sets field on object with specified value . |
19,584 | public void onEndpointInstantiated ( final Endpoint endpoint , final Invocation invocation ) { final Object _targetBean = this . getTargetBean ( invocation ) ; final Reference reference = endpoint . getInstanceProvider ( ) . getInstance ( _targetBean . getClass ( ) . getName ( ) ) ; final Object targetBean = reference . getValue ( ) ; InjectionHelper . injectWebServiceContext ( targetBean , ThreadLocalAwareWebServiceContext . getInstance ( ) ) ; if ( ! reference . isInitialized ( ) ) { InjectionHelper . callPostConstructMethod ( targetBean ) ; reference . setInitialized ( ) ; } endpoint . addAttachment ( PreDestroyHolder . class , new PreDestroyHolder ( targetBean ) ) ; } | Injects resources on target bean and calls post construct method . Finally it registers target bean for predestroy phase . |
19,585 | private Object getTargetBean ( final Invocation invocation ) { final InvocationContext invocationContext = invocation . getInvocationContext ( ) ; return invocationContext . getTargetBean ( ) ; } | Returns endpoint instance associated with current invocation . |
19,586 | public static < A > A getRequiredAttachment ( final Deployment dep , final Class < A > key ) { final A value = dep . getAttachment ( key ) ; if ( value == null ) { throw Messages . MESSAGES . cannotFindAttachmentInDeployment ( key , dep . getSimpleName ( ) ) ; } return value ; } | Returns required attachment value from webservice deployment . |
19,587 | public static < A > A getOptionalAttachment ( final Deployment dep , final Class < A > key ) { return dep . getAttachment ( key ) ; } | Returns optional attachment value from webservice deployment or null if not bound . |
19,588 | protected void createConstructorDelegates ( ConstructorBodyCreator creator ) { ClassMetadataSource data = reflectionMetadataSource . getClassMetadata ( getSuperClass ( ) ) ; for ( Constructor < ? > constructor : data . getConstructors ( ) ) { if ( ! Modifier . isPrivate ( constructor . getModifiers ( ) ) ) { creator . overrideConstructor ( classFile . addMethod ( AccessFlag . PUBLIC , "<init>" , "V" , DescriptorUtils . parameterDescriptors ( constructor . getParameterTypes ( ) ) ) , constructor ) ; } } } | Adds constructors that delegate the the superclass constructor for all non - private constructors present on the superclass |
19,589 | public static void assertNoPrimitiveParameters ( final Method method , Class < ? extends Annotation > annotation ) { for ( Class < ? > type : method . getParameterTypes ( ) ) { if ( type . isPrimitive ( ) ) { throw annotation == null ? MESSAGES . methodCannotDeclarePrimitiveParameters ( method ) : MESSAGES . methodCannotDeclarePrimitiveParameters2 ( method , annotation ) ; } } } | Asserts method don t declare primitive parameters . |
19,590 | public static void assertNotPrimitiveType ( final Field field , Class < ? extends Annotation > annotation ) { if ( field . getType ( ) . isPrimitive ( ) ) { throw annotation == null ? MESSAGES . fieldCannotBeOfPrimitiveOrVoidType ( field ) : MESSAGES . fieldCannotBeOfPrimitiveOrVoidType2 ( field , annotation ) ; } } | Asserts field is not of primitive type . |
19,591 | public static void assertNoParameters ( final Method method , Class < ? extends Annotation > annotation ) { if ( method . getParameterTypes ( ) . length != 0 ) { throw annotation == null ? MESSAGES . methodHasToHaveNoParameters ( method ) : MESSAGES . methodHasToHaveNoParameters2 ( method , annotation ) ; } } | Asserts method have no parameters . |
19,592 | public static void assertVoidReturnType ( final Method method , Class < ? extends Annotation > annotation ) { if ( ( ! method . getReturnType ( ) . equals ( Void . class ) ) && ( ! method . getReturnType ( ) . equals ( Void . TYPE ) ) ) { throw annotation == null ? MESSAGES . methodHasToReturnVoid ( method ) : MESSAGES . methodHasToReturnVoid2 ( method , annotation ) ; } } | Asserts method return void . |
19,593 | public static void assertNotVoidType ( final Field field , Class < ? extends Annotation > annotation ) { if ( ( field . getClass ( ) . equals ( Void . class ) ) && ( field . getClass ( ) . equals ( Void . TYPE ) ) ) { throw annotation == null ? MESSAGES . fieldCannotBeOfPrimitiveOrVoidType ( field ) : MESSAGES . fieldCannotBeOfPrimitiveOrVoidType2 ( field , annotation ) ; } } | Asserts field isn t of void type . |
19,594 | public static void assertNoCheckedExceptionsAreThrown ( final Method method , Class < ? extends Annotation > annotation ) { Class < ? > [ ] declaredExceptions = method . getExceptionTypes ( ) ; for ( int i = 0 ; i < declaredExceptions . length ; i ++ ) { Class < ? > exception = declaredExceptions [ i ] ; if ( ! exception . isAssignableFrom ( RuntimeException . class ) ) { throw annotation == null ? MESSAGES . methodCannotThrowCheckedException ( method ) : MESSAGES . methodCannotThrowCheckedException2 ( method , annotation ) ; } } } | Asserts method don t throw checked exceptions . |
19,595 | public static void assertNotStatic ( final Method method , Class < ? extends Annotation > annotation ) { if ( Modifier . isStatic ( method . getModifiers ( ) ) ) { throw annotation == null ? MESSAGES . methodCannotBeStatic ( method ) : MESSAGES . methodCannotBeStatic2 ( method , annotation ) ; } } | Asserts method is not static . |
19,596 | public static void assertNotStatic ( final Field field , Class < ? extends Annotation > annotation ) { if ( Modifier . isStatic ( field . getModifiers ( ) ) ) { throw annotation == null ? MESSAGES . fieldCannotBeStaticOrFinal ( field ) : MESSAGES . fieldCannotBeStaticOrFinal2 ( field , annotation ) ; } } | Asserts field is not static . |
19,597 | public static void assertNotFinal ( final Field field , Class < ? extends Annotation > annotation ) { if ( Modifier . isFinal ( field . getModifiers ( ) ) ) { throw annotation == null ? MESSAGES . fieldCannotBeStaticOrFinal ( field ) : MESSAGES . fieldCannotBeStaticOrFinal2 ( field , annotation ) ; } } | Asserts field is not final . |
19,598 | public static void assertOneParameter ( final Method method , Class < ? extends Annotation > annotation ) { if ( method . getParameterTypes ( ) . length != 1 ) { throw annotation == null ? MESSAGES . methodHasToDeclareExactlyOneParameter ( method ) : MESSAGES . methodHasToDeclareExactlyOneParameter2 ( method , annotation ) ; } } | Asserts method have exactly one parameter . |
19,599 | public static void assertValidSetterName ( final Method method , Class < ? extends Annotation > annotation ) { final String methodName = method . getName ( ) ; final boolean correctMethodNameLength = methodName . length ( ) > 3 ; final boolean isSetterMethodName = methodName . startsWith ( "set" ) ; final boolean isUpperCasedPropertyName = correctMethodNameLength ? Character . isUpperCase ( methodName . charAt ( 3 ) ) : false ; if ( ! correctMethodNameLength || ! isSetterMethodName || ! isUpperCasedPropertyName ) { throw annotation == null ? MESSAGES . methodDoesNotRespectJavaBeanSetterMethodName ( method ) : MESSAGES . methodDoesNotRespectJavaBeanSetterMethodName2 ( method , annotation ) ; } } | Asserts valid Java Beans setter method name . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.