idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
155,700 | public static int compareRows ( Object [ ] a , Object [ ] b , int [ ] cols , Type [ ] coltypes ) { int fieldcount = cols . length ; for ( int j = 0 ; j < fieldcount ; j ++ ) { int i = coltypes [ cols [ j ] ] . compare ( a [ cols [ j ] ] , b [ cols [ j ] ] ) ; if ( i != 0 ) { return i ; } } return 0 ; } | compares two full table rows based on a set of columns | 105 | 12 |
155,701 | @ Override public int size ( PersistentStore store ) { int count = 0 ; readLock . lock ( ) ; try { RowIterator it = firstRow ( null , store ) ; while ( it . hasNext ( ) ) { it . getNextRow ( ) ; count ++ ; } return count ; } finally { readLock . unlock ( ) ; } } | Returns the node count . | 76 | 5 |
155,702 | @ Override public void insert ( Session session , PersistentStore store , Row row ) { NodeAVL n ; NodeAVL x ; boolean isleft = true ; int compare = - 1 ; writeLock . lock ( ) ; try { n = getAccessor ( store ) ; x = n ; if ( n == null ) { store . setAccessor ( this , ( ( RowAVL ) row ) . getNode ( position ) ) ; return ... | Insert a node into the index | 236 | 6 |
155,703 | @ Override public RowIterator findFirstRow ( Session session , PersistentStore store , Object [ ] rowdata , int match ) { NodeAVL node = findNode ( session , store , rowdata , defaultColMap , match ) ; return getIterator ( session , store , node ) ; } | Return the first node equal to the indexdata object . The rowdata has the same column mapping as this index . | 62 | 23 |
155,704 | @ Override public RowIterator findFirstRow ( Session session , PersistentStore store , Object [ ] rowdata ) { NodeAVL node = findNode ( session , store , rowdata , colIndex , colIndex . length ) ; return getIterator ( session , store , node ) ; } | Return the first node equal to the rowdata object . The rowdata has the same column mapping as this table . | 61 | 23 |
155,705 | @ Override public RowIterator findFirstRow ( Session session , PersistentStore store , Object value , int compare ) { readLock . lock ( ) ; try { if ( compare == OpTypes . SMALLER || compare == OpTypes . SMALLER_EQUAL ) { return findFirstRowNotNull ( session , store ) ; } boolean isEqual = compare == OpTypes . EQUAL ||... | Finds the first node that is larger or equal to the given one based on the first column of the index only . | 625 | 24 |
155,706 | @ Override public RowIterator findFirstRowNotNull ( Session session , PersistentStore store ) { readLock . lock ( ) ; try { NodeAVL x = getAccessor ( store ) ; while ( x != null ) { boolean t = colTypes [ 0 ] . compare ( null , x . getRow ( store ) . getData ( ) [ colIndex [ 0 ] ] ) >= 0 ; if ( t ) { NodeAVL r = x . ge... | Finds the first node where the data is not null . | 283 | 12 |
155,707 | @ Override public RowIterator firstRow ( Session session , PersistentStore store ) { int tempDepth = 0 ; readLock . lock ( ) ; try { NodeAVL x = getAccessor ( store ) ; NodeAVL l = x ; while ( l != null ) { x = l ; l = x . getLeft ( store ) ; tempDepth ++ ; } while ( session != null && x != null ) { Row row = x . getRo... | Returns the row for the first node of the index | 159 | 10 |
155,708 | @ Override public Row lastRow ( Session session , PersistentStore store ) { readLock . lock ( ) ; try { NodeAVL x = getAccessor ( store ) ; NodeAVL l = x ; while ( l != null ) { x = l ; l = x . getRight ( store ) ; } while ( session != null && x != null ) { Row row = x . getRow ( store ) ; if ( session . database . txM... | Returns the row for the last node of the index | 147 | 10 |
155,709 | private NodeAVL next ( Session session , PersistentStore store , NodeAVL x ) { if ( x == null ) { return null ; } readLock . lock ( ) ; try { while ( true ) { x = next ( store , x ) ; if ( x == null ) { return x ; } if ( session == null ) { return x ; } Row row = x . getRow ( store ) ; if ( session . database . txManag... | Returns the node after the given one | 122 | 7 |
155,710 | private void replace ( PersistentStore store , NodeAVL x , NodeAVL n ) { if ( x . isRoot ( ) ) { if ( n != null ) { n = n . setParent ( store , null ) ; } store . setAccessor ( this , n ) ; } else { set ( store , x . getParent ( store ) , x . isFromLeft ( store ) , n ) ; } } | Replace x with n | 90 | 5 |
155,711 | @ Override public int compareRowNonUnique ( Object [ ] a , Object [ ] b , int fieldcount ) { for ( int j = 0 ; j < fieldcount ; j ++ ) { int i = colTypes [ j ] . compare ( a [ j ] , b [ colIndex [ j ] ] ) ; if ( i != 0 ) { return i ; } } return 0 ; } | As above but use the index column data | 83 | 8 |
155,712 | private int compareRowForInsertOrDelete ( Session session , Row newRow , Row existingRow ) { Object [ ] a = newRow . getData ( ) ; Object [ ] b = existingRow . getData ( ) ; int j = 0 ; boolean hasNull = false ; for ( ; j < colIndex . length ; j ++ ) { Object currentvalue = a [ colIndex [ j ] ] ; Object othervalue = b ... | Compare two rows of the table for inserting rows into unique indexes Supports descending columns . | 490 | 16 |
155,713 | private NodeAVL findNode ( Session session , PersistentStore store , Object [ ] rowdata , int [ ] rowColMap , int fieldCount ) { readLock . lock ( ) ; try { NodeAVL x = getAccessor ( store ) ; NodeAVL n ; NodeAVL result = null ; while ( x != null ) { int i = this . compareRowNonUnique ( rowdata , rowColMap , x . getRow... | Finds a match with a row from a different table | 290 | 11 |
155,714 | private void balance ( PersistentStore store , NodeAVL x , boolean isleft ) { while ( true ) { int sign = isleft ? 1 : - 1 ; switch ( x . getBalance ( ) * sign ) { case 1 : x = x . setBalance ( store , 0 ) ; return ; case 0 : x = x . setBalance ( store , - sign ) ; break ; case - 1 : NodeAVL l = child ( store , x , isl... | Balances part of the tree after an alteration to the index . | 396 | 13 |
155,715 | public AbstractExpression resolveTVE ( TupleValueExpression tve ) { AbstractExpression resolvedExpr = processTVE ( tve , tve . getColumnName ( ) ) ; List < TupleValueExpression > tves = ExpressionUtil . getTupleValueExpressions ( resolvedExpr ) ; for ( TupleValueExpression subqTve : tves ) { resolveLeafTve ( subqTve ) ... | The parameter tve is a column reference obtained by parsing a column ref VoltXML element . We need to find out to which column in the current table scan the name of the TVE refers and transfer metadata from the schema s column to the tve . The function processTVE does the transfer . | 103 | 61 |
155,716 | void resolveColumnIndexesUsingSchema ( NodeSchema inputSchema ) { // get all the TVEs in the output columns int difftor = 0 ; for ( SchemaColumn col : m_outputSchema ) { col . setDifferentiator ( difftor ) ; ++ difftor ; Collection < TupleValueExpression > allTves = ExpressionUtil . getTupleValueExpressions ( col . get... | Given an input schema resolve all the TVEs in all the output column expressions . This method is necessary to be able to do this for inlined projection nodes that don t have a child from which they can get an output schema . | 181 | 46 |
155,717 | public boolean isIdentity ( AbstractPlanNode childNode ) throws PlanningErrorException { assert ( childNode != null ) ; // Find the output schema. // If the child node has an inline projection node, // then the output schema is the inline projection // node's output schema. Otherwise it's the output // schema of the ch... | Return true if this node unneeded if its input schema is the given one . | 315 | 16 |
155,718 | public void replaceChildOutputSchemaNames ( AbstractPlanNode child ) { NodeSchema childSchema = child . getTrueOutputSchema ( false ) ; NodeSchema mySchema = getOutputSchema ( ) ; assert ( childSchema . size ( ) == mySchema . size ( ) ) ; for ( int idx = 0 ; idx < childSchema . size ( ) ; idx += 1 ) { SchemaColumn cCol... | Replace the column names output schema of the child node with the output schema column names of this node . We use this when we delete an unnecessary projection node . We only need to make sure the column names are changed since we will have checked carefully that everything else is the same . | 228 | 56 |
155,719 | void deliverToRepairLog ( VoltMessage msg ) { assert ( Thread . currentThread ( ) . getId ( ) == m_taskThreadId ) ; m_repairLog . deliver ( msg ) ; } | when the MpScheduler needs to log the completion of a transaction to its local repair log | 44 | 20 |
155,720 | private void sendInternal ( long destHSId , VoltMessage message ) { message . m_sourceHSId = getHSId ( ) ; m_messenger . send ( destHSId , message ) ; } | have a serialized order to all hosts . | 44 | 9 |
155,721 | public static ClientAffinityStats diff ( ClientAffinityStats newer , ClientAffinityStats older ) { if ( newer . m_partitionId != older . m_partitionId ) { throw new IllegalArgumentException ( "Can't diff these ClientAffinityStats instances." ) ; } ClientAffinityStats retval = new ClientAffinityStats ( older . m_partiti... | Subtract one ClientAffinityStats instance from another to produce a third . | 156 | 16 |
155,722 | private int addFramesForCompleteMessage ( ) { boolean added = false ; EncryptFrame frame = null ; int delta = 0 ; while ( ! added && ( frame = m_encryptedFrames . poll ( ) ) != null ) { if ( ! frame . isLast ( ) ) { //TODO: Review - I don't think this synchronized(m_partialMessages) is required. // This is the only met... | Gather all the frames that comprise a whole Volt Message Returns the delta between the original message byte count and encrypted message byte count . | 347 | 26 |
155,723 | void shutdown ( ) { m_isShutdown = true ; try { int waitFor = 1 - Math . min ( m_inFlight . availablePermits ( ) , - 4 ) ; for ( int i = 0 ; i < waitFor ; ++ i ) { try { if ( m_inFlight . tryAcquire ( 1 , TimeUnit . SECONDS ) ) { m_inFlight . release ( ) ; break ; } } catch ( InterruptedException e ) { break ; } } m_ec... | Called from synchronized block only | 236 | 6 |
155,724 | private Runnable createCompletionTask ( final Mailbox mb ) { return new Runnable ( ) { @ Override public void run ( ) { VoltDB . instance ( ) . getHostMessenger ( ) . removeMailbox ( mb . getHSId ( ) ) ; } } ; } | Remove the mailbox from the host messenger after all data targets are done . | 65 | 14 |
155,725 | private Callable < Boolean > coalesceTruncationSnapshotPlan ( String file_path , String pathType , String file_nonce , long txnId , Map < Integer , Long > partitionTransactionIds , SystemProcedureExecutionContext context , VoltTable result , ExtensibleSnapshotDigestData extraSnapshotData , SiteTracker tracker , Hashina... | NativeSnapshotWritePlan to include all tables . | 275 | 10 |
155,726 | void killSocket ( ) { try { m_closing = true ; m_socket . setKeepAlive ( false ) ; m_socket . setSoLinger ( false , 0 ) ; Thread . sleep ( 25 ) ; m_socket . close ( ) ; Thread . sleep ( 25 ) ; System . gc ( ) ; Thread . sleep ( 25 ) ; } catch ( Exception e ) { // don't REALLY care if this fails e . printStackTrace ( ) ... | Used only for test code to kill this FH | 103 | 10 |
155,727 | void send ( final long destinations [ ] , final VoltMessage message ) { if ( ! m_isUp ) { hostLog . warn ( "Failed to send VoltMessage because connection to host " + CoreUtils . getHostIdFromHSId ( destinations [ 0 ] ) + " is closed" ) ; return ; } if ( destinations . length == 0 ) { return ; } // if this link is "gone... | Send a message to the network . This public method is re - entrant . | 731 | 16 |
155,728 | private void deliverMessage ( long destinationHSId , VoltMessage message ) { if ( ! m_hostMessenger . validateForeignHostId ( m_hostId ) ) { hostLog . warn ( String . format ( "Message (%s) sent to site id: %s @ (%s) at %d from %s " + "which is a known failed host. The message will be dropped\n" , message . getClass ( ... | Deliver a deserialized message from the network to a local mailbox | 415 | 14 |
155,729 | private void handleRead ( ByteBuffer in , Connection c ) throws IOException { // port is locked by VoltNetwork when in valid use. // assert(m_port.m_lock.tryLock() == true); long recvDests [ ] = null ; final long sourceHSId = in . getLong ( ) ; final int destCount = in . getInt ( ) ; if ( destCount == POISON_PILL ) { /... | Read data from the network . Runs in the context of PicoNetwork thread when data is available . | 833 | 20 |
155,730 | @ Nullable private AvlNode < E > firstNode ( ) { AvlNode < E > root = rootReference . get ( ) ; if ( root == null ) { return null ; } AvlNode < E > node ; if ( range . hasLowerBound ( ) ) { E endpoint = range . getLowerEndpoint ( ) ; node = rootReference . get ( ) . ceiling ( comparator ( ) , endpoint ) ; if ( node == ... | Returns the first node in the tree that is in range . | 180 | 12 |
155,731 | public static MediaType create ( String type , String subtype ) { return create ( type , subtype , ImmutableListMultimap . < String , String > of ( ) ) ; } | Creates a new media type with the given type and subtype . | 40 | 14 |
155,732 | private static int getSerializedParamSizeForApplyBinaryLog ( int streamCount , int remotePartitionCount , int concatLogSize ) { int serializedParamSize = 2 + 1 + 4 // placeholder byte[0] + 1 + 4 // producerClusterId Integer + 1 + 4 + 4 + ( 4 + 8 * remotePartitionCount ) * streamCount // concatLogIds byte[] + 1 + 4 + 4 ... | calculate based on BinaryLogHelper and ParameterSet . fromArrayNoCopy | 177 | 17 |
155,733 | void restart ( ) { // The poisoning path will, unfortunately, set this to true. Need to undo that. setNeedsRollback ( false ) ; // Also need to make sure that we get the original invocation in the first fragment // since some masters may not have seen it. m_haveDistributedInitTask = false ; m_isRestart = true ; m_haveS... | Used to reset the internal state of this transaction so it can be successfully restarted | 96 | 16 |
155,734 | @ Override public void setupProcedureResume ( int [ ] dependencies ) { // Reset state so we can run this batch cleanly m_localWork = null ; m_remoteWork = null ; m_remoteDeps = null ; m_remoteDepTables . clear ( ) ; } | Overrides needed by MpProcedureRunner | 63 | 11 |
155,735 | public void setupProcedureResume ( List < Integer > deps ) { setupProcedureResume ( com . google_voltpatches . common . primitives . Ints . toArray ( deps ) ) ; } | I met this List at bandcamp ... | 49 | 8 |
155,736 | public void restartFragment ( FragmentResponseMessage message , List < Long > masters , Map < Integer , Long > partitionMastersMap ) { final int partionId = message . getPartitionId ( ) ; Long restartHsid = partitionMastersMap . get ( partionId ) ; Long hsid = message . getExecutorSiteId ( ) ; if ( ! hsid . equals ( re... | Restart this fragment after the fragment is mis - routed from MigratePartitionLeader If the masters have been updated the fragment will be routed to its new master . The fragment will be routed to the old master . until new master is updated . | 283 | 49 |
155,737 | private boolean checkNewUniqueIndex ( Index newIndex ) { Table table = ( Table ) newIndex . getParent ( ) ; CatalogMap < Index > existingIndexes = m_originalIndexesByTable . get ( table . getTypeName ( ) ) ; for ( Index existingIndex : existingIndexes ) { if ( indexCovers ( newIndex , existingIndex ) ) { return true ; ... | Check if there is a unique index that exists in the old catalog that is covered by the new index . That would mean adding this index can t fail with a duplicate key . | 88 | 35 |
155,738 | private String createViewDisallowedMessage ( String viewName , String singleTableName ) { boolean singleTable = ( singleTableName != null ) ; return String . format ( "Unable to create %sview %s %sbecause the view definition uses operations that cannot always be applied if %s." , ( singleTable ? "single table " : "mult... | Return an error message asserting that we cannot create a view with a given name . | 130 | 16 |
155,739 | private TablePopulationRequirements getMVHandlerInfoMessage ( MaterializedViewHandlerInfo mvh ) { if ( ! mvh . getIssafewithnonemptysources ( ) ) { TablePopulationRequirements retval ; String viewName = mvh . getDesttable ( ) . getTypeName ( ) ; String errorMessage = createViewDisallowedMessage ( viewName , null ) ; re... | Check a MaterializedViewHandlerInfo object for safety . Return an object with table population requirements on the table for it to be allowed . The return object if it is non - null will have a set of names of tables one of which must be empty if the view can be created . It will also have an error message . | 166 | 65 |
155,740 | private void writeModification ( CatalogType newType , CatalogType prevType , String field ) { // Don't write modifications if the field can be ignored if ( checkModifyIgnoreList ( newType , prevType , field ) ) { return ; } // verify this is possible, write an error and mark return code false if so String errorMessage... | Add a modification | 352 | 3 |
155,741 | protected static boolean checkCatalogDiffShouldApplyToEE ( final CatalogType suspect ) { // Warning: // This check list should be consistent with catalog items defined in EE // Once a new catalog type is added in EE, we should add it here. if ( suspect instanceof Cluster || suspect instanceof Database ) { return true ;... | Our EE has a list of Catalog items that are in use but Java catalog contains much more . Some of the catalog diff commands will only be useful to Java . So this function will decide whether the | 365 | 39 |
155,742 | private void processModifyResponses ( String errorMessage , List < TablePopulationRequirements > responseList ) { assert ( errorMessage != null ) ; // if no requirements, then it's just not possible if ( responseList == null ) { m_supported = false ; m_errors . append ( errorMessage + "\n" ) ; return ; } // otherwise, ... | After we decide we can t modify add or delete something on a full table we do a check to see if we can do that on an empty table . The original error and any response from the empty table check is processed here . This code is basically in this method so it s not repeated 3 times for modify add and delete . See where i... | 247 | 121 |
155,743 | private void writeDeletion ( CatalogType prevType , CatalogType newlyChildlessParent , String mapName ) { // Don't write deletions if the field can be ignored if ( checkDeleteIgnoreList ( prevType , newlyChildlessParent , mapName , prevType . getTypeName ( ) ) ) { return ; } // verify this is possible, write an error a... | Add a deletion | 336 | 3 |
155,744 | private void writeAddition ( CatalogType newType ) { // Don't write additions if the field can be ignored if ( checkAddIgnoreList ( newType ) ) { return ; } // verify this is possible, write an error and mark return code false if so String errorMessage = checkAddDropWhitelist ( newType , ChangeType . ADDITION ) ; // if... | Add an addition | 303 | 3 |
155,745 | private void getCommandsToDiff ( String mapName , CatalogMap < ? extends CatalogType > prevMap , CatalogMap < ? extends CatalogType > newMap ) { assert ( prevMap != null ) ; assert ( newMap != null ) ; // in previous, not in new for ( CatalogType prevType : prevMap ) { String name = prevType . getTypeName ( ) ; Catalog... | Check if all the children in prevMap are present and identical in newMap . Then check if anything is in newMap that isn t in prevMap . | 194 | 31 |
155,746 | public String getSQL ( ) { StringBuffer sb = new StringBuffer ( 64 ) ; switch ( opType ) { case OpTypes . VALUE : if ( valueData == null ) { return Tokens . T_NULL ; } return dataType . convertToSQLString ( valueData ) ; case OpTypes . ROW : sb . append ( ' ' ) ; for ( int i = 0 ; i < nodes . length ; i ++ ) { sb . app... | For use with CHECK constraints . Under development . | 311 | 10 |
155,747 | void setDataType ( Session session , Type type ) { if ( opType == OpTypes . VALUE ) { valueData = type . convertToType ( session , valueData , dataType ) ; } dataType = type ; } | Set the data type | 49 | 4 |
155,748 | Expression replaceAliasInOrderBy ( Expression [ ] columns , int length ) { for ( int i = 0 ; i < nodes . length ; i ++ ) { if ( nodes [ i ] == null ) { continue ; } nodes [ i ] = nodes [ i ] . replaceAliasInOrderBy ( columns , length ) ; } return this ; } | return the expression for an alias used in an ORDER BY clause | 73 | 12 |
155,749 | public HsqlList resolveColumnReferences ( RangeVariable [ ] rangeVarArray , HsqlList unresolvedSet ) { return resolveColumnReferences ( rangeVarArray , rangeVarArray . length , unresolvedSet , true ) ; } | resolve tables and collect unresolved column expressions | 45 | 8 |
155,750 | void insertValuesIntoSubqueryTable ( Session session , PersistentStore store ) { for ( int i = 0 ; i < nodes . length ; i ++ ) { Object [ ] data = nodes [ i ] . getRowValue ( session ) ; for ( int j = 0 ; j < nodeDataTypes . length ; j ++ ) { data [ j ] = nodeDataTypes [ j ] . convertToType ( session , data [ j ] , nod... | Details of IN condition optimisation for 1 . 9 . 0 Predicates with SELECT are QUERY expressions | 163 | 20 |
155,751 | static QuerySpecification getCheckSelect ( Session session , Table t , Expression e ) { CompileContext compileContext = new CompileContext ( session ) ; QuerySpecification s = new QuerySpecification ( compileContext ) ; s . exprColumns = new Expression [ 1 ] ; s . exprColumns [ 0 ] = EXPR_TRUE ; RangeVariable range = n... | Returns a Select object that can be used for checking the contents of an existing table against the given CHECK search condition . | 228 | 24 |
155,752 | static void collectAllExpressions ( HsqlList set , Expression e , OrderedIntHashSet typeSet , OrderedIntHashSet stopAtTypeSet ) { if ( e == null ) { return ; } if ( stopAtTypeSet . contains ( e . opType ) ) { return ; } for ( int i = 0 ; i < e . nodes . length ; i ++ ) { collectAllExpressions ( set , e . nodes [ i ] , ... | collect all extrassions of a set of expression types appearing anywhere in a select statement and its subselects etc . | 176 | 24 |
155,753 | protected String getUniqueId ( final Session session ) { if ( cached_id != null ) { return cached_id ; } // // Calculated an new Id // // this line ripped from the "describe" method // seems to help with some types like "equal" cached_id = new String ( ) ; // // If object is a leaf node, then we'll use John's original ... | Get the hex address of this Expression Object in memory to be used as a unique identifier . | 180 | 18 |
155,754 | private VoltXMLElement convertUsingColumnrefToCoaleseExpression ( Session session , VoltXMLElement exp , Type dataType ) throws org . hsqldb_voltpatches . HSQLInterface . HSQLParseException { // Hsql has check dataType can not be null. assert ( dataType != null ) ; exp . attributes . put ( "valuetype" , dataType . getN... | columnref T1 . C | 839 | 6 |
155,755 | private void appendOptionGroup ( StringBuffer buff , OptionGroup group ) { if ( ! group . isRequired ( ) ) { buff . append ( "[" ) ; } List < Option > optList = new ArrayList < Option > ( group . getOptions ( ) ) ; if ( getOptionComparator ( ) != null ) { Collections . sort ( optList , getOptionComparator ( ) ) ; } // ... | Appends the usage clause for an OptionGroup to a StringBuffer . The clause is wrapped in square brackets if the group is required . The display of the options is handled by appendOption | 187 | 37 |
155,756 | private void appendOption ( StringBuffer buff , Option option , boolean required ) { if ( ! required ) { buff . append ( "[" ) ; } if ( option . getOpt ( ) != null ) { buff . append ( "-" ) . append ( option . getOpt ( ) ) ; } else { buff . append ( "--" ) . append ( option . getLongOpt ( ) ) ; } // if the Option has a... | Appends the usage clause for an Option to a StringBuffer . | 224 | 13 |
155,757 | public void printUsage ( PrintWriter pw , int width , String cmdLineSyntax ) { int argPos = cmdLineSyntax . indexOf ( ' ' ) + 1 ; printWrapped ( pw , width , getSyntaxPrefix ( ) . length ( ) + argPos , getSyntaxPrefix ( ) + cmdLineSyntax ) ; } | Print the cmdLineSyntax to the specified writer using the specified width . | 77 | 15 |
155,758 | protected StringBuffer renderOptions ( StringBuffer sb , int width , Options options , int leftPad , int descPad ) { final String lpad = createPadding ( leftPad ) ; final String dpad = createPadding ( descPad ) ; // first create list containing only <lpad>-a,--aaa where // -a is opt and --aaa is long opt; in parallel l... | Render the specified Options and return the rendered Options in a StringBuffer . | 674 | 14 |
155,759 | protected StringBuffer renderWrappedText ( StringBuffer sb , int width , int nextLineTabStop , String text ) { int pos = findWrapPos ( text , width , 0 ) ; if ( pos == - 1 ) { sb . append ( rtrim ( text ) ) ; return sb ; } sb . append ( rtrim ( text . substring ( 0 , pos ) ) ) . append ( getNewLine ( ) ) ; if ( nextLin... | Render the specified text and return the rendered Options in a StringBuffer . | 261 | 14 |
155,760 | private static boolean functionMatches ( FunctionDescriptor existingFd , Type returnType , Type [ ] parameterTypes ) { if ( returnType != existingFd . m_type ) { return false ; } if ( parameterTypes . length != existingFd . m_paramTypes . length ) { return false ; } for ( int idx = 0 ; idx < parameterTypes . length ; i... | Return true iff the existing function descriptor matches the given return type and parameter types . These are all HSQLDB types not Volt types . | 120 | 28 |
155,761 | private static FunctionDescriptor findFunction ( String functionName , Type returnType , Type [ ] parameterType ) { m_logger . debug ( "Looking for UDF " + functionName ) ; FunctionDescriptor fd = FunctionDescriptor . m_by_LC_name . get ( functionName ) ; if ( fd == null ) { m_logger . debug ( " Not defined in by_LC_na... | Given a function name and signature find if there is an existing definition or saved defintion which matches the name and signature and return the definition . | 208 | 29 |
155,762 | public static synchronized int registerTokenForUDF ( String functionName , int functionId , VoltType voltReturnType , VoltType [ ] voltParameterTypes ) { int retFunctionId ; Type hsqlReturnType = hsqlTypeFromVoltType ( voltReturnType ) ; Type [ ] hsqlParameterTypes = hsqlTypeFromVoltType ( voltParameterTypes ) ; // If ... | This function registers a UDF using VoltType values for the return type and parameter types . | 513 | 18 |
155,763 | public static Type hsqlTypeFromVoltType ( VoltType voltReturnType ) { Class < ? > typeClass = VoltType . classFromByteValue ( voltReturnType . getValue ( ) ) ; int typeNo = Types . getParameterSQLTypeNumber ( typeClass ) ; return Type . getDefaultTypeWithSize ( typeNo ) ; } | Convert a VoltType to an HSQL type . | 73 | 11 |
155,764 | public static Type [ ] hsqlTypeFromVoltType ( VoltType [ ] voltParameterTypes ) { Type [ ] answer = new Type [ voltParameterTypes . length ] ; for ( int idx = 0 ; idx < voltParameterTypes . length ; idx ++ ) { answer [ idx ] = hsqlTypeFromVoltType ( voltParameterTypes [ idx ] ) ; } return answer ; } | Map the single parameter hsqlTypeFromVoltType over an array . | 87 | 15 |
155,765 | void setNewNodes ( ) { int index = tTable . getIndexCount ( ) ; nPrimaryNode = new NodeAVLMemoryPointer ( this ) ; NodeAVL n = nPrimaryNode ; for ( int i = 1 ; i < index ; i ++ ) { n . nNext = new NodeAVLMemoryPointer ( this ) ; n = n . nNext ; } } | Used when data is read from the disk into the Cache the first time . New Nodes are created which are then indexed . | 84 | 25 |
155,766 | private void bufferCatchup ( int messageSize ) throws IOException { // If the current buffer has too many tasks logged, queue it and // create a new one. if ( m_tail != null && m_tail . size ( ) > 0 && messageSize > m_bufferHeadroom ) { // compile the invocation buffer m_tail . compile ( ) ; final RejoinTaskBuffer boun... | The buffers are bound by the number of tasks in them . Once the current buffer has enough tasks it will be queued and a new buffer will be created . | 328 | 32 |
155,767 | @ Override public TransactionInfoBaseMessage getNextMessage ( ) throws IOException { if ( m_closed ) { throw new IOException ( "Closed" ) ; } if ( m_head == null ) { // Get another buffer asynchronously final Runnable r = new Runnable ( ) { @ Override public void run ( ) { try { BBContainer cont = m_reader . poll ( Per... | Try to get the next task message from the queue . | 555 | 11 |
155,768 | void sendBufferSync ( ByteBuffer bb ) { try { /* configure socket to be blocking * so that we dont have to do write in * a tight while loop */ sock . configureBlocking ( true ) ; if ( bb != closeConn ) { if ( sock != null ) { sock . write ( bb ) ; } packetSent ( ) ; } } catch ( IOException ie ) { LOG . error ( "Error s... | send buffer without using the asynchronous calls to selector and then close the socket | 100 | 14 |
155,769 | private void cleanupWriterSocket ( PrintWriter pwriter ) { try { if ( pwriter != null ) { pwriter . flush ( ) ; pwriter . close ( ) ; } } catch ( Exception e ) { LOG . info ( "Error closing PrintWriter " , e ) ; } finally { try { close ( ) ; } catch ( Exception e ) { LOG . error ( "Error closing a command socket " , e ... | clean up the socket related to a command and also make sure we flush the data before we do that | 92 | 20 |
155,770 | private boolean readLength ( SelectionKey k ) throws IOException { // Read the length, now get the buffer int len = lenBuffer . getInt ( ) ; if ( ! initialized && checkFourLetterWord ( k , len ) ) { return false ; } if ( len < 0 || len > BinaryInputArchive . maxBuffer ) { throw new IOException ( "Len error " + len ) ; ... | Reads the first 4 bytes of lenBuffer which could be true length or four letter word . | 124 | 19 |
155,771 | private void closeSock ( ) { if ( sock == null ) { return ; } LOG . debug ( "Closed socket connection for client " + sock . socket ( ) . getRemoteSocketAddress ( ) + ( sessionId != 0 ? " which had sessionid 0x" + Long . toHexString ( sessionId ) : " (no session established for client)" ) ) ; try { /* * The following se... | Close resources associated with the sock of this cnxn . | 404 | 13 |
155,772 | void increment ( ) { long id = rand . nextInt ( config . tuples ) ; long toIncrement = rand . nextInt ( 5 ) ; // 0 - 4 try { client . callProcedure ( new CMCallback ( ) , "Increment" , toIncrement , id ) ; } catch ( IOException e ) { // This is not ideal error handling for production, but should be // harmless in a ben... | Run the Increment procedure on the server asynchronously . | 113 | 12 |
155,773 | public synchronized void writeToLog ( Session session , String statement ) { if ( logStatements && log != null ) { log . writeStatement ( session , statement ) ; } } | Records a Log entry for the specified SQL statement on behalf of the specified Session object . | 37 | 18 |
155,774 | public DataFileCache openTextCache ( Table table , String source , boolean readOnlyData , boolean reversed ) { return log . openTextCache ( table , source , readOnlyData , reversed ) ; } | Opens the TextCache object . | 42 | 7 |
155,775 | protected void initParams ( Database database , String baseFileName ) { HsqlDatabaseProperties props = database . getProperties ( ) ; fileName = baseFileName + ".data" ; backupFileName = baseFileName + ".backup" ; this . database = database ; fa = database . getFileAccess ( ) ; int cacheScale = props . getIntegerProper... | initial external parameters are set here . | 394 | 7 |
155,776 | public void close ( boolean write ) { SimpleLog appLog = database . logger . appLog ; try { if ( cacheReadonly ) { if ( dataFile != null ) { dataFile . close ( ) ; dataFile = null ; } return ; } StopWatch sw = new StopWatch ( ) ; appLog . sendLine ( SimpleLog . LOG_NORMAL , "DataFileCache.close(" + write + ") : start" ... | Parameter write indicates either an orderly close or a fast close without backup . | 566 | 14 |
155,777 | public void defrag ( ) { if ( cacheReadonly ) { return ; } if ( fileFreePosition == INITIAL_FREE_POS ) { return ; } database . logger . appLog . logContext ( SimpleLog . LOG_NORMAL , "start" ) ; try { boolean wasNio = dataFile . wasNio ( ) ; cache . saveAll ( ) ; DataFileDefrag dfd = new DataFileDefrag ( database , thi... | Writes out all the rows to a new file without fragmentation . | 334 | 13 |
155,778 | public void remove ( int i , PersistentStore store ) { writeLock . lock ( ) ; try { CachedObject r = release ( i ) ; if ( r != null ) { int size = r . getStorageSize ( ) ; freeBlocks . add ( i , size ) ; } } finally { writeLock . unlock ( ) ; } } | Used when a row is deleted as a result of some DML or DDL statement . Removes the row from the cache data structures . Adds the file space for the row to the list of free positions . | 73 | 42 |
155,779 | public void restore ( CachedObject object ) { writeLock . lock ( ) ; try { int i = object . getPos ( ) ; cache . put ( i , object ) ; // was previously used for text tables if ( storeOnInsert ) { saveRow ( object ) ; } } finally { writeLock . unlock ( ) ; } } | For a CacheObject that had been previously released from the cache . A new version is introduced using the preallocated space for the object . | 71 | 28 |
155,780 | static void deleteOrResetFreePos ( Database database , String filename ) { ScaledRAFile raFile = null ; database . getFileAccess ( ) . removeElement ( filename ) ; // OOo related code if ( database . isStoredFileAccess ( ) ) { return ; } // OOo end if ( ! database . getFileAccess ( ) . isStreamElement ( filename ) ) { ... | This method deletes a data file or resets its free position . this is used only for nio files - not OOo files | 205 | 28 |
155,781 | public static boolean isDurableFragment ( byte [ ] planHash ) { long fragId = VoltSystemProcedure . hashToFragId ( planHash ) ; return ( fragId == PF_prepBalancePartitions || fragId == PF_balancePartitions || fragId == PF_balancePartitionsData || fragId == PF_balancePartitionsClearIndex || fragId == PF_distribute || fr... | for sysprocs and we cant distinguish if this needs to be replayed or not . | 97 | 18 |
155,782 | protected void set ( ClientResponse response ) { if ( ! this . status . compareAndSet ( STATUS_RUNNING , STATUS_SUCCESS ) ) return ; this . response = response ; this . latch . countDown ( ) ; } | Sets the result of the operation and flag the execution call as completed . | 53 | 15 |
155,783 | private static List < JoinNode > generateInnerJoinOrdersForTree ( JoinNode subTree ) { // Get a list of the leaf nodes(tables) to permute them List < JoinNode > tableNodes = subTree . generateLeafNodesJoinOrder ( ) ; List < List < JoinNode > > joinOrders = PermutationGenerator . generatePurmutations ( tableNodes ) ; Li... | Helper method to generate join orders for a join tree containing only INNER joins that can be obtained by the permutation of the original tables . | 294 | 28 |
155,784 | private static List < JoinNode > generateOuterJoinOrdersForTree ( JoinNode subTree ) { List < JoinNode > treePermutations = new ArrayList <> ( ) ; treePermutations . add ( subTree ) ; return treePermutations ; } | Helper method to generate join orders for an OUTER join tree . At the moment permutations for LEFT Joins are not supported yet | 58 | 27 |
155,785 | private static List < JoinNode > generateFullJoinOrdersForTree ( JoinNode subTree ) { assert ( subTree != null ) ; List < JoinNode > joinOrders = new ArrayList <> ( ) ; if ( ! ( subTree instanceof BranchNode ) ) { // End of recursion joinOrders . add ( subTree ) ; return joinOrders ; } BranchNode branchNode = ( BranchN... | Helper method to generate join orders for a join tree containing only FULL joins . The only allowed permutation is a join order that has original left and right nodes swapped . | 508 | 33 |
155,786 | private void generateMorePlansForJoinTree ( JoinNode joinTree ) { assert ( joinTree != null ) ; // generate the access paths for all nodes generateAccessPaths ( joinTree ) ; List < JoinNode > nodes = joinTree . generateAllNodesJoinOrder ( ) ; generateSubPlanForJoinNodeRecursively ( joinTree , 0 , nodes ) ; } | Given a specific join order compute all possible sub - plan - graphs for that join order and add them to the deque of plans . If this doesn t add plans it doesn t mean no more plans can be generated . It s possible that the particular join order it got had no reasonable plans . | 79 | 59 |
155,787 | private AbstractPlanNode getSelectSubPlanForJoinNode ( JoinNode joinNode ) { assert ( joinNode != null ) ; if ( joinNode instanceof BranchNode ) { BranchNode branchJoinNode = ( BranchNode ) joinNode ; // Outer node AbstractPlanNode outerScanPlan = getSelectSubPlanForJoinNode ( branchJoinNode . getLeftNode ( ) ) ; if ( ... | Given a specific join node and access path set for inner and outer tables construct the plan that gives the right tuples . | 605 | 24 |
155,788 | private static List < AbstractExpression > filterSingleTVEExpressions ( List < AbstractExpression > exprs , List < AbstractExpression > otherExprs ) { List < AbstractExpression > singleTVEExprs = new ArrayList <> ( ) ; for ( AbstractExpression expr : exprs ) { List < TupleValueExpression > tves = ExpressionUtil . getTu... | A method to filter out single - TVE expressions . | 141 | 11 |
155,789 | public void notifyShutdown ( ) { if ( m_shutdown . compareAndSet ( false , true ) ) { for ( KafkaExternalConsumerRunner consumer : m_consumers ) { consumer . shutdown ( ) ; } close ( ) ; } } | shutdown hook to notify kafka consumer threads of shutdown | 52 | 12 |
155,790 | protected void runDDL ( String ddl , boolean transformDdl ) { String modifiedDdl = ( transformDdl ? transformDDL ( ddl ) : ddl ) ; printTransformedSql ( ddl , modifiedDdl ) ; super . runDDL ( modifiedDdl ) ; } | Optionally modifies DDL statements in such a way that PostgreSQL results will match VoltDB results ; and then passes the remaining work to the base class version . | 64 | 33 |
155,791 | @ Override protected String getVoltColumnTypeName ( String columnTypeName ) { String equivalentTypeName = m_PostgreSQLTypeNames . get ( columnTypeName ) ; return ( equivalentTypeName == null ) ? columnTypeName . toUpperCase ( ) : equivalentTypeName ; } | Returns the column type name in VoltDB corresponding to the specified column type name in PostgreSQL . | 62 | 19 |
155,792 | static private int numOccurencesOfCharIn ( String str , char ch ) { boolean inMiddleOfQuote = false ; int num = 0 , previousIndex = 0 ; for ( int index = str . indexOf ( ch ) ; index >= 0 ; index = str . indexOf ( ch , index + 1 ) ) { if ( hasOddNumberOfSingleQuotes ( str . substring ( previousIndex , index ) ) ) { inM... | Returns the number of occurrences of the specified character in the specified String but ignoring those contained in single quotes . | 126 | 21 |
155,793 | static private int indexOfNthOccurrenceOfCharIn ( String str , char ch , int n ) { boolean inMiddleOfQuote = false ; int index = - 1 , previousIndex = 0 ; for ( int i = 0 ; i < n ; i ++ ) { do { index = str . indexOf ( ch , index + 1 ) ; if ( index < 0 ) { return - 1 ; } if ( hasOddNumberOfSingleQuotes ( str . substrin... | Returns the Nth occurrence of the specified character in the specified String but ignoring those contained in single quotes . | 139 | 21 |
155,794 | protected VoltTable runDML ( String dml , boolean transformDml ) { String modifiedDml = ( transformDml ? transformDML ( dml ) : dml ) ; printTransformedSql ( dml , modifiedDml ) ; return super . runDML ( modifiedDml ) ; } | Optionally modifies queries in such a way that PostgreSQL results will match VoltDB results ; and then passes the remaining work to the base class version . | 66 | 31 |
155,795 | static int getClassCode ( Class cla ) { if ( ! cla . isPrimitive ( ) ) { return ArrayUtil . CLASS_CODE_OBJECT ; } return classCodeMap . get ( cla , - 1 ) ; } | Returns a distinct int code for each primitive type and for all Object types . | 50 | 15 |
155,796 | public static void clearArray ( int type , Object data , int from , int to ) { switch ( type ) { case ArrayUtil . CLASS_CODE_BYTE : { byte [ ] array = ( byte [ ] ) data ; while ( -- to >= from ) { array [ to ] = 0 ; } return ; } case ArrayUtil . CLASS_CODE_CHAR : { byte [ ] array = ( byte [ ] ) data ; while ( -- to >= ... | Clears an area of the given array of the given type . | 422 | 13 |
155,797 | public static void adjustArray ( int type , Object array , int usedElements , int index , int count ) { if ( index >= usedElements ) { return ; } int newCount = usedElements + count ; int source ; int target ; int size ; if ( count >= 0 ) { source = index ; target = index + count ; size = usedElements - index ; } else ... | Moves the contents of an array to allow both addition and removal of elements . Used arguments must be in range . | 152 | 23 |
155,798 | public static void sortArray ( int [ ] array ) { boolean swapped ; do { swapped = false ; for ( int i = 0 ; i < array . length - 1 ; i ++ ) { if ( array [ i ] > array [ i + 1 ] ) { int temp = array [ i + 1 ] ; array [ i + 1 ] = array [ i ] ; array [ i ] = temp ; swapped = true ; } } } while ( swapped ) ; } | Basic sort for small arrays of int . | 97 | 8 |
155,799 | public static int find ( Object [ ] array , Object object ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] == object ) { // hadles both nulls return i ; } if ( object != null && object . equals ( array [ i ] ) ) { return i ; } } return - 1 ; } | Basic find for small arrays of Object . | 78 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.