opendap/src/main/java/ucar/nc2/dods/DODSNetcdfFile.java
@Override
  public List<Array> readArrays(List<Variable> preloadVariables) throws IOException
  {
    //For performance tests:
    //if (true) return super.readArrays (variables);
    if (preloadVariables.size() == 0) return new ArrayList<Array>();

    // construct the list of variables, skipping ones with cached data
    List<DodsV> reqDodsVlist = new ArrayList<DodsV>();
    DodsV root;
    for (Variable var : preloadVariables) {
      if (var.hasCachedData()) continue;
      reqDodsVlist.add((DodsV) var.getSPobject());
    }
    Collections.sort(reqDodsVlist); // "depth first" order

    // read the data
    DataDDS dataDDS;
    Map<DodsV, DodsV> map = new HashMap<DodsV, DodsV>(2 * reqDodsVlist.size() + 1);
    if (reqDodsVlist.size() > 0) {

      // Create the request
      StringBuilder requestString = new StringBuilder();
      for (int i = 0; i < reqDodsVlist.size(); i++) {
        DodsV dodsV = reqDodsVlist.get(i);
        requestString.append(i == 0 ? "?" : ",");
        // requestString.append(makeDODSname(dodsV));
        requestString.append(dodsV.getEncodedName());
      }
      String s = requestString.toString();

      try {
        dataDDS = readDataDDSfromServer(requestString.toString());
        root = DodsV.parseDataDDS(dataDDS);

      } catch (Exception exc) {
        logger.error("ERROR readDataDDSfromServer on " + requestString, exc);
        throw new IOException(exc.getMessage());
      }

      // gotta find the corresponding data in "depth first" order
      for (DodsV ddsV : reqDodsVlist) {
        DodsV dataV = root.findDataV(ddsV);
        if (dataV != null) {
          if (debugConvertData) System.out.println("readArray found dataV= " + makeDODSname(ddsV));
          dataV.isDone = true;
          map.put(ddsV, dataV); // thread safe!
        } else {
          logger.error("ERROR findDataV cant find " + makeDODSname(ddsV) + " on " + location);
        }
      }
    }

    // For each variable either extract the data or use cached data.
    List<Array> result = new ArrayList<Array>();
    for (Variable var : preloadVariables) {
      if (var.hasCachedData()) {
        result.add(var.read());

      } else {
        Array data = null;
        DodsV ddsV = (DodsV) var.getSPobject();

        DodsV dataV = map.get(ddsV);
        if (dataV == null) {
          logger.error("DODSNetcdfFile.readArrays cant find " + makeDODSname(ddsV) + " in dataDDS; " + location);
          //dataDDS.print( System.out);
        } else {
          if (debugConvertData) System.out.println("readArray converting " + makeDODSname(ddsV));
          dataV.isDone = true;

          try {
            if (var.isMemberOfStructure()) {

              // we want the top structure this variable is contained in.
              while ((dataV.parent != null) && (dataV.parent.bt != null)) {
                dataV = dataV.parent;
              }
              data = convertD2N.convertNestedVariable(var, null, dataV, true);

            } else
              data = convertD2N.convertTopVariable(var, null, dataV);

          } catch (DAP2Exception de) {
            logger.error("ERROR convertVariable on " + var.getFullName(), de);
            throw new IOException(de.getMessage());
          }

          if (var.isCaching()) {
            var.setCachedData(data);
            if (debugCached)
              System.out.println(" cache for <" + var.getFullName() + "> length =" + data.getSize());
          }
        }
        result.add(data);
      }
    }
    return result;
  }
@Override
  public List<Array> readArrays(List<Variable> preloadVariables) throws IOException
  {
    //For performance tests:
    //if (true) return super.readArrays (variables);
    if (preloadVariables.size() == 0) return new ArrayList<Array>();

    // construct the list of variables, skipping ones with cached data
    List<DodsV> reqDodsVlist = new ArrayList<DodsV>();
    DodsV root;
    for (Variable var : preloadVariables) {
      if (var.hasCachedData()) continue;
      reqDodsVlist.add((DodsV) var.getSPobject());
    }
    Collections.sort(reqDodsVlist); // "depth first" order

    // read the data
    DataDDS dataDDS;
    Map<DodsV, DodsV> map = new HashMap<DodsV, DodsV>(2 * reqDodsVlist.size() + 1);
    if (reqDodsVlist.size() > 0) {

      // Create the request
      StringBuilder requestString = new StringBuilder();
      for (int i = 0; i < reqDodsVlist.size(); i++) {
        DodsV dodsV = reqDodsVlist.get(i);
        requestString.append(i == 0 ? "?" : ",");
        // requestString.append(makeDODSname(dodsV));
        requestString.append(dodsV.getEncodedName());
      }
      String s = requestString.toString();

      try {
        dataDDS = readDataDDSfromServer(requestString.toString());
        root = DodsV.parseDataDDS(dataDDS);

      } catch (Exception exc) {
        logger.error("ERROR readDataDDSfromServer on " + requestString, exc);
        throw new IOException(exc.getMessage());
      }

      // gotta find the corresponding data in "depth first" order
      for (DodsV ddsV : reqDodsVlist) {
        DodsV dataV = root.findDataV(ddsV);
        if (dataV != null) {
          if (debugConvertData) System.out.println("readArray found dataV= " + makeDODSname(ddsV));
          dataV.isDone = true;
          map.put(ddsV, dataV); // thread safe!
        } else {
          logger.error("ERROR findDataV cant find " + makeDODSname(ddsV) + " on " + location);
        }
      }
    }

    // For each variable either extract the data or use cached data.
    List<Array> result = new ArrayList<Array>();
    for (Variable var : preloadVariables) {
      if (var.hasCachedData()) {
        result.add(var.read());

      } else {
        Array data = null;
        DodsV ddsV = (DodsV) var.getSPobject();

        DodsV dataV = map.get(ddsV);
        if (dataV == null) {
          logger.error("DODSNetcdfFile.readArrays cant find " + makeDODSname(ddsV) + " in dataDDS; " + location);
          //dataDDS.print( System.out);
        } else {
          if (debugConvertData) System.out.println("readArray converting " + makeDODSname(ddsV));
          dataV.isDone = true;

          try {
            if (var.isMemberOfStructure()) {

              // we want the top structure this variable is contained in.
              while ((dataV.parent != null) && (dataV.parent.bt != null)) {
                dataV = dataV.parent;
              }
              data = convertD2N.convertNestedVariable(var, null, dataV, true);

            } else
              data = convertD2N.convertTopVariable(var, null, dataV);

          } catch (DAP2Exception de) {
            logger.error("ERROR convertVariable on " + var.getFullName(), de);
            throw new IOException(de.getMessage());
          }

          if (var.isCaching()) {
            var.setCachedData(data);
            if (debugCached)
              System.out.println(" cache for <" + var.getFullName() + "> length =" + data.getSize());
          }
        }
        result.add(data);
      }
    }
    return result;
  }
@ Override public List < Array > readArrays ( List < Variable > preloadVariables ) throws IOException { //For performance tests: //if (true) return super.readArrays (variables); if ( preloadVariables . size ( ) == 0 ) return new ArrayList < Array > ( ) ; // construct the list of variables, skipping ones with cached data List < DodsV > reqDodsVlist = new ArrayList < DodsV > ( ) ; DodsV root ; for ( Variable var : preloadVariables ) { if ( var . hasCachedData ( ) ) continue ; reqDodsVlist . add ( ( DodsV ) var . getSPobject ( ) ) ; } Collections . sort ( reqDodsVlist ) ; // "depth first" order // read the data DataDDS dataDDS ; Map < DodsV , DodsV > map = new HashMap < DodsV , DodsV > ( 2 * reqDodsVlist . size ( ) + 1 ) ; if ( reqDodsVlist . size ( ) > 0 ) { // Create the request StringBuilder requestString = new StringBuilder ( ) ; for ( int i = 0 ; i < reqDodsVlist . size ( ) ; i ++ ) { DodsV dodsV = reqDodsVlist . get ( i ) ; requestString . append ( i == 0 ? "?" : "," ) ; // requestString.append(makeDODSname(dodsV)); requestString . append ( dodsV . getEncodedName ( ) ) ; } String s = requestString . toString ( ) ; try { dataDDS = readDataDDSfromServer ( requestString . toString ( ) ) ; root = DodsV . parseDataDDS ( dataDDS ) ; } catch ( Exception exc ) { logger . error ( "ERROR readDataDDSfromServer on " + requestString , exc ) ; throw new IOException ( exc . getMessage ( ) ) ; } // gotta find the corresponding data in "depth first" order for ( DodsV ddsV : reqDodsVlist ) { DodsV dataV = root . findDataV ( ddsV ) ; if ( dataV != null ) { if ( debugConvertData ) System . out . println ( "readArray found dataV= " + makeDODSname ( ddsV ) ) ; dataV . isDone = true ; map . put ( ddsV , dataV ) ; // thread safe! } else { logger . error ( "ERROR findDataV cant find " + makeDODSname ( ddsV ) + " on " + location ) ; } } } // For each variable either extract the data or use cached data. List < Array > result = new ArrayList < Array > ( ) ; for ( Variable var : preloadVariables ) { if ( var . hasCachedData ( ) ) { result . add ( var . read ( ) ) ; } else { Array data = null ; DodsV ddsV = ( DodsV ) var . getSPobject ( ) ; DodsV dataV = map . get ( ddsV ) ; if ( dataV == null ) { logger . error ( "DODSNetcdfFile.readArrays cant find " + makeDODSname ( ddsV ) + " in dataDDS; " + location ) ; //dataDDS.print( System.out); } else { if ( debugConvertData ) System . out . println ( "readArray converting " + makeDODSname ( ddsV ) ) ; dataV . isDone = true ; try { if ( var . isMemberOfStructure ( ) ) { // we want the top structure this variable is contained in. while ( ( dataV . parent != null ) && ( dataV . parent . bt != null ) ) { dataV = dataV . parent ; } data = convertD2N . convertNestedVariable ( var , null , dataV , true ) ; } else data = convertD2N . convertTopVariable ( var , null , dataV ) ; } catch ( DAP2Exception de ) { logger . error ( "ERROR convertVariable on " + var . getFullName ( ) , de ) ; throw new IOException ( de . getMessage ( ) ) ; } if ( var . isCaching ( ) ) { var . setCachedData ( data ) ; if ( debugCached ) System . out . println ( " cache for <" + var . getFullName ( ) + "> length =" + data . getSize ( ) ) ; } } result . add ( data ) ; } } return result ; }
Make a single call to the DODS Server to read all the named variable's data
in one client/server roundtrip.

@param preloadVariables list of type Variable
@return list of type Array, contains the data
@throws IOException on error
Make a single call to the DODS Server to read all the named variable s data in one client / server roundtrip .