Permalink
Browse files

initial commit

  • Loading branch information...
stuarthalloway committed Mar 17, 2012
0 parents commit 1e2b5807690459135f9d27cca47bb9d064c14869
Showing with 4,031 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +2 −0 COPYRIGHT
  3. +55 −0 docs/overview.org
  4. +77 −0 pom.xml
  5. +15 −0 script/run_generative_tests.clj
  6. +7 −0 src/org/fressian/Cached.java
  7. +23 −0 src/org/fressian/CachedObject.java
  8. +79 −0 src/org/fressian/Codes.java
  9. +153 −0 src/org/fressian/Fns.java
  10. +953 −0 src/org/fressian/FressianReader.java
  11. +494 −0 src/org/fressian/FressianWriter.java
  12. +260 −0 src/org/fressian/InterleavedIndexHopMap.java
  13. +72 −0 src/org/fressian/Ranges.java
  14. +110 −0 src/org/fressian/RawInput.java
  15. +114 −0 src/org/fressian/RawOutput.java
  16. +15 −0 src/org/fressian/Reader.java
  17. +46 −0 src/org/fressian/StreamingWriter.java
  18. +14 −0 src/org/fressian/StructType.java
  19. +12 −0 src/org/fressian/Tagged.java
  20. +34 −0 src/org/fressian/TaggedObject.java
  21. +29 −0 src/org/fressian/Writer.java
  22. +36 −0 src/org/fressian/handlers/CachingLookup.java
  23. +19 −0 src/org/fressian/handlers/ChainedLookup.java
  24. +8 −0 src/org/fressian/handlers/ConvertBytes.java
  25. +8 −0 src/org/fressian/handlers/ConvertDouble.java
  26. +8 −0 src/org/fressian/handlers/ConvertFloat.java
  27. +10 −0 src/org/fressian/handlers/ConvertList.java
  28. +413 −0 src/org/fressian/handlers/Handlers.java
  29. +8 −0 src/org/fressian/handlers/ILookup.java
  30. +6 −0 src/org/fressian/handlers/IWriteHandlerLookup.java
  31. +60 −0 src/org/fressian/handlers/InheritanceLookup.java
  32. +19 −0 src/org/fressian/handlers/MapLookup.java
  33. +12 −0 src/org/fressian/handlers/ReadHandler.java
  34. +12 −0 src/org/fressian/handlers/WriteHandler.java
  35. +48 −0 src/org/fressian/handlers/WriteHandlerLookup.java
  36. +58 −0 src/org/fressian/impl/ByteBufferInputStream.java
  37. +24 −0 src/org/fressian/impl/BytesOutputStream.java
  38. +142 −0 test/org/fressian/api.clj
  39. +58 −0 test/org/fressian/caching_test.clj
  40. +216 −0 test/org/fressian/codegen.clj
  41. +69 −0 test/org/fressian/fressian_test.clj
  42. +143 −0 test/org/fressian/generators.clj
  43. +85 −0 test/org/fressian/test_helpers.clj
@@ -0,0 +1,5 @@
*.ipr
*.iws
.idea/*
*.iml
target/*
@@ -0,0 +1,2 @@
// Copyright (c) Metadata Partners, LLC.
// All rights reserved.
@@ -0,0 +1,55 @@
* Objectives
** efficient
*** compact
*** support primitives
*** avoid copying/boxing
** general
** extensible
** self-describing
** avoid platform specifics
* Extensibility
** fixed set of core types
** extension types in terms of core types
*** avoid blobs
** no type descriptors, just components
*** enough to skip unknown
* Core Types
| Tag | Fressian | Notes |
|--------+----------+--------------------------------------------------|
| null | null | not really a type, but possible value everywhere |
| true | true | special value |
| false | false | special value |
| int | int | |
| double | double | |
| float | float | |
| string | string | |
| bytes | bytes | array of bytes in user semantics |
| list | list | |
| struct | struct | must supply type tag |
* Standard Extension Types
| Tag | size | struct | notes |
|---------+------+---------------+-------------------------------------------|
| map | 1 | list<k,v> | |
| set | 1 | list | |
| inst | 1 | int | ms since 1970 |
| sym | 2 | string,string | |
| uuid | 1 | bytes | |
| uri | 1 | string | |
| bigint | 1 | bytes | signed, two's complement, msb first |
| bigdec | 2 | bytes,int | val (as per integer), scale |
| regex | 1 | string | |
| sym | 2 | ns, name | |
| key | 2 | ns, name | |
| (array) | 2 | count, vals | int, long, float, double, boolean, Object |
* Writer Interface
** org.fressian.Writer
**
* Tagged interface
In order to support construction, writing and reading of (esp. nested)
values of types for which there are no mappings, or no unique
mappings, or coercion is required, a single Tagged type must be
present. write(Object) must be able to distinguish Tagged objects.
77 pom.xml
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.metadatapartners</groupId>
<artifactId>fressian</artifactId>
<version>0.6.0</version>
<name>${project.artifactId}</name>
<organization>
<name>Metadata Partners, LLC</name>
<url>http://www.metadatapartners.com/</url>
</organization>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.4.0-beta4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>test.generative</artifactId>
<version>0.1.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>${basedir}/src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>com.theoryinpractise</groupId>
<artifactId>clojure-maven-plugin</artifactId>
<version>1.3.6</version>
<configuration>
<sourceDirectories>
<sourceDirectory>src</sourceDirectory>
</sourceDirectories>
<testSourceDirectories>
<testSourceDirectory>test</testSourceDirectory>
</testSourceDirectories>
<testScript>script/run_generative_tests.clj</testScript>
<copiedNamespaces>
<namespace>!.*</namespace>
</copiedNamespaces>
<warnOnReflection>true</warnOnReflection>
</configuration>
<executions>
<execution>
<id>test-clojure</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,15 @@
(set! *warn-on-reflection* true)
(use '[clojure.test.generative])
(try
(binding [*msec* 10000]
(let [futures (test-dirs "test")]
(doseq [f futures]
@f)))
(catch Throwable t
(.printStackTrace t)
(System/exit -1))
(finally
(shutdown-agents)))
@@ -0,0 +1,7 @@
// Copyright (c) Metadata Partners, LLC.
// All rights reserved.
package org.fressian;
public interface Cached {
public Object getObjectToCache();
}
@@ -0,0 +1,23 @@
// Copyright (c) Metadata Partners, LLC.
// All rights reserved.
package org.fressian;
public class CachedObject implements Cached {
public final Object objectToCache;
public CachedObject(Object objectToCache) {
this.objectToCache = objectToCache;
}
public Object getObjectToCache() {
return objectToCache;
}
public static Object unwrap(Object o) {
if (o instanceof Cached) {
return ((Cached)o).getObjectToCache();
}
return o;
}
}
@@ -0,0 +1,79 @@
// Copyright (c) Metadata Partners, LLC.
// All rights reserved.
package org.fressian;
public class Codes {
public static final int PRIORITY_CACHE_PACKED_START = 0x80;
public static final int PRIORITY_CACHE_PACKED_END = 0xA0;
public static final int STRUCT_CACHE_PACKED_START = 0xA0;
public static final int STRUCT_CACHE_PACKED_END = 0xB0;
public static final int LONG_ARRAY = 0xB0;
public static final int DOUBLE_ARRAY = 0xB1;
public static final int BOOLEAN_ARRAY = 0xB2;
public static final int INT_ARRAY = 0xB3;
public static final int FLOAT_ARRAY = 0xB4;
public static final int OBJECT_ARRAY = 0xB5;
public static final int MAP = 0xC0;
public static final int SET = 0xC1;
public static final int UUID = 0xC3;
public static final int REGEX = 0xC4;
public static final int URI = 0xC5;
public static final int BIGINT = 0xC6;
public static final int BIGDEC = 0xC7;
public static final int INST = 0xC8;
public static final int SYM = 0xC9;
public static final int KEY = 0xCA;
public static final int GET_PRIORITY_CACHE = 0xCC;
public static final int PUT_PRIORITY_CACHE = 0xCD;
public static final int PRECACHE = 0xCE;
public static final int FOOTER = 0xCF;
public static final int FOOTER_MAGIC = 0xCFCFCFCF;
public static final int BYTES_PACKED_LENGTH_START = 0xD0;
public static final int BYTES_PACKED_LENGTH_END = 0xD8;
public static final int BYTES_CHUNK = 0xD8;
public static final int BYTES = 0xD9;
public static final int STRING_PACKED_LENGTH_START = 0xDA;
public static final int STRING_PACKED_LENGTH_END = 0xE2;
public static final int STRING_CHUNK = 0xE2;
public static final int STRING = 0xE3;
public static final int LIST_PACKED_LENGTH_START = 0xE4;
public static final int LIST_PACKED_LENGTH_END = 0xEC;
public static final int LIST = 0xEC;
public static final int BEGIN_CLOSED_LIST = 0xED;
public static final int BEGIN_OPEN_LIST = 0xEE;
public static final int STRUCTTYPE = 0xEF;
public static final int STRUCT = 0xF0;
public static final int META = 0xF1;
public static final int ANY = 0xF4;
public static final int TRUE = 0xF5;
public static final int FALSE = 0xF6;
public static final int NULL = 0xF7;
public static final int INT = 0xF8;
public static final int FLOAT = 0xF9;
public static final int DOUBLE = 0xFA;
public static final int DOUBLE_0 = 0xFB;
public static final int DOUBLE_1 = 0xFC;
public static final int END_COLLECTION = 0xFD;
public static final int RESET_CACHES = 0xFE;
public static final int INT_PACKED_1_START = 0xFF;
public static final int INT_PACKED_1_END = 0x40;
public static final int INT_PACKED_2_START = 0x40;
public static final int INT_PACKED_2_ZERO = 0x50;
public static final int INT_PACKED_2_END = 0x60;
public static final int INT_PACKED_3_START = 0x60;
public static final int INT_PACKED_3_ZERO = 0x68;
public static final int INT_PACKED_3_END = 0x70;
public static final int INT_PACKED_4_START = 0x70;
public static final int INT_PACKED_4_ZERO = 0x72;
public static final int INT_PACKED_4_END = 0x74;
public static final int INT_PACKED_5_START = 0x74;
public static final int INT_PACKED_5_ZERO = 0x76;
public static final int INT_PACKED_5_END = 0x78;
public static final int INT_PACKED_6_START = 0x78;
public static final int INT_PACKED_6_ZERO = 0x7A;
public static final int INT_PACKED_6_END = 0x7C;
public static final int INT_PACKED_7_START = 0x7C;
public static final int INT_PACKED_7_ZERO = 0x7E;
public static final int INT_PACKED_7_END = 0x80;
}
Oops, something went wrong.

0 comments on commit 1e2b580

Please sign in to comment.