• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ChronicleMapBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.openhft.chronicle.map.ChronicleMapBuilder的典型用法代码示例。如果您正苦于以下问题:Java ChronicleMapBuilder类的具体用法?Java ChronicleMapBuilder怎么用?Java ChronicleMapBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ChronicleMapBuilder类属于net.openhft.chronicle.map包,在下文中一共展示了ChronicleMapBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getMap

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
private ChronicleMap<Integer, String> getMap(String mapName, Class<Integer> kClass, Class<String> vClass, int entrySize) throws BenchmarkException {
    try {
        return ChronicleMapBuilder
                .of(kClass, vClass)
                .entrySize(entrySize)
                .createPersistedTo(new File(mapName));
    } catch (IOException e) {
        throw new BenchmarkException("", e);
    }
}
 
开发者ID:hailpam,项目名称:dobef,代码行数:11,代码来源:ChronicleBenchmark.java


示例2: OffHeapVarBitMetricStore

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
public OffHeapVarBitMetricStore(long size, int valueSize, String chunkInfo, String dir) {
  this.chunkInfo = chunkInfo;

  ChronicleMapBuilder<LongValue, ByteBuffer> mapBuilder = ChronicleMap
      .of(LongValue.class, ByteBuffer.class)
      .entries(size)
      .averageValueSize(valueSize);

  if (chunkInfo != null && !chunkInfo.isEmpty() && !dir.isEmpty()) {
    File offHeapFile = new File(dir + "/" + offHeapNamePrefix + "_" + chunkInfo);
    try {
      timeSeries = mapBuilder.name(offHeapNamePrefix + "_" + chunkInfo)
          .createPersistedTo(offHeapFile);
    } catch (IOException e) {
      LOG.error("Failed to create an offheap store {} with error {}", offHeapFile, e.getMessage());
      throw new IllegalArgumentException("Failed to create an off heap store.", e);
    }
  } else {
    timeSeries = mapBuilder.name(offHeapNamePrefix).create();
  }
  LOG.info("Created an off heap metric store of size={} valueSize={} chunkInfo={} in dir={}",
      size, valueSize, chunkInfo, dir);
}
 
开发者ID:pinterest,项目名称:yuvi,代码行数:24,代码来源:OffHeapVarBitMetricStore.java


示例3: buildMap

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
private static Map<String, String> buildMap(final File f, final boolean reverse) {
	final ElapsedTime et = SystemClock.startClock();
	final Number[] stats = computeStats(f);
	final long entries = stats[0].longValue(); 
	final double avgKeySize = stats[1].doubleValue();
	final double avgValueSize = stats[2].doubleValue();
	final ChronicleMap<String, String> map = ChronicleMapBuilder.of(String.class, String.class)
			.averageKeySize(avgKeySize)
			.averageValueSize(avgValueSize)
			.entries(entries)				
			.maxBloatFactor(5.0)
			.create();		
	final String[] lines = URLHelper.getTextFromFile(f).split("\n");
	Arrays.stream(lines)
		.parallel()
		.map(line -> line.split(","))
		.forEach(kv -> {
			if(reverse) {
				map.put(kv[1], kv[0]);
			} else {
				map.put(kv[0], kv[1]);
			}
		});
	final String avg = et.printAvg("Records", entries);
	log.info("Loaded Map from {}. Entries:{}, Size:{},  {}", f.getName(), entries, map.size(), avg);
	return map;
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:28,代码来源:CQ4GenFromTestData.java


示例4: shouldApplyLambdaConfigsAgainstBuilder

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void shouldApplyLambdaConfigsAgainstBuilder() throws Throwable {
    ChronicleMapMacheProvisioner<String, Integer> provisioner = chronicleMap(String.class, Integer.class)
            .averageKeySize(10.0)
            .actualChunksPerSegment(100);

    List<ChronicleMapBuilderConfig<String, Integer>> configs =
            (List<ChronicleMapBuilderConfig<String, Integer>>) getInternalState(provisioner, "configToApply");

    ChronicleMapBuilder<String, Integer> mockBuilder = Mockito.mock(ChronicleMapBuilder.class);

    configs.stream().forEach((config) -> config.apply(mockBuilder));

    verify(mockBuilder).averageKeySize(10.0);
    verify(mockBuilder).actualChunksPerSegment(100);
}
 
开发者ID:Excelian,项目名称:Mache,代码行数:18,代码来源:ChronicleMapMacheProvisionerShould.java


示例5: shouldCorrectlySetSizeValues

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void shouldCorrectlySetSizeValues() throws Throwable {
    ChronicleMapMacheProvisioner<String, Integer> provisioner = chronicleMap(String.class, Integer.class)
            .size(1000);

    assertEquals(1000, getInternalState(provisioner, "upperWatermark"));
    assertEquals(850 - 1, getInternalState(provisioner, "lowerWatermark"));
    assertEquals(925, getInternalState(provisioner, "acceptableWatermark"));

    List<ChronicleMapBuilderConfig<String, Integer>> configs =
            (List<ChronicleMapBuilderConfig<String, Integer>>) getInternalState(provisioner, "configToApply");

    ChronicleMapBuilder<String, Integer> mockBuilder = Mockito.mock(ChronicleMapBuilder.class);

    configs.stream().forEach((config) -> config.apply(mockBuilder));

    verify(mockBuilder).entries(1150);
}
 
开发者ID:Excelian,项目名称:Mache,代码行数:20,代码来源:ChronicleMapMacheProvisionerShould.java


示例6: test

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
@Test
public void test() throws ExecutionException, InterruptedException
{
	ChronicleMapBuilder<LongValue, PortfolioAssetInterface> mapBuilder = ChronicleMapBuilder.of(LongValue.class, PortfolioAssetInterface.class).entries(nAssets);

	try (ChronicleMap<LongValue, PortfolioAssetInterface> cache = mapBuilder.create())
	{
		createData(cache);

		// Compute multiple times to get an reasonable average compute time
		for (int i = 0; i < nRepetitions; i++)
		{
			computeValue(cache);
		}
	}
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:17,代码来源:PortfolioValueTest.java


示例7: testComplexSerialization

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
@Test
public void testComplexSerialization() {
    try (ChronicleMap<String, A> map = ChronicleMapBuilder
            .of(String.class, A.class)
            .valueMarshaller(AMarshaller.INSTANCE)
            .entries(5)
            .averageKeySize(4)
            .averageValueSize(1000)
            .create()) {
        A obj_A = new A();
        obj_A.str_ = "a";
        obj_A.list_ = new ArrayList<>();
        B b = new B();
        b.str_ = "b";
        obj_A.list_.add(b);
        map.put("KEY1", obj_A);
        map.get("KEY1");
    }
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:20,代码来源:PointListSerializationTest.java


示例8: addToAMap2

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
@Test
@Ignore("TODO What is HACK???")
public void addToAMap2() {
    DoubleArray.HACK = false;
    DoubleArray a = new DoubleArray(10);
    a.setData(new double[]{1, 2, 3, 4, 5});

    DoubleArray b = new DoubleArray(10);
    b.setData(new double[]{5, 6, 7, 8, 9});

    ChronicleMap<Integer, DoubleArray> proxyMap = ChronicleMapBuilder
            .of(Integer.class, DoubleArray.class)
            .averageValueSize(6 * 8)
            .create();
    proxyMap.put(1, a);
    proxyMap.put(2, b);

    System.out.println(proxyMap.get(1));
    System.out.println(proxyMap.get(2));
    proxyMap.close();
    DoubleArray.HACK = true;
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:23,代码来源:DoubleArrayTest.java


示例9: ChronicleMapStore

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
public ChronicleMapStore(String filePath) {
    try {
        this.store = ChronicleMapBuilder
                .of(String.class, Member.class)
                .entries(50000)
                .createOrRecoverPersistedTo(new File(filePath));
    } catch (IOException e) {
        LOGGER.error("Initialize persistent KVStore exception", e);
        throw new RuntimeException(e);
    }
}
 
开发者ID:GrapeBaBa,项目名称:fabric-java,代码行数:12,代码来源:ChronicleMapStore.java


示例10: create

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
@Override
public Mache<K, V> create(Class<K> keyType, Class<V> valueType, MacheLoader<K, V> cacheLoader) {
    ChronicleMapBuilder<K, V> chronicleMapBuilder = ChronicleMapBuilder.of(keyType, valueType).entries(11500);
    applyConfig(chronicleMapBuilder);

    ConcurrentMap<K, V> map = buildMap(chronicleMapBuilder);

    ConcurrentLRUCache<K, V> cache = new ConcurrentLRUCache<>(upperWatermark, lowerWatermark,
            acceptableWatermark, runCleanupThread, runNewThreadForCleanup, evictionListener, map);

    return new ChronicleMapMache<>(cacheLoader, cache);
}
 
开发者ID:Excelian,项目名称:Mache,代码行数:13,代码来源:ChronicleMapMacheProvisioner.java


示例11: buildMap

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
private ConcurrentMap<K, V> buildMap(ChronicleMapBuilder<K, V> chronicleMapBuilder) {
    ConcurrentMap<K, V> map;
    if (persistedTo == null) {
        map = chronicleMapBuilder.create();
    } else {
        try {
            map = chronicleMapBuilder.createPersistedTo(persistedTo);
        } catch (IOException e) {
            throw new IllegalArgumentException("Failed to create persisted Chronicle Map.", e);
        }
    }
    return map;
}
 
开发者ID:Excelian,项目名称:Mache,代码行数:14,代码来源:ChronicleMapMacheProvisioner.java


示例12: ProcessInstanceLimiter

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
/**
 * Create a ProcessInstanceLimiter instance using the default shared file
 * named ProcessInstanceLimiter_DEFAULT_SHARED_MAP_ in the tmp directory.
 *
 * @param sharedMapPath - The path to a file which will be used to store the shared
 *                      map (the file need not pre-exist)
 * @param callback      - An instance of the Callback interface, which will receive
 *                      callbacks
 * @throws IOException - if the default shared file cannot be created
 */
public ProcessInstanceLimiter(String sharedMapPath, Callback callback) throws IOException {
    this.sharedMapPath = sharedMapPath;
    this.callback = callback;
    ChronicleMapBuilder<String, Data> builder =
            ChronicleMapBuilder.of(String.class, Data.class);
    builder.entries(1000);
    builder.averageKeySize((DEFAULT_PROCESS_NAME + "#").length());
    this.theSharedMap = builder.createPersistedTo(new File(sharedMapPath));
    Thread t = new Thread(this, "ProcessInstanceLimiter updater");
    t.setDaemon(true);
    t.start();
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:23,代码来源:ProcessInstanceLimiter.java


示例13: acquireCHM

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
static ChronicleMap<String, BondVOInterface> acquireCHM() throws IOException {
    // ensure thread ids are globally unique.
    AffinitySupport.setThreadId();
    return ChronicleMapBuilder.of(String.class, BondVOInterface.class)
            .entries(16)
            .averageKeySize("369604101".length()).create();
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:8,代码来源:PingPongCASLeft.java


示例14: newMap

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
static Map newMap() {
    try {
        return ChronicleMapBuilder.of(Object.class, Object.class).create();
    } catch (Exception e) {
        throw new RuntimeException("Can't instantiate CHM : " + e);
    }
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:8,代码来源:MapCheck.java


示例15: beforeClass

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() {
    chm = ChronicleMapBuilder
            .of(LongValue.class, ByteArray.class)
            .entries(1000)
            .create();
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:8,代码来源:OffHeapByteArrayExampleTest.java


示例16: MetaDataSync2

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
/**
 * Creates a new MetaDataSync2
 * @param tsdb The TSDB instance we're operating in
 * @param sink The sink to write the discovered metas to
 * @param threads The number of threads to run
 */
public MetaDataSync2(final TSDB tsdb, final MetricMetaSink sink, final int runThreads, final double avgKeySize) {
	this.client = tsdb.getClient();
	this.tsdb = tsdb;
	this.tsuidSet = ChronicleSetBuilder.of(byte[].class)
			.averageKeySize(128)
			.entries(1000000)
			.maxBloatFactor(10.0D)
			.create();
	this.metric_uids = ChronicleMapBuilder.of(String.class, Long.class)
			.entries(10000)
			.averageKeySize(128)
			.maxBloatFactor(10.0D)
			.create();
	this.tagk_uids = ChronicleMapBuilder.of(String.class, Long.class)
			.entries(10000)
			.averageKeySize(128)
			.maxBloatFactor(10.0D)
			.create();
	this.tagv_uids = ChronicleMapBuilder.of(String.class, Long.class)
			.entries(10000)
			.averageKeySize(128)
			.maxBloatFactor(10.0D)
			.create();

	this.sink = sink;
	this.runThreads = runThreads;
	final long maxMetricId = getMaxMetricID();
	final List<Scanner> scanners = getDataTableScanners(maxMetricId, runThreads);
	final int actualRunThreads = scanners.size();
	threads = new ArrayList<Thread>(actualRunThreads);
	latch = new CountDownLatch(actualRunThreads);
	int threadId = 1;
	for(Scanner scanner : scanners) {
		final Thread t = new MSync(scanner, threadId, latch);
		t.setDaemon(true);
		threads.add(t);			
		threadId++;
	}


}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:48,代码来源:MetaDataSync2.java


示例17: applyConfig

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
private void applyConfig(ChronicleMapBuilder<K, V> chronicleMapBuilder) {
    configToApply.stream().forEach((config) -> config.apply(chronicleMapBuilder));
}
 
开发者ID:Excelian,项目名称:Mache,代码行数:4,代码来源:ChronicleMapMacheProvisioner.java


示例18: VanillaChronicleHash

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
public VanillaChronicleHash(ChronicleMapBuilder<K, ?> builder) {
    // Version
    dataFileVersion = BuildVersion.version();

    createdOrInMemory = true;

    @SuppressWarnings({"deprecation", "unchecked"})
    ChronicleHashBuilderPrivateAPI<K, ?> privateAPI =
            (ChronicleHashBuilderPrivateAPI<K, ?>) builder.privateAPI();

    // Data model
    SerializationBuilder<K> keyBuilder = privateAPI.keyBuilder();
    keyClass = keyBuilder.tClass;
    keySizeMarshaller = keyBuilder.sizeMarshaller();
    keyReader = keyBuilder.reader();
    keyDataAccess = keyBuilder.dataAccess();

    actualSegments = privateAPI.actualSegments();
    hashSplitting = HashSplitting.forSegments(actualSegments);

    chunkSize = privateAPI.chunkSize();
    maxChunksPerEntry = privateAPI.maxChunksPerEntry();
    actualChunksPerSegmentTier = privateAPI.actualChunksPerSegmentTier();

    // Precomputed offsets and sizes for fast Context init
    segmentHeaderSize = privateAPI.segmentHeaderSize();

    tierHashLookupValueBits = valueBits(actualChunksPerSegmentTier);
    tierHashLookupKeyBits = keyBits(privateAPI.entriesPerSegment(), tierHashLookupValueBits);
    tierHashLookupSlotSize =
            entrySize(tierHashLookupKeyBits, tierHashLookupValueBits);
    if (!privateAPI.aligned64BitMemoryOperationsAtomic() && tierHashLookupSlotSize > 4) {
        throw new IllegalStateException("aligned64BitMemoryOperationsAtomic() == false, " +
                "but hash lookup slot is " + tierHashLookupSlotSize);
    }
    tierHashLookupCapacity = privateAPI.tierHashLookupCapacity();
    maxEntriesPerHashLookup = (long) (tierHashLookupCapacity * MAX_LOAD_FACTOR);
    tierHashLookupInnerSize = tierHashLookupCapacity * tierHashLookupSlotSize;
    tierHashLookupOuterSize = CACHE_LINES.align(tierHashLookupInnerSize, BYTES);

    tierFreeListInnerSize = LONGS.align(
            BYTES.alignAndConvert(actualChunksPerSegmentTier, BITS), BYTES);
    tierFreeListOuterSize = CACHE_LINES.align(tierFreeListInnerSize, BYTES);

    tierEntrySpaceInnerSize = chunkSize * actualChunksPerSegmentTier;
    tierEntrySpaceInnerOffset = privateAPI.segmentEntrySpaceInnerOffset();
    tierEntrySpaceOuterSize = CACHE_LINES.align(
            tierEntrySpaceInnerOffset + tierEntrySpaceInnerSize, BYTES);

    tierSize = tierSize();

    maxExtraTiers = privateAPI.maxExtraTiers();
    tiersInBulk = computeNumberOfTiersInBulk();
    log2TiersInBulk = Maths.intLog2(tiersInBulk);
    tierBulkInnerOffsetToTiers = computeTierBulkInnerOffsetToTiers(tiersInBulk);
    tierBulkSizeInBytes = computeTierBulkBytesSize(tiersInBulk);

    checksumEntries = privateAPI.checksumEntries();
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:60,代码来源:VanillaChronicleHash.java


示例19: newShmIntString

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
static ChronicleMap<Integer, CharSequence> newShmIntString(int size) throws IOException {
    return ChronicleMapBuilder.of(Integer.class, CharSequence.class)
            .averageValueSize(1)
            .entries(size).create();
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:6,代码来源:ChronicleMapTest.java


示例20: newStrStrMap

import net.openhft.chronicle.map.ChronicleMapBuilder; //导入依赖的package包/类
static ChronicleMap<CharSequence, CharSequence> newStrStrMap(int size) throws IOException {
    return ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
            .averageKeySize(20).averageValueSize(20)
            .entries(size).create();
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Map,代码行数:6,代码来源:ChronicleMapTest.java



注:本文中的net.openhft.chronicle.map.ChronicleMapBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StyleImpl类代码示例发布时间:2022-05-23
下一篇:
Java IpPrefix类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap