java.util.concurrent.ConcurrentSkipListMap#get ( )源码实例Demo

下面列出了java.util.concurrent.ConcurrentSkipListMap#get ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: kylin-on-parquet-v2   文件: SegmentMemoryStore.java
@SuppressWarnings("unchecked")
private void aggregate(ConcurrentSkipListMap<String[], MeasureAggregator[]> cuboidAggBufMap, String[] dimensions,
        Object[] metricsValues) {
    MeasureAggregator[] aggrs = cuboidAggBufMap.get(dimensions);
    if (aggrs != null) {
        aggregateValues(aggrs, metricsValues);
    }

    if (aggrs == null) {
        MeasureAggregator[] newAggrs = newMetricsAggregators(parsedStreamingCubeInfo.metricsAggrFuncs);
        aggregateValues(newAggrs, metricsValues);
        aggrs = cuboidAggBufMap.putIfAbsent(dimensions, newAggrs);
        if (aggrs == null) {
            rowCount.incrementAndGet();
        } else {
            aggregateValues(aggrs, metricsValues);
        }
    }

}
 
源代码2 项目: kylin   文件: SegmentMemoryStore.java
@SuppressWarnings("unchecked")
private void aggregate(ConcurrentSkipListMap<String[], MeasureAggregator[]> cuboidAggBufMap, String[] dimensions,
        Object[] metricsValues) {
    MeasureAggregator[] aggrs = cuboidAggBufMap.get(dimensions);
    if (aggrs != null) {
        aggregateValues(aggrs, metricsValues);
    }

    if (aggrs == null) {
        MeasureAggregator[] newAggrs = newMetricsAggregators(parsedStreamingCubeInfo.metricsAggrFuncs);
        aggregateValues(newAggrs, metricsValues);
        aggrs = cuboidAggBufMap.putIfAbsent(dimensions, newAggrs);
        if (aggrs == null) {
            rowCount.incrementAndGet();
        } else {
            aggregateValues(aggrs, metricsValues);
        }
    }

}
 
源代码3 项目: openjdk-jdk9   文件: ConcurrentSkipListMapTest.java
/**
 * get(null) of nonempty map throws NPE
 */
public void testGet_NullPointerException() {
    ConcurrentSkipListMap c = map5();
    try {
        c.get(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
源代码4 项目: vertexium   文件: PropertyCollection.java
public synchronized void addProperty(Property property) {
    ConcurrentSkipListMap<String, ConcurrentSkipListSet<Property>> propertiesByKey = propertiesByNameAndKey.get(property.getName());
    if (propertiesByKey == null) {
        propertiesByKey = new ConcurrentSkipListMap<>();
        this.propertiesByNameAndKey.put(property.getName(), propertiesByKey);
    }
    ConcurrentSkipListSet<Property> properties = propertiesByKey.get(property.getKey());
    if (properties == null) {
        properties = new ConcurrentSkipListSet<>();
        propertiesByKey.put(property.getKey(), properties);
    }
    properties.add(property);
    this.propertiesList.add(property);
}
 
源代码5 项目: j2objc   文件: ConcurrentSkipListMapTest.java
/**
 * get(null) of nonempty map throws NPE
 */
public void testGet_NullPointerException() {
    ConcurrentSkipListMap c = map5();
    try {
        c.get(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
源代码6 项目: aparapi   文件: ProfileReportNewAPITest.java
public boolean singleThreadedSingleKernelReportObserverTestHelper(Device device, int size) {
  	final int runs = 100;
  	final int inputArray[] = new int[size];
  	final Basic1Kernel kernel = new Basic1Kernel();

  	int[] outputArray = null;
  	Range range = device.createRange(size, size);

  	ReportObserver observer = new ReportObserver(device, 1, runs);
  	observer.addAcceptedThreadId(Thread.currentThread().getId());
  	kernel.registerProfileReportObserver(observer);

for (int i = 0; i < runs; i++) {
	assertFalse("Report with id " + i + " shouldn't have been received yet", observer.receivedReportIds[i]);
}

  	long startOfExecution = System.currentTimeMillis();
  	try {
  		for (int i = 0; i < runs; i++) {
  			outputArray = Arrays.copyOf(inputArray, inputArray.length);
  			kernel.setInputOuputArray(outputArray);
  			kernel.execute(range);
  		}
  		long runTime = System.currentTimeMillis() - startOfExecution;
  		ConcurrentSkipListMap<Long, ThreadTestState> results = observer.getObservedThreadsIds();
  		ThreadTestState state = results.get(Thread.currentThread().getId());
  		assertNotNull("Reports should have been received for thread", state);

  		assertEquals("Number of profiling reports doesn't match the expected", runs, state.receivedReportsCount);
  		assertEquals("Aparapi Accumulated execution time doesn't match", kernel.getAccumulatedExecutionTimeAllThreads(device), state.accumulatedElapsedTime, 1e-10);
  		// FIXME failing: assertEquals("Test estimated accumulated time doesn't match within 200ms window", runTime, kernel.getAccumulatedExecutionTimeAllThreads(device), 200);
  		for (int i = 0; i < runs; i++) {
  			assertTrue("Report with id " + i + " wasn't received", observer.receivedReportIds[i]);
  		}
  		assertTrue(validateBasic1Kernel(inputArray, outputArray));
  	} finally {
  		kernel.registerProfileReportObserver(null);
  		kernel.dispose();
  	}

  	return true;
  }
 
源代码7 项目: aparapi   文件: ProfileReportNewAPITest.java
public boolean multiThreadedSingleKernelReportObserverTestHelper(Device device, int size) throws InterruptedException, ExecutionException {
  	final int runs = 100;
  	final int javaThreads = 10;
  	final int inputArray[] = new int[size];
  	ExecutorService executorService = Executors.newFixedThreadPool(javaThreads);

  	final ReportObserver observer = new ReportObserver(device, javaThreads, runs);

for (int i = 0; i < runs; i++) {
	assertFalse("Report with id " + i + " shouldn't have been received yet", observer.receivedReportIds[i]);
}

  	final List<Basic1Kernel> kernels = new ArrayList<Basic1Kernel>(javaThreads);
  	for (int i = 0; i < javaThreads; i++) {
      	final Basic1Kernel kernel = new Basic1Kernel();
      	kernel.registerProfileReportObserver(observer);
      	kernels.add(kernel);
  	}

  	final ThreadResults[] results = new ThreadResults[javaThreads];
  	for (int i = 0; i < results.length; i++) {
  		results[i] = new ThreadResults();
  	}


  	boolean terminatedOk = multiThreadedSingleKernelReportObserverTestRunner(executorService, kernels, results,
  			inputArray, runs, javaThreads, device, observer, size);

  	assertTrue("Threads did not terminate correctly", terminatedOk);

  	double allThreadsAccumulatedTime = 0;
  	ConcurrentSkipListMap<Long, ThreadTestState> states = observer.getObservedThreadsIds();
  	assertEquals("Number of Java threads sending profile reports should match the number of JavaThreads", javaThreads, states.values().size());
  	for (int i = 0; i < javaThreads; i++) {
  		ThreadTestState state = states.get(results[i].threadId);
  		assertNotNull("Report should have been received for thread with index " + i, state);
  		assertEquals("Number of total iteration should match number of runs for thread with index " + i, runs, results[i].kernelCalls);
      	assertEquals("Number of received reports should match total number of calls for thread with index " + i, runs, state.receivedReportsCount);
      	assertEquals("Overall elapsed time received in reports doesn't match KernelDeviceProfile.Accumulator for threa with index " + i,
      			results[i].accumulatedExecutionTime, state.accumulatedElapsedTime, 1e-10);
      	allThreadsAccumulatedTime += state.accumulatedElapsedTime;
      	assertTrue("Thread index " + i + " kernel computation doesn't match the expected", validateBasic1Kernel(inputArray, results[i].outputArray));
      	//FIXME Find a better way of determining kernel execution time
      	//assertEquals("Runtime is not within 600ms of the kernel estimated", results[i].runTime, state.accumulatedElapsedTime, 600);
  	}

  	assertEquals("Overall kernel execution time doesn't match",
  			kernels.get(0).getAccumulatedExecutionTimeAllThreads(device), allThreadsAccumulatedTime, 1e10);

  	return true;
  }
 
源代码8 项目: freeinternals   文件: ICCProfile.java
public void generateTreeNode(DefaultMutableTreeNode parentNode) {
    DefaultMutableTreeNode nodeHeader;
    DefaultMutableTreeNode nodeTagTable;
    int lastPos;
    int diff;

    parentNode.add(nodeHeader = new DefaultMutableTreeNode(new JTreeNodeFileComponent(
            this.header.getStartPos(),
            this.header.getLength(),
            "Profile header")));
    this.header.generateTreeNode(nodeHeader);

    parentNode.add(nodeHeader = new DefaultMutableTreeNode(new JTreeNodeFileComponent(
            lastPos = this.header.getStartPos() + this.header.getLength(),
            4,
            String.format("Tag count = %d", this.tagCount))));

    lastPos = lastPos + 4;

    ConcurrentSkipListMap<Long, RefItem> sortedMap = new ConcurrentSkipListMap<Long, RefItem>();
    for (int i = 0; i < this.tagTable.length; i++) {
        parentNode.add(nodeTagTable = new DefaultMutableTreeNode(new JTreeNodeFileComponent(
                lastPos + Tag.LENGTH * i,
                Tag.LENGTH,
                String.format("Tag[%d]", i))));
        this.tagTable[i].generateTreeNode(nodeTagTable);

        if (sortedMap.get(this.tagTable[i].Offset) == null) {
            RefItem refItem = new RefItem();
            refItem.i = i;
            refItem.tag = this.tagTable[i];
            sortedMap.put(refItem.tag.Offset, refItem);
        }
    }

    lastPos = lastPos + this.tagTable.length * Tag.LENGTH;
    for (RefItem ref : sortedMap.values()) {
        diff = (int) ((this.startPos + ref.tag.Offset) - lastPos);
        if (diff > 0) {
            UITool.generateTreeNodeDiff(
                    parentNode, lastPos, diff,
                    this.rawData, this.startPos);
        }

        parentNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent(
                this.startPos + (int) ref.tag.Offset,
                (int) ref.tag.Size,
                String.format("Data of Tag [%d]", ref.i))));
        lastPos = this.startPos + (int) ref.tag.Offset + (int) ref.tag.Size;
    }

    diff = (this.startPos + this.rawData.length) - lastPos;
    if (diff > 0) {
        UITool.generateTreeNodeDiff(
                parentNode, lastPos, diff,
                this.rawData, this.startPos);
    }
}
 
protected synchronized AbstractGraphRow getNewRow(
        ConcurrentSkipListMap<String, AbstractGraphRow> model,
        int rowType,
        String label,
        int markerSize,
        boolean isBarRow,
        boolean displayLabel,
        boolean thickLines,
        boolean showInLegend,
        Color color,
        boolean canCompose) {
    AbstractGraphRow row;
    if (log.isDebugEnabled()) {
        log.debug("This AbstractGraphPanelVisualizer is an instance of [" + this.getClass().getName() + "]");
    }
    if (!model.containsKey(label)) {
        row = AbstractGraphRow.instantiateNewRow(rowType);
        row.setLabel(label);
        row.setMarkerSize(markerSize);
        row.setDrawBar(isBarRow);
        row.setDrawLine(!isBarRow);
        row.setDrawValueLabel(displayLabel);
        row.setDrawThickLines(thickLines);
        row.setShowInLegend(showInLegend);

        Color overrideColor = null;
        if (this.labelToColorMapping != null)
            overrideColor = labelToColorMapping.getColorForLabel(row.getLabel());
        if (log.isDebugEnabled())
            if (row != null) {
                log.debug("%#@ Found override color [" + (overrideColor == null ? "null" : overrideColor.toString()) + "]");
                log.debug("%#@ for label [" + row.getLabel() + "] color in-parm [" + (color == null ? "null" : color.toString()) + "]");
                log.debug("%#@ prev row.getColor() [" + (row.getColor() == null ? "null" : row.getColor().toString()) + "]");
            } else
                log.debug("%#@ Found null row displayLabel[" + displayLabel + "] and label [" + label + "]");

        row.setColor(overrideColor != null ? overrideColor : colors.getNextColor());
        if (log.isDebugEnabled())
            log.debug("%#@ new row.getColor() [" + (row.getColor() == null ? "null" : row.getColor().toString()) + "]");

        model.put(label, row);
        graphPanel.addRow(row);
        if (canCompose) {
            addRowToCompositeModels(getModel().getName(), row);
        }
    } else {
        row = model.get(label);
    }

    return row;
}