@Override public int compareTo(final ObjectWritable objectWritable) { if (null == this.t) return objectWritable.isEmpty() ? 0 : -1; else if (this.t instanceof Comparable && !objectWritable.isEmpty()) return ((Comparable) this.t).compareTo(objectWritable.get()); else if (this.t.equals(objectWritable.get())) return 0; else return -1; }
@Override public Set<String> keys() { if (this.inExecute) return this.broadcast.getValue().keySet(); else { final Set<String> trueKeys = new HashSet<>(); this.sparkMemory.forEach((key, value) -> { if (!value.value().isEmpty()) trueKeys.add(key); }); return Collections.unmodifiableSet(trueKeys); } }
protected void broadcastMemory(final JavaSparkContext sparkContext) { this.broadcast.destroy(true); // do we need to block? final Map<String, Object> toBroadcast = new HashMap<>(); this.sparkMemory.forEach((key, object) -> { if (!object.value().isEmpty() && this.memoryComputeKeys.get(key).isBroadcast()) toBroadcast.put(key, object.value()); }); this.broadcast = sparkContext.broadcast(toBroadcast); }
@Override public <R> R get(final String key) throws IllegalArgumentException { if (!this.memoryComputeKeys.containsKey(key)) throw Memory.Exceptions.memoryDoesNotExist(key); if (this.inExecute && !this.memoryComputeKeys.get(key).isBroadcast()) throw Memory.Exceptions.memoryDoesNotExist(key); final ObjectWritable<R> r = (ObjectWritable<R>) (this.inExecute ? this.broadcast.value().get(key) : this.sparkMemory.get(key).value()); if (null == r || r.isEmpty()) throw Memory.Exceptions.memoryDoesNotExist(key); else return r.get(); }
@Override public int compareTo(final ObjectWritable objectWritable) { if (null == this.t) return objectWritable.isEmpty() ? 0 : -1; else if (this.t instanceof Comparable && !objectWritable.isEmpty()) return ((Comparable) this.t).compareTo(objectWritable.get()); else if (this.t.equals(objectWritable.get())) return 0; else return -1; }
@Override public Set<String> keys() { if (this.inExecute) return this.broadcast.getValue().keySet(); else { final Set<String> trueKeys = new HashSet<>(); this.sparkMemory.forEach((key, value) -> { if (!value.value().isEmpty()) trueKeys.add(key); }); return Collections.unmodifiableSet(trueKeys); } }
@Override public Set<String> keys() { if (this.inExecute) { return this.broadcast.getValue().keySet(); } else { final Set<String> trueKeys = new HashSet<>(); this.sparkMemory.forEach((key, value) -> { if (!value.value().isEmpty()) { trueKeys.add(key); } }); return Collections.unmodifiableSet(trueKeys); } }
protected void broadcastMemory(final JavaSparkContext sparkContext) { this.broadcast.destroy(true); // do we need to block? final Map<String, Object> toBroadcast = new HashMap<>(); this.sparkMemory.forEach((key, object) -> { if (!object.value().isEmpty() && this.memoryComputeKeys.get(key).isBroadcast()) { toBroadcast.put(key, object.value()); } }); this.broadcast = sparkContext.broadcast(toBroadcast); }
protected void broadcastMemory(final JavaSparkContext sparkContext) { this.broadcast.destroy(true); // do we need to block? final Map<String, Object> toBroadcast = new HashMap<>(); this.sparkMemory.forEach((key, object) -> { if (!object.value().isEmpty() && this.memoryComputeKeys.get(key).isBroadcast()) toBroadcast.put(key, object.value()); }); this.broadcast = sparkContext.broadcast(toBroadcast); }
@Override public <R> R get(final String key) throws IllegalArgumentException { if (!this.memoryComputeKeys.containsKey(key)) throw Memory.Exceptions.memoryDoesNotExist(key); if (this.inExecute && !this.memoryComputeKeys.get(key).isBroadcast()) throw Memory.Exceptions.memoryDoesNotExist(key); final ObjectWritable<R> r = (ObjectWritable<R>) (this.inExecute ? this.broadcast.value().get(key) : this.sparkMemory.get(key).value()); if (null == r || r.isEmpty()) throw Memory.Exceptions.memoryDoesNotExist(key); else return r.get(); }
@Override public <R> R get(final String key) throws IllegalArgumentException { if (!this.memoryComputeKeys.containsKey(key)) { throw Memory.Exceptions.memoryDoesNotExist(key); } if (this.inExecute && !this.memoryComputeKeys.get(key).isBroadcast()) { throw Memory.Exceptions.memoryDoesNotExist(key); } final ObjectWritable<R> r = (ObjectWritable<R>) (this.inExecute ? this.broadcast.value().get(key) : this.sparkMemory.get(key).value()); if (null == r || r.isEmpty()) { throw Memory.Exceptions.memoryDoesNotExist(key); } else { return r.get(); } }