idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
155,400
public static void enableCategories ( Category ... categories ) throws IOException { if ( s_tracer == null ) { start ( ) ; } final VoltTrace tracer = s_tracer ; assert tracer != null ; final ImmutableSet . Builder < Category > builder = ImmutableSet . builder ( ) ; builder . addAll ( tracer . m_enabledCategories ) ; bu...
Enable the given categories . If the tracer is not running at the moment create a new one .
155,401
public static void disableCategories ( Category ... categories ) { final VoltTrace tracer = s_tracer ; if ( tracer == null ) { return ; } final List < Category > toDisable = Arrays . asList ( categories ) ; final ImmutableSet . Builder < Category > builder = ImmutableSet . builder ( ) ; for ( Category enabledCategory :...
Disable the given categories . If the tracer has no enabled category after this call shutdown the tracer .
155,402
public Thread newThread ( Runnable r ) { return factory == this ? new Thread ( r ) : factory . newThread ( r ) ; }
Retreives a thread instance for running the specified Runnable
155,403
public synchronized ThreadFactory setImpl ( ThreadFactory f ) { ThreadFactory old ; old = factory ; factory = ( f == null ) ? this : f ; return old ; }
Sets the factory implementation that this factory will use to produce threads . If the specified argument f is null then this factory uses itself as the implementation .
155,404
final byte [ ] getRaw ( int columnIndex ) { byte [ ] retval ; int pos = m_buffer . position ( ) ; int offset = getOffset ( columnIndex ) ; VoltType type = getColumnType ( columnIndex ) ; switch ( type ) { case TINYINT : case SMALLINT : case INTEGER : case BIGINT : case TIMESTAMP : case FLOAT : case DECIMAL : case GEOGR...
A way to get a column value in raw byte form without doing any expensive conversions like date processing or string encoding .
155,405
final void validateColumnType ( int columnIndex , VoltType ... types ) { if ( m_position < 0 ) throw new RuntimeException ( "VoltTableRow is in an invalid state. Consider calling advanceRow()." ) ; if ( ( columnIndex >= getColumnCount ( ) ) || ( columnIndex < 0 ) ) { throw new IndexOutOfBoundsException ( "Column index ...
Validates that type and columnIndex match and are valid .
155,406
final String readString ( int position , Charset encoding ) { if ( STRING_LEN_SIZE > m_buffer . limit ( ) - position ) { throw new RuntimeException ( String . format ( "VoltTableRow::readString: Can't read string size as %d byte integer " + "from buffer with %d bytes remaining." , STRING_LEN_SIZE , m_buffer . limit ( )...
Reads a string from a buffer with a specific encoding .
155,407
public int appendTask ( long sourceHSId , TransactionInfoBaseMessage task ) throws IOException { Preconditions . checkState ( compiledSize == 0 , "buffer is already compiled" ) ; final int msgSerializedSize = task . getSerializedSize ( ) ; ensureCapacity ( taskHeaderSize ( ) + msgSerializedSize ) ; ByteBuffer bb = m_co...
Appends a task message to the buffer .
155,408
public TransactionInfoBaseMessage nextTask ( ) throws IOException { if ( ! hasMoreEntries ( ) ) { return null ; } ByteBuffer bb = m_container . b ( ) ; int position = bb . position ( ) ; int length = bb . getInt ( ) ; long sourceHSId = bb . getLong ( ) ; VoltDbMessageFactory factory = new VoltDbMessageFactory ( ) ; fin...
Get the next task message in this buffer .
155,409
public void compile ( ) { if ( compiledSize == 0 ) { ByteBuffer bb = m_container . b ( ) ; compiledSize = bb . position ( ) ; bb . flip ( ) ; m_allocator . track ( compiledSize ) ; } if ( log . isTraceEnabled ( ) ) { StringBuilder sb = new StringBuilder ( "Compiling buffer: " ) ; ByteBuffer dup = m_container . bDR ( ...
Generate the byte array in preparation of moving over a message bus . Idempotent but not thread - safe . Also changes state to immutable .
155,410
void updateCatalog ( String diffCmds , CatalogContext context ) { if ( m_shuttingDown ) { return ; } m_catalogContext = context ; Iterator < MpRoSiteContext > siterator = m_idleSites . iterator ( ) ; while ( siterator . hasNext ( ) ) { MpRoSiteContext site = siterator . next ( ) ; if ( site . getCatalogCRC ( ) != m_cat...
Update the catalog
155,411
boolean doWork ( long txnId , TransactionTask task ) { boolean retval = canAcceptWork ( ) ; if ( ! retval ) { return false ; } MpRoSiteContext site ; if ( m_busySites . containsKey ( txnId ) ) { site = m_busySites . get ( txnId ) ; } else { if ( m_idleSites . isEmpty ( ) ) { MpRoSiteContext newSite = new MpRoSiteContex...
Attempt to start the transaction represented by the given task . Need the txn ID for future reference .
155,412
void completeWork ( long txnId ) { if ( m_shuttingDown ) { return ; } MpRoSiteContext site = m_busySites . remove ( txnId ) ; if ( site == null ) { throw new RuntimeException ( "No busy site for txnID: " + txnId + " found, shouldn't happen." ) ; } if ( site . getCatalogCRC ( ) == m_catalogContext . getCatalogCRC ( ) &&...
Inform the pool that the work associated with the given txnID is complete
155,413
public VoltTable [ ] run ( SystemProcedureExecutionContext ctx ) { VoltTable [ ] result = null ; try { result = createAndExecuteSysProcPlan ( SysProcFragmentId . PF_quiesce_sites , SysProcFragmentId . PF_quiesce_processed_sites ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } return result ; }
There are no user specified parameters .
155,414
public static void writeFile ( final String dir , final String filename , String content , boolean debug ) { if ( debug && ! VoltCompiler . DEBUG_MODE ) { return ; } if ( m_debugRoot == null ) { if ( System . getenv ( "TEST_DIR" ) != null ) { m_debugRoot = System . getenv ( "TEST_DIR" ) + File . separator + debugRootPr...
Write a file to disk during compilation that has some neato info generated during compilation . If the debug flag is true that means this file should only be written if the compiler is running in debug mode .
155,415
public AbstractExpression getAllFilters ( ) { ArrayDeque < JoinNode > joinNodes = new ArrayDeque < > ( ) ; ArrayDeque < AbstractExpression > in = new ArrayDeque < > ( ) ; ArrayDeque < AbstractExpression > out = new ArrayDeque < > ( ) ; joinNodes . add ( this ) ; while ( ! joinNodes . isEmpty ( ) ) { JoinNode joinNode =...
Collect all JOIN and WHERE expressions combined with AND for the entire tree .
155,416
public AbstractExpression getSimpleFilterExpression ( ) { if ( m_whereExpr != null ) { if ( m_joinExpr != null ) { return ExpressionUtil . combine ( m_whereExpr , m_joinExpr ) ; } return m_whereExpr ; } return m_joinExpr ; }
Get the WHERE expression for a single - table statement .
155,417
public List < JoinNode > generateAllNodesJoinOrder ( ) { ArrayList < JoinNode > nodes = new ArrayList < > ( ) ; listNodesJoinOrderRecursive ( nodes , true ) ; return nodes ; }
Returns nodes in the order they are joined in the tree by iterating the tree depth - first
155,418
public List < JoinNode > extractSubTrees ( ) { List < JoinNode > subTrees = new ArrayList < > ( ) ; subTrees . add ( this ) ; List < JoinNode > leafNodes = new ArrayList < > ( ) ; extractSubTree ( leafNodes ) ; for ( JoinNode leaf : leafNodes ) { subTrees . addAll ( leaf . extractSubTrees ( ) ) ; } return subTrees ; }
Split a join tree into one or more sub - trees . Each sub - tree has the same join type for all join nodes . The root of the child tree in the parent tree is replaced with a dummy node which id is negated id of the child root node .
155,419
public static JoinNode reconstructJoinTreeFromTableNodes ( List < JoinNode > tableNodes , JoinType joinType ) { JoinNode root = null ; for ( JoinNode leafNode : tableNodes ) { JoinNode node = leafNode . cloneWithoutFilters ( ) ; if ( root == null ) { root = node ; } else { root = new BranchNode ( - node . m_id , joinTy...
Reconstruct a join tree from the list of tables always appending the next node to the right .
155,420
public static JoinNode reconstructJoinTreeFromSubTrees ( List < JoinNode > subTrees ) { if ( subTrees == null || subTrees . isEmpty ( ) ) { return null ; } JoinNode joinNode = subTrees . get ( 0 ) ; for ( int i = 1 ; i < subTrees . size ( ) ; ++ i ) { JoinNode nextNode = subTrees . get ( i ) ; boolean replaced = joinNo...
Reconstruct a join tree from the list of sub - trees connecting the sub - trees in the order they appear in the list . The list of sub - trees must be initially obtained by calling the extractSubTrees method on the original tree .
155,421
protected static void applyTransitiveEquivalence ( List < AbstractExpression > outerTableExprs , List < AbstractExpression > innerTableExprs , List < AbstractExpression > innerOuterTableExprs ) { List < AbstractExpression > simplifiedOuterExprs = applyTransitiveEquivalence ( innerTableExprs , innerOuterTableExprs ) ; L...
Apply implied transitive constant filter to join expressions outer . partkey = ? and outer . partkey = inner . partkey is equivalent to outer . partkey = ? and inner . partkey = ?
155,422
protected static void classifyJoinExpressions ( Collection < AbstractExpression > exprList , Collection < String > outerTables , Collection < String > innerTables , List < AbstractExpression > outerList , List < AbstractExpression > innerList , List < AbstractExpression > innerOuterList , List < AbstractExpression > no...
Split the input expression list into the three categories 1 . TVE expressions with outer tables only 2 . TVE expressions with inner tables only 3 . TVE expressions with inner and outer tables The outer tables are the tables reachable from the outer node of the join The inner tables are the tables reachable from the inn...
155,423
public static HSQLInterface . ParameterStateManager getParamStateManager ( ) { return new ParameterStateManager ( ) { public int getNextParamIndex ( ) { return ParameterizationInfo . getNextParamIndex ( ) ; } public void resetCurrentParamIndex ( ) { ParameterizationInfo . resetCurrentParamIndex ( ) ; } } ; }
This method produces a ParameterStateManager to pass to HSQL so that VoltDB can track the parameters it created when parsing the current statement .
155,424
private static Object decodeNextColumn ( ByteBuffer bb , VoltType columnType ) throws IOException { Object retval = null ; switch ( columnType ) { case TINYINT : retval = decodeTinyInt ( bb ) ; break ; case SMALLINT : retval = decodeSmallInt ( bb ) ; break ; case INTEGER : retval = decodeInteger ( bb ) ; break ; case B...
Rather it decodes the next non - null column in the FastDeserializer
155,425
static public BigDecimal decodeDecimal ( final ByteBuffer bb ) { final int scale = bb . get ( ) ; final int precisionBytes = bb . get ( ) ; final byte [ ] bytes = new byte [ precisionBytes ] ; bb . get ( bytes ) ; return new BigDecimal ( new BigInteger ( bytes ) , scale ) ; }
Read a decimal according to the Four Dot Four encoding specification .
155,426
static public Object decodeVarbinary ( final ByteBuffer bb ) { final int length = bb . getInt ( ) ; final byte [ ] data = new byte [ length ] ; bb . get ( data ) ; return data ; }
Read a varbinary according to the Export encoding specification
155,427
static public GeographyValue decodeGeography ( final ByteBuffer bb ) { final int strLength = bb . getInt ( ) ; final int startPosition = bb . position ( ) ; GeographyValue gv = GeographyValue . unflattenFromBuffer ( bb ) ; assert ( bb . position ( ) - startPosition == strLength ) ; return gv ; }
Read a geography according to the Four Dot Four Export encoding specification .
155,428
public final Iterable < T > children ( final T root ) { checkNotNull ( root ) ; return new FluentIterable < T > ( ) { public Iterator < T > iterator ( ) { return new AbstractIterator < T > ( ) { boolean doneLeft ; boolean doneRight ; protected T computeNext ( ) { if ( ! doneLeft ) { doneLeft = true ; Optional < T > lef...
Returns the children of this node in left - to - right order .
155,429
private boolean processTrueOrFalse ( ) { if ( token . tokenType == Tokens . TRUE ) { read ( ) ; return true ; } else if ( token . tokenType == Tokens . FALSE ) { read ( ) ; return false ; } else { throw unexpectedToken ( ) ; } }
Retrieves boolean value corresponding to the next token .
155,430
public VoltTable sortByAverage ( String tableName ) { List < ProcProfRow > sorted = new ArrayList < ProcProfRow > ( m_table ) ; Collections . sort ( sorted , new Comparator < ProcProfRow > ( ) { public int compare ( ProcProfRow lhs , ProcProfRow rhs ) { return compareByAvg ( rhs , lhs ) ; } } ) ; long sumOfAverage = 0L...
Return table sorted by weighted avg
155,431
public int compareByAvg ( ProcProfRow lhs , ProcProfRow rhs ) { if ( lhs . avg * lhs . invocations > rhs . avg * rhs . invocations ) { return 1 ; } else if ( lhs . avg * lhs . invocations < rhs . avg * rhs . invocations ) { return - 1 ; } else { return 0 ; } }
Sort by average weighting the sampled average by the real invocation count .
155,432
void doInitiation ( RejoinMessage message ) { m_coordinatorHsId = message . m_sourceHSId ; m_hasPersistentTables = message . schemaHasPersistentTables ( ) ; if ( m_hasPersistentTables ) { m_streamSnapshotMb = VoltDB . instance ( ) . getHostMessenger ( ) . createMailbox ( ) ; m_rejoinSiteProcessor = new StreamSnapshotSi...
Runs when the RejoinCoordinator decides this site should start rejoin .
155,433
void updateTableIndexRoots ( ) { HsqlArrayList allTables = database . schemaManager . getAllTables ( ) ; for ( int i = 0 , size = allTables . size ( ) ; i < size ; i ++ ) { Table t = ( Table ) allTables . get ( i ) ; if ( t . getTableType ( ) == TableBase . CACHED_TABLE ) { int [ ] rootsArray = rootsList [ i ] ; t . se...
called from outside after the complete end of defrag
155,434
public final void sendSentinel ( long txnId , int partitionId ) { final long initiatorHSId = m_cartographer . getHSIdForSinglePartitionMaster ( partitionId ) ; sendSentinel ( txnId , initiatorHSId , - 1 , - 1 , true ) ; }
Send a command log replay sentinel to the given partition .
155,435
private final ClientResponseImpl dispatchLoadSinglepartitionTable ( Procedure catProc , StoredProcedureInvocation task , InvocationClientHandler handler , Connection ccxn ) { int partition = - 1 ; try { CatalogMap < Table > tables = m_catalogContext . get ( ) . database . getTables ( ) ; int partitionParamType = getLoa...
Coward way out of the legacy hashinator hell . LoadSinglepartitionTable gets the partitioning parameter as a byte array . Legacy hashinator hashes numbers and byte arrays differently so have to convert it back to long if it s a number . UGLY!!!
155,436
public void handleAllHostNTProcedureResponse ( ClientResponseImpl clientResponseData ) { long handle = clientResponseData . getClientHandle ( ) ; ProcedureRunnerNT runner = m_NTProcedureService . m_outstanding . get ( handle ) ; if ( runner == null ) { hostLog . info ( "Run everywhere NTProcedure early returned, probab...
Passes responses to NTProcedureService
155,437
private static boolean valueConstantsMatch ( AbstractExpression e1 , AbstractExpression e2 ) { return ( e1 instanceof ParameterValueExpression && e2 instanceof ConstantValueExpression || e1 instanceof ConstantValueExpression && e2 instanceof ParameterValueExpression ) && equalsAsCVE ( e1 , e2 ) ; }
Value comparison between one CVE and one PVE .
155,438
private static boolean equalsAsCVE ( AbstractExpression e1 , AbstractExpression e2 ) { final ConstantValueExpression ce1 = asCVE ( e1 ) , ce2 = asCVE ( e2 ) ; return ce1 == null || ce2 == null ? ce1 == ce2 : ce1 . equals ( ce2 ) ; }
Check whether two expressions each either a CVE or PVE have same content . \ pre both must be either CVE or PVE .
155,439
private static ConstantValueExpression asCVE ( AbstractExpression expr ) { return expr instanceof ConstantValueExpression ? ( ConstantValueExpression ) expr : ( ( ParameterValueExpression ) expr ) . getOriginalValue ( ) ; }
Convert a ConstantValueExpression or ParameterValueExpression into a ConstantValueExpression . \ pre argument must be either of the two .
155,440
protected void addCorrelationParameterValueExpression ( AbstractExpression expr , List < AbstractExpression > pves ) { int paramIdx = ParameterizationInfo . getNextParamIndex ( ) ; m_parameterIdxList . add ( paramIdx ) ; ParameterValueExpression pve = new ParameterValueExpression ( paramIdx , expr ) ; pves . add ( pve ...
to get the original expression value
155,441
public synchronized CachedObject get ( int pos ) { if ( accessCount == Integer . MAX_VALUE ) { resetAccessCount ( ) ; } int lookup = getLookup ( pos ) ; if ( lookup == - 1 ) { return null ; } accessTable [ lookup ] = accessCount ++ ; return ( CachedObject ) objectValueTable [ lookup ] ; }
Returns a row if in memory cache .
155,442
synchronized void put ( int key , CachedObject row ) { int storageSize = row . getStorageSize ( ) ; if ( size ( ) >= capacity || storageSize + cacheBytesLength > bytesCapacity ) { cleanUp ( ) ; } if ( accessCount == Integer . MAX_VALUE ) { super . resetAccessCount ( ) ; } super . addOrRemove ( key , row , false ) ; row...
Adds a row to the cache .
155,443
synchronized CachedObject release ( int i ) { CachedObject r = ( CachedObject ) super . addOrRemove ( i , null , true ) ; if ( r == null ) { return null ; } cacheBytesLength -= r . getStorageSize ( ) ; r . setInMemory ( false ) ; return r ; }
Removes an object from memory cache . Does not release the file storage .
155,444
synchronized void saveAll ( ) { Iterator it = new BaseHashIterator ( ) ; int savecount = 0 ; for ( ; it . hasNext ( ) ; ) { CachedObject r = ( CachedObject ) it . next ( ) ; if ( r . hasChanged ( ) ) { rowTable [ savecount ++ ] = r ; } } saveRows ( savecount ) ; Error . printSystemOut ( saveAllTimer . elapsedTimeToMess...
Writes out all modified cached Rows .
155,445
public void addAggregate ( ExpressionType aggType , boolean isDistinct , Integer aggOutputColumn , AbstractExpression aggInputExpr ) { m_aggregateTypes . add ( aggType ) ; if ( isDistinct ) { m_aggregateDistinct . add ( 1 ) ; } else { m_aggregateDistinct . add ( 0 ) ; } m_aggregateOutputColumns . add ( aggOutputColumn ...
Add an aggregate to this plan node .
155,446
public static AggregatePlanNode convertToSerialAggregatePlanNode ( HashAggregatePlanNode hashAggregateNode ) { AggregatePlanNode serialAggr = new AggregatePlanNode ( ) ; return setAggregatePlanNode ( hashAggregateNode , serialAggr ) ; }
Convert HashAggregate into a Serialized Aggregate
155,447
public static AggregatePlanNode convertToPartialAggregatePlanNode ( HashAggregatePlanNode hashAggregateNode , List < Integer > aggrColumnIdxs ) { final AggregatePlanNode partialAggr = setAggregatePlanNode ( hashAggregateNode , new PartialAggregatePlanNode ( ) ) ; partialAggr . m_partialGroupByColumns = aggrColumnIdxs ;...
Convert HashAggregate into a Partial Aggregate
155,448
public String getSQLState ( ) { String state = null ; try { state = new String ( m_sqlState , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } return state ; }
Retrieve the SQLState code for the error that generated this exception .
155,449
private static String [ ] aggregatePerHostResults ( VoltTable vtable ) { String [ ] ret = new String [ 2 ] ; vtable . advanceRow ( ) ; String kitCheckResult = vtable . getString ( "KIT_CHECK_RESULT" ) ; String rootCheckResult = vtable . getString ( "ROOT_CHECK_RESULT" ) ; String xdcrCheckResult = vtable . getString ( "...
Be user - friendly return reasons of all failed checks .
155,450
public static long millisFromJDBCformat ( String param ) { java . sql . Timestamp sqlTS = java . sql . Timestamp . valueOf ( param ) ; final long fractionalSecondsInNanos = sqlTS . getNanos ( ) ; if ( ( fractionalSecondsInNanos % 1000000 ) != 0 ) { throw new IllegalArgumentException ( "Can't convert from String to Date...
Given a string parseable by the JDBC Timestamp parser return the fractional component in milliseconds .
155,451
public int compareTo ( TimestampType dateval ) { int comp = m_date . compareTo ( dateval . m_date ) ; if ( comp == 0 ) { return m_usecs - dateval . m_usecs ; } else { return comp ; } }
CompareTo - to mimic Java Date
155,452
public java . sql . Date asExactJavaSqlDate ( ) { if ( m_usecs != 0 ) { throw new RuntimeException ( "Can't convert to sql Date from TimestampType with fractional milliseconds" ) ; } return new java . sql . Date ( m_date . getTime ( ) ) ; }
Retrieve a properly typed copy of the Java date for a TimeStamp with millisecond granularity . The returned date is a copy ; this object will not be affected by modifications of the returned instance .
155,453
public java . sql . Timestamp asJavaTimestamp ( ) { java . sql . Timestamp result = new java . sql . Timestamp ( m_date . getTime ( ) ) ; result . setNanos ( result . getNanos ( ) + m_usecs * 1000 ) ; return result ; }
Retrieve a properly typed copy of the Java Timestamp for the VoltDB TimeStamp . The returned Timestamp is a copy ; this object will not be affected by modifications of the returned instance .
155,454
public boolean load ( ) { boolean exists ; if ( ! DatabaseURL . isFileBasedDatabaseType ( database . getType ( ) ) ) { return true ; } try { exists = super . load ( ) ; } catch ( Exception e ) { throw Error . error ( ErrorCode . FILE_IO_ERROR , ErrorCode . M_LOAD_SAVE_PROPERTIES , new Object [ ] { fileName , e } ) ; } ...
Creates file with defaults if it didn t exist . Returns false if file already existed .
155,455
public void setDatabaseVariables ( ) { if ( isPropertyTrue ( db_readonly ) ) { database . setReadOnly ( ) ; } if ( isPropertyTrue ( hsqldb_files_readonly ) ) { database . setFilesReadOnly ( ) ; } database . sqlEnforceStrictSize = isPropertyTrue ( sql_enforce_strict_size ) ; if ( isPropertyTrue ( sql_compare_in_locale )...
Sets the database member variables after creating the properties object openning a properties file or changing a property with a command
155,456
public void setURLProperties ( HsqlProperties p ) { if ( p != null ) { for ( Enumeration e = p . propertyNames ( ) ; e . hasMoreElements ( ) ; ) { String propertyName = ( String ) e . nextElement ( ) ; Object [ ] row = ( Object [ ] ) meta . get ( propertyName ) ; if ( row != null && ( db_readonly . equals ( propertyNam...
overload file database properties with any passed on URL line do not store password etc
155,457
private void runSubmissions ( boolean block ) throws InterruptedException { if ( block ) { Runnable r = m_submissionQueue . take ( ) ; do { r . run ( ) ; } while ( ( r = m_submissionQueue . poll ( ) ) != null ) ; } else { Runnable r = null ; while ( ( r = m_submissionQueue . poll ( ) ) != null ) { r . run ( ) ; } } }
if there is no other work to do
155,458
public void queueNotification ( final Collection < ClientInterfaceHandleManager > connections , final Supplier < DeferredSerialization > notification , final Predicate < ClientInterfaceHandleManager > wantsNotificationPredicate ) { m_submissionQueue . offer ( new Runnable ( ) { public void run ( ) { for ( ClientInterfa...
The collection will be filtered to exclude non VoltPort connections
155,459
public PerfCounter get ( String counter ) { if ( ! this . Counters . containsKey ( counter ) ) this . Counters . put ( counter , new PerfCounter ( false ) ) ; return this . Counters . get ( counter ) ; }
Gets a performance counter .
155,460
public void update ( String counter , long executionDuration , boolean success ) { this . get ( counter ) . update ( executionDuration , success ) ; }
Tracks a generic call execution by reporting the execution duration . This method should be used for successful calls only .
155,461
public String toRawString ( char delimiter ) { StringBuilder result = new StringBuilder ( ) ; for ( Entry < String , PerfCounter > e : Counters . entrySet ( ) ) { result . append ( e . getKey ( ) ) . append ( delimiter ) . append ( e . getValue ( ) . toRawString ( delimiter ) ) . append ( '\n' ) ; } return result . toS...
Gets the statistics as delimiter separated strings . Each line contains statistics for a single procedure . There might be multiple lines .
155,462
private void leaderElection ( ) { loggingLog . info ( "Starting leader election for snapshot truncation daemon" ) ; try { while ( true ) { Stat stat = m_zk . exists ( VoltZK . snapshot_truncation_master , new Watcher ( ) { public void process ( WatchedEvent event ) { switch ( event . getType ( ) ) { case NodeDeleted : ...
Leader election for snapshots . Leader will watch for truncation and user snapshot requests
155,463
public ListenableFuture < Void > mayGoActiveOrInactive ( final SnapshotSchedule schedule ) { return m_es . submit ( new Callable < Void > ( ) { public Void call ( ) throws Exception { makeActivePrivate ( schedule ) ; return null ; } } ) ; }
Make this SnapshotDaemon responsible for generating snapshots
155,464
private void doPeriodicWork ( final long now ) { if ( m_lastKnownSchedule == null ) { setState ( State . STARTUP ) ; return ; } if ( m_frequencyUnit == null ) { return ; } if ( m_state == State . STARTUP ) { initiateSnapshotScan ( ) ; } else if ( m_state == State . SCANNING ) { RateLimitedLogger . tryLogForMessage ( Sy...
Invoked by the client interface occasionally . Returns null if nothing needs to be done or the name of a sysproc along with procedure parameters if there is work to be done . Responses come back later via invocations of processClientResponse
155,465
private void processWaitingPeriodicWork ( long now ) { if ( now - m_lastSysprocInvocation < m_minTimeBetweenSysprocs ) { return ; } if ( m_snapshots . size ( ) > m_retain ) { if ( ! SnapshotSiteProcessor . ExecutionSitesCurrentlySnapshotting . isEmpty ( ) ) { m_lastSysprocInvocation = System . currentTimeMillis ( ) + 3...
Do periodic work when the daemon is in the waiting state . The daemon paces out sysproc invocations over time to avoid disrupting regular work . If the time for the next snapshot has passed it attempts to initiate a new snapshot . If there are too many snapshots being retains it attempts to delete the extras . Then it ...
155,466
public Future < Void > processClientResponse ( final Callable < ClientResponseImpl > response ) { return m_es . submit ( new Callable < Void > ( ) { public Void call ( ) throws Exception { try { ClientResponseImpl resp = response . call ( ) ; long handle = resp . getClientHandle ( ) ; m_procedureCallbacks . remove ( ha...
Process responses to sysproc invocations generated by this daemon via processPeriodicWork
155,467
private void processSnapshotResponse ( ClientResponse response ) { setState ( State . WAITING ) ; final long now = System . currentTimeMillis ( ) ; m_nextSnapshotTime += m_frequencyInMillis ; if ( m_nextSnapshotTime < now ) { m_nextSnapshotTime = now - 1 ; } if ( response . getStatus ( ) != ClientResponse . SUCCESS ) {...
Confirm and log that the snapshot was a success
155,468
private void processDeleteResponse ( ClientResponse response ) { setState ( State . WAITING ) ; if ( response . getStatus ( ) != ClientResponse . SUCCESS ) { logFailureResponse ( "Delete of snapshots failed" , response ) ; return ; } final VoltTable results [ ] = response . getResults ( ) ; final String err = SnapshotU...
Process a response to a request to delete snapshots . Always transitions to the waiting state even if the delete fails . This ensures the system will continue to snapshot until the disk is full in the event that there is an administration error or a bug .
155,469
private void processScanResponse ( ClientResponse response ) { setState ( State . WAITING ) ; if ( response . getStatus ( ) != ClientResponse . SUCCESS ) { logFailureResponse ( "Initial snapshot scan failed" , response ) ; return ; } final VoltTable results [ ] = response . getResults ( ) ; if ( results . length == 1 )...
Process the response to a snapshot scan . Find the snapshots that are managed by this daemon by path and nonce and add it the list . Initiate a delete of any that should not be retained
155,470
private void deleteExtraSnapshots ( ) { if ( m_snapshots . size ( ) <= m_retain ) { setState ( State . WAITING ) ; } else { m_lastSysprocInvocation = System . currentTimeMillis ( ) ; setState ( State . DELETING ) ; final int numberToDelete = m_snapshots . size ( ) - m_retain ; String pathsToDelete [ ] = new String [ nu...
Check if there are extra snapshots and initiate deletion
155,471
public void createAndWatchRequestNode ( final long clientHandle , final Connection c , SnapshotInitiationInfo snapInfo , boolean notifyChanges ) throws ForwardClientException { boolean requestExists = false ; final String requestId = createRequestNode ( snapInfo ) ; if ( requestId == null ) { requestExists = true ; } e...
Try to create the ZK request node and watch it if created successfully .
155,472
private String createRequestNode ( SnapshotInitiationInfo snapInfo ) { String requestId = null ; try { requestId = java . util . UUID . randomUUID ( ) . toString ( ) ; if ( ! snapInfo . isTruncationRequest ( ) ) { final JSONObject jsObj = snapInfo . getJSONObjectForZK ( ) ; jsObj . put ( "requestId" , requestId ) ; Str...
Try to create the ZK node to request the snapshot .
155,473
public final static < T extends FastSerializable > T deserialize ( final byte [ ] data , final Class < T > expectedType ) throws IOException { final FastDeserializer in = new FastDeserializer ( data ) ; return in . readObject ( expectedType ) ; }
Read an object from its byte array representation . This is a shortcut utility method useful when only a single object needs to be deserialized .
155,474
public < T extends FastSerializable > T readObject ( final Class < T > expectedType ) throws IOException { assert ( expectedType != null ) ; T obj = null ; try { obj = expectedType . newInstance ( ) ; obj . readExternal ( this ) ; } catch ( final InstantiationException e ) { e . printStackTrace ( ) ; } catch ( final Il...
Read an object from a a byte array stream assuming you know the expected type .
155,475
public FastSerializable readObject ( final FastSerializable obj , final DeserializationMonitor monitor ) throws IOException { final int startPosition = buffer . position ( ) ; obj . readExternal ( this ) ; final int endPosition = buffer . position ( ) ; if ( monitor != null ) { monitor . deserializedBytes ( endPosition...
Read an object from a a byte array stream into th provied instance . Takes in a deserialization monitor which is notified of how many bytes were deserialized .
155,476
public static String readString ( ByteBuffer buffer ) throws IOException { final int NULL_STRING_INDICATOR = - 1 ; final int len = buffer . getInt ( ) ; if ( len == NULL_STRING_INDICATOR ) return null ; assert len >= 0 ; if ( len > VoltType . MAX_VALUE_LENGTH ) { throw new IOException ( "Serializable strings cannot be ...
Read a string in the standard VoltDB way without wrapping the byte buffer [
155,477
public String readString ( ) throws IOException { final int len = readInt ( ) ; if ( len == VoltType . NULL_STRING_LENGTH ) { return null ; } if ( len < VoltType . NULL_STRING_LENGTH ) { throw new IOException ( "String length is negative " + len ) ; } if ( len > buffer . remaining ( ) ) { throw new IOException ( "Strin...
Read a string in the standard VoltDB way . That is four bytes of length info followed by the bytes of characters encoded in UTF - 8 .
155,478
public ByteBuffer readBuffer ( final int byteLen ) { final byte [ ] data = new byte [ byteLen ] ; buffer . get ( data ) ; return ByteBuffer . wrap ( data ) ; }
Create a copy of the first byteLen bytes of the underlying buffer .
155,479
private boolean removeUDFInSchema ( String functionName ) { for ( int idx = 0 ; idx < m_schema . children . size ( ) ; idx ++ ) { VoltXMLElement func = m_schema . children . get ( idx ) ; if ( "ud_function" . equals ( func . name ) ) { String fnm = func . attributes . get ( "name" ) ; if ( fnm != null && functionName ....
Remove the function with the given name from the VoltXMLElement schema if it is there already .
155,480
public String toXML ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" ) ; toXML ( sb , 0 ) ; return sb . toString ( ) ; }
Convert VoltXML to more conventional XML .
155,481
public List < VoltXMLElement > findChildrenRecursively ( String name ) { List < VoltXMLElement > retval = new ArrayList < > ( ) ; for ( VoltXMLElement vxe : children ) { if ( name . equals ( vxe . name ) ) { retval . add ( vxe ) ; } retval . addAll ( vxe . findChildrenRecursively ( name ) ) ; } return retval ; }
Given a name recursively find all the children with matching name if any .
155,482
public List < VoltXMLElement > findChildren ( String name ) { List < VoltXMLElement > retval = new ArrayList < > ( ) ; for ( VoltXMLElement vxe : children ) { if ( name . equals ( vxe . name ) ) { retval . add ( vxe ) ; } } return retval ; }
Given a name find all the immediate children with matching name if any .
155,483
public VoltXMLElement findChild ( String uniqueName ) { for ( VoltXMLElement vxe : children ) { if ( uniqueName . equals ( vxe . getUniqueName ( ) ) ) { return vxe ; } } return null ; }
Given an value in the format of that returned by getUniqueName find the child element which matches if any .
155,484
static public VoltXMLDiff computeDiff ( VoltXMLElement before , VoltXMLElement after ) { if ( ! before . getUniqueName ( ) . equals ( after . getUniqueName ( ) ) ) { return null ; } VoltXMLDiff result = new VoltXMLDiff ( before . getUniqueName ( ) ) ; if ( before . toMinString ( ) . equals ( after . toMinString ( ) ) )...
Compute the diff necessary to turn the before tree into the after tree .
155,485
public List < VoltXMLElement > extractSubElements ( String elementName , String attrName , String attrValue ) { assert ( elementName != null ) ; assert ( ( elementName != null && attrValue != null ) || attrName == null ) ; List < VoltXMLElement > elements = new ArrayList < > ( ) ; extractSubElements ( elementName , att...
Recursively extract sub elements of a given name with matching attribute if it is not null .
155,486
static int getHexValue ( int c ) { if ( c >= '0' && c <= '9' ) { c -= '0' ; } else if ( c > 'z' ) { c = 16 ; } else if ( c >= 'a' ) { c -= ( 'a' - 10 ) ; } else if ( c > 'Z' ) { c = 16 ; } else if ( c >= 'A' ) { c -= ( 'A' - 10 ) ; } else { c = - 1 ; } return c ; }
returns hex value of a hex character or 16 if not a hex character
155,487
boolean scanSpecialIdentifier ( String identifier ) { int length = identifier . length ( ) ; if ( limit - currentPosition < length ) { return false ; } for ( int i = 0 ; i < length ; i ++ ) { int character = identifier . charAt ( i ) ; if ( character == sqlString . charAt ( currentPosition + i ) ) { continue ; } if ( c...
Only for identifiers that are part of known token sequences
155,488
IntervalType scanIntervalType ( ) { int precision = - 1 ; int scale = - 1 ; int startToken ; int endToken ; final int errorCode = ErrorCode . X_22006 ; startToken = endToken = token . tokenType ; scanNext ( errorCode ) ; if ( token . tokenType == Tokens . OPENBRACKET ) { scanNext ( errorCode ) ; if ( token . dataType =...
Reads the type part of the INTERVAL
155,489
public synchronized Object convertToDatetimeInterval ( String s , DTIType type ) { Object value ; IntervalType intervalType = null ; int dateTimeToken = - 1 ; int errorCode = type . isDateTimeType ( ) ? ErrorCode . X_22007 : ErrorCode . X_22006 ; reset ( s ) ; resetState ( ) ; scanToken ( ) ; scanWhitespace ( ) ; switc...
should perform range checks etc .
155,490
public void writeData ( Object [ ] data , Type [ ] types ) { writeData ( types . length , types , data , null , null ) ; }
This method is called to write data for a table row .
155,491
void addWarning ( SQLWarning w ) { synchronized ( rootWarning_mutex ) { if ( rootWarning == null ) { rootWarning = w ; } else { rootWarning . setNextWarning ( w ) ; } } }
Adds another SQLWarning to this Connection object s warning chain .
155,492
public void reset ( ) throws SQLException { try { this . sessionProxy . resetSession ( ) ; } catch ( HsqlException e ) { throw Util . sqlException ( ErrorCode . X_08006 , e . getMessage ( ) , e ) ; } }
Resets this connection so it can be used again . Used when connections are returned to a connection pool .
155,493
private int onStartEscapeSequence ( String sql , StringBuffer sb , int i ) throws SQLException { sb . setCharAt ( i ++ , ' ' ) ; i = StringUtil . skipSpaces ( sql , i ) ; if ( sql . regionMatches ( true , i , "fn " , 0 , 3 ) || sql . regionMatches ( true , i , "oj " , 0 , 3 ) || sql . regionMatches ( true , i , "ts " ,...
is called from within nativeSQL when the start of an JDBC escape sequence is encountered
155,494
synchronized long userUpdate ( long value ) { if ( value == currValue ) { currValue += increment ; return value ; } if ( increment > 0 ) { if ( value > currValue ) { currValue += ( ( value - currValue + increment ) / increment ) * increment ; } } else { if ( value < currValue ) { currValue += ( ( value - currValue + in...
getter for a given value
155,495
synchronized long systemUpdate ( long value ) { if ( value == currValue ) { currValue += increment ; return value ; } if ( increment > 0 ) { if ( value > currValue ) { currValue = value + increment ; } } else { if ( value < currValue ) { currValue = value + increment ; } } return value ; }
Updates are necessary for text tables For memory tables the logged and scripted RESTART WITH will override this . No checks as values may have overridden the sequnece defaults
155,496
synchronized public long getValue ( ) { if ( limitReached ) { throw Error . error ( ErrorCode . X_2200H ) ; } long nextValue ; if ( increment > 0 ) { if ( currValue > maxValue - increment ) { if ( isCycle ) { nextValue = minValue ; } else { limitReached = true ; nextValue = minValue ; } } else { nextValue = currValue +...
principal getter for the next sequence value
155,497
synchronized public void reset ( long value ) { if ( value < minValue || value > maxValue ) { throw Error . error ( ErrorCode . X_42597 ) ; } startValue = currValue = lastValue = value ; }
reset to new initial value
155,498
public int compareTo ( Sha1Wrapper arg0 ) { if ( arg0 == null ) return 1 ; for ( int i = 0 ; i < 20 ; i ++ ) { int cmp = hashBytes [ i ] - arg0 . hashBytes [ i ] ; if ( cmp != 0 ) return cmp ; } return 0 ; }
Not totally sure if this is a sensible ordering
155,499
private static void appendSpaces ( final StringBuilder sb , final int spaces ) { for ( int i = 0 ; i < spaces ; i ++ ) { sb . append ( SPACE ) ; } }
Appends the required number of spaces to the StringBuilder .