Skip to content

Commit

Permalink
Improved hash functions
Browse files Browse the repository at this point in the history
  • Loading branch information
michbarsinai committed Feb 21, 2019
1 parent 650d19c commit f2d87b9
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ a link to this page somewhere in the documentation/system about section.

## Change Log for the BPjs Library.

### 2019-02-10
* :arrow_up: Improved hash functions for `ContinuationProgramState` (affects b-thread sync snapshots as well).

### 2019-02-10
* :bug: Instances of the constant sets class `EventSets` now cannot be duplicated even when they are serialized.
* :bug: Fixed a bug in the verifier, where inspections were invoked twice.
Expand Down
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.github.bthink-bgu</groupId>
<artifactId>BPjs</artifactId>
<name>BPjs</name>
<version>0.9.9</version>
<version>0.10.0-SNAPSHOT</version>
<description>Provides a runtime for behavioral programs written in Javascript. It can
run stand-alone (from the commmandline) or be embedded in larger
JVM-based systems.</description>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.bthink-bgu</groupId>
<artifactId>BPjs</artifactId>
<version>0.9.9</version>
<version>0.10.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>BPjs</name>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/il/ac/bgu/cs/bp/bpjs/mains/BPJsCliRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ private static void println(String template, String... params) {

private static void print(String template, String... params) {
if (params.length == 0) {
System.out.print("# " + template);
System.out.print(template);
} else {
System.out.printf("# " + template, (Object[]) params);
System.out.printf(template, (Object[]) params);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ Stream<StartFork> convertToTasks(ForkStatement fkStmt, BPEngineTask.Listener lis

@Override
public int hashCode() {
return threadSnapshots.hashCode() ^ externalEvents.hashCode() ;
return Objects.hash(threadSnapshots, externalEvents);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public int hashCode() {
final int prime = 31;
int result = prime * Objects.hash(name, syncStatement);
if (continuation != null) {
result ^= getContinuationProgramState().hashCode();
result += getContinuationProgramState().hashCode();
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ private Object getValue( Object instance, String fieldName ) throws NoSuchFieldE

@Override
public int hashCode() {
return 37 * (programCounter+1) * (frameIndex+1) *
(variables.entrySet().stream()
.map( es->Objects.hash(es.getKey(), es.getValue()) )
.collect( Collectors.reducing(0, (x,y)->x*y))+1);
return 37*programCounter
+ frameIndex
+ variables.entrySet().stream()
.map( es->Objects.hash(es.getKey(), es.getValue()) )
.collect( Collectors.reducing(0, (x,y)->x+y) );
}

@Override
Expand Down

0 comments on commit f2d87b9

Please sign in to comment.