org.apache.commons.collections.map.MultiKeyMap Java Examples

The following examples show how to use org.apache.commons.collections.map.MultiKeyMap. 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
Source File: CooccurrenceFileCorpus.java    From cocolian-nlp with Apache License 2.0 6 votes vote down vote up
public void load(InputStream bigramFilePath) throws IOException {
	if(this.bigramTables == null)
		this.bigramTables = new MultiKeyMap();
	BufferedReader reader = new BufferedReader(new InputStreamReader(bigramFilePath,CORPUS_ENCODER));
	String row = reader.readLine().trim();
	while (row != null) {
		row = row.trim();
		if (row.length() > 0) {
			String[] items = row.split("\\s");
			int freq = Integer.parseInt(items[2]);
			bigramTables.put(items[0], items[1], freq);
		}
		row = reader.readLine();
	}
	reader.close();
}
 
Example #2
Source File: DefaultPivotModel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public void calculate() {
	long start = System.currentTimeMillis();
	rowsHeaderTree = null;
	columnsHeaderTree = null;
	getRowsHeaderTree();
	long t1 = System.currentTimeMillis();
	System.out.println("created rowsHeaderTree in " + (t1 - start));
	getColumnsHeaderTree();
	long t2 = System.currentTimeMillis();
	System.out.println("created columnsHeaderTree in " + (t2 - t1));

	t1 = System.currentTimeMillis();
	List<PivotField> dataFields = getFields(PivotField.Area.DATA);
	calculatedData = new ArrayList<MultiKeyMap>();
	for (PivotField field : dataFields) {
		field.getAggregator().init();
		calculatedData.add(getData(field));
	}
	t2 = System.currentTimeMillis();
	System.out.println("filled calculatedData in " + (t2 - t1));
	long stop = System.currentTimeMillis();
	System.out.println("calculated in " + (stop- start));
	System.out.println("calculatedData = " + calculatedData);
	// getValues(field, filter)
}
 
Example #3
Source File: HbaseDataSourceListDao.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
private List<DataSourceListBo> reorderDataSourceListBos(List<DataSourceListBo> dataSourceListBos) {
    // reorder dataSourceBo using id and timeSlot
    MultiKeyMap dataSourceListBoMap = new MultiKeyMap();

    for (DataSourceListBo dataSourceListBo : dataSourceListBos) {
        for (DataSourceBo dataSourceBo : dataSourceListBo.getList()) {
            int id = dataSourceBo.getId();
            long timestamp = dataSourceBo.getTimestamp();
            long timeSlot = AgentStatUtils.getBaseTimestamp(timestamp);

            DataSourceListBo mappedDataSourceListBo = (DataSourceListBo) dataSourceListBoMap.get(id, timeSlot);
            if (mappedDataSourceListBo == null) {
                mappedDataSourceListBo = new DataSourceListBo();
                mappedDataSourceListBo.setAgentId(dataSourceBo.getAgentId());
                mappedDataSourceListBo.setStartTimestamp(dataSourceBo.getStartTimestamp());
                mappedDataSourceListBo.setTimestamp(dataSourceBo.getTimestamp());

                dataSourceListBoMap.put(id, timeSlot, mappedDataSourceListBo);
            }

            // set fastest timestamp
            if (mappedDataSourceListBo.getTimestamp() > dataSourceBo.getTimestamp()) {
                mappedDataSourceListBo.setTimestamp(dataSourceBo.getTimestamp());
            }

            mappedDataSourceListBo.add(dataSourceBo);
        }
    }

    Collection values = dataSourceListBoMap.values();
    return new ArrayList<DataSourceListBo>(values);
}
 
Example #4
Source File: DefaultPivotModel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private MultiKeyMap getData(PivotField dataField) {
		MultiKeyMap data = new MultiKeyMap();
		List<List<Object>> rowKeys = getRowKeys();
		System.out.println("rowKeys.size() = " + rowKeys.size());
		List<List<Object>> columnKeys = getColumnKeys();
		System.out.println("columnKeys.size() = " + columnKeys.size());
		
		List<PivotField> rowFields = getFields(PivotField.Area.ROW);
		List<PivotField> columnFields = getFields(PivotField.Area.COLUMN);
		for (List<Object> rowKey : rowKeys) {
			for (List<Object> columnKey : columnKeys) {
				Map<Integer, Object> rowFilter = getFilter(rowFields, rowKey);
				Map<Integer, Object> columnFilter = getFilter(columnFields, columnKey);
				Map<Integer, Object> filter = new HashMap<Integer, Object>(rowFilter);
				filter.putAll(columnFilter);				
				List<Object> values = getValues(dataField, filter);
				if (!CollectionUtils.isEmpty(values)) {
					/*
					System.out.println("filter = " + filter);
					System.out.println("values = " + values);
					System.out.println(values.size());
					*/
					Object summary = PivotUtils.getSummary(dataField, values);
//					System.out.println("summary = " + summary);
					data.put(rowKey, columnKey, summary);
				}
			}
		}
		
		return data;
	}
 
Example #5
Source File: TOSIngredientRandomSearchStrategy.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public MultiKeyMap getCacheInstances() {
	return cacheInstances;
}
 
Example #6
Source File: Topology.java    From knox with Apache License 2.0 4 votes vote down vote up
public Topology() {
  serviceMap = MultiKeyMap.decorate(new HashedMap());
}