Skip to content

Instantly share code, notes, and snippets.

@fancellu
Created October 3, 2014 19:56
Embed
What would you like to do?
Tiny Chronicle Map + Scala example
package chroniclemap
import net.openhft.chronicle.map._
import java.io.File
object C1 extends App {
val tmp = System.getProperty("java.io.tmpdir");
val pathname = tmp + "/mychronicle.dat";
val file = new File(pathname)
val size=1000000
val map= ChronicleMapBuilder.of(classOf[Integer], classOf[CharSequence]).entries(size).file(file).create
val sb=new StringBuilder()
val ti=System.currentTimeMillis()
for (x<-1 to size)
{
val acquired=map.acquireUsing(x, sb)
map.put(x,"oink "+new java.util.Date)
//println(s"$x $acquired")
}
println(System.currentTimeMillis()-ti)
map.close()
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Scala-1.8</groupId>
<artifactId>Scala-1.8</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<scala.version>2.11.2</scala.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<!-- see http://davidb.github.com/scala-maven-plugin -->
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<jvmArgs>
<jvmArg>-Xms512m</jvmArg>
<jvmArg>-Xmx4096m</jvmArg>
</jvmArgs>
<args>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>net.openhft</groupId>
<artifactId>chronicle-map</artifactId>
<version>1.0.2</version>
<exclusions>
<exclusion>
<groupId>com.sun.java</groupId>
<artifactId>tools</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment