TODO: this method is oldddddd, needs to be ported into BasicBWT AND reworked to do this better
        @param k - the length of the k-mers to profile
        @param profileCsvFN - the filename of the csv to create
199120
def createKmerProfile(self, k, profileCsvFN):
        '''
        
        '''
        searches = [('', 0, self.bwt.shape[0])]
        normTotal = 0
        lines = []
        while len(searches) > 0:
            (seq, start, end) = searches.pop(0)
            
            if len(seq) == k:
                lines.append(seq+','+str(end-start))
                normTotal += (end-start)**2
            else:
                nls = self.getFullFMAtIndex(start)
                nhs = self.getFullFMAtIndex(end)
                for c in xrange(self.vcLen-1, -1, -1):
                    if nls[c] == nhs[c]:
                        #do nothing
                        pass
                    else:
                        newSeq = self.numToChar[c]+seq
                        searches.insert(0, (newSeq, int(nls[c]), int(nhs[c])))
        
        fp = open(profileCsvFN, 'w+')
        fp.write('total,'+str(math.sqrt(normTotal))+'\n')
        for l in sorted(lines):
            fp.write(l+'\n')
        fp.close()
1112754
public SortedMap<Variable, Integer> variableProfile(final BDD bdd) {
    final int[] varProfile = this.kernel.varProfile(bdd.index());
    final SortedMap<Variable, Integer> profile = new TreeMap<>();
    for (int i = 0; i < varProfile.length; i++) {
      profile.put(this.idx2var.get(i), varProfile[i]);
    }
    return profile;
  }
992866
private static byte[] writeCsv(String[] columnHeaders, String[][] rows) throws IOException {
    try (ByteArrayOutputStream csvStream = new ByteArrayOutputStream(); OutputStreamWriter streamWriter = new OutputStreamWriter(csvStream, Charset.forName("UTF-8"))) {
      CSVWriter csvWriter = new CSVWriter(streamWriter, ',');

      csvWriter.writeNext(columnHeaders);
      
      for (String[] row : rows) {
        csvWriter.writeNext(row);
      }

      csvWriter.close();
      
      return csvStream.toByteArray();
    }
  }
561575
public Vec close(int rowLayout, Futures fs) {
    // Compute #chunks
    int nchunk = _tmp_espc.length;
    DKV.remove(chunkKey(nchunk),fs); // remove potential trailing key
    while( nchunk > 1 && _tmp_espc[nchunk-1] == 0 ) {
      nchunk--;
      DKV.remove(chunkKey(nchunk),fs); // remove potential trailing key
    }

    // Replacement plain Vec for AppendableVec.
    Vec vec = new Vec(_key, rowLayout, domain(), _type);
    DKV.put(_key,vec,fs);       // Inject the header into the K/V store
    return vec;
  }
1037393
public static void writeCSVColumns(XYSeries series, String path2Dir) {

    File newFile = new File(path2Dir + series.getName() + ".csv");
    Writer out = null;
    try {

      out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile), "UTF8"));
      double[] xData = series.getXData();
      double[] yData = series.getYData();
      double[] errorBarData = series.getExtraValues();
      for (int i = 0; i < xData.length; i++) {

        StringBuilder sb = new StringBuilder();
        sb.append(xData[i]).append(",");
        sb.append(yData[i]).append(",");
        if (errorBarData != null) {
          sb.append(errorBarData[i]).append(",");
        }
        sb.setLength(sb.length() - 1);
        sb.append(System.getProperty("line.separator"));

        // String csv = xDataPoint + "," + yDataPoint + errorBarValue == null ? "" : ("," +
        // errorBarValue) + System.getProperty("line.separator");
        // String csv = + yDataPoint + System.getProperty("line.separator");
        out.write(sb.toString());
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (out != null) {
        try {
          out.flush();
          out.close();
        } catch (IOException e) {
          // NOP
        }
      }
    }
  }
604270
@SuppressWarnings("rawtypes")
    public static <E extends Exception> DataSet loadCSV(final InputStream csvInputStream, final long offset, final long count,
            final Try.Predicate<String[], E> filter, final List<? extends Type> columnTypeList) throws E {
        final Reader csvReader = new InputStreamReader(csvInputStream);

        return loadCSV(csvReader, offset, count, filter, columnTypeList);
    }
191230
public SuperCsvValidationException.Builder createValidationException(final CsvContext context) {
        
        String message = getValidationMessage();
        if(Utils.isEmpty(message)) {
            message = getDefaultValidationMessage();
        }
        
        return new SuperCsvValidationException.Builder(context, this)
                .validationMessage(message);
    }
311296
public Profile add(String profileName) throws Exception {
        Profile profile = new Profile();
        int id = -1;
        PreparedStatement statement = null;
        ResultSet results = null;

        try (Connection sqlConnection = sqlService.getConnection()) {
            Clob clobProfileName = sqlService.toClob(profileName, sqlConnection);

            statement = sqlConnection.prepareStatement(
                "INSERT INTO " + Constants.DB_TABLE_PROFILE
                    + "(" + Constants.PROFILE_PROFILE_NAME + ") " +
                    " VALUES (?)", PreparedStatement.RETURN_GENERATED_KEYS
            );

            statement.setClob(1, clobProfileName);
            statement.executeUpdate();
            results = statement.getGeneratedKeys();
            if (results.next()) {
                id = results.getInt(1);
            } else {
                // something went wrong
                throw new Exception("Could not add client");
            }
            results.close();
            statement.close();

            statement = sqlConnection.prepareStatement("INSERT INTO " + Constants.DB_TABLE_CLIENT +
                                                           "(" + Constants.CLIENT_CLIENT_UUID + "," + Constants.CLIENT_IS_ACTIVE + ","
                                                           + Constants.CLIENT_PROFILE_ID + ") " +
                                                           " VALUES (?, ?, ?)");
            statement.setString(1, Constants.PROFILE_CLIENT_DEFAULT_ID);
            statement.setBoolean(2, false);
            statement.setInt(3, id);
            statement.executeUpdate();

            profile.setName(profileName);
            profile.setId(id);
        } catch (SQLException e) {
            throw e;
        } finally {
            try {
                if (results != null) {
                    results.close();
                }
            } catch (Exception e) {
            }
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }

        return profile;
    }
1211963
public static final void chkBMTFromXML(List<ContainerTransaction> tranAttrList, EnterpriseBean enterpriseBean, J2EEName j2eeName)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "chkBMTFromXML");

        if (tranAttrList != null && enterpriseBean != null) {
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "tranAttrList non-null");

            // Elements of highestStyleOnMethod[] are initialized to zero by Java rules.

            // i : TranAttrList loop
            // j : MethodElements loop

            for (int i = 0; i < tranAttrList.size(); ++i) {
                ContainerTransaction methodTransaction = tranAttrList.get(i);
                List<com.ibm.ws.javaee.dd.ejb.Method> methodElements = methodTransaction.getMethodElements();
                for (int j = 0; j < methodElements.size(); ++j) {
                    com.ibm.ws.javaee.dd.ejb.Method me = methodElements.get(j);
                    if (isTraceOn && tc.isDebugEnabled()) {
                        trace(me, me.getInterfaceTypeValue() == com.ibm.ws.javaee.dd.ejb.Method.INTERFACE_TYPE_UNSPECIFIED ?
                                        "Interface type unspecified" :
                                        "Interface type: " + me.getInterfaceTypeValue());
                    }
                    if (enterpriseBean.getName().equals(me.getEnterpriseBeanName())) {

                        Tr.warning(tc, "BMT_DEFINES_CMT_ATTRIBUTES_CNTR0067W", new Object[] { j2eeName });

                    } // enterpriseBean name matches parm in methodExtension
                } // methodElements loop (j)
            } // tranAttrList loop (i)

        } // tranAttrList != nullcd

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "chkBMTFromXML");

        return;
    }
704336
function _createKDF(kdf, md, counterStart, digestLength) {
  /**
   * Generate a key of the specified length.
   *
   * @param x the binary-encoded byte string to generate a key from.
   * @param length the number of bytes to generate (the size of the key).
   *
   * @return the key as a binary-encoded string.
   */
  kdf.generate = function(x, length) {
    var key = new forge.util.ByteBuffer();

    // run counter from counterStart to ceil(length / Hash.len)
    var k = Math.ceil(length / digestLength) + counterStart;

    var c = new forge.util.ByteBuffer();
    for(var i = counterStart; i < k; ++i) {
      // I2OSP(i, 4): convert counter to an octet string of 4 octets
      c.putInt32(i);

      // digest 'x' and the counter and add the result to the key
      md.start();
      md.update(x + c.getBytes());
      var hash = md.digest();
      key.putBytes(hash.getBytes(digestLength));
    }

    // truncate to the correct key length
    key.truncate(key.length() - length);
    return key.getBytes();
  };
}
1110149
private static Cell convertKv(Cell kv, Map<byte[], byte[]> cfRenameMap) {
    if(cfRenameMap != null) {
      // If there's a rename mapping for this CF, create a new KeyValue
      byte[] newCfName = cfRenameMap.get(CellUtil.cloneFamily(kv));
      if(newCfName != null) {
          kv = new KeyValue(kv.getRowArray(), // row buffer 
                  kv.getRowOffset(),        // row offset
                  kv.getRowLength(),        // row length
                  newCfName,                // CF buffer
                  0,                        // CF offset 
                  newCfName.length,         // CF length 
                  kv.getQualifierArray(),   // qualifier buffer
                  kv.getQualifierOffset(),  // qualifier offset
                  kv.getQualifierLength(),  // qualifier length
                  kv.getTimestamp(),        // timestamp
                  KeyValue.Type.codeToType(kv.getTypeByte()), // KV Type
                  kv.getValueArray(),       // value buffer 
                  kv.getValueOffset(),      // value offset
                  kv.getValueLength());     // value length
      }
    }
    return kv;
  }
511542
public ApplyProfile createDefaultProfile(String profileType) throws RuntimeFault, RemoteException {
        return createDefaultProfile(profileType, null, null);
    }
1306246
@SuppressWarnings("rawtypes")
    public static long importCSV(final File file, final Connection conn, final String insertSQL, final Map<String, ? extends Type> columnTypeMap)
            throws UncheckedSQLException, UncheckedIOException {
        return importCSV(file, 0, Long.MAX_VALUE, conn, insertSQL, 200, 0, columnTypeMap);
    }
923009
public static KSMetaData fromSchema(Row serializedKs, Row serializedCFs, Row serializedUserTypes)
    {
        Map<String, CFMetaData> cfs = deserializeColumnFamilies(serializedCFs);
        UTMetaData userTypes = new UTMetaData(UTMetaData.fromSchema(serializedUserTypes));
        return fromSchema(serializedKs, cfs.values(), userTypes);
    }
681900
public ColumnFamilyType getColumnFamilyType(String ksName, String cfName)
    {
        assert ksName != null && cfName != null;
        CFMetaData cfMetaData = getCFMetaData(ksName, cfName);
        return (cfMetaData == null) ? null : cfMetaData.cfType;
    }
609466
public void initCf(UUID cfId, String cfName, boolean loadSSTables)
    {
        ColumnFamilyStore cfs = columnFamilyStores.get(cfId);

        if (cfs == null)
        {
            // CFS being created for the first time, either on server startup or new CF being added.
            // We don't worry about races here; startup is safe, and adding multiple idential CFs
            // simultaneously is a "don't do that" scenario.
            ColumnFamilyStore oldCfs = columnFamilyStores.putIfAbsent(cfId, ColumnFamilyStore.createColumnFamilyStore(this, cfName, loadSSTables));
            // CFS mbean instantiation will error out before we hit this, but in case that changes...
            if (oldCfs != null)
                throw new IllegalStateException("added multiple mappings for cf id " + cfId);
        }
        else
        {
            // re-initializing an existing CF.  This will happen if you cleared the schema
            // on this node and it's getting repopulated from the rest of the cluster.
            assert cfs.name.equals(cfName);
            cfs.metadata.reload();
            cfs.reload();
        }
    }
688215
public static long importCSV(final File file, final Connection conn, final String insertSQL,
            final Try.BiConsumer<? super PreparedStatement, ? super String[], SQLException> stmtSetter) throws UncheckedSQLException, UncheckedIOException {
        return importCSV(file, 0, Long.MAX_VALUE, conn, insertSQL, 200, 0, stmtSetter);
    }