Java Code Examples for org.apache.commons.lang.StringUtils#splitPreserveAllTokens()

The following examples show how to use org.apache.commons.lang.StringUtils#splitPreserveAllTokens() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static List<String> readDoubleTextDataRowNames(String fileName, char delimiter) throws IOException {
	if (!(fileName.endsWith(".txt") || fileName.endsWith(".txt.gz")  || fileName.endsWith(".tsv.bgz") || fileName.endsWith(".tsv") || fileName.endsWith(".tsv.gz") || fileName.endsWith(".gct") || fileName.endsWith(".gct.gz"))) {
		throw new IllegalArgumentException("File type must be \".txt\", \".tsv\" or \".txt.gz\" when delimiter is set. \n Input filename: " + fileName);
	}

	//Pattern splitPatern = Pattern.compile(delimiter);
	TextFile in = new TextFile(fileName, TextFile.R);
	String str = in.readLine(); // header
	String[] data = StringUtils.splitPreserveAllTokens(str, delimiter);

	ArrayList<String> rowNames = new ArrayList<>();

	while ((str = in.readLine()) != null) {
		data = StringUtils.splitPreserveAllTokens(str, delimiter);
		rowNames.add(data[0]);
	}

	return rowNames;

}
 
Example 2
@Override
public Event apply(List<Map.Entry<Key, Value>> entries) {
    EventBuilder toReturn = null;

    for (Map.Entry<Key, Value> attributeCol : entries) {
        String[] splits = splitPreserveAllTokens(new String(attributeCol.getValue().get()), NULL_BYTE);
        String cq = attributeCol.getKey().getColumnQualifier().toString();
        String[] cqParts = StringUtils.splitPreserveAllTokens(cq, ONE_BYTE);
        int idx = cq.lastIndexOf(ONE_BYTE);
        if (toReturn == null)
            toReturn = EventBuilder.create(cqParts[1], cqParts[2], encoder.decode(cqParts[0]));
        String vis = splits[3];
        toReturn.attr(new Attribute(splits[0], typeRegistry.decode(splits[1], splits[2]), setVisibility(new HashMap<String,String>(1), vis)));
    }

    return toReturn.build();
}
 
Example 3
/** {@inheritDoc} */
@Override
public void execute(final MutableShoppingCart shoppingCart, final Map<String, Object> parameters) {
    if (parameters.containsKey(getCmdKey())) {
        final String values = (String) parameters.get(getCmdKey());
        if (values == null) {
            shoppingCart.getOrderInfo().setDetails(null);
            markDirty(shoppingCart);
        } else {
            final String[] keyAndValues = StringUtils.split(values, '|');
            if (keyAndValues != null) {
                boolean modified = false;
                for (final String keyAndValueRaw : keyAndValues) {
                    final String[] keyAndValue = StringUtils.splitPreserveAllTokens(keyAndValueRaw, ":", 2);
                    if (keyAndValue != null && keyAndValue.length == 2) {
                        shoppingCart.getOrderInfo().putDetail(keyAndValue[0], keyAndValue[1]);
                        modified = true;
                    }
                }
                if (modified) {
                    markDirty(shoppingCart);
                }
            }
        }
    }
}
 
Example 4
Source Project: incubator-tajo   File: TestBytes.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSplitProjectionBytes() {
  String text = "abcde|12345|ABCDE";
  int[] target = new int[]{ 1 };
  char separatorChar = '|';

  String[] textArray = StringUtils.splitPreserveAllTokens(text, separatorChar);
  byte[][] bytesArray =  Bytes.splitPreserveAllTokens(text.getBytes(), separatorChar, target);

  assertEquals(textArray.length, bytesArray.length);

  assertNull(bytesArray[0]);
  assertNotNull(bytesArray[1]);
  assertArrayEquals(textArray[1].getBytes(), bytesArray[1]);
  assertNull(bytesArray[2]);
}
 
Example 5
public static List<String> readDoubleTextDataColNames(String fileName, char delimiter) throws IOException {
	if (!(fileName.endsWith(".txt") || fileName.endsWith(".txt.gz")  || fileName.endsWith(".tsv.bgz") || fileName.endsWith(".tsv") || fileName.endsWith(".tsv.gz") || fileName.endsWith(".gct") || fileName.endsWith(".gct.gz"))) {
		throw new IllegalArgumentException("File type must be \".txt\", \".tsv\" or \".txt.gz\" when delimiter is set. \n Input filename: " + fileName);
	}

	//Pattern splitPatern = Pattern.compile(delimiter);
	int columnOffset = 1;

	TextFile in = new TextFile(fileName, TextFile.R);
	String str = in.readLine(); // header
	String[] data = StringUtils.splitPreserveAllTokens(str, delimiter);

	int tmpCols = (data.length - columnOffset);

	ArrayList<String> colNames = new ArrayList<>(tmpCols);

	for (int s = 0; s < tmpCols; s++) {
		String colName = data[s + columnOffset];
		colNames.add(colName);
	}

	return colNames;

}
 
Example 6
Source Project: hiped2   File: Node.java    License: Apache License 2.0 6 votes vote down vote up
public static Node fromMR(String value) throws IOException {
  String[] parts = StringUtils.splitPreserveAllTokens(
      value, fieldSeparator);
  if (parts.length < 2) {
    throw new IOException(
        "Expected 2 or more parts but received " + parts.length);
  }
  Node node = new Node()
      .setDistance(Integer.valueOf(parts[0]))
      .setBackpointer(StringUtils.trimToNull(parts[1]));
  if (parts.length > 2) {
    node.setAdjacentNodeNames(Arrays.copyOfRange(parts, 2,
        parts.length));
  }
  return node;
}
 
Example 7
Source Project: sofa-jraft   File: PeerId.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Parse peerId from string that generated by {@link #toString()}
 * This method can support parameter string values are below:
 *
 * <pre>
 * PeerId.parse("a:b")          = new PeerId("a", "b", 0 , -1)
 * PeerId.parse("a:b:c")        = new PeerId("a", "b", "c", -1)
 * PeerId.parse("a:b::d")       = new PeerId("a", "b", 0, "d")
 * PeerId.parse("a:b:c:d")      = new PeerId("a", "b", "c", "d")
 * </pre>
 *
 */
public boolean parse(final String s) {
    if (StringUtils.isEmpty(s)) {
        return false;
    }

    final String[] tmps = StringUtils.splitPreserveAllTokens(s, ':');
    if (tmps.length < 2 || tmps.length > 4) {
        return false;
    }
    try {
        final int port = Integer.parseInt(tmps[1]);
        this.endpoint = new Endpoint(tmps[0], port);

        switch (tmps.length) {
            case 3:
                this.idx = Integer.parseInt(tmps[2]);
                break;
            case 4:
                if (tmps[2].equals("")) {
                    this.idx = 0;
                } else {
                    this.idx = Integer.parseInt(tmps[2]);
                }
                this.priority = Integer.parseInt(tmps[3]);
                break;
            default:
                break;
        }
        this.str = null;
        return true;
    } catch (final Exception e) {
        LOG.error("Parse peer from string failed: {}.", s, e);
        return false;
    }
}
 
Example 8
Source Project: flowmix   File: AbstractAggregator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param configuration
 */
@Override
public void configure(Map<String, String> configuration) {
    if (configuration.get(GROUP_BY) != null) {
        groupByFields = StringUtils.splitPreserveAllTokens(configuration.get(GROUP_BY), GROUP_BY_DELIM);
    }
    if (configuration.get(OUTPUT_FIELD) != null) {
        outputField = configuration.get(OUTPUT_FIELD);
    }
    if (configuration.get(OPERATED_FIELD) != null) {
        operatedField = configuration.get(OPERATED_FIELD);
    } else {
        throw new RuntimeException("Aggregator needs a field to operate it. Property missing: " + OPERATED_FIELD);
    }
}
 
Example 9
Source Project: flowmix   File: LongSumAggregator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Map<String, String> configuration) {

  if(configuration.get(GROUP_BY) != null)
    groupByFields = StringUtils.splitPreserveAllTokens(configuration.get(GROUP_BY), GROUP_BY_DELIM);

  if(configuration.get(OUTPUT_FIELD) != null)
    outputField = configuration.get(OUTPUT_FIELD);

  if(configuration.get(SUM_FIELD) != null)
    sumField = configuration.get(SUM_FIELD);
  else
    throw new RuntimeException("Sum aggregator needs a field to sum. Property missing: " + SUM_FIELD);

}
 
Example 10
Source Project: tajo   File: SQLErrorListener.java    License: Apache License 2.0 5 votes vote down vote up
public void syntaxError(Recognizer<?, ?> recognizer,
                        Object offendingSymbol,
                        int line, int charPositionInLine,
                        String msg,
                        RecognitionException e) {
  CommonTokenStream tokens = (CommonTokenStream) recognizer.getInputStream();
  String input = tokens.getTokenSource().getInputStream().toString();
  Token token = (Token) offendingSymbol;
  String[] lines = StringUtils.splitPreserveAllTokens(input, '\n');
  String errorLine = lines[line - 1];

  String simpleMessage = "syntax error at or near \"" + token.getText() + "\"";
  throw new SQLParseError(token, line, charPositionInLine, simpleMessage, errorLine);
}
 
Example 11
Source Project: incubator-tajo   File: SQLErrorListener.java    License: Apache License 2.0 5 votes vote down vote up
public void syntaxError(Recognizer<?, ?> recognizer,
                        Object offendingSymbol,
                        int line, int charPositionInLine,
                        String msg,
                        RecognitionException e) {
  CommonTokenStream tokens = (CommonTokenStream) recognizer.getInputStream();
  String input = tokens.getTokenSource().getInputStream().toString();
  Token token = (Token) offendingSymbol;
  String[] lines = StringUtils.splitPreserveAllTokens(input, '\n');
  String errorLine = lines[line - 1];

  throw new SQLParseError(token, line, charPositionInLine, msg, errorLine);
}
 
Example 12
Source Project: incubator-tajo   File: TestBytes.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSplitBytes() {
  String text = "abcde|12345|ABCDE";
  char separatorChar = '|';

  String[] textArray = StringUtils.splitPreserveAllTokens(text, separatorChar);
  byte[][] bytesArray =  Bytes.splitPreserveAllTokens(text.getBytes(), separatorChar);

  assertEquals(textArray.length, bytesArray.length);
  for (int i = 0; i < textArray.length; i++){
    assertArrayEquals(textArray[i].getBytes(), bytesArray[i]);
  }
}
 
Example 13
/**
 * Splits the line based on the given delimiter and parses into properties
 * @see org.kuali.kfs.sys.batch.FlatFileSpecification#parseLineIntoObject(FlatFilePrefixObjectSpecification, String, Object)
 */
@Override
public void parseLineIntoObject(FlatFileObjectSpecification parseSpecification, String lineToParse, Object parseIntoObject, int lineNumber) {
    String[] lineSegments = StringUtils.splitPreserveAllTokens(lineToParse, delimiter);
    for (FlatFilePropertySpecification propertySpecification : parseSpecification.getParseProperties()) {
        try {
            propertySpecification.setProperty(lineSegments[((DelimitedFlatFilePropertySpecification) propertySpecification).getLineSegmentIndex()], parseIntoObject, lineNumber);
        }
        catch (ArrayIndexOutOfBoundsException e) {
            LOG.debug("Unable to set property " + propertySpecification.getPropertyName() + " since lineSegmentIndex does not exist for line");
        }
    }
}
 
Example 14
Source Project: hiped2   File: Node.java    License: Apache License 2.0 5 votes vote down vote up
public static Node fromMR(String value) throws IOException {
  String[] parts = StringUtils.splitPreserveAllTokens(
      value, fieldSeparator);
  if (parts.length < 1) {
    throw new IOException(
        "Expected 1 or more parts but received " + parts.length);
  }
  Node node = new Node()
      .setPageRank(Double.valueOf(parts[0]));
  if (parts.length > 1) {
    node.setAdjacentNodeNames(Arrays.copyOfRange(parts, 1,
        parts.length));
  }
  return node;
}
 
Example 15
Source Project: datawave   File: EdgeKeyDecoder.java    License: Apache License 2.0 4 votes vote down vote up
public EdgeKey decode(Key key, EdgeKey.EdgeKeyBuilder builder) {
    key.getColumnFamily(textCf);
    
    builder.setFormat(determineEdgeFormat(textCf));
    
    // Parse row for type and source/sink information
    
    final String row = key.getRow(textRow).toString();
    
    // the previous code threw an exception when there was no row key, so
    // we should maintain that same
    if (row.isEmpty())
        throw new IllegalStateException("Invalid row identifier");
    
    int nullPos = row.indexOf('\0');
    
    if (nullPos < 0 && log.isTraceEnabled()) {
        log.trace("No null character found");
    }
    
    /**
     * determine if we are dealing with a stats edge
     */
    boolean statsEdge = builder.getFormat() == EDGE_FORMAT.STATS;
    
    /**
     * If we have a stats edge or an invalid row key, we will assign the row to the source and null to the sink.
     */
    String source = (statsEdge || nullPos <= 0) ? row : row.substring(0, nullPos);
    String sink = (statsEdge || nullPos <= 0) ? null : row.substring(nullPos + 1);
    
    if (log.isTraceEnabled()) {
        log.trace("Source is " + source + " sink is " + sink);
    }
    switch (builder.getFormat()) {
        case STANDARD:
            builder.setSourceData(source);
            builder.setSinkData(sink);
            break;
        case STATS:
            builder.setSourceData(source);
            break;
    }
    
    byte[] colQual = key.getColumnQualifier(textCq).getBytes();
    
    // Parse colf and colq as one big list, decoding with EDGE_VERSION logic
    EdgeColumnParts parts = new EdgeColumnParts(textCf, textCq);
    
    EDGE_VERSION version = EDGE_VERSION.getEdgeVersion(parts);
    
    builder.setType(parts.get(version.getTypeIndex()));
    builder.setYyyymmdd(parts.get(version.getYMDIndex()));
    if (version.getFormat() == EDGE_FORMAT.STATS) {
        builder.setStatsType(version.getStatsType(parts));
        builder.setSourceRelationship(parts.get(version.getRelationshipIndex()));
        builder.setSourceAttribute1(parts.get(version.getCategoryIndex()));
    } else {
        String[] subPieces = StringUtils.splitPreserveAllTokens(parts.get(version.getRelationshipIndex()), COL_SUB_SEPARATOR);
        builder.setSourceRelationship(subPieces[0]);
        builder.setSinkRelationship(subPieces[1]);
        subPieces = StringUtils.splitPreserveAllTokens(parts.get(version.getCategoryIndex()), COL_SUB_SEPARATOR);
        builder.setSourceAttribute1(subPieces[0]);
        builder.setSinkAttribute1(subPieces[1]);
    }
    
    if (version.hasAttribute2()) {
        builder.setAttribute2(parts.get(version.getAttribute2Index()));
    }
    if (version.hasAttribute3()) {
        builder.setAttribute3(parts.get(version.getAttribute3Index()));
    }
    if (version.getDateTypeIndex() >= 0) {
        builder.setDateType(DATE_TYPE.parse(parts.get(version.getDateTypeIndex())));
    }
    
    // set the rest
    builder.setColvis(key.getColumnVisibility(textCv));
    builder.setDeleted(key.isDeleted());
    builder.setTimestamp(key.getTimestamp());
    
    return builder.build();
}
 
Example 16
Source Project: yes-cart   File: SearchUtil.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Tokenize search phrase and clean from empty strings.
 *
 * @param phrase optional phrase
 * @param charThreshold character threshold for single words. e.g. if set to 3 will skip words less than 3 characters
 *
 * @return list of tokens, that found in phrase.
 */
public static List<String> splitForSearch(final String phrase, final int charThreshold) {
    if (phrase != null) {
        String [] token = StringUtils.splitPreserveAllTokens(phrase, "| ;/\\");
        List<String> words = new ArrayList<>(token.length);
        for (final String aToken : token) {
            if (StringUtils.isNotBlank(aToken)) {
                String clean = aToken.trim();
                if (clean.length() >= charThreshold) {
                    // remove tailing punctuation
                    int pos = clean.length() - 1;
                    for (; pos >= 0; pos--) {
                        char last = clean.charAt(pos);
                        if (last != ',' && last != '.' && last != '!' && last != '?' && last != ')' && last != '}' && last != ']') {
                            break;
                        }
                    }
                    if (pos < clean.length() - 1) {
                        clean = clean.substring(0, pos + 1);
                    }
                    // remove leading punctuation
                    pos = 0;
                    for (; pos < clean.length(); pos++) {
                        char first = clean.charAt(pos);
                        if (first != '(' && first != '{' && first != '[') {
                            break;
                        }
                    }
                    if (pos > 0) {
                        clean = clean.substring(pos);
                    }

                    if (clean.length() >= charThreshold) {
                        // look for words separates by dash
                        pos = clean.indexOf('-');
                        if (pos >= charThreshold &&
                                /* more than just dashed min words */ clean.length() > charThreshold * 2 + 1 &&
                                /* full words */ pos != 0 && (pos < clean.length() - charThreshold) &&
                                /* double dash */ clean.charAt(pos + 1) != '-') {
                            words.add(clean.substring(0, pos));
                            words.add(clean.substring(pos + 1, clean.length()));
                        } else {
                            words.add(clean);
                        }
                    }
                }
            }
        }
        return words;
    }
    return Collections.EMPTY_LIST;
}
 
Example 17
public static DoubleMatrixDataset<String, String> loadDoubleTextDoubleDataExlcudeCols(String fileName, char delimiter, HashSet<String> colsToExclude, int linesToSkip) throws IOException, Exception {

		TextFile in = new TextFile(fileName, TextFile.R);

		for (int i = 0; i < linesToSkip; ++i) {
			in.readLine();//Skip first lines
		}

		String str = in.readLine(); // header
		String[] data = StringUtils.splitPreserveAllTokens(str, delimiter);

		HashSet<String> desiredCols = new HashSet<>();

		for (String colName : data) {

			if (!colsToExclude.contains(colName)) {
				desiredCols.add(colName);
			}

		}

		return DoubleMatrixDataset.loadSubsetOfTextDoubleData(fileName, delimiter, null, desiredCols, linesToSkip);

	}
 
Example 18
/**
 * This method loads UserAdminRole entity temporal and ARBAC constraint instance variables with data that was retrieved from the
 * 'ftARC' attribute on the 'ftUserAttrs' object class.  This is the raw format that Fortress uses to condense the temporal and ARBAC data into
 * a compact String for efficient storage and retrieval and is not intended to be called by external programs.
 *
 * @param szRawData contains a raw formatted String that maps to 'ftARC' attribute on 'ftUserAttrs' object class
 * @param contextId contains the tenant id.
 * @param parentUtil provides method to getParents.
 */
public void load( String szRawData, String contextId, ParentUtil parentUtil )
{
    if ( ( szRawData != null ) && ( szRawData.length() > 0 ) )
    {
        String[] tokens = StringUtils.splitPreserveAllTokens( szRawData, Config.getInstance().getDelimiter() );
        for ( int i = 0; i < tokens.length; i++ )
        {
            if ( StringUtils.isNotEmpty( tokens[i] ) )
            {
                switch ( i )
                {
                    case 0:
                        name = tokens[i];
                        parents = parentUtil.getParentsCB( name.toUpperCase(), contextId );
                        break;

                    case 1:
                        this.setTimeout( Integer.parseInt( tokens[i] ) );
                        break;

                    case 2:
                        this.setBeginTime( tokens[i] );
                        break;

                    case 3:
                        this.setEndTime( tokens[i] );
                        break;

                    case 4:
                        this.setBeginDate( tokens[i] );
                        break;

                    case 5:
                        this.setEndDate( tokens[i] );
                        break;

                    case 6:
                        this.setBeginLockDate( tokens[i] );
                        break;

                    case 7:
                        this.setEndLockDate( tokens[i] );
                        break;

                    case 8:
                        this.setDayMask( tokens[i] );
                        break;

                    default:
                        String szValue = tokens[i];
                        int indx = szValue.indexOf( P + GlobalIds.PROP_SEP );
                        if ( indx >= 0 )
                        {
                            String szOsP = szValue.substring( indx + 2 );
                            this.setOsP( szOsP );
                        }
                        indx = szValue.indexOf( U + GlobalIds.PROP_SEP );
                        if ( indx >= 0 )
                        {
                            String szOsU = szValue.substring( indx + 2 );
                            this.setOsU( szOsU );
                        }
                        indx = szValue.indexOf( R + GlobalIds.PROP_SEP );
                        if ( indx >= 0 )
                        {
                            String szRangeRaw = szValue.substring( indx + 2 );
                            this.setRoleRangeRaw( szRangeRaw );
                        }
                        break;
                }
            }
        }
    }
}
 
Example 19
public static DoubleMatrixDataset<String, String> loadSubsetOfTextDoubleData(String fileName, char delimiter, Set<String> desiredRows, Set<String> desiredCols, int linesToSkip) throws IOException, Exception {
	if (!(fileName.endsWith(".txt") || fileName.endsWith(".txt.gz")  || fileName.endsWith(".tsv.bgz") || fileName.endsWith(".tsv") || fileName.endsWith(".tsv.gz") || fileName.endsWith(".gct") || fileName.endsWith(".gct.gz"))) {
		throw new IllegalArgumentException("File type must be .txt or .tsv when delimiter is given (given filename: " + fileName + ")");
	}

	//Pattern splitPatern = Pattern.compile(delimiter);
	int columnOffset = 1;

	TextFile in = new TextFile(fileName, TextFile.R);

	for (int i = 0; i < linesToSkip; ++i) {
		in.readLine();//Skip first lines
	}

	String str = in.readLine(); // header
	String[] data = StringUtils.splitPreserveAllTokens(str, delimiter);

	int tmpCols = (data.length - columnOffset);

	LinkedHashMap<String, Integer> colMap = new LinkedHashMap<String, Integer>((int) Math.ceil(tmpCols / 0.75));

	int storedCols = 0;
	ArrayList<Pair<Integer, Integer>> desiredColIds = new ArrayList<>();
	for (int s = 0; s < tmpCols; s++) {
		String colName = data[s + columnOffset];
		if (!colMap.containsKey(colName) && (desiredCols == null || desiredCols.isEmpty() || desiredCols.contains(colName))) {
			colMap.put(colName, storedCols);
			desiredColIds.add(new Pair<>(s, storedCols));
			storedCols++;
		} else if (colMap.containsKey(colName)) {
			LOGGER.warning("Duplicated column name!");
			throw new Exception("Duplicated column are not allowed. Tried to add: " + colName);
		}
	}

	int storingRow = 0;
	LinkedHashMap<String, Integer> rowMap = new LinkedHashMap<String, Integer>((int) Math.ceil(20000 / 0.75));

	AtomicBoolean correctData = new AtomicBoolean(true);
	ArrayList<double[]> tmpdata = new ArrayList<>();
	Pattern p = Pattern.compile("" + delimiter);
	while ((str = in.readLine()) != null) {
		String rowname = Strings.subsplit(str, p, 0, 1)[0];

		if (desiredRows == null || desiredRows.isEmpty() || desiredRows.contains(rowname)) {
			if (!rowMap.containsKey(rowname)) {
				data = StringUtils.splitPreserveAllTokens(str, delimiter);
				rowMap.put(data[0], storingRow);
				double[] tmp = new double[desiredColIds.size()];
				String[] finalData = data;

				desiredColIds.parallelStream().forEach(c -> {
					int col = c.getLeft();
					int pos = c.getRight();
					double d;
					try {
						d = Double.parseDouble(finalData[col + columnOffset]);
					} catch (NumberFormatException e) {
						correctData.set(false);
						d = Double.NaN;
					}
					tmp[pos] = d;
				});

				tmpdata.add(tmp);
				storingRow++;

			} else if (rowMap.containsKey(data[0])) {
				LOGGER.warning("Duplicated row name!");
				throw new Exception("Duplicated row are not allowed. Tried to add: " + data[0]);
			}
		}
	}
	if (!correctData.get()) {
		LOGGER.warning("Your data contains NaN/unparseable values!");
	}
	in.close();

	DoubleMatrix2D matrix;
	int rowsToStore = tmpdata.size();
	if ((rowsToStore * (long) tmpCols) < (Integer.MAX_VALUE - 2)) {
		matrix = new DenseDoubleMatrix2D(rowsToStore, storedCols);
	} else {
		matrix = new DenseLargeDoubleMatrix2D(rowsToStore, storedCols);
	}

	IntStream.range(0, tmpdata.size()).parallel().forEach(r -> {
		double[] tmpd = tmpdata.get(r);
		for (int c = 0; c < tmpd.length; c++) {
			matrix.setQuick(r, c, tmpd[c]);
		}
	});

	DoubleMatrixDataset<String, String> dataset = new DoubleMatrixDataset<String, String>(matrix, rowMap, colMap);

	//LOGGER.log(Level.INFO, "''{0}'' has been loaded, nrRows: {1} nrCols: {2}", new Object[]{fileName, dataset.matrix.rows(), dataset.matrix.columns()});
	return dataset;
}
 
Example 20
@Override
protected EntityBuilder buildAttributeCollectionFromKey(Key k) {
    String[] typeId = StringUtils.splitPreserveAllTokens(k.getColumnFamily().toString(), ONE_BYTE);
    return EntityBuilder.create(typeId[1], typeId[2]);
}