Skip to content

Commit 1e2b580

Browse files
initial commit
0 parents  commit 1e2b580

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4031
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.ipr
2+
*.iws
3+
.idea/*
4+
*.iml
5+
target/*

COPYRIGHT

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Copyright (c) Metadata Partners, LLC.
2+
// All rights reserved.

docs/overview.org

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
* Objectives
2+
** efficient
3+
*** compact
4+
*** support primitives
5+
*** avoid copying/boxing
6+
** general
7+
** extensible
8+
** self-describing
9+
** avoid platform specifics
10+
* Extensibility
11+
** fixed set of core types
12+
** extension types in terms of core types
13+
*** avoid blobs
14+
** no type descriptors, just components
15+
*** enough to skip unknown
16+
* Core Types
17+
| Tag | Fressian | Notes |
18+
|--------+----------+--------------------------------------------------|
19+
| null | null | not really a type, but possible value everywhere |
20+
| true | true | special value |
21+
| false | false | special value |
22+
| int | int | |
23+
| double | double | |
24+
| float | float | |
25+
| string | string | |
26+
| bytes | bytes | array of bytes in user semantics |
27+
| list | list | |
28+
| struct | struct | must supply type tag |
29+
* Standard Extension Types
30+
| Tag | size | struct | notes |
31+
|---------+------+---------------+-------------------------------------------|
32+
| map | 1 | list<k,v> | |
33+
| set | 1 | list | |
34+
| inst | 1 | int | ms since 1970 |
35+
| sym | 2 | string,string | |
36+
| uuid | 1 | bytes | |
37+
| uri | 1 | string | |
38+
| bigint | 1 | bytes | signed, two's complement, msb first |
39+
| bigdec | 2 | bytes,int | val (as per integer), scale |
40+
| regex | 1 | string | |
41+
| sym | 2 | ns, name | |
42+
| key | 2 | ns, name | |
43+
| (array) | 2 | count, vals | int, long, float, double, boolean, Object |
44+
* Writer Interface
45+
** org.fressian.Writer
46+
**
47+
48+
* Tagged interface
49+
In order to support construction, writing and reading of (esp. nested)
50+
values of types for which there are no mappings, or no unique
51+
mappings, or coercion is required, a single Tagged type must be
52+
present. write(Object) must be able to distinguish Tagged objects.
53+
54+
55+

pom.xml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
6+
7+
<modelVersion>4.0.0</modelVersion>
8+
<groupId>com.metadatapartners</groupId>
9+
<artifactId>fressian</artifactId>
10+
<version>0.6.0</version>
11+
<name>${project.artifactId}</name>
12+
13+
<organization>
14+
<name>Metadata Partners, LLC</name>
15+
<url>http://www.metadatapartners.com/</url>
16+
</organization>
17+
18+
<properties>
19+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20+
</properties>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>org.clojure</groupId>
25+
<artifactId>clojure</artifactId>
26+
<version>1.4.0-beta4</version>
27+
<scope>test</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.clojure</groupId>
31+
<artifactId>test.generative</artifactId>
32+
<version>0.1.4</version>
33+
<scope>test</scope>
34+
</dependency>
35+
</dependencies>
36+
37+
<build>
38+
<sourceDirectory>${basedir}/src</sourceDirectory>
39+
<plugins>
40+
<plugin>
41+
<artifactId>maven-compiler-plugin</artifactId>
42+
<version>2.3.2</version>
43+
<configuration>
44+
<source>1.5</source>
45+
<target>1.5</target>
46+
</configuration>
47+
</plugin>
48+
<plugin>
49+
<groupId>com.theoryinpractise</groupId>
50+
<artifactId>clojure-maven-plugin</artifactId>
51+
<version>1.3.6</version>
52+
<configuration>
53+
<sourceDirectories>
54+
<sourceDirectory>src</sourceDirectory>
55+
</sourceDirectories>
56+
<testSourceDirectories>
57+
<testSourceDirectory>test</testSourceDirectory>
58+
</testSourceDirectories>
59+
<testScript>script/run_generative_tests.clj</testScript>
60+
<copiedNamespaces>
61+
<namespace>!.*</namespace>
62+
</copiedNamespaces>
63+
<warnOnReflection>true</warnOnReflection>
64+
</configuration>
65+
<executions>
66+
<execution>
67+
<id>test-clojure</id>
68+
<phase>test</phase>
69+
<goals>
70+
<goal>test</goal>
71+
</goals>
72+
</execution>
73+
</executions>
74+
</plugin>
75+
</plugins>
76+
</build>
77+
</project>

script/run_generative_tests.clj

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(set! *warn-on-reflection* true)
2+
3+
(use '[clojure.test.generative])
4+
(try
5+
(binding [*msec* 10000]
6+
(let [futures (test-dirs "test")]
7+
(doseq [f futures]
8+
@f)))
9+
(catch Throwable t
10+
(.printStackTrace t)
11+
(System/exit -1))
12+
(finally
13+
(shutdown-agents)))
14+
15+

src/org/fressian/Cached.java

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) Metadata Partners, LLC.
2+
// All rights reserved.
3+
package org.fressian;
4+
5+
public interface Cached {
6+
public Object getObjectToCache();
7+
}

src/org/fressian/CachedObject.java

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) Metadata Partners, LLC.
2+
// All rights reserved.
3+
4+
package org.fressian;
5+
6+
public class CachedObject implements Cached {
7+
public final Object objectToCache;
8+
9+
public CachedObject(Object objectToCache) {
10+
this.objectToCache = objectToCache;
11+
}
12+
13+
public Object getObjectToCache() {
14+
return objectToCache;
15+
}
16+
17+
public static Object unwrap(Object o) {
18+
if (o instanceof Cached) {
19+
return ((Cached)o).getObjectToCache();
20+
}
21+
return o;
22+
}
23+
}

src/org/fressian/Codes.java

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright (c) Metadata Partners, LLC.
2+
// All rights reserved.
3+
4+
package org.fressian;
5+
6+
public class Codes {
7+
public static final int PRIORITY_CACHE_PACKED_START = 0x80;
8+
public static final int PRIORITY_CACHE_PACKED_END = 0xA0;
9+
public static final int STRUCT_CACHE_PACKED_START = 0xA0;
10+
public static final int STRUCT_CACHE_PACKED_END = 0xB0;
11+
public static final int LONG_ARRAY = 0xB0;
12+
public static final int DOUBLE_ARRAY = 0xB1;
13+
public static final int BOOLEAN_ARRAY = 0xB2;
14+
public static final int INT_ARRAY = 0xB3;
15+
public static final int FLOAT_ARRAY = 0xB4;
16+
public static final int OBJECT_ARRAY = 0xB5;
17+
public static final int MAP = 0xC0;
18+
public static final int SET = 0xC1;
19+
public static final int UUID = 0xC3;
20+
public static final int REGEX = 0xC4;
21+
public static final int URI = 0xC5;
22+
public static final int BIGINT = 0xC6;
23+
public static final int BIGDEC = 0xC7;
24+
public static final int INST = 0xC8;
25+
public static final int SYM = 0xC9;
26+
public static final int KEY = 0xCA;
27+
public static final int GET_PRIORITY_CACHE = 0xCC;
28+
public static final int PUT_PRIORITY_CACHE = 0xCD;
29+
public static final int PRECACHE = 0xCE;
30+
public static final int FOOTER = 0xCF;
31+
public static final int FOOTER_MAGIC = 0xCFCFCFCF;
32+
public static final int BYTES_PACKED_LENGTH_START = 0xD0;
33+
public static final int BYTES_PACKED_LENGTH_END = 0xD8;
34+
public static final int BYTES_CHUNK = 0xD8;
35+
public static final int BYTES = 0xD9;
36+
public static final int STRING_PACKED_LENGTH_START = 0xDA;
37+
public static final int STRING_PACKED_LENGTH_END = 0xE2;
38+
public static final int STRING_CHUNK = 0xE2;
39+
public static final int STRING = 0xE3;
40+
public static final int LIST_PACKED_LENGTH_START = 0xE4;
41+
public static final int LIST_PACKED_LENGTH_END = 0xEC;
42+
public static final int LIST = 0xEC;
43+
public static final int BEGIN_CLOSED_LIST = 0xED;
44+
public static final int BEGIN_OPEN_LIST = 0xEE;
45+
public static final int STRUCTTYPE = 0xEF;
46+
public static final int STRUCT = 0xF0;
47+
public static final int META = 0xF1;
48+
public static final int ANY = 0xF4;
49+
public static final int TRUE = 0xF5;
50+
public static final int FALSE = 0xF6;
51+
public static final int NULL = 0xF7;
52+
public static final int INT = 0xF8;
53+
public static final int FLOAT = 0xF9;
54+
public static final int DOUBLE = 0xFA;
55+
public static final int DOUBLE_0 = 0xFB;
56+
public static final int DOUBLE_1 = 0xFC;
57+
public static final int END_COLLECTION = 0xFD;
58+
public static final int RESET_CACHES = 0xFE;
59+
public static final int INT_PACKED_1_START = 0xFF;
60+
public static final int INT_PACKED_1_END = 0x40;
61+
public static final int INT_PACKED_2_START = 0x40;
62+
public static final int INT_PACKED_2_ZERO = 0x50;
63+
public static final int INT_PACKED_2_END = 0x60;
64+
public static final int INT_PACKED_3_START = 0x60;
65+
public static final int INT_PACKED_3_ZERO = 0x68;
66+
public static final int INT_PACKED_3_END = 0x70;
67+
public static final int INT_PACKED_4_START = 0x70;
68+
public static final int INT_PACKED_4_ZERO = 0x72;
69+
public static final int INT_PACKED_4_END = 0x74;
70+
public static final int INT_PACKED_5_START = 0x74;
71+
public static final int INT_PACKED_5_ZERO = 0x76;
72+
public static final int INT_PACKED_5_END = 0x78;
73+
public static final int INT_PACKED_6_START = 0x78;
74+
public static final int INT_PACKED_6_ZERO = 0x7A;
75+
public static final int INT_PACKED_6_END = 0x7C;
76+
public static final int INT_PACKED_7_START = 0x7C;
77+
public static final int INT_PACKED_7_ZERO = 0x7E;
78+
public static final int INT_PACKED_7_END = 0x80;
79+
}

0 commit comments

Comments
 (0)