@Override public OUT compute(IN input, OUT out) { if (!input.iterationOrder().equals(out.iterationOrder())) { throw new IllegalArgumentException( "IterationOrders not the same in StandardMultilevelThresholder"); } Cursor<T> outputCursor = out.cursor(); Cursor<T> inputCursor = input.cursor(); ThresholdValueCollection thresholdValues = m_op.compute(input); double[] sortedValues = thresholdValues.getSortedVector(); while (inputCursor.hasNext()) { outputCursor.fwd(); double value = inputCursor.next().getRealDouble(); int idx = 0; for (int d = 0; d < sortedValues.length; d++) { if (value > sortedValues[d]) { idx++; } else { break; } } outputCursor.get().setReal(idx); } return out; }
protected ODocument createModel() { final String schemaName = getSchemaName(); return db().createEdge( outVertex != null ? outVertex.getDocument() : null, inVertex != null ? inVertex.getDocument() : null, schemaName); }
@Override protected void _save() { final ODocument edge = getDocument(); final List<Property> propertyList = GraphDBPropertyUtils.listProperties(this.getClass()); GraphDB.serializeFiledsOfPojoToGraphDocument(propertyList, this, edge); if (outVertex != null) outVertex.save(); if (inVertex != null) inVertex.save(); edge.save(); GraphDB.serializeFiledsOfGraphDocumentToPojo(propertyList, edge, this); }
@Override public Buffer apply(OUT o) { try { return writeTypeName(o.getClass(), fn.apply(o)); } catch (RuntimeException e) { if (log.isErrorEnabled()) { log.error("Could not encode " + o, e); } throw e; } }
public FaunusEdge addEdge(final Direction direction, final FaunusEdge edge) { if (OUT.equals(direction)) { List<Edge> edges = this.outEdges.get(edge.getLabel()); if (null == edges) { edges = new ArrayList<Edge>(); this.outEdges.put(edge.getLabel(), edges); } edges.add(edge); } else if (IN.equals(direction)) { List<Edge> edges = this.inEdges.get(edge.getLabel()); if (null == edges) { edges = new ArrayList<Edge>(); this.inEdges.put(edge.getLabel(), edges); } edges.add(edge); } else throw ExceptionFactory.bothIsNotSupported(); return edge; }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { for (Entry<PacketListener, List<Method>> listener : OUT.entrySet()) { for (Method method : listener.getValue()) { PacketHandler ann = method.getAnnotation(PacketHandler.class); if (!ann.packet().getName().equals(msg.getClass().getSimpleName())) continue; PacketEvent evt = new PacketEvent(player, msg); method.setAccessible(true); method.invoke(listener.getKey(), evt); msg = evt.getPacket(); } } if (msg != null) { super.write(ctx, msg, promise); } }
@Override public OUT readRecord(OUT reuse, byte[] bytes, int offset, int numBytes) { /* * Fix to support windows line endings in CSVInputFiles with standard delimiter setup = \n */ // Find windows end line, so find carriage return before the newline if (this.lineDelimiterIsLinebreak == true && numBytes > 0 && bytes[offset + numBytes - 1] == '\r') { // reduce the number of bytes so that the Carriage return is not taken as data numBytes--; } if (parseRecord(parsedValues, bytes, offset, numBytes)) { // valid parse, map values into pact record for (int i = 0; i < parsedValues.length; i++) { reuse.setField(parsedValues[i], i); } return reuse; } else { return null; } }