Skip to content

Commit 38f4a2c

Browse files
committed
Merge pull request #412 from cogmission/java_serialize
Introduces new PersistenceAPI
2 parents 1c55505 + fd78265 commit 38f4a2c

File tree

140 files changed

+29558
-1007
lines changed

Some content is hidden

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

140 files changed

+29558
-1007
lines changed

.classpath

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@
1717
<classpathentry kind="lib" path="libs/rxjava-1.0.10.jar" sourcepath="/Users/cogmission/Resources/RxJava/rxjava-1.0.10-sources.jar"/>
1818
<classpathentry kind="lib" path="libs/slf4j-api-1.7.10.jar"/>
1919
<classpathentry kind="lib" path="libs/trove-3.1a1.jar" sourcepath="/Users/cogmission/Resources/trove/3.1a1/trove-3.1a1-src.jar"/>
20+
<classpathentry kind="lib" path="libs/java-util-1.19.3.jar" sourcepath="/Users/cogmission/.m2/repository/com/cedarsoftware/java-util/1.19.3/java-util-1.19.3-sources.jar"/>
21+
<classpathentry kind="lib" path="libs/objenesis-2.1.jar"/>
22+
<classpathentry combineaccessrules="false" kind="src" path="/fast-serialization"/>
2023
<classpathentry kind="output" path="bin"/>
2124
</classpath>

Changelog.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Changes for Serialization branch (notes for CHANGELOG.md)
2+
3+
1. Renamed class ClassifierResult to Classification
4+
2. Renamed class EncoderResult to Encoding
5+
3. Removed extraneous constructor from FastRandom
6+
4. Added functionality to gradle build script:
7+
a.) Ability to see standard out/err
8+
b.) Changed ability to skip tests when code hasn't changed to "always run tests"
9+
c.) Added ability to toggle (b) so that it will skip again.
10+
5. Changed return type of assemble method of MultiEncoderAssembler from void to MultiEncoder
11+
6. Added getEncoderOfType(FieldMetaType type) method to MultiEncoder for convenient returning.
12+
7. Fixed erroneous creation of Sensors in every Layer of a multi-layer network (except the layer
13+
representing the entry point or input - where it belongs)
14+
8. Added Persistable interface which extends Serializable and all HTM object which are serializable
15+
implement.
16+
9. Added CheckPointer rx.Observable operator which executes check point operation and notification
17+
containing byte[] of serialized Network (can be ignored if not needed because it's save to disk)
18+
10. Added PersistenceAPI interface now implemented by Network.
19+
11. Added NetworkSerializer interface (and NetworkSerializerImpl) which executes FST serialization
20+
and simultaneously implements the Kryo interface also.
21+
12. Added the SerialConfig class which contains config information for the NetworkSerializer.

[ htm.java Integration Test ] BasicTemporalMemoryTest.launch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
33
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
4-
<listEntry value="/htm.java/src/test/java/org/numenta/nupic/integration/BasicTemporalMemoryTest.java"/>
4+
<listEntry value="/htm.java"/>
55
</listAttribute>
66
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
7-
<listEntry value="1"/>
7+
<listEntry value="4"/>
88
</listAttribute>
99
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
1010
<mapEntry key="[run]" value="org.eclipse.jdt.junit.launchconfig"/>

build.gradle

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ repositories {
2323
mavenCentral()
2424
}
2525

26+
// COMMENT OUT TO SKIP TESTS WHEN CODE HASN'T CHANGED
27+
test {
28+
outputs.upToDateWhen { false }
29+
}
30+
31+
/* UNCOMMENT TO SEE STANDARD_OUT & STANDARD_ERR DURING BUILD
32+
test {
33+
testLogging.showStandardStreams = true
34+
}*/
35+
2636
dependencies {
2737
compile group: 'joda-time', name: 'joda-time', version: '2.5'
2838
compile(group: 'com.chaschev', name: 'chutils', version:'1.4') {
@@ -37,8 +47,10 @@ dependencies {
3747
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version:'2.4.4'
3848
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.4.4'
3949
compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.10'
40-
compile group: 'io.reactivex', name: 'rxjava', version: '1.0.10'
41-
testCompile group: 'junit', name: 'junit', version:'4.11'
50+
compile group: 'io.reactivex', name: 'rxjava', version: '1.0.10'
51+
compile group: 'de.ruedigermoeller', name: 'fst', version: '2.45'
52+
compile group: 'com.cedarsoftware', name: 'java-util', version: '1.19.3'
53+
testCompile group: 'junit', name: 'junit', version:'4.11'
4254
testCompile group: 'ch.qos.logback', name: 'logback-classic', version:'1.1.2'
4355
}
4456

libs/fst-2.45.jar

367 KB
Binary file not shown.

libs/java-util-1.19.3.jar

70.6 KB
Binary file not shown.

libs/objenesis-2.1.jar

40.8 KB
Binary file not shown.

pom.xml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</scm>
3939
<properties>
4040
<argLine>-Xmx2048m -Xms1024m</argLine>
41-
</properties>
41+
</properties>
4242
<dependencies>
4343
<dependency>
4444
<groupId>joda-time</groupId>
@@ -49,8 +49,8 @@
4949
<groupId>com.chaschev</groupId>
5050
<artifactId>chutils</artifactId>
5151
<version>1.4</version>
52-
<!--WE ONLY INTERESTED IN ASCIITable from this library, so exclude all
53-
transitive dependencies -->
52+
<!--We're only interested in ASCIITable from this library, so exclude
53+
all transitive dependencies -->
5454
<exclusions>
5555
<exclusion>
5656
<groupId>org.mockito</groupId>
@@ -117,6 +117,16 @@
117117
<version>1.0.10</version>
118118
<scope />
119119
</dependency>
120+
<dependency>
121+
<groupId>com.cedarsoftware</groupId>
122+
<artifactId>java-util</artifactId>
123+
<version>1.19.3</version>
124+
</dependency>
125+
<dependency>
126+
<groupId>de.ruedigermoeller</groupId>
127+
<artifactId>fst</artifactId>
128+
<version>2.45</version>
129+
</dependency>
120130
<dependency>
121131
<groupId>org.openjdk.jmh</groupId>
122132
<artifactId>jmh-core</artifactId>

src/main/java/org/numenta/nupic/ComputeCycle.java

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
*
4141
* @author David Ray
4242
*/
43-
public class ComputeCycle {
43+
public class ComputeCycle implements Persistable {
44+
private static final long serialVersionUID = 1L;
45+
4446
public Set<Cell> activeCells = new LinkedHashSet<>();
4547
public Set<Cell> winnerCells = new LinkedHashSet<>();
4648
public Set<Cell> predictiveCells = new LinkedHashSet<>();
@@ -149,4 +151,83 @@ public Set<DistalDendrite> matchingSegments() {
149151
public Set<Cell> matchingCells() {
150152
return matchingCells;
151153
}
154+
155+
/* (non-Javadoc)
156+
* @see java.lang.Object#hashCode()
157+
*/
158+
@Override
159+
public int hashCode() {
160+
final int prime = 31;
161+
int result = 1;
162+
result = prime * result + ((activeCells == null) ? 0 : activeCells.hashCode());
163+
result = prime * result + ((activeSegments == null) ? 0 : activeSegments.hashCode());
164+
result = prime * result + ((learningSegments == null) ? 0 : learningSegments.hashCode());
165+
result = prime * result + ((matchingCells == null) ? 0 : matchingCells.hashCode());
166+
result = prime * result + ((matchingSegments == null) ? 0 : matchingSegments.hashCode());
167+
result = prime * result + ((predictedInactiveCells == null) ? 0 : predictedInactiveCells.hashCode());
168+
result = prime * result + ((predictiveCells == null) ? 0 : predictiveCells.hashCode());
169+
result = prime * result + ((successfullyPredictedColumns == null) ? 0 : successfullyPredictedColumns.hashCode());
170+
result = prime * result + ((winnerCells == null) ? 0 : winnerCells.hashCode());
171+
return result;
172+
}
173+
174+
/* (non-Javadoc)
175+
* @see java.lang.Object#equals(java.lang.Object)
176+
*/
177+
@Override
178+
public boolean equals(Object obj) {
179+
if(this == obj)
180+
return true;
181+
if(obj == null)
182+
return false;
183+
if(getClass() != obj.getClass())
184+
return false;
185+
ComputeCycle other = (ComputeCycle)obj;
186+
if(activeCells == null) {
187+
if(other.activeCells != null)
188+
return false;
189+
} else if(!activeCells.equals(other.activeCells))
190+
return false;
191+
if(activeSegments == null) {
192+
if(other.activeSegments != null)
193+
return false;
194+
} else if(!activeSegments.equals(other.activeSegments))
195+
return false;
196+
if(learningSegments == null) {
197+
if(other.learningSegments != null)
198+
return false;
199+
} else if(!learningSegments.equals(other.learningSegments))
200+
return false;
201+
if(matchingCells == null) {
202+
if(other.matchingCells != null)
203+
return false;
204+
} else if(!matchingCells.equals(other.matchingCells))
205+
return false;
206+
if(matchingSegments == null) {
207+
if(other.matchingSegments != null)
208+
return false;
209+
} else if(!matchingSegments.equals(other.matchingSegments))
210+
return false;
211+
if(predictedInactiveCells == null) {
212+
if(other.predictedInactiveCells != null)
213+
return false;
214+
} else if(!predictedInactiveCells.equals(other.predictedInactiveCells))
215+
return false;
216+
if(predictiveCells == null) {
217+
if(other.predictiveCells != null)
218+
return false;
219+
} else if(!predictiveCells.equals(other.predictiveCells))
220+
return false;
221+
if(successfullyPredictedColumns == null) {
222+
if(other.successfullyPredictedColumns != null)
223+
return false;
224+
} else if(!successfullyPredictedColumns.equals(other.successfullyPredictedColumns))
225+
return false;
226+
if(winnerCells == null) {
227+
if(other.winnerCells != null)
228+
return false;
229+
} else if(!winnerCells.equals(other.winnerCells))
230+
return false;
231+
return true;
232+
}
152233
}

0 commit comments

Comments
 (0)