idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
14,500 | static public List < String > interpretPath ( String path ) throws Exception { if ( null == path ) { throw new Exception ( "path parameter should not be null" ) ; } if ( path . codePointAt ( 0 ) == ' ' ) { throw new Exception ( "absolute path is not acceptable" ) ; } // Verify path List < String > pathFragments = new V... | Utility method used to convert a path into its effective segments . | 193 | 13 |
14,501 | protected List < I > rankItems ( final Map < I , Double > userItems ) { List < I > sortedItems = new ArrayList <> ( ) ; if ( userItems == null ) { return sortedItems ; } Map < Double , Set < I > > itemsByRank = new HashMap <> ( ) ; for ( Map . Entry < I , Double > e : userItems . entrySet ( ) ) { I item = e . getKey ( ... | Ranks the set of items by associated score . | 315 | 10 |
14,502 | protected List < Double > rankScores ( final Map < I , Double > userItems ) { List < Double > sortedScores = new ArrayList <> ( ) ; if ( userItems == null ) { return sortedScores ; } for ( Map . Entry < I , Double > e : userItems . entrySet ( ) ) { double pref = e . getValue ( ) ; if ( Double . isNaN ( pref ) ) { // we... | Ranks the scores of an item - score map . | 137 | 11 |
14,503 | public static void runLenskitRecommenders ( final Set < String > paths , final Properties properties ) { for ( AbstractRunner < Long , Long > rec : instantiateLenskitRecommenders ( paths , properties ) ) { RecommendationRunner . run ( rec ) ; } } | Runs the Lenskit recommenders . | 56 | 8 |
14,504 | public static void runMahoutRecommenders ( final Set < String > paths , final Properties properties ) { for ( AbstractRunner < Long , Long > rec : instantiateMahoutRecommenders ( paths , properties ) ) { RecommendationRunner . run ( rec ) ; } } | Runs Mahout - based recommenders . | 56 | 9 |
14,505 | public static void runRanksysRecommenders ( final Set < String > paths , final Properties properties ) { for ( AbstractRunner < Long , Long > rec : instantiateRanksysRecommenders ( paths , properties ) ) { RecommendationRunner . run ( rec ) ; } } | Runs Ranksys - based recommenders . | 58 | 10 |
14,506 | public static void listAllFiles ( final Set < String > setOfPaths , final String inputPath ) { if ( inputPath == null ) { return ; } File [ ] files = new File ( inputPath ) . listFiles ( ) ; if ( files == null ) { return ; } for ( File file : files ) { if ( file . isDirectory ( ) ) { listAllFiles ( setOfPaths , file . ... | List all files at a certain path . | 151 | 8 |
14,507 | @ Override public double getValueAt ( final U user , final int at ) { if ( userRecallAtCutoff . containsKey ( at ) && userRecallAtCutoff . get ( at ) . containsKey ( user ) ) { return userRecallAtCutoff . get ( at ) . get ( user ) / userTotalRecall . get ( user ) ; } return Double . NaN ; } | Method to return the recall value at a particular cutoff level for a given user . | 88 | 16 |
14,508 | public static void getAllRecommendationFiles ( final Set < String > recommendationFiles , final File path , final String prefix , final String suffix ) { if ( path == null ) { return ; } File [ ] files = path . listFiles ( ) ; if ( files == null ) { return ; } for ( File file : files ) { if ( file . isDirectory ( ) ) {... | Get all recommendation files . | 145 | 5 |
14,509 | @ Override public void compute ( ) { if ( ! Double . isNaN ( getValue ( ) ) ) { // since the data cannot change, avoid re-doing the calculations return ; } iniCompute ( ) ; Map < U , List < Double > > data = processDataAsPredictedDifferencesToTest ( ) ; int testItems = 0 ; for ( U testUser : getTest ( ) . getUsers ( ) ... | Instantiates and computes the RMSE value . Prior to running this there is no valid value . | 258 | 21 |
14,510 | @ Override public TemporalDataModelIF < Long , Long > run ( final RUN_OPTIONS opts ) throws RecommenderException , TasteException , IOException { if ( isAlreadyRecommended ( ) ) { return null ; } DataModel trainingModel = new FileDataModel ( new File ( getProperties ( ) . getProperty ( RecommendationRunner . TRAINING_S... | Runs the recommender using models from file . | 135 | 10 |
14,511 | public void split ( final String inFile , final String outPath , boolean perUser , long seed , String delimiter , boolean isTemporalData ) { try { if ( delimiter == null ) delimiter = this . delimiter ; DataModelIF < Long , Long > [ ] splits = new CrossValidationSplitter < Long , Long > ( this . numFolds , perUser , se... | Load a dataset and stores the splits generated from it . | 415 | 11 |
14,512 | public void recommend ( final String inPath , final String outPath ) throws IOException , TasteException { for ( int i = 0 ; i < this . numFolds ; i ++ ) { org . apache . mahout . cf . taste . model . DataModel trainModel ; org . apache . mahout . cf . taste . model . DataModel testModel ; trainModel = new FileDataMode... | Make predictions . | 546 | 3 |
14,513 | public void buildEvaluationModels ( final String splitPath , final String predictionsPath , final String outPath ) { for ( int i = 0 ; i < this . numFolds ; i ++ ) { File trainingFile = new File ( Paths . get ( splitPath , "train_" + i + FILE_EXT ) . toString ( ) ) ; File testFile = new File ( Paths . get ( splitPath ,... | Prepare the strategy models using prediction files . | 661 | 9 |
14,514 | @ Override public Double getUserItemPreference ( U u , I i ) { if ( userItemPreferences . containsKey ( u ) && userItemPreferences . get ( u ) . containsKey ( i ) ) { return userItemPreferences . get ( u ) . get ( i ) ; } return Double . NaN ; } | Method that returns the preference between a user and an item . | 72 | 12 |
14,515 | @ Override public Iterable < I > getUserItems ( U u ) { if ( userItemPreferences . containsKey ( u ) ) { return userItemPreferences . get ( u ) . keySet ( ) ; } return Collections . emptySet ( ) ; } | Method that returns the items of a user . | 57 | 9 |
14,516 | @ Override public void addPreference ( final U u , final I i , final Double d ) { // update direct map Map < I , Double > userPreferences = userItemPreferences . get ( u ) ; if ( userPreferences == null ) { userPreferences = new HashMap <> ( ) ; userItemPreferences . put ( u , userPreferences ) ; } Double preference = ... | Method that adds a preference to the model between a user and an item . | 176 | 15 |
14,517 | public static void writeData ( final long user , final List < Preference < Long , Long > > recommendations , final String path , final String fileName , final boolean append , final TemporalDataModelIF < Long , Long > model ) { BufferedWriter out = null ; try { File dir = null ; if ( path != null ) { dir = new File ( p... | Write recommendations to file . | 369 | 5 |
14,518 | public static void main ( final String [ ] args ) throws Exception { String propertyFile = System . getProperty ( "propertyFile" ) ; final Properties properties = new Properties ( ) ; try { properties . load ( new FileInputStream ( propertyFile ) ) ; } catch ( IOException ie ) { ie . printStackTrace ( ) ; } run ( prope... | Main method for running a single evaluation metric . | 78 | 9 |
14,519 | @ SuppressWarnings ( "unchecked" ) public static void run ( final Properties properties ) throws IOException , ClassNotFoundException , IllegalAccessException , InstantiationException , InvocationTargetException , NoSuchMethodException { System . out . println ( "Parsing started: recommendation file" ) ; File recommend... | Runs a single evaluation metric . | 539 | 7 |
14,520 | @ SuppressWarnings ( "unchecked" ) public static < U , I > void generateOutput ( final DataModelIF < U , I > testModel , final int [ ] rankingCutoffs , final EvaluationMetric < U > metric , final String metricName , final Boolean perUser , final File resultsFile , final Boolean overwrite , final Boolean append ) throws... | Generates the output of the evaluation . | 434 | 8 |
14,521 | public static void run ( final Properties properties ) throws IOException , ClassNotFoundException , IllegalAccessException , InstantiationException , InvocationTargetException , NoSuchMethodException { // read splits System . out . println ( "Parsing started: training file" ) ; File trainingFile = new File ( propertie... | Process the property file and runs the specified strategies on some data . | 645 | 13 |
14,522 | public static void generateOutput ( final DataModelIF < Long , Long > testModel , final File userRecommendationFile , final EvaluationStrategy < Long , Long > strategy , final EvaluationStrategy . OUTPUT_FORMAT format , final File rankingFile , final File groundtruthFile , final Boolean overwrite ) throws IOException {... | Runs a particular strategy on some data using pre - computed recommendations and outputs the result into a file . | 422 | 21 |
14,523 | public double getPValue ( final String method ) { double p = Double . NaN ; if ( "t" . equals ( method ) ) { double [ ] baselineValues = new double [ baselineMetricPerDimension . values ( ) . size ( ) ] ; int i = 0 ; for ( Double d : baselineMetricPerDimension . values ( ) ) { baselineValues [ i ] = d ; i ++ ; } double... | Gets the p - value according to the requested method . | 352 | 12 |
14,524 | @ Override public void compute ( ) { if ( ! Double . isNaN ( getValue ( ) ) ) { // since the data cannot change, avoid re-doing the calculations return ; } iniCompute ( ) ; Map < U , List < Pair < I , Double > > > data = processDataAsRankedTestRelevance ( ) ; userDcgAtCutoff = new HashMap < Integer , Map < U , Double >... | Computes the global NDCG by first summing the NDCG for each user and then averaging by the number of users . | 592 | 27 |
14,525 | protected double computeDCG ( final double rel , final int rank ) { double dcg = 0.0 ; if ( rel >= getRelevanceThreshold ( ) ) { switch ( type ) { default : case EXP : dcg = ( Math . pow ( 2.0 , rel ) - 1.0 ) / ( Math . log ( rank + 1 ) / Math . log ( 2 ) ) ; break ; case LIN : dcg = rel ; if ( rank > 1 ) { dcg /= ( Ma... | Method that computes the discounted cumulative gain of a specific item taking into account its ranking in a user s list and its relevance value . | 164 | 27 |
14,526 | @ Override public double getValueAt ( final int at ) { if ( userDcgAtCutoff . containsKey ( at ) && userIdcgAtCutoff . containsKey ( at ) ) { int n = 0 ; double ndcg = 0.0 ; for ( U u : userIdcgAtCutoff . get ( at ) . keySet ( ) ) { double udcg = getValueAt ( u , at ) ; if ( ! Double . isNaN ( udcg ) ) { ndcg += udcg ;... | Method to return the NDCG value at a particular cutoff level . | 167 | 14 |
14,527 | @ Override public double getValueAt ( final U user , final int at ) { if ( userDcgAtCutoff . containsKey ( at ) && userDcgAtCutoff . get ( at ) . containsKey ( user ) && userIdcgAtCutoff . containsKey ( at ) && userIdcgAtCutoff . get ( at ) . containsKey ( user ) ) { double idcg = userIdcgAtCutoff . get ( at ) . get ( ... | Method to return the NDCG value at a particular cutoff level for a given user . | 148 | 18 |
14,528 | public Recommender buildRecommender ( final DataModel dataModel , final String recType ) throws RecommenderException { return buildRecommender ( dataModel , recType , null , DEFAULT_N , NOFACTORS , NOITER , null ) ; } | CF recommender with default parameters . | 54 | 7 |
14,529 | public TemporalDataModelIF < Long , Long > parseData ( final File f , final String token , final boolean isTemporal ) throws IOException { TemporalDataModelIF < Long , Long > dataset = DataModelFactory . getDefaultTemporalModel ( ) ; BufferedReader br = SimpleParser . getBufferedReader ( f ) ; String line = br . readLi... | Parses a data file with a specific separator between fields . | 168 | 14 |
14,530 | public void download ( ) { URL dataURL = null ; String fileName = folder + "/" + url . substring ( url . lastIndexOf ( "/" ) + 1 ) ; if ( new File ( fileName ) . exists ( ) ) { return ; } try { dataURL = new URL ( url ) ; } catch ( MalformedURLException e ) { e . printStackTrace ( ) ; } File downloadedData = new File (... | Downloads the file from the provided url . | 143 | 9 |
14,531 | public void downloadAndUnzip ( ) { URL dataURL = null ; String fileName = folder + "/" + url . substring ( url . lastIndexOf ( "/" ) + 1 ) ; File compressedData = new File ( fileName ) ; if ( ! new File ( fileName ) . exists ( ) ) { try { dataURL = new URL ( url ) ; } catch ( MalformedURLException e ) { e . printStackT... | Downloads the file from the provided url and uncompresses it to the given folder . | 209 | 17 |
14,532 | public static void recommend ( final int nFolds , final String inPath , final String outPath ) { for ( int i = 0 ; i < nFolds ; i ++ ) { org . apache . mahout . cf . taste . model . DataModel trainModel ; org . apache . mahout . cf . taste . model . DataModel testModel ; try { trainModel = new FileDataModel ( new File ... | Recommends using an UB algorithm . | 507 | 8 |
14,533 | public static void evaluate ( final int nFolds , final String splitPath , final String recPath ) { double ndcgRes = 0.0 ; double precisionRes = 0.0 ; double rmseRes = 0.0 ; for ( int i = 0 ; i < nFolds ; i ++ ) { File testFile = new File ( splitPath + "test_" + i + ".csv" ) ; File recFile = new File ( recPath + "recs_"... | Evaluates the recommendations generated in previous steps . | 415 | 10 |
14,534 | public static void run ( final Properties properties ) throws IOException { // read parameters for output (do this at the beginning to avoid unnecessary reading) File outputFile = new File ( properties . getProperty ( OUTPUT_FILE ) ) ; Boolean overwrite = Boolean . parseBoolean ( properties . getProperty ( OUTPUT_OVERW... | Run all the statistic functions included in the properties mapping . | 523 | 11 |
14,535 | public static void readLine ( final String format , final String line , final Map < String , Map < String , Double > > mapMetricUserValue , final Set < String > usersToAvoid ) { String [ ] toks = line . split ( "\t" ) ; // default (also trec_eval) format: metric \t user|all \t value if ( format . equals ( "default" ) )... | Read a line from the metric file . | 211 | 8 |
14,536 | public static void run ( final Properties properties ) throws IOException , ClassNotFoundException , IllegalAccessException , InstantiationException , InvocationTargetException , NoSuchMethodException { // read splits System . out . println ( "Parsing started: training file" ) ; File trainingFile = new File ( propertie... | Runs a single evaluation strategy . | 555 | 7 |
14,537 | public static EvaluationStrategy < Long , Long > instantiateStrategy ( final Properties properties , final DataModelIF < Long , Long > trainingModel , final DataModelIF < Long , Long > testModel ) throws ClassNotFoundException , IllegalAccessException , InstantiationException , InvocationTargetException , NoSuchMethodE... | Instantiates an strategy according to the provided properties mapping . | 320 | 12 |
14,538 | public static TemporalDataModelIF < Long , Long > run ( final Properties properties ) throws ClassNotFoundException , IllegalAccessException , InstantiationException , InvocationTargetException , NoSuchMethodException , IOException { System . out . println ( "Parsing started" ) ; TemporalDataModelIF < Long , Long > mod... | Run the parser based on given properties . | 317 | 8 |
14,539 | protected Set < Long > getModelTrainingDifference ( final DataModelIF < Long , Long > model , final Long user ) { final Set < Long > items = new HashSet < Long > ( ) ; if ( training . getUserItems ( user ) != null ) { final Set < Long > trainingItems = new HashSet <> ( ) ; for ( Long i : training . getUserItems ( user ... | Get the items appearing in the training set and not in the data model . | 136 | 15 |
14,540 | protected void printRanking ( final String user , final Map < Long , Double > scoredItems , final PrintStream out , final OUTPUT_FORMAT format ) { final Map < Double , Set < Long > > preferenceMap = new HashMap < Double , Set < Long > > ( ) ; for ( Map . Entry < Long , Double > e : scoredItems . entrySet ( ) ) { long i... | Print the item ranking and scores for a specific user . | 333 | 11 |
14,541 | public static < U , I > void saveDataModel ( final DataModelIF < U , I > dm , final String outfile , final boolean overwrite , final String delimiter ) throws FileNotFoundException , UnsupportedEncodingException { if ( new File ( outfile ) . exists ( ) && ! overwrite ) { System . out . println ( "Ignoring " + outfile )... | Method that saves a data model to a file . | 177 | 10 |
14,542 | public static < U , I > void saveDataModel ( final TemporalDataModelIF < U , I > dm , final String outfile , final boolean overwrite , String delimiter ) throws FileNotFoundException , UnsupportedEncodingException { if ( new File ( outfile ) . exists ( ) && ! overwrite ) { System . out . println ( "Ignoring " + outfile... | Method that saves a temporal data model to a file . | 249 | 11 |
14,543 | public void setFileName ( ) { String type = "" ; // lenskit does not provide a factorizer class. This check is to actually see if it's a Mahout or Lenskit SVD. if ( properties . containsKey ( RecommendationRunner . FACTORIZER ) || properties . containsKey ( RecommendationRunner . SIMILARITY ) ) { if ( properties . cont... | Create the file name of the output file . | 410 | 9 |
14,544 | @ SuppressWarnings ( "unchecked" ) public static void prepareStrategy ( final String splitPath , final String recPath , final String outPath ) { int i = 0 ; File trainingFile = new File ( splitPath + "train_" + i + ".csv" ) ; File testFile = new File ( splitPath + "test_" + i + ".csv" ) ; File recFile = new File ( recP... | Prepares the strategies to be evaluated with the recommenders already generated . | 531 | 14 |
14,545 | public static < U , I > void run ( final Properties properties , final TemporalDataModelIF < U , I > data , final boolean doDataClear ) throws FileNotFoundException , UnsupportedEncodingException { System . out . println ( "Start splitting" ) ; TemporalDataModelIF < U , I > [ ] splits ; // read parameters String output... | Runs a Splitter instance based on the properties . | 453 | 11 |
14,546 | public static < U , I > Splitter < U , I > instantiateSplitter ( final Properties properties ) { // read parameters String splitterClassName = properties . getProperty ( DATASET_SPLITTER ) ; Boolean perUser = Boolean . parseBoolean ( properties . getProperty ( SPLIT_PERUSER ) ) ; Boolean doSplitPerItems = Boolean . par... | Instantiates a splitter based on the properties . | 475 | 11 |
14,547 | @ Override public Iterable < Long > getUserItemTimestamps ( U u , I i ) { if ( userItemTimestamps . containsKey ( u ) && userItemTimestamps . get ( u ) . containsKey ( i ) ) { return userItemTimestamps . get ( u ) . get ( i ) ; } return null ; } | Method that returns the map with the timestamps between users and items . | 77 | 15 |
14,548 | @ Override public void addTimestamp ( final U u , final I i , final Long t ) { Map < I , Set < Long > > userTimestamps = userItemTimestamps . get ( u ) ; if ( userTimestamps == null ) { userTimestamps = new HashMap <> ( ) ; userItemTimestamps . put ( u , userTimestamps ) ; } Set < Long > timestamps = userTimestamps . g... | Method that adds a timestamp to the model between a user and an item . | 151 | 15 |
14,549 | public static void readLine ( final String line , final Map < Long , List < Pair < Long , Double > > > mapUserRecommendations ) { String [ ] toks = line . split ( "\t" ) ; // mymedialite format: user \t [item:score,item:score,...] if ( line . contains ( ":" ) && line . contains ( "," ) ) { Long user = Long . parseLong ... | Read a file from the recommended items file . | 397 | 9 |
14,550 | protected double getNumberOfRelevantItems ( final U user ) { int n = 0 ; if ( getTest ( ) . getUserItems ( user ) != null ) { for ( I i : getTest ( ) . getUserItems ( user ) ) { if ( getTest ( ) . getUserItemPreference ( user , i ) >= relevanceThreshold ) { n ++ ; } } } return n * 1.0 ; } | Method that computes the number of relevant items in the test set for a user . | 91 | 17 |
14,551 | @ Override public double getValueAt ( final int at ) { if ( userPrecAtCutoff . containsKey ( at ) ) { int n = 0 ; double prec = 0.0 ; for ( U u : userPrecAtCutoff . get ( at ) . keySet ( ) ) { double uprec = getValueAt ( u , at ) ; if ( ! Double . isNaN ( uprec ) ) { prec += uprec ; n ++ ; } } if ( n == 0 ) { prec = 0.... | Method to return the precision value at a particular cutoff level . | 136 | 12 |
14,552 | public static double considerEstimatedPreference ( final ErrorStrategy errorStrategy , final double recValue ) { boolean consider = true ; double v = recValue ; switch ( errorStrategy ) { default : case CONSIDER_EVERYTHING : break ; case NOT_CONSIDER_NAN : consider = ! Double . isNaN ( recValue ) ; break ; case CONSIDE... | Method that returns an estimated preference according to a given value and an error strategy . | 198 | 16 |
14,553 | @ Override public double getValueAt ( final int at ) { if ( userMAPAtCutoff . containsKey ( at ) ) { int n = 0 ; double map = 0.0 ; for ( U u : userMAPAtCutoff . get ( at ) . keySet ( ) ) { double uMAP = getValueAt ( u , at ) ; if ( ! Double . isNaN ( uMAP ) ) { map += uMAP ; n ++ ; } } if ( n == 0 ) { map = 0.0 ; } el... | Method to return the MAP value at a particular cutoff level . | 134 | 12 |
14,554 | @ SuppressWarnings ( "unchecked" ) public static void run ( final Properties properties ) throws IOException , ClassNotFoundException , IllegalAccessException , InstantiationException , InvocationTargetException , NoSuchMethodException { EvaluationStrategy . OUTPUT_FORMAT recFormat ; if ( properties . getProperty ( PRE... | Runs multiple evaluation metrics . | 662 | 6 |
14,555 | public static void getAllPredictionFiles ( final Set < String > predictionFiles , final File path , final String predictionPrefix ) { if ( path == null ) { return ; } File [ ] files = path . listFiles ( ) ; if ( files == null ) { return ; } for ( File file : files ) { if ( file . isDirectory ( ) ) { getAllPredictionFil... | Gets all prediction files . | 142 | 6 |
14,556 | public static void main ( final String [ ] args ) { String propertyFile = System . getProperty ( "file" ) ; if ( propertyFile == null ) { System . out . println ( "Property file not given, exiting." ) ; System . exit ( 0 ) ; } final Properties properties = new Properties ( ) ; try { properties . load ( new FileInputStr... | Main method for running a recommendation . | 126 | 7 |
14,557 | public static void run ( final AbstractRunner rr ) { time = System . currentTimeMillis ( ) ; boolean statsExist = false ; statPath = rr . getCanonicalFileName ( ) ; statsExist = rr . isAlreadyRecommended ( ) ; try { rr . run ( AbstractRunner . RUN_OPTIONS . OUTPUT_RECS ) ; } catch ( Exception e ) { e . printStackTrace ... | Run recommendations based on an already instantiated recommender . | 134 | 11 |
14,558 | public static AbstractRunner < Long , Long > instantiateRecommender ( final Properties properties ) { if ( properties . getProperty ( RECOMMENDER ) == null ) { System . out . println ( "No recommenderClass specified, exiting." ) ; return null ; } if ( properties . getProperty ( TRAINING_SET ) == null ) { System . out .... | Instantiates a recommender according to the provided properties mapping . | 256 | 13 |
14,559 | public static void writeStats ( final String path , final String statLabel , final long stat ) { BufferedWriter out = null ; try { out = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( path , true ) , "UTF-8" ) ) ; out . write ( statLabel + "\t" + stat + "\n" ) ; out . flush ( ) ; out . close ( ) ;... | Write the system stats to file . | 145 | 7 |
14,560 | public static boolean areEqual ( byte [ ] array1 , byte [ ] array2 ) { if ( array1 . length != array2 . length ) return false ; for ( int i = 0 ; i < array1 . length ; ++ i ) if ( array1 [ i ] != array2 [ i ] ) return false ; return true ; } | Compares two byte arrays element by element | 73 | 8 |
14,561 | public static boolean isZero ( byte [ ] bytes ) { int x = 0 ; for ( int i = 0 ; i < bytes . length ; i ++ ) { x |= bytes [ i ] ; } return x == 0 ; } | Checks whether a byte array just contains elements equal to zero | 49 | 12 |
14,562 | public Position decodePosition ( double time , SurfacePositionV0Msg msg ) { if ( last_pos == null ) return null ; return decodePosition ( time , msg , last_pos ) ; } | Shortcut for using the last known position for reference ; no reasonableness check on distance to receiver | 41 | 20 |
14,563 | public Position decodePosition ( SurfacePositionV0Msg msg , Position reference ) { return decodePosition ( System . currentTimeMillis ( ) / 1000.0 , msg , reference ) ; } | Shortcut for live decoding ; no reasonableness check on distance to receiver | 39 | 15 |
14,564 | public Position decodePosition ( double time , Position receiver , SurfacePositionV0Msg msg , Position reference ) { Position ret = decodePosition ( time , msg , reference ) ; if ( ret != null && receiver != null && ! withinReasonableRange ( receiver , ret ) ) { ret . setReasonable ( false ) ; num_reasonable = 0 ; } re... | Performs all reasonableness tests . | 77 | 8 |
14,565 | public void gc ( ) { List < Integer > toRemove = new ArrayList < Integer > ( ) ; for ( Integer transponder : decoderData . keySet ( ) ) if ( decoderData . get ( transponder ) . posDec . getLastUsedTime ( ) < latestTimestamp - 3600000 ) toRemove . add ( transponder ) ; for ( Integer transponder : toRemove ) decoderData ... | Clean state by removing decoders not used for more than an hour . This happens automatically every 1 Mio messages if more than 50000 aircraft are tracked . | 101 | 32 |
14,566 | private static int grayToBin ( int gray , int bitlength ) { int result = 0 ; for ( int i = bitlength - 1 ; i >= 0 ; -- i ) result = result | ( ( ( ( 0x1 << ( i + 1 ) ) & result ) >>> 1 ) ^ ( ( 1 << i ) & gray ) ) ; return result ; } | This method converts a gray code encoded int to a standard decimal int | 78 | 13 |
14,567 | private static char [ ] mapChar ( byte [ ] digits ) { char [ ] result = new char [ digits . length ] ; for ( int i = 0 ; i < digits . length ; i ++ ) result [ i ] = mapChar ( digits [ i ] ) ; return result ; } | Maps ADS - B encoded to readable characters | 61 | 8 |
14,568 | public double [ ] toECEF ( ) { double lon0r = toRadians ( this . longitude ) ; double lat0r = toRadians ( this . latitude ) ; double height = tools . feet2Meters ( altitude ) ; double v = a / Math . sqrt ( 1 - e2 * Math . sin ( lat0r ) * Math . sin ( lat0r ) ) ; return new double [ ] { ( v + height ) * Math . cos ( lat... | Converts the WGS84 position to cartesian coordinates | 173 | 11 |
14,569 | public static Position fromECEF ( double x , double y , double z ) { double p = sqrt ( x * x + y * y ) ; double th = atan2 ( a * z , b * p ) ; double lon = atan2 ( y , x ) ; double lat = atan2 ( ( z + ( a * a - b * b ) / ( b * b ) * b * pow ( sin ( th ) , 3 ) ) , p - e2 * a * pow ( cos ( th ) , 3 ) ) ; double N = a / s... | Converts a cartesian earth - centered earth - fixed coordinate into an WGS84 LLA position | 253 | 20 |
14,570 | public Double distance3d ( Position other ) { if ( other == null || latitude == null || longitude == null || altitude == null ) return null ; double [ ] xyz1 = this . toECEF ( ) ; double [ ] xyz2 = other . toECEF ( ) ; return Math . sqrt ( Math . pow ( xyz2 [ 0 ] - xyz1 [ 0 ] , 2 ) + Math . pow ( xyz2 [ 1 ] - xyz1 [ 1 ... | Calculate the three - dimensional distance between this and another position . This method assumes that the coordinates are WGS84 . | 133 | 25 |
14,571 | public PagedResult < AutomationRule > listAutomationRules ( long sheetId , PaginationParameters pagination ) throws SmartsheetException { String path = "sheets/" + sheetId + "/automationrules" ; HashMap < String , Object > parameters = new HashMap < String , Object > ( ) ; if ( pagination != null ) { parameters = pagin... | Get all automation rules for this sheet | 120 | 7 |
14,572 | public AutomationRule updateAutomationRule ( long sheetId , AutomationRule automationRule ) throws SmartsheetException { Util . throwIfNull ( automationRule ) ; return this . updateResource ( "sheets/" + sheetId + "/automationrules/" + automationRule . getId ( ) , AutomationRule . class , automationRule ) ; } | Updates an automation rule . | 75 | 6 |
14,573 | public String newAuthorizationURL ( EnumSet < AccessScope > scopes , String state ) { Util . throwIfNull ( scopes ) ; if ( state == null ) { state = "" ; } // Build a map of parameters for the URL HashMap < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( "response_type" , "code" ) ; para... | Generate a new authorization URL . | 215 | 7 |
14,574 | public Token obtainNewToken ( AuthorizationResult authorizationResult ) throws OAuthTokenException , JSONSerializerException , HttpClientException , URISyntaxException , InvalidRequestException { if ( authorizationResult == null ) { throw new IllegalArgumentException ( ) ; } // Prepare the hash String doHash = clientSe... | Obtain a new token using AuthorizationResult . | 375 | 9 |
14,575 | public Token refreshToken ( Token token ) throws OAuthTokenException , JSONSerializerException , HttpClientException , URISyntaxException , InvalidRequestException { // Prepare the hash String doHash = clientSecret + "|" + token . getRefreshToken ( ) ; MessageDigest md ; try { md = MessageDigest . getInstance ( "SHA-25... | Refresh token . | 357 | 4 |
14,576 | private Token requestToken ( String url ) throws OAuthTokenException , JSONSerializerException , HttpClientException , URISyntaxException , InvalidRequestException { // Create the request and send it to get the response/token. HttpRequest request = new HttpRequest ( ) ; request . setUri ( new URI ( url ) ) ; request . ... | Request a token . | 659 | 4 |
14,577 | public void revokeAccessToken ( Token token ) throws OAuthTokenException , JSONSerializerException , HttpClientException , URISyntaxException , InvalidRequestException { HttpRequest request = new HttpRequest ( ) ; request . setUri ( new URI ( tokenURL ) ) ; request . setMethod ( HttpMethod . DELETE ) ; request . setHea... | Revoke access token . | 185 | 5 |
14,578 | public Discussion createDiscussion ( long sheetId , long rowId , Discussion discussion ) throws SmartsheetException { return this . createResource ( "sheets/" + sheetId + "/rows/" + rowId + "/discussions" , Discussion . class , discussion ) ; } | Create discussion on a row . | 55 | 6 |
14,579 | public PagedResult < Discussion > listDiscussions ( long sheetId , long rowId , PaginationParameters pagination , EnumSet < DiscussionInclusion > includes ) throws SmartsheetException { String path = "sheets/" + sheetId + "/rows/" + rowId + "/discussions" ; HashMap < String , Object > parameters = new HashMap < String ... | Gets a list of all Discussions associated with the specified Row . | 158 | 14 |
14,580 | public < T > String serialize ( T object ) throws JSONSerializerException { Util . throwIfNull ( object ) ; String value ; try { value = OBJECT_MAPPER . writeValueAsString ( object ) ; } catch ( JsonGenerationException e ) { throw new JSONSerializerException ( e ) ; } catch ( JsonMappingException e ) { throw new JSONSe... | Serialize an object to JSON . | 113 | 7 |
14,581 | @ Override public CopyOrMoveRowResult deserializeCopyOrMoveRow ( java . io . InputStream inputStream ) throws JSONSerializerException { Util . throwIfNull ( inputStream ) ; CopyOrMoveRowResult rw = null ; try { // Read the json input stream into a List. rw = OBJECT_MAPPER . readValue ( inputStream , CopyOrMoveRowResult... | De - serialize to a CopyOrMoveRowResult object from JSON | 155 | 14 |
14,582 | public PagedResult < UpdateRequest > listUpdateRequests ( long sheetId , PaginationParameters paging ) throws SmartsheetException { String path = "sheets/" + sheetId + "/updaterequests" ; HashMap < String , Object > parameters = new HashMap < String , Object > ( ) ; if ( paging != null ) { parameters = paging . toHashM... | Gets a list of all Update Requests that have future schedules associated with the specified Sheet . | 117 | 19 |
14,583 | public UpdateRequest updateUpdateRequest ( long sheetId , UpdateRequest updateRequest ) throws SmartsheetException { return this . updateResource ( "sheets/" + sheetId + "/updaterequests/" + updateRequest . getId ( ) , UpdateRequest . class , updateRequest ) ; } | Changes the specified Update Request for the Sheet . | 59 | 9 |
14,584 | public PagedResult < SentUpdateRequest > listSentUpdateRequests ( long sheetId , PaginationParameters paging ) throws SmartsheetException { String path = "sheets/" + sheetId + "/sentupdaterequests" ; HashMap < String , Object > parameters = new HashMap < String , Object > ( ) ; if ( paging != null ) { parameters = pagi... | Gets a list of all Sent Update Requests that have future schedules associated with the specified Sheet . | 121 | 20 |
14,585 | public PagedResult < Attachment > listAllVersions ( long sheetId , long attachmentId , PaginationParameters parameters ) throws SmartsheetException { String path = "sheets/" + sheetId + "/attachments/" + attachmentId + "/versions" ; if ( parameters != null ) { path += parameters . toQueryString ( ) ; } return this . li... | Get all versions of an attachment . | 89 | 7 |
14,586 | private Attachment attachNewVersion ( long sheetId , long attachmentId , InputStream inputStream , String contentType , long contentLength , String attachmentName ) throws SmartsheetException { return super . attachFile ( "sheets/" + sheetId + "/attachments/" + attachmentId + "/versions" , inputStream , contentType , c... | Attach a new version of an attachment . | 77 | 8 |
14,587 | public PagedResult < User > listUsers ( Set < String > email , PaginationParameters pagination ) throws SmartsheetException { String path = "users" ; HashMap < String , Object > parameters = new HashMap < String , Object > ( ) ; if ( pagination != null ) { parameters = pagination . toHashMap ( ) ; } parameters . put ( ... | List all users . | 130 | 4 |
14,588 | public User addUser ( User user , boolean sendEmail ) throws SmartsheetException { return this . createResource ( "users?sendEmail=" + sendEmail , User . class , user ) ; } | Add a user to the organization without sending email . | 42 | 10 |
14,589 | public PagedResult < AlternateEmail > listAlternateEmails ( long userId , PaginationParameters pagination ) throws SmartsheetException { String path = "users/" + userId + "/alternateemails" ; if ( pagination != null ) { path += pagination . toQueryString ( ) ; } return this . listResourcesWithWrapper ( path , Alternate... | List all user alternate emails . | 85 | 6 |
14,590 | public List < AlternateEmail > addAlternateEmail ( long userId , List < AlternateEmail > altEmails ) throws SmartsheetException { Util . throwIfNull ( altEmails ) ; if ( altEmails . size ( ) == 0 ) { return altEmails ; } return this . postAndReceiveList ( "users/" + userId + "/alternateemails" , altEmails , AlternateEm... | Add an alternate email . | 95 | 5 |
14,591 | public AlternateEmail promoteAlternateEmail ( long userId , long altEmailId ) throws SmartsheetException { HttpRequest request = createHttpRequest ( smartsheet . getBaseURI ( ) . resolve ( "users/" + userId + "/alternateemails/" + altEmailId + "/makeprimary" ) , HttpMethod . POST ) ; Object obj = null ; try { HttpRespo... | Promote and alternate email to primary . | 191 | 8 |
14,592 | public User addProfileImage ( long userId , String file , String fileType ) throws SmartsheetException , FileNotFoundException { return attachProfileImage ( "users/" + userId + "/profileimage" , file , fileType ) ; } | Uploads a profile image for the specified user . | 52 | 10 |
14,593 | public Attachment attachFile ( long sheetId , long commentId , File file , String contentType ) throws FileNotFoundException , SmartsheetException { Util . throwIfNull ( sheetId , commentId , file , contentType ) ; Util . throwIfEmpty ( contentType ) ; return attachFile ( sheetId , commentId , new FileInputStream ( fil... | Attach a file to a comment with simple upload . | 98 | 10 |
14,594 | public void setMaxRetryTimeMillis ( long maxRetryTimeMillis ) { if ( this . httpClient instanceof DefaultHttpClient ) { ( ( DefaultHttpClient ) this . httpClient ) . setMaxRetryTimeMillis ( maxRetryTimeMillis ) ; } else throw new UnsupportedOperationException ( "Invalid operation for class " + this . httpClient . getCl... | Sets the max retry time if the HttpClient is an instance of DefaultHttpClient | 88 | 19 |
14,595 | public void setTracePrettyPrint ( boolean pretty ) { if ( this . httpClient instanceof DefaultHttpClient ) { ( ( DefaultHttpClient ) this . httpClient ) . setTracePrettyPrint ( pretty ) ; } else throw new UnsupportedOperationException ( "Invalid operation for class " + this . httpClient . getClass ( ) ) ; } | set whether or not to generate pretty formatted JSON in trace - logging | 74 | 13 |
14,596 | public HomeResources homeResources ( ) { if ( home . get ( ) == null ) { home . compareAndSet ( null , new HomeResourcesImpl ( this ) ) ; } return home . get ( ) ; } | Returns the HomeResources instance that provides access to Home resources . | 45 | 12 |
14,597 | public WorkspaceResources workspaceResources ( ) { if ( workspaces . get ( ) == null ) { workspaces . compareAndSet ( null , new WorkspaceResourcesImpl ( this ) ) ; } return workspaces . get ( ) ; } | Returns the WorkspaceResources instance that provides access to Workspace resources . | 50 | 14 |
14,598 | public FolderResources folderResources ( ) { if ( folders . get ( ) == null ) { folders . compareAndSet ( null , new FolderResourcesImpl ( this ) ) ; } return folders . get ( ) ; } | Returns the FolderResources instance that provides access to Folder resources . | 45 | 12 |
14,599 | public TemplateResources templateResources ( ) { if ( templates . get ( ) == null ) { templates . compareAndSet ( null , new TemplateResourcesImpl ( this ) ) ; } return templates . get ( ) ; } | Returns the TemplateResources instance that provides access to Template resources . | 45 | 12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.