idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
11,900
public static < T > AppendingFactoryExpression < T > appending ( Expression < T > base , Expression < ? > ... rest ) { return new AppendingFactoryExpression < T > ( base , rest ) ; }
Create an appending factory expression which serializes all the arguments but the uses the base value as the return value
11,901
public static < T > ConstructorExpression < T > constructor ( Class < ? extends T > type , Class < ? > [ ] paramTypes , Expression < ? > ... exprs ) { return new ConstructorExpression < T > ( type , paramTypes , exprs ) ; }
Create a constructor invocation projection for given type parameter types and expressions
11,902
@ WithBridgeMethods ( value = SQLDeleteClause . class , castRequired = true ) public C addBatch ( ) { batches . add ( metadata ) ; metadata = new DefaultQueryMetadata ( ) ; metadata . addJoin ( JoinType . DEFAULT , entity ) ; metadata . setValidatingVisitor ( validatingVisitor ) ; return ( C ) this ; }
Add current state of bindings as a batch item
11,903
@ WithBridgeMethods ( value = OracleQuery . class , castRequired = true ) public C orderSiblingsBy ( Expression < ? > path ) { return addFlag ( Position . BEFORE_ORDER , ORDER_SIBLINGS_BY , path ) ; }
ORDER SIBLINGS BY preserves any ordering specified in the hierarchical query clause and then applies the order_by_clause to the siblings of the hierarchy .
11,904
@ WithBridgeMethods ( value = SQLInsertClause . class , castRequired = true ) public C populate ( Object bean ) { return populate ( bean , DefaultMapper . DEFAULT ) ; }
Populate the INSERT clause with the properties of the given bean . The properties need to match the fields of the clause s entity instance .
11,905
@ SuppressWarnings ( "rawtypes" ) @ WithBridgeMethods ( value = SQLInsertClause . class , castRequired = true ) public < T > C populate ( T obj , Mapper < T > mapper ) { Map < Path < ? > , Object > values = mapper . createMap ( entity , obj ) ; for ( Map . Entry < Path < ? > , Object > entry : values . entrySet ( ) ) { set ( ( Path ) entry . getKey ( ) , entry . getValue ( ) ) ; } return ( C ) this ; }
Populate the INSERT clause with the properties of the given bean using the given Mapper .
11,906
@ SuppressWarnings ( "unchecked" ) public String asLiteral ( Object o ) { if ( o == null || o instanceof Null ) { return "null" ; } else { Type type = javaTypeMapping . getType ( o . getClass ( ) ) ; if ( type != null ) { return templates . serialize ( type . getLiteral ( o ) , type . getSQLTypes ( ) [ 0 ] ) ; } else { throw new IllegalArgumentException ( "Unsupported literal type " + o . getClass ( ) . getName ( ) ) ; } } }
Get the literal representation of the given constant
11,907
public Class < ? > getJavaType ( int sqlType , String typeName , int size , int digits , String tableName , String columnName ) { Type < ? > type = javaTypeMapping . getType ( tableName , columnName ) ; if ( type != null ) { return type . getReturnedClass ( ) ; } else if ( typeName != null && ! typeName . isEmpty ( ) ) { typeName = typeName . toLowerCase ( ) ; Class < ? > clazz = typeToName . get ( typeName ) ; if ( clazz != null ) { return clazz ; } if ( sqlType == Types . ARRAY ) { if ( typeName . startsWith ( "_" ) ) { typeName = typeName . substring ( 1 ) ; } else if ( typeName . endsWith ( " array" ) ) { typeName = typeName . substring ( 0 , typeName . length ( ) - 6 ) ; } if ( typeName . contains ( "[" ) ) { typeName = typeName . substring ( 0 , typeName . indexOf ( "[" ) ) ; } if ( typeName . contains ( "(" ) ) { typeName = typeName . substring ( 0 , typeName . indexOf ( "(" ) ) ; } Integer sqlComponentType = templates . getCodeForTypeName ( typeName ) ; if ( sqlComponentType == null ) { logger . warn ( "Found no JDBC type for " + typeName + " using OTHER instead" ) ; sqlComponentType = Types . OTHER ; } Class < ? > componentType = jdbcTypeMapping . get ( sqlComponentType , size , digits ) ; return Array . newInstance ( componentType , 0 ) . getClass ( ) ; } } return jdbcTypeMapping . get ( sqlType , size , digits ) ; }
Get the java type for the given jdbc type table name and column name
11,908
public String getColumnOverride ( SchemaAndTable key , String column ) { return nameMapping . getColumnOverride ( key , column ) . or ( column ) ; }
Get the column override
11,909
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public < T > void set ( PreparedStatement stmt , Path < ? > path , int i , T value ) throws SQLException { if ( value == null || value instanceof Null ) { Integer sqlType = null ; if ( path != null ) { ColumnMetadata columnMetadata = ColumnMetadata . getColumnMetadata ( path ) ; if ( columnMetadata . hasJdbcType ( ) ) { sqlType = columnMetadata . getJdbcType ( ) ; } } if ( sqlType != null ) { stmt . setNull ( i , sqlType ) ; } else { stmt . setNull ( i , Types . NULL ) ; } } else { getType ( path , ( Class ) value . getClass ( ) ) . setValue ( stmt , i , value ) ; } }
Set the value at the given index in the statement
11,910
public String getTypeName ( Class < ? > type ) { Integer jdbcType = jdbcTypeMapping . get ( type ) ; if ( jdbcType == null ) { jdbcType = javaTypeMapping . getType ( type ) . getSQLTypes ( ) [ 0 ] ; } return templates . getTypeNameForCode ( jdbcType ) ; }
Get the SQL type name for the given java type
11,911
public String getTypeNameForCast ( Class < ? > type ) { Integer jdbcType = jdbcTypeMapping . get ( type ) ; if ( jdbcType == null ) { jdbcType = javaTypeMapping . getType ( type ) . getSQLTypes ( ) [ 0 ] ; } return templates . getCastTypeNameForCode ( jdbcType ) ; }
Get the SQL type name for a cast operation
11,912
public String registerSchemaOverride ( String oldSchema , String newSchema ) { return schemaMapping . put ( oldSchema , newSchema ) ; }
Register a schema override
11,913
public String registerTableOverride ( String oldTable , String newTable ) { return internalNameMapping . registerTableOverride ( oldTable , newTable ) ; }
Register a table override
11,914
public String registerColumnOverride ( String schema , String table , String oldColumn , String newColumn ) { return internalNameMapping . registerColumnOverride ( schema , table , oldColumn , newColumn ) ; }
Register a column override
11,915
public void registerType ( String typeName , Class < ? > clazz ) { typeToName . put ( typeName . toLowerCase ( ) , clazz ) ; }
Register a typeName to Class mapping
11,916
public void registerNumeric ( int total , int decimal , Class < ? > javaType ) { jdbcTypeMapping . registerNumeric ( total , decimal , javaType ) ; }
Override the binding for the given NUMERIC type
11,917
public void registerNumeric ( int beginTotal , int endTotal , int beginDecimal , int endDecimal , Class < ? > javaType ) { for ( int total = beginTotal ; total <= endTotal ; total ++ ) { for ( int decimal = beginDecimal ; decimal <= endDecimal ; decimal ++ ) { registerNumeric ( total , decimal , javaType ) ; } } }
Override multiple numeric bindings both begin and end are inclusive
11,918
public void register ( String table , String column , Class < ? > javaType ) { register ( table , column , javaTypeMapping . getType ( javaType ) ) ; }
Register the given javaType for the given table and column
11,919
public RuntimeException translate ( String sql , List < Object > bindings , SQLException ex ) { return exceptionTranslator . translate ( sql , bindings , ex ) ; }
Translate the given SQLException
11,920
public static NumberExpression < Double > ymax ( GeometryExpression < ? > expr ) { return Expressions . numberOperation ( Double . class , SpatialOps . YMAX , expr ) ; }
Returns Y maxima of a bounding box 2d or 3d or a geometry .
11,921
public final OrderSpecifier < T > asc ( ) { if ( asc == null ) { asc = new OrderSpecifier < T > ( Order . ASC , mixin ) ; } return asc ; }
Create an OrderSpecifier for ascending order of this expression
11,922
public final OrderSpecifier < T > desc ( ) { if ( desc == null ) { desc = new OrderSpecifier < T > ( Order . DESC , mixin ) ; } return desc ; }
Create an OrderSpecifier for descending order of this expression
11,923
public < T > Evaluator < T > create ( QueryMetadata metadata , List < ? extends Expression < ? > > sources , Expression < T > projection ) { final CollQuerySerializer serializer = new CollQuerySerializer ( templates ) ; serializer . append ( "return " ) ; if ( projection instanceof FactoryExpression < ? > ) { serializer . append ( "(" ) ; serializer . append ( ClassUtils . getName ( projection . getType ( ) ) ) ; serializer . append ( ")(" ) ; serializer . handle ( projection ) ; serializer . append ( ")" ) ; } else { serializer . handle ( projection ) ; } serializer . append ( ";" ) ; Map < Object , String > constantToLabel = serializer . getConstantToLabel ( ) ; Map < String , Object > constants = getConstants ( metadata , constantToLabel ) ; Class < ? > [ ] types = new Class < ? > [ sources . size ( ) ] ; String [ ] names = new String [ sources . size ( ) ] ; for ( int i = 0 ; i < sources . size ( ) ; i ++ ) { types [ i ] = sources . get ( i ) . getType ( ) ; names [ i ] = sources . get ( i ) . toString ( ) ; } for ( int i = 0 ; i < types . length ; i ++ ) { if ( Primitives . isWrapperType ( types [ i ] ) ) { types [ i ] = Primitives . unwrap ( types [ i ] ) ; } } return factory . createEvaluator ( serializer . toString ( ) , projection . getType ( ) , names , types , constants ) ; }
Create an Evaluator for the given query sources and projection
11,924
public < T > Evaluator < List < T > > createEvaluator ( QueryMetadata metadata , Expression < ? extends T > source , Predicate filter ) { String typeName = ClassUtils . getName ( source . getType ( ) ) ; CollQuerySerializer ser = new CollQuerySerializer ( templates ) ; ser . append ( "java.util.List<" + typeName + "> rv = new java.util.ArrayList<" + typeName + ">();\n" ) ; ser . append ( "for (" + typeName + " " + source + " : " + source + "_) {\n" ) ; ser . append ( " try {\n" ) ; ser . append ( " if (" ) . handle ( filter ) . append ( ") {\n" ) ; ser . append ( " rv.add(" + source + ");\n" ) ; ser . append ( " }\n" ) ; ser . append ( " } catch (NullPointerException npe) { }\n" ) ; ser . append ( "}\n" ) ; ser . append ( "return rv;" ) ; Map < Object , String > constantToLabel = ser . getConstantToLabel ( ) ; Map < String , Object > constants = getConstants ( metadata , constantToLabel ) ; Type sourceType = new ClassType ( TypeCategory . SIMPLE , source . getType ( ) ) ; ClassType sourceListType = new ClassType ( TypeCategory . SIMPLE , Iterable . class , sourceType ) ; return factory . createEvaluator ( ser . toString ( ) , sourceListType , new String [ ] { source + "_" } , new Type [ ] { sourceListType } , new Class < ? > [ ] { Iterable . class } , constants ) ; }
Create an Evaluator for the given source and filter
11,925
public NumberExpression < Integer > numPoints ( ) { if ( numPoints == null ) { numPoints = Expressions . numberOperation ( Integer . class , SpatialOps . NUM_POINTS , mixin ) ; } return numPoints ; }
The number of Points in this LineString .
11,926
public static Type resolve ( Type type , Type declaringType , EntityType context ) { Type resolved = unwrap ( type ) ; String varName = getVarName ( resolved ) ; if ( varName != null ) { resolved = resolveVar ( resolved , varName , declaringType , context ) ; } else if ( ! resolved . getParameters ( ) . isEmpty ( ) ) { resolved = resolveWithParameters ( resolved , declaringType , context ) ; } if ( type instanceof EntityType ) { if ( ! unwrap ( type ) . equals ( resolved ) ) { resolved = new EntityType ( resolved , ( ( EntityType ) type ) . getSuperTypes ( ) ) ; } else { resolved = type ; } } return resolved ; }
Resolve type declared in declaringType for context
11,927
public void execute ( ) throws IOException { try { collectTypes ( ) ; } catch ( Exception e ) { throw new QueryException ( e ) ; } Set < Supertype > additions = Sets . newHashSet ( ) ; for ( Map . Entry < Class < ? > , EntityType > entry : allTypes . entrySet ( ) ) { EntityType entityType = entry . getValue ( ) ; if ( entityType . getSuperType ( ) != null && ! allTypes . containsKey ( entityType . getSuperType ( ) . getType ( ) . getJavaClass ( ) ) ) { additions . add ( entityType . getSuperType ( ) ) ; } } for ( Supertype type : additions ) { type . setEntityType ( createEntityType ( type . getType ( ) , this . superTypes ) ) ; } Set < EntityType > handled = new HashSet < EntityType > ( ) ; for ( EntityType type : superTypes . values ( ) ) { addSupertypeFields ( type , allTypes , handled ) ; } for ( EntityType type : entityTypes . values ( ) ) { addSupertypeFields ( type , allTypes , handled ) ; } for ( EntityType type : embeddableTypes . values ( ) ) { addSupertypeFields ( type , allTypes , handled ) ; } serialize ( superTypes , supertypeSerializer ) ; serialize ( embeddableTypes , embeddableSerializer ) ; serialize ( entityTypes , entitySerializer ) ; }
Export the contents
11,928
public static < A > CollDeleteClause < A > delete ( Path < A > path , Collection < A > col ) { return new CollDeleteClause < A > ( path , col ) ; }
Create a new delete clause
11,929
public static < A > CollUpdateClause < A > update ( Path < A > path , Iterable < A > col ) { return new CollUpdateClause < A > ( path , col ) ; }
Create a new update clause
11,930
public SQLInsertClause insertIgnore ( RelationalPath < ? > entity ) { SQLInsertClause insert = insert ( entity ) ; insert . addFlag ( Position . START_OVERRIDE , "insert ignore into " ) ; return insert ; }
Create a INSERT IGNORE INTO clause
11,931
public static void addSupport ( AbstractModule module ) { module . bindInstance ( SQLCodegenModule . ENTITYPATH_TYPE , RelationalPathSpatial . class ) ; registerTypes ( module . get ( Configuration . class ) ) ; registerTypes ( module . get ( TypeMappings . class ) ) ; addImports ( module ) ; }
Register spatial types to the given codegen module
11,932
public void setColumnComparatorClass ( Class < ? extends Comparator < Property > > columnComparatorClass ) { module . bind ( SQLCodegenModule . COLUMN_COMPARATOR , columnComparatorClass ) ; }
Set the column comparator class
11,933
public void setSchemaToPackage ( boolean schemaToPackage ) { this . schemaToPackage = schemaToPackage ; module . bind ( SQLCodegenModule . SCHEMA_TO_PACKAGE , schemaToPackage ) ; }
Set whether schema names should be appended to the package name .
11,934
public void setImports ( String [ ] imports ) { module . bind ( CodegenModule . IMPORTS , new HashSet < String > ( Arrays . asList ( imports ) ) ) ; }
Set the java imports
11,935
public void export ( Package ... packages ) { String [ ] pkgs = new String [ packages . length ] ; for ( int i = 0 ; i < packages . length ; i ++ ) { pkgs [ i ] = packages [ i ] . getName ( ) ; } export ( pkgs ) ; }
Export the given packages
11,936
public static NumberExpression < Double > random ( int seed ) { return Expressions . numberOperation ( Double . class , MathOps . RANDOM2 , ConstantImpl . create ( seed ) ) ; }
Return a random number expression with the given seed
11,937
public static < A extends Number & Comparable < ? > > NumberExpression < A > round ( Expression < A > num ) { return Expressions . numberOperation ( num . getType ( ) , MathOps . ROUND , num ) ; }
Round to nearest integer
11,938
public static < A extends Number & Comparable < ? > > NumberExpression < A > round ( Expression < A > num , int s ) { return Expressions . numberOperation ( num . getType ( ) , MathOps . ROUND2 , num , ConstantImpl . create ( s ) ) ; }
Round to s decimal places
11,939
public static < T > Expression < T > set ( Path < T > target , Expression < ? extends T > value ) { if ( value != null ) { return Expressions . operation ( target . getType ( ) , SQLOps . SET_PATH , target , value ) ; } else { return Expressions . operation ( target . getType ( ) , SQLOps . SET_LITERAL , target , Expressions . nullExpression ( ) ) ; } }
Create an assignment expression
11,940
public static < T > Union < T > union ( List < SubQueryExpression < T > > sq ) { return new SQLQuery < Void > ( ) . union ( sq ) ; }
Create a new UNION clause
11,941
public static < T > Union < T > unionAll ( SubQueryExpression < T > ... sq ) { return new SQLQuery < Void > ( ) . unionAll ( sq ) ; }
Create a new UNION ALL clause
11,942
public static BooleanExpression any ( BooleanExpression expr ) { return Expressions . booleanOperation ( Ops . AggOps . BOOLEAN_ANY , expr ) ; }
Get an aggregate any expression for the given boolean expression
11,943
public static BooleanExpression all ( BooleanExpression expr ) { return Expressions . booleanOperation ( Ops . AggOps . BOOLEAN_ALL , expr ) ; }
Get an aggregate all expression for the given boolean expression
11,944
public static < T > RelationalFunctionCall < T > relationalFunctionCall ( Class < ? extends T > type , String function , Object ... args ) { return new RelationalFunctionCall < T > ( type , function , args ) ; }
Create a new RelationalFunctionCall for the given function and arguments
11,945
public static < D extends Comparable > DateExpression < D > datetrunc ( DatePart unit , DateExpression < D > expr ) { return Expressions . dateOperation ( expr . getType ( ) , DATE_TRUNC_OPS . get ( unit ) , expr ) ; }
Truncate the given date expression
11,946
public static < D extends Comparable > DateTimeExpression < D > datetrunc ( DatePart unit , DateTimeExpression < D > expr ) { return Expressions . dateTimeOperation ( expr . getType ( ) , DATE_TRUNC_OPS . get ( unit ) , expr ) ; }
Truncate the given datetime expression
11,947
public static < D extends Comparable > DateTimeExpression < D > addHours ( DateTimeExpression < D > date , int hours ) { return Expressions . dateTimeOperation ( date . getType ( ) , Ops . DateTimeOps . ADD_HOURS , date , ConstantImpl . create ( hours ) ) ; }
Add the given amount of hours to the date
11,948
public static < D extends Comparable > DateTimeExpression < D > addMinutes ( DateTimeExpression < D > date , int minutes ) { return Expressions . dateTimeOperation ( date . getType ( ) , Ops . DateTimeOps . ADD_MINUTES , date , ConstantImpl . create ( minutes ) ) ; }
Add the given amount of minutes to the date
11,949
public static < D extends Comparable > DateTimeExpression < D > addSeconds ( DateTimeExpression < D > date , int seconds ) { return Expressions . dateTimeOperation ( date . getType ( ) , Ops . DateTimeOps . ADD_SECONDS , date , ConstantImpl . create ( seconds ) ) ; }
Add the given amount of seconds to the date
11,950
public static < T > WindowOver < T > lead ( Expression < T > expr ) { return new WindowOver < T > ( expr . getType ( ) , SQLOps . LEAD , expr ) ; }
expr evaluated at the row that is one row after the current row within the partition ;
11,951
public static < T > WindowOver < T > lag ( Expression < T > expr ) { return new WindowOver < T > ( expr . getType ( ) , SQLOps . LAG , expr ) ; }
expr evaluated at the row that is one row before the current row within the partition
11,952
public static WithinGroup < Object > listagg ( Expression < ? > expr , String delimiter ) { return new WithinGroup < Object > ( Object . class , SQLOps . LISTAGG , expr , ConstantImpl . create ( delimiter ) ) ; }
LISTAGG orders data within each group specified in the ORDER BY clause and then concatenates the values of the measure column .
11,953
public static < T > WindowOver < T > nthValue ( Expression < T > expr , Number n ) { return nthValue ( expr , ConstantImpl . create ( n ) ) ; }
NTH_VALUE returns the expr value of the nth row in the window defined by the analytic clause . The returned value has the data type of the expr .
11,954
public static < T > WindowOver < T > nthValue ( Expression < T > expr , Expression < ? extends Number > n ) { return new WindowOver < T > ( expr . getType ( ) , SQLOps . NTHVALUE , expr , n ) ; }
NTH_VALUE returns the expr value of the nth row in the window defined by the analytic clause . The returned value has the data type of the expr
11,955
@ SuppressWarnings ( "unchecked" ) public static < T extends Number & Comparable > WindowOver < T > ntile ( T num ) { return new WindowOver < T > ( ( Class < T > ) num . getClass ( ) , SQLOps . NTILE , ConstantImpl . create ( num ) ) ; }
divides an ordered data set into a number of buckets indicated by expr and assigns the appropriate bucket number to each row
11,956
public static WithinGroup < Long > rank ( Expression < ? > ... args ) { return new WithinGroup < Long > ( Long . class , SQLOps . RANK2 , args ) ; }
As an aggregate function RANK calculates the rank of a hypothetical row identified by the arguments of the function with respect to a given sort specification . The arguments of the function must all evaluate to constant expressions within each aggregate group because they identify a single row within each group . The constant argument expressions and the expressions in the ORDER BY clause of the aggregate match by position . Therefore the number of arguments must be the same and their types must be compatible .
11,957
public static WithinGroup < Long > denseRank ( Expression < ? > ... args ) { return new WithinGroup < Long > ( Long . class , SQLOps . DENSERANK2 , args ) ; }
As an aggregate function DENSE_RANK calculates the dense rank of a hypothetical row identified by the arguments of the function with respect to a given sort specification . The arguments of the function must all evaluate to constant expressions within each aggregate group because they identify a single row within each group . The constant argument expressions and the expressions in the order_by_clause of the aggregate match by position . Therefore the number of arguments must be the same and types must be compatible .
11,958
public static WithinGroup < Double > percentRank ( Expression < ? > ... args ) { return new WithinGroup < Double > ( Double . class , SQLOps . PERCENTRANK2 , args ) ; }
As an aggregate function PERCENT_RANK calculates for a hypothetical row r identified by the arguments of the function and a corresponding sort specification the rank of row r minus 1 divided by the number of rows in the aggregate group . This calculation is made as if the hypothetical row r were inserted into the group of rows over which Oracle Database is to aggregate . The arguments of the function identify a single hypothetical row within each aggregate group . Therefore they must all evaluate to constant expressions within each aggregate group . The constant argument expressions and the expressions in the ORDER BY clause of the aggregate match by position . Therefore the number of arguments must be the same and their types must be compatible .
11,959
public static < T extends Number > WithinGroup < T > percentileDisc ( Expression < T > arg ) { return new WithinGroup < T > ( arg . getType ( ) , SQLOps . PERCENTILEDISC , arg ) ; }
PERCENTILE_DISC is an inverse distribution function that assumes a discrete distribution model . It takes a percentile value and a sort specification and returns an element from the set . Nulls are ignored in the calculation .
11,960
public static WindowOver < Double > regrSlope ( Expression < ? extends Number > arg1 , Expression < ? extends Number > arg2 ) { return new WindowOver < Double > ( Double . class , SQLOps . REGR_SLOPE , arg1 , arg2 ) ; }
REGR_SLOPE returns the slope of the line
11,961
public static WindowOver < Double > regrIntercept ( Expression < ? extends Number > arg1 , Expression < ? extends Number > arg2 ) { return new WindowOver < Double > ( Double . class , SQLOps . REGR_INTERCEPT , arg1 , arg2 ) ; }
REGR_INTERCEPT returns the y - intercept of the regression line .
11,962
public static WindowOver < Double > regrCount ( Expression < ? extends Number > arg1 , Expression < ? extends Number > arg2 ) { return new WindowOver < Double > ( Double . class , SQLOps . REGR_COUNT , arg1 , arg2 ) ; }
REGR_COUNT returns an integer that is the number of non - null number pairs used to fit the regression line .
11,963
public static WithinGroup < Double > cumeDist ( Expression < ? > ... args ) { return new WithinGroup < Double > ( Double . class , SQLOps . CUMEDIST2 , args ) ; }
As an aggregate function CUME_DIST calculates for a hypothetical row r identified by the arguments of the function and a corresponding sort specification the relative position of row r among the rows in the aggregation group . Oracle makes this calculation as if the hypothetical row r were inserted into the group of rows to be aggregated over . The arguments of the function identify a single hypothetical row within each aggregate group . Therefore they must all evaluate to constant expressions within each aggregate group . The constant argument expressions and the expressions in the ORDER BY clause of the aggregate match by position . Therefore the number of arguments must be the same and their types must be compatible .
11,964
public static < T > WindowOver < T > ratioToReport ( Expression < T > expr ) { return new WindowOver < T > ( expr . getType ( ) , SQLOps . RATIOTOREPORT , expr ) ; }
computes the ratio of a value to the sum of a set of values . If expr evaluates to null then the ratio - to - report value also evaluates to null .
11,965
public static < T extends Number > WindowOver < T > stddevPop ( Expression < T > expr ) { return new WindowOver < T > ( expr . getType ( ) , SQLOps . STDDEVPOP , expr ) ; }
returns the population standard deviation and returns the square root of the population variance .
11,966
public static < T extends Number > WindowOver < T > stddevSamp ( Expression < T > expr ) { return new WindowOver < T > ( expr . getType ( ) , SQLOps . STDDEVSAMP , expr ) ; }
returns the cumulative sample standard deviation and returns the square root of the sample variance .
11,967
public static < T extends Number > WindowOver < T > variance ( Expression < T > expr ) { return new WindowOver < T > ( expr . getType ( ) , SQLOps . VARIANCE , expr ) ; }
returns the variance of expr
11,968
public static < T extends Number > WindowOver < T > varPop ( Expression < T > expr ) { return new WindowOver < T > ( expr . getType ( ) , SQLOps . VARPOP , expr ) ; }
returns the population variance of a set of numbers after discarding the nulls in this set .
11,969
public static < T extends Number > WindowOver < T > varSamp ( Expression < T > expr ) { return new WindowOver < T > ( expr . getType ( ) , SQLOps . VARSAMP , expr ) ; }
returns the sample variance of a set of numbers after discarding the nulls in this set .
11,970
public static < T > WindowOver < T > firstValue ( Expression < T > expr ) { return new WindowOver < T > ( expr . getType ( ) , SQLOps . FIRSTVALUE , expr ) ; }
returns value evaluated at the row that is the first row of the window frame
11,971
public static < T > WindowOver < T > lastValue ( Expression < T > expr ) { return new WindowOver < T > ( expr . getType ( ) , SQLOps . LASTVALUE , expr ) ; }
returns value evaluated at the row that is the last row of the window frame
11,972
public static StringExpression right ( Expression < String > lhs , int rhs ) { return right ( lhs , ConstantImpl . create ( rhs ) ) ; }
Get the rhs rightmost characters of lhs
11,973
public static JobContext create ( AlluxioConfiguration alluxioConf ) { JobContext context = new JobContext ( ) ; context . init ( alluxioConf ) ; return context ; }
Creates a job context .
11,974
private synchronized void init ( AlluxioConfiguration alluxioConf ) { mJobMasterInquireClient = MasterInquireClient . Factory . createForJobMaster ( alluxioConf ) ; mJobMasterClientPool = new JobMasterClientPool ( JobMasterClientContext . newBuilder ( ClientContext . create ( alluxioConf ) ) . build ( ) ) ; }
Initializes the context . Only called in the factory methods and reset .
11,975
public LockResource lockInode ( InodeView inode , LockMode mode ) { return mInodeLocks . get ( inode . getId ( ) , mode ) ; }
Acquires an inode lock .
11,976
public Optional < LockResource > tryLockInode ( Long inodeId , LockMode mode ) { return mInodeLocks . tryGet ( inodeId , mode ) ; }
Attempts to acquire an inode lock .
11,977
public LockResource lockEdge ( Edge edge , LockMode mode ) { return mEdgeLocks . get ( edge , mode ) ; }
Acquires an edge lock .
11,978
public Optional < LockResource > tryLockEdge ( Edge edge , LockMode mode ) { return mEdgeLocks . tryGet ( edge , mode ) ; }
Attempts to acquire an edge lock .
11,979
public Optional < Scoped > tryAcquirePersistingLock ( long inodeId ) { AtomicBoolean lock = mPersistingLocks . getUnchecked ( inodeId ) ; if ( lock . compareAndSet ( false , true ) ) { return Optional . of ( ( ) -> lock . set ( false ) ) ; } return Optional . empty ( ) ; }
Tries to acquire a lock for persisting the specified inode id .
11,980
public synchronized void gainPrimacy ( ) throws IOException { Preconditions . checkState ( mWriter == null , "writer must be null in secondary mode" ) ; Preconditions . checkState ( mTailerThread != null , "tailer thread must not be null in secondary mode" ) ; mTailerThread . awaitTermination ( true ) ; long nextSequenceNumber = mTailerThread . getNextSequenceNumber ( ) ; mTailerThread = null ; nextSequenceNumber = catchUp ( nextSequenceNumber ) ; mWriter = new UfsJournalLogWriter ( this , nextSequenceNumber ) ; mAsyncWriter = new AsyncJournalWriter ( mWriter ) ; mState = State . PRIMARY ; }
Transitions the journal from secondary to primary mode . The journal will apply the latest journal entries to the state machine then begin to allow writes .
11,981
public synchronized void losePrimacy ( ) throws IOException { Preconditions . checkState ( mState == State . PRIMARY , "unexpected state " + mState ) ; Preconditions . checkState ( mWriter != null , "writer thread must not be null in primary mode" ) ; Preconditions . checkState ( mTailerThread == null , "tailer thread must be null in primary mode" ) ; mWriter . close ( ) ; mWriter = null ; mAsyncWriter = null ; mMaster . resetState ( ) ; mTailerThread = new UfsJournalCheckpointThread ( mMaster , this ) ; mTailerThread . start ( ) ; mState = State . SECONDARY ; }
Transitions the journal from primary to secondary mode . The journal will no longer allow writes and the state machine is rebuilt from the journal and kept up to date .
11,982
public void format ( ) throws IOException { URI location = getLocation ( ) ; LOG . info ( "Formatting {}" , location ) ; if ( mUfs . isDirectory ( location . toString ( ) ) ) { for ( UfsStatus status : mUfs . listStatus ( location . toString ( ) ) ) { String childPath = URIUtils . appendPathOrDie ( location , status . getName ( ) ) . toString ( ) ; if ( status . isDirectory ( ) && ! mUfs . deleteDirectory ( childPath , DeleteOptions . defaults ( ) . setRecursive ( true ) ) || status . isFile ( ) && ! mUfs . deleteFile ( childPath ) ) { throw new IOException ( String . format ( "Failed to delete %s" , childPath ) ) ; } } } else if ( ! mUfs . mkdirs ( location . toString ( ) ) ) { throw new IOException ( String . format ( "Failed to create %s" , location ) ) ; } UnderFileSystemUtils . touch ( mUfs , URIUtils . appendPathOrDie ( location , ServerConfiguration . get ( PropertyKey . MASTER_FORMAT_FILE_PREFIX ) + System . currentTimeMillis ( ) ) . toString ( ) ) ; }
Formats the journal .
11,983
private synchronized long catchUp ( long nextSequenceNumber ) { JournalReader journalReader = new UfsJournalReader ( this , nextSequenceNumber , true ) ; try { return catchUp ( journalReader ) ; } finally { try { journalReader . close ( ) ; } catch ( IOException e ) { LOG . warn ( "Failed to close journal reader: {}" , e . toString ( ) ) ; } } }
Reads and applies all journal entries starting from the specified sequence number .
11,984
public synchronized void notifyTaskCompletion ( long jobId , int taskId , Object result ) { Pair < Long , Integer > id = new Pair < > ( jobId , taskId ) ; TaskInfo . Builder taskInfo = mUnfinishedTasks . get ( id ) ; taskInfo . setStatus ( Status . COMPLETED ) ; try { taskInfo . setResult ( ByteString . copyFrom ( SerializationUtils . serialize ( result ) ) ) ; } catch ( IOException e ) { LOG . warn ( "Failed to serialize {} : {}" , result , e . getMessage ( ) ) ; LOG . debug ( "Exception: " , e ) ; } finally { finishTask ( id ) ; LOG . info ( "Task {} for job {} completed." , taskId , jobId ) ; } }
Notifies the completion of the task .
11,985
public synchronized void notifyTaskFailure ( long jobId , int taskId , String errorMessage ) { Pair < Long , Integer > id = new Pair < > ( jobId , taskId ) ; TaskInfo . Builder taskInfo = mUnfinishedTasks . get ( id ) ; taskInfo . setStatus ( Status . FAILED ) ; taskInfo . setErrorMessage ( errorMessage ) ; finishTask ( id ) ; LOG . info ( "Task {} for job {} failed: {}" , taskId , jobId , errorMessage ) ; }
Notifies the failure of the task .
11,986
public synchronized void notifyTaskCancellation ( long jobId , int taskId ) { Pair < Long , Integer > id = new Pair < > ( jobId , taskId ) ; TaskInfo . Builder taskInfo = mUnfinishedTasks . get ( id ) ; taskInfo . setStatus ( Status . CANCELED ) ; finishTask ( id ) ; LOG . info ( "Task {} for job {} canceled" , taskId , jobId ) ; }
Notifies the cancellation of the task .
11,987
public synchronized void executeTask ( long jobId , int taskId , JobConfig jobConfig , Serializable taskArgs , RunTaskContext context ) { Future < ? > future = mTaskExecutionService . submit ( new TaskExecutor ( jobId , taskId , jobConfig , taskArgs , context , this ) ) ; Pair < Long , Integer > id = new Pair < > ( jobId , taskId ) ; mTaskFutures . put ( id , future ) ; TaskInfo . Builder taskInfo = TaskInfo . newBuilder ( ) ; taskInfo . setJobId ( jobId ) ; taskInfo . setTaskId ( taskId ) ; taskInfo . setStatus ( Status . RUNNING ) ; mUnfinishedTasks . put ( id , taskInfo ) ; mTaskUpdates . put ( id , taskInfo . build ( ) ) ; LOG . info ( "Task {} for job {} started" , taskId , jobId ) ; }
Executes the given task .
11,988
public synchronized void cancelTask ( long jobId , int taskId ) { Pair < Long , Integer > id = new Pair < > ( jobId , taskId ) ; TaskInfo . Builder taskInfo = mUnfinishedTasks . get ( id ) ; if ( ! mTaskFutures . containsKey ( id ) || taskInfo . getStatus ( ) . equals ( Status . CANCELED ) ) { return ; } Future < ? > future = mTaskFutures . get ( id ) ; if ( ! future . cancel ( true ) ) { taskInfo . setStatus ( Status . FAILED ) ; taskInfo . setErrorMessage ( "Failed to cancel the task" ) ; finishTask ( id ) ; } }
Cancels the given task .
11,989
public synchronized void restoreTaskUpdates ( List < TaskInfo > tasks ) { for ( TaskInfo task : tasks ) { Pair < Long , Integer > id = new Pair < > ( task . getJobId ( ) , task . getTaskId ( ) ) ; if ( ! mTaskUpdates . containsKey ( id ) ) { mTaskUpdates . put ( id , task ) ; } } }
Adds the given tasks to the task updates data structure . If there is already an update for the specified task it is not changed .
11,990
public static String getUfsBlockPath ( UfsManager . UfsClient ufsInfo , long blockId ) { return PathUtils . concatPath ( ufsInfo . getUfsMountPointUri ( ) , PathUtils . temporaryFileName ( MAGIC_NUMBER , ".alluxio_ufs_blocks" ) , blockId ) ; }
For a given block ID derives the corresponding UFS file of this block if it falls back to be stored in UFS .
11,991
public JournalEntry readEntry ( ) throws IOException { int firstByte = mStream . read ( ) ; if ( firstByte == - 1 ) { return null ; } int size ; try { size = ProtoUtils . readRawVarint32 ( firstByte , mStream ) ; } catch ( IOException e ) { LOG . warn ( "Journal entry was truncated in the size portion." ) ; throw e ; } if ( mBuffer . length < size ) { mBuffer = new byte [ size ] ; } int totalBytesRead = 0 ; while ( totalBytesRead < size ) { int latestBytesRead = mStream . read ( mBuffer , totalBytesRead , size - totalBytesRead ) ; if ( latestBytesRead < 0 ) { break ; } totalBytesRead += latestBytesRead ; } if ( totalBytesRead < size ) { LOG . warn ( "Journal entry was truncated. Expected to read {} bytes but only got {}" , size , totalBytesRead ) ; return null ; } JournalEntry entry = JournalEntry . parseFrom ( new ByteArrayInputStream ( mBuffer , 0 , size ) ) ; return entry ; }
Reads a journal entry from the input stream .
11,992
public static String getSizeFromBytes ( long bytes ) { double ret = bytes ; if ( ret <= 1024 * 5 ) { return String . format ( Locale . ENGLISH , "%dB" , bytes ) ; } ret /= 1024 ; if ( ret <= 1024 * 5 ) { return String . format ( Locale . ENGLISH , "%.2fKB" , ret ) ; } ret /= 1024 ; if ( ret <= 1024 * 5 ) { return String . format ( Locale . ENGLISH , "%.2fMB" , ret ) ; } ret /= 1024 ; if ( ret <= 1024 * 5 ) { return String . format ( Locale . ENGLISH , "%.2fGB" , ret ) ; } ret /= 1024 ; if ( ret <= 1024 * 5 ) { return String . format ( Locale . ENGLISH , "%.2fTB" , ret ) ; } ret /= 1024 ; return String . format ( Locale . ENGLISH , "%.2fPB" , ret ) ; }
Returns a human - readable version of bytes 10GB 2048KB etc .
11,993
public static long parseSpaceSize ( String spaceSize ) { double alpha = 0.0001 ; String ori = spaceSize ; String end = "" ; int index = spaceSize . length ( ) - 1 ; while ( index >= 0 ) { if ( spaceSize . charAt ( index ) > '9' || spaceSize . charAt ( index ) < '0' ) { end = spaceSize . charAt ( index ) + end ; } else { break ; } index -- ; } spaceSize = spaceSize . substring ( 0 , index + 1 ) ; double ret = Double . parseDouble ( spaceSize ) ; end = end . toLowerCase ( ) ; if ( end . isEmpty ( ) || end . equals ( "b" ) ) { return ( long ) ( ret + alpha ) ; } else if ( end . equals ( "kb" ) || end . equals ( "k" ) ) { return ( long ) ( ret * Constants . KB + alpha ) ; } else if ( end . equals ( "mb" ) || end . equals ( "m" ) ) { return ( long ) ( ret * Constants . MB + alpha ) ; } else if ( end . equals ( "gb" ) || end . equals ( "g" ) ) { return ( long ) ( ret * Constants . GB + alpha ) ; } else if ( end . equals ( "tb" ) || end . equals ( "t" ) ) { return ( long ) ( ret * Constants . TB + alpha ) ; } else if ( end . equals ( "pb" ) || end . equals ( "p" ) ) { BigDecimal pBDecimal = new BigDecimal ( Constants . PB ) ; return pBDecimal . multiply ( BigDecimal . valueOf ( ret ) ) . longValue ( ) ; } else { throw new IllegalArgumentException ( "Fail to parse " + ori + " to bytes" ) ; } }
Parses a String size to Bytes .
11,994
public static long parseTimeSize ( String timeSize ) { double alpha = 0.0001 ; String time = "" ; String size = "" ; Matcher m = SEP_DIGIT_LETTER . matcher ( timeSize ) ; if ( m . matches ( ) ) { time = m . group ( 1 ) ; size = m . group ( 2 ) ; } double douTime = Double . parseDouble ( time ) ; long sign = 1 ; if ( douTime < 0 ) { sign = - 1 ; douTime = - douTime ; } size = size . toLowerCase ( ) ; if ( size . isEmpty ( ) || size . equalsIgnoreCase ( "ms" ) || size . equalsIgnoreCase ( "millisecond" ) ) { return sign * ( long ) ( douTime + alpha ) ; } else if ( size . equalsIgnoreCase ( "s" ) || size . equalsIgnoreCase ( "sec" ) || size . equalsIgnoreCase ( "second" ) ) { return sign * ( long ) ( douTime * Constants . SECOND + alpha ) ; } else if ( size . equalsIgnoreCase ( "m" ) || size . equalsIgnoreCase ( "min" ) || size . equalsIgnoreCase ( "minute" ) ) { return sign * ( long ) ( douTime * Constants . MINUTE + alpha ) ; } else if ( size . equalsIgnoreCase ( "h" ) || size . equalsIgnoreCase ( "hr" ) || size . equalsIgnoreCase ( "hour" ) ) { return sign * ( long ) ( douTime * Constants . HOUR + alpha ) ; } else if ( size . equalsIgnoreCase ( "d" ) || size . equalsIgnoreCase ( "day" ) ) { return sign * ( long ) ( douTime * Constants . DAY + alpha ) ; } else { throw new IllegalArgumentException ( "Fail to parse " + timeSize + " to milliseconds" ) ; } }
Parses a String size to Milliseconds . Supports negative numbers .
11,995
public static String formatMode ( short mode , boolean directory , boolean hasExtended ) { StringBuilder str = new StringBuilder ( ) ; if ( directory ) { str . append ( "d" ) ; } else { str . append ( "-" ) ; } str . append ( new Mode ( mode ) . toString ( ) ) ; if ( hasExtended ) { str . append ( "+" ) ; } return str . toString ( ) ; }
Formats digital representation of a model as a human - readable string .
11,996
public static void persistAndWait ( final FileSystem fs , final AlluxioURI uri , int timeoutMs ) throws FileDoesNotExistException , IOException , AlluxioException , TimeoutException , InterruptedException { fs . persist ( uri ) ; CommonUtils . waitFor ( String . format ( "%s to be persisted" , uri ) , ( ) -> { try { return fs . getStatus ( uri ) . isPersisted ( ) ; } catch ( Exception e ) { Throwables . throwIfUnchecked ( e ) ; throw new RuntimeException ( e ) ; } } , WaitForOptions . defaults ( ) . setTimeoutMs ( timeoutMs ) . setInterval ( Constants . SECOND_MS ) ) ; }
Persists the given path to the under file system and returns once the persist is complete . Note that if this method times out the persist may still occur after the timeout period .
11,997
private void initMultiPartUpload ( ) throws IOException { ObjectMetadata meta = new ObjectMetadata ( ) ; if ( mSseEnabled ) { meta . setSSEAlgorithm ( ObjectMetadata . AES_256_SERVER_SIDE_ENCRYPTION ) ; } if ( mHash != null ) { meta . setContentMD5 ( Base64 . encodeAsString ( mHash . digest ( ) ) ) ; } meta . setContentType ( Mimetypes . MIMETYPE_OCTET_STREAM ) ; AmazonClientException lastException ; InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest ( mBucketName , mKey ) . withObjectMetadata ( meta ) ; do { try { mUploadId = mClient . initiateMultipartUpload ( initRequest ) . getUploadId ( ) ; return ; } catch ( AmazonClientException e ) { lastException = e ; } } while ( mRetryPolicy . attempt ( ) ) ; throw new IOException ( "Unable to init multipart upload to " + mKey , lastException ) ; }
Initializes multipart upload .
11,998
private void initNewFile ( ) throws IOException { mFile = new File ( PathUtils . concatPath ( CommonUtils . getTmpDir ( mTmpDirs ) , UUID . randomUUID ( ) ) ) ; if ( mHash != null ) { mLocalOutputStream = new BufferedOutputStream ( new DigestOutputStream ( new FileOutputStream ( mFile ) , mHash ) ) ; } else { mLocalOutputStream = new BufferedOutputStream ( new FileOutputStream ( mFile ) ) ; } mPartitionOffset = 0 ; LOG . debug ( "Init new temp file @ {}" , mFile . getPath ( ) ) ; }
Creates a new temp file to write to .
11,999
private void uploadPart ( ) throws IOException { if ( mFile == null ) { return ; } mLocalOutputStream . close ( ) ; int partNumber = mPartNumber . getAndIncrement ( ) ; File newFileToUpload = new File ( mFile . getPath ( ) ) ; mFile = null ; mLocalOutputStream = null ; UploadPartRequest uploadRequest = new UploadPartRequest ( ) . withBucketName ( mBucketName ) . withKey ( mKey ) . withUploadId ( mUploadId ) . withPartNumber ( partNumber ) . withFile ( newFileToUpload ) . withPartSize ( newFileToUpload . length ( ) ) ; execUpload ( uploadRequest ) ; }
Uploads part async .