private VarNominal() { this.reverse = new Object2ShortOpenHashMap<>(); this.reverse.put("?", (short) 0); this.dict = new ArrayList<>(); this.dict.add("?"); data = new short[0]; rows = 0; }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { rows = in.readInt(); dict = new ArrayList<>(); reverse = new Object2ShortOpenHashMap<>(); int len = in.readInt(); for (int i = 0; i < len; i++) { dict.add(in.readUTF()); reverse.put(dict.get(i), (short) i); } data = new short[rows]; for (int i = 0; i < rows; i++) { data[i] = in.readShort(); } }
@Override public void setLevels(String... dict) { List<String> oldDict = this.dict; if (dict.length > 0 && !dict[0].equals("?")) { String[] newDict = new String[dict.length + 1]; newDict[0] = "?"; System.arraycopy(dict, 0, newDict, 1, dict.length); dict = newDict; } if (this.dict.size() > dict.length) { throw new IllegalArgumentException("new levels does not contains all old labels"); } this.dict = new ArrayList<>(); this.reverse = new Object2ShortOpenHashMap<>(dict.length); this.dict.add("?"); this.reverse.put("?", (short) 0); short[] pos = new short[oldDict.size()]; for (int i = 0; i < dict.length; i++) { String term = dict[i]; if (!reverse.containsKey(term)) { this.dict.add(term); this.reverse.put(term, (short) this.reverse.size()); } if (i < oldDict.size()) pos[i] = this.reverse.getShort(term); } for (int i = 0; i < rows; i++) { data[i] = pos[data[i]]; } }
public ColumnStore(GraphStore graphStore, Class<T> elementType, boolean indexed) { if (MAX_SIZE >= Short.MAX_VALUE - Short.MIN_VALUE + 1) { throw new RuntimeException("Column Store size can't exceed 65534"); } this.graphStore = graphStore; this.configuration = graphStore != null ? graphStore.configuration : new Configuration(); this.lock = GraphStoreConfiguration.ENABLE_AUTO_LOCKING ? new TableLock() : null; this.garbageQueue = new ShortRBTreeSet(); this.idMap = new Object2ShortOpenHashMap<String>(MAX_SIZE); this.columns = new ColumnImpl[MAX_SIZE]; this.elementType = elementType; this.indexStore = indexed ? new IndexStore<T>(this) : null; idMap.defaultReturnValue(NULL_SHORT); this.observers = GraphStoreConfiguration.ENABLE_OBSERVERS ? new ArrayList<TableObserverImpl>() : null; }
public ColumnStore(GraphStore graphStore, Class<T> elementType, boolean indexed) { if (MAX_SIZE >= Short.MAX_VALUE - Short.MIN_VALUE + 1) { throw new RuntimeException("Column Store size can't exceed 65534"); } this.graphStore = graphStore; this.configuration = graphStore != null ? graphStore.configuration : new Configuration(); this.lock = GraphStoreConfiguration.ENABLE_AUTO_LOCKING ? new TableLock() : null; this.garbageQueue = new ShortRBTreeSet(); this.idMap = new Object2ShortOpenHashMap<String>(MAX_SIZE); this.columns = new ColumnImpl[MAX_SIZE]; this.elementType = elementType; this.indexStore = indexed ? new IndexStore<T>(this) : null; idMap.defaultReturnValue(NULL_SHORT); this.observers = GraphStoreConfiguration.ENABLE_OBSERVERS ? new ArrayList<TableObserverImpl>() : null; }
public EdgeTypeStore(Configuration config) { if (MAX_SIZE >= Short.MAX_VALUE - Short.MIN_VALUE + 1) { throw new RuntimeException("Edge Type Store size can't exceed 65534"); } this.configuration = config; this.garbageQueue = new ShortRBTreeSet(); this.labelMap = new Object2ShortOpenHashMap(MAX_SIZE); this.idMap = new Short2ObjectOpenHashMap(MAX_SIZE); labelMap.defaultReturnValue(NULL_SHORT); // Add null type short id = intToShort(NULL_LABEL); length++; labelMap.put(null, id); idMap.put(id, null); }
public EdgeTypeStore(Configuration config) { if (MAX_SIZE >= Short.MAX_VALUE - Short.MIN_VALUE + 1) { throw new RuntimeException("Edge Type Store size can't exceed 65534"); } this.configuration = config; this.garbageQueue = new ShortRBTreeSet(); this.labelMap = new Object2ShortOpenHashMap(MAX_SIZE); this.idMap = new Short2ObjectOpenHashMap(MAX_SIZE); labelMap.defaultReturnValue(NULL_SHORT); // Add null type short id = intToShort(NULL_LABEL); length++; labelMap.put(null, id); idMap.put(id, null); }
protected Object2ShortMap<FloodFill.Point> createFloodSources(DataView view, ShortRasterTile resultTile) { Object2ShortMap<FloodFill.Point> floodSources = new Object2ShortOpenHashMap<>(); for (int localY = 0; localY < view.getHeight(); localY++) { for (int localX = 0; localX < view.getWidth(); localX++) { int sampled = resultTile.getShort(localX, localY); if (this.isFillingBankType(sampled)) { if (localX > 0) { short left = (sampled & BANK_UP_FLAG) != 0 ? LAND : OCEAN; floodSources.put(new FloodFill.Point(localX - 1, localY), left); } if (localX < view.getWidth() - 1) { short right = (sampled & BANK_UP_FLAG) != 0 ? OCEAN : LAND; floodSources.put(new FloodFill.Point(localX + 1, localY), right); } } } } return floodSources; }