/** * Returns the IterationType for the given ID. * * @return the IterationType for the given ID * @throws IllegalArgumentException if no IterationType was found */ public static IterationType getById(byte id) { for (IterationType type : values()) { if (type.id == id) { return type; } } throw new IllegalArgumentException("unknown id:" + id); } }
@Override public void readData(ObjectDataInput in) throws IOException { int partitionSize = in.readInt(); if (partitionSize > 0) { partitionIds = new ArrayList<Integer>(partitionSize); for (int i = 0; i < partitionSize; i++) { partitionIds.add(in.readInt()); } } iterationType = IterationType.getById(in.readByte()); int resultSize = in.readInt(); if (resultSize > 0) { for (int i = 0; i < resultSize; i++) { QueryResultRow row = new QueryResultRow(); row.readData(in); rows.add(row); } } }
@Override public void writeData(ObjectDataOutput out) throws IOException { int partitionSize = (partitionIds == null) ? 0 : partitionIds.size(); out.writeInt(partitionSize); if (partitionSize > 0) { for (Integer partitionId : partitionIds) { out.writeInt(partitionId); } } out.writeByte(iterationType.getId()); int resultSize = rows.size(); out.writeInt(resultSize); if (resultSize > 0) { for (QueryResultRow row : (List<QueryResultRow>) rows) { row.writeData(out); } } }
@Override public void writeData(ObjectDataOutput out) throws IOException { out.writeObject(predicate); out.writeObject(comparator); out.writeInt(page); out.writeInt(pageSize); out.writeUTF(iterationType.name()); out.writeInt(anchorList.size()); for (Map.Entry<Integer, Map.Entry<K, V>> anchor : anchorList) { out.writeInt(anchor.getKey()); Map.Entry<K, V> anchorEntry = anchor.getValue(); out.writeObject(anchorEntry.getKey()); out.writeObject(anchorEntry.getValue()); } }
@Override public void readData(ObjectDataInput in) throws IOException { predicate = in.readObject(); comparator = in.readObject(); page = in.readInt(); pageSize = in.readInt(); iterationType = IterationType.valueOf(in.readUTF()); int size = in.readInt(); anchorList = new ArrayList<Map.Entry<Integer, Map.Entry<K, V>>>(size); for (int i = 0; i < size; i++) { int anchorPage = in.readInt(); Object anchorKey = in.readObject(); Object anchorValue = in.readObject(); Map.Entry anchorEntry = new SimpleImmutableEntry(anchorKey, anchorValue); anchorList.add(new SimpleImmutableEntry<Integer, Map.Entry<K, V>>(anchorPage, anchorEntry)); } }
@Override public void readData(ObjectDataInput in) throws IOException { int partitionSize = in.readInt(); if (partitionSize > 0) { partitionIds = new ArrayList<Integer>(partitionSize); for (int i = 0; i < partitionSize; i++) { partitionIds.add(in.readInt()); } } iterationType = IterationType.getById(in.readByte()); int resultSize = in.readInt(); if (resultSize > 0) { for (int i = 0; i < resultSize; i++) { QueryResultRow row = new QueryResultRow(); row.readData(in); rows.add(row); } } }
@Override public void writeData(ObjectDataOutput out) throws IOException { int partitionSize = (partitionIds == null) ? 0 : partitionIds.size(); out.writeInt(partitionSize); if (partitionSize > 0) { for (Integer partitionId : partitionIds) { out.writeInt(partitionId); } } out.writeByte(iterationType.getId()); int resultSize = rows.size(); out.writeInt(resultSize); if (resultSize > 0) { for (QueryResultRow row : (List<QueryResultRow>) rows) { row.writeData(out); } } }
@Override public void writeData(ObjectDataOutput out) throws IOException { out.writeObject(predicate); out.writeObject(comparator); out.writeInt(page); out.writeInt(pageSize); out.writeUTF(iterationType.name()); out.writeInt(anchorList.size()); for (Map.Entry<Integer, Map.Entry<K, V>> anchor : anchorList) { out.writeInt(anchor.getKey()); Map.Entry<K, V> anchorEntry = anchor.getValue(); out.writeObject(anchorEntry.getKey()); out.writeObject(anchorEntry.getValue()); } }
@Override public void readData(ObjectDataInput in) throws IOException { predicate = in.readObject(); comparator = in.readObject(); page = in.readInt(); pageSize = in.readInt(); iterationType = IterationType.valueOf(in.readUTF()); int size = in.readInt(); anchorList = new ArrayList<Map.Entry<Integer, Map.Entry<K, V>>>(size); for (int i = 0; i < size; i++) { int anchorPage = in.readInt(); Object anchorKey = in.readObject(); Object anchorValue = in.readObject(); Map.Entry anchorEntry = new SimpleImmutableEntry(anchorKey, anchorValue); anchorList.add(new SimpleImmutableEntry<Integer, Map.Entry<K, V>>(anchorPage, anchorEntry)); } }
@Override public void readData(ObjectDataInput in) throws IOException { this.mapName = in.readUTF(); this.predicate = in.readObject(); this.iterationType = IterationType.getById(in.readByte()); this.aggregator = in.readObject(); this.projection = in.readObject(); }
@Override public void writeData(ObjectDataOutput out) throws IOException { out.writeUTF(mapName); out.writeObject(predicate); out.writeByte(iterationType.getId()); out.writeObject(aggregator); out.writeObject(projection); }
/** * Returns the IterationType for the given ID. * * @return the IterationType for the given ID * @throws IllegalArgumentException if no IterationType was found */ public static IterationType getById(byte id) { for (IterationType type : values()) { if (type.id == id) { return type; } } throw new IllegalArgumentException("unknown id:" + id); } }
@Override public void readData(ObjectDataInput in) throws IOException { this.mapName = in.readUTF(); this.predicate = in.readObject(); this.iterationType = IterationType.getById(in.readByte()); this.aggregator = in.readObject(); this.projection = in.readObject(); }
@Override public void writeData(ObjectDataOutput out) throws IOException { out.writeUTF(mapName); out.writeObject(predicate); out.writeByte(iterationType.getId()); out.writeObject(aggregator); out.writeObject(projection); }