diff --git a/convex-benchmarks/src/main/java/convex/benchmarks/ThreadCoordinationBenchmark.java b/convex-benchmarks/src/main/java/convex/benchmarks/ThreadCoordinationBenchmark.java index 24f56e26f..c7e9de23a 100644 --- a/convex-benchmarks/src/main/java/convex/benchmarks/ThreadCoordinationBenchmark.java +++ b/convex-benchmarks/src/main/java/convex/benchmarks/ThreadCoordinationBenchmark.java @@ -21,7 +21,6 @@ public class ThreadCoordinationBenchmark { o = INPUT.take(); OUTPUT.put(o); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } diff --git a/convex-core/src/main/java/convex/core/data/AMap.java b/convex-core/src/main/java/convex/core/data/AMap.java index c0cca1b21..b276bd7d5 100644 --- a/convex-core/src/main/java/convex/core/data/AMap.java +++ b/convex-core/src/main/java/convex/core/data/AMap.java @@ -237,7 +237,7 @@ public final V get(Object key) { * @return Value for the specified key, or the notFound value. */ @SuppressWarnings("unchecked") - public final V get(ACell key, ACell notFound) { + public V get(ACell key, ACell notFound) { MapEntry me = getEntry((K) key); if (me == null) { return (V) notFound; diff --git a/convex-core/src/main/java/convex/core/data/ARecord.java b/convex-core/src/main/java/convex/core/data/ARecord.java index 65e57565d..248118a6d 100644 --- a/convex-core/src/main/java/convex/core/data/ARecord.java +++ b/convex-core/src/main/java/convex/core/data/ARecord.java @@ -53,8 +53,6 @@ protected ARecord toCanonical() { return true; } - - /** * Gets a vector of keys for this record * @@ -161,7 +159,6 @@ public final AMap dissoc(ACell key) { @Override public MapEntry getKeyRefEntry(Ref keyRef) { - // TODO: could maybe be more efficient? return getEntry(keyRef.getValue()); } @@ -228,8 +225,16 @@ public boolean print(BlobBuilder sb, long limit) { @Override public MapEntry getEntry(ACell k) { - if (!containsKey(k)) return null; - return MapEntry.create((Keyword)k,get(k)); + ACell v=get(k); + if ((v==null)&&!containsKey(k)) return null; //if null, need to check if key exists + return MapEntry.create((Keyword)k,v); + } + + @Override + public ACell get(ACell key, ACell notFound) { + ACell v=get(key); + if ((v==null)&&!containsKey(key)) return notFound; //if null, need to check if key exists + return v; } @Override diff --git a/convex-core/src/main/java/convex/core/data/AccountStatus.java b/convex-core/src/main/java/convex/core/data/AccountStatus.java index 0070299a9..6528bce3d 100644 --- a/convex-core/src/main/java/convex/core/data/AccountStatus.java +++ b/convex-core/src/main/java/convex/core/data/AccountStatus.java @@ -192,7 +192,7 @@ public static AccountStatus read(Blob b, int pos) throws BadFormatException { }; Address controller=null; if ((included&HAS_CONTROLLER)!=0) { - controller=Format.read(b, epos); // TODO should be raw Address, save a byte? + controller=Format.read(b, epos); epos+=controller.getEncodingLength(); } AHashMap environment = null; diff --git a/convex-core/src/main/java/convex/core/data/Address.java b/convex-core/src/main/java/convex/core/data/Address.java index 53cb386e3..960f8dbf1 100644 --- a/convex-core/src/main/java/convex/core/data/Address.java +++ b/convex-core/src/main/java/convex/core/data/Address.java @@ -303,7 +303,6 @@ public final int getBytes(byte[] bs, int pos) { @Override public long longValue() { - // TODO Auto-generated method stub return value; } diff --git a/convex-core/src/main/java/convex/core/data/Cells.java b/convex-core/src/main/java/convex/core/data/Cells.java index c27912a56..6426aec50 100644 --- a/convex-core/src/main/java/convex/core/data/Cells.java +++ b/convex-core/src/main/java/convex/core/data/Cells.java @@ -6,6 +6,7 @@ import java.util.function.Consumer; import convex.core.Result; +import convex.core.data.impl.DummyCell; import convex.core.exceptions.ParseException; import convex.core.store.AStore; import convex.core.store.Stores; @@ -27,6 +28,8 @@ public class Cells { */ public static final int MAX_BRANCH_COUNT = 68; + public static final ACell DUMMY = new DummyCell(); + /** * Equality method allowing for nulls * diff --git a/convex-core/src/main/java/convex/core/data/impl/DummyCell.java b/convex-core/src/main/java/convex/core/data/impl/DummyCell.java new file mode 100644 index 000000000..5221fe609 --- /dev/null +++ b/convex-core/src/main/java/convex/core/data/impl/DummyCell.java @@ -0,0 +1,73 @@ +package convex.core.data.impl; + +import convex.core.data.ACell; +import convex.core.data.Tag; +import convex.core.data.util.BlobBuilder; +import convex.core.exceptions.InvalidDataException; + +/** + * A dummy cell implementation, not a valid CVM value + */ +public class DummyCell extends ACell { + + @Override + public int estimatedEncodingSize() { + return 1; + } + + @Override + public void validateCell() throws InvalidDataException { + throw new InvalidDataException("This is a dummy value",this); + } + + @Override + protected byte getTag() { + return Tag.ILLEGAL; + } + + @Override + public boolean equals(ACell a) { + return this==a; + } + + @Override + public int encode(byte[] bs, int pos) { + bs[pos++]=Tag.ILLEGAL; + return pos; + } + + @Override + protected int encodeRaw(byte[] bs, int pos) { + // Nothing to encode + return pos; + } + + @Override + public boolean isCanonical() { + return true; + } + + @Override + protected ACell toCanonical() { + return this; + } + + @Override + public boolean isCVMValue() { + return false; + } + + @Override + public boolean isDataValue() { + return false; + } + + @Override + public boolean print(BlobBuilder sb, long limit) { + sb.append("DUMMY"); + return sb.check(limit); + } + + + +}