@Override public Class<? super T> typeClass() { return schema.typeClass(); }
@Override protected void transferKey(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException { if (kPipeSchema == null) { throw new RuntimeException("No pipe schema for key: " + kSchema.typeClass().getName()); } output.writeObject(number, pipe, kPipeSchema, repeated); }
@Override protected void transferValue(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException { if (pipeSchema == null) { throw new RuntimeException("No pipe schema for value: " + schema.typeClass().getName()); } output.writeObject(number, pipe, pipeSchema, repeated); }
@Override protected void transferValue(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException { if (vPipeSchema == null) { throw new RuntimeException("No pipe schema for value: " + vSchema.typeClass().getName()); } output.writeObject(number, pipe, vPipeSchema, repeated); }
@Override protected void transferValue(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException { if (vPipeSchema == null) { throw new RuntimeException("No pipe schema for value: " + vSchema.typeClass().getName()); } output.writeObject(number, pipe, vPipeSchema, repeated); }
/** * Pojo ids start at 1. */ @Override public <T> Registry registerPojo(Schema<T> schema, Pipe.Schema<T> pipeSchema, int id) { if (id >= strategy.pojoIdStart) throw new IllegalArgumentException("pojo ids must be lesser than " + strategy.pojoIdStart); else if (strategy.pojos.get(id) != null) { throw new IllegalArgumentException("Duplicate id registration: " + id + " (" + schema.typeClass().getName() + ")"); } if (strategy.pojoMapping.containsKey(schema.typeClass())) throw new IllegalArgumentException("Duplicate registration for: " + schema.typeClass()); Registered<T> wrapper = new Registered<T>(id, schema, pipeSchema, strategy); strategy.pojos.set(id, wrapper); strategy.pojoMapping.put(schema.typeClass(), wrapper); return this; }
/** * Pojo ids start at 1. */ @Override public <T> Registry registerPojo(Schema<T> schema, Pipe.Schema<T> pipeSchema, int id) { if (id >= strategy.pojos.size()) grow(strategy.pojos, id + 1); else if (strategy.pojos.get(id) != null) { throw new IllegalArgumentException("Duplicate id registration: " + id + " (" + schema.typeClass().getName() + ")"); } if (strategy.pojoMapping.containsKey(schema.typeClass())) throw new IllegalArgumentException("Duplicate registration for: " + schema.typeClass()); Registered<T> wrapper = new Registered<T>(id, schema, pipeSchema, strategy); strategy.pojos.set(id, wrapper); strategy.pojoMapping.put(schema.typeClass(), wrapper); return this; }
@Override public Pipe.Schema<T> getPipeSchema() { Pipe.Schema<T> pipeSchema = this.pipeSchema; if (pipeSchema == null) { synchronized (this) { if ((pipeSchema = this.pipeSchema) == null) { this.pipeSchema = pipeSchema = RuntimeSchema .resolvePipeSchema(schema, schema.typeClass(), true); } } } return pipeSchema; } }
@Override protected Class<?> pojoClass(int id) { final BaseHS<?> wrapper = id < pojos.size() ? pojos.get(id) : null; if (wrapper == null) throw new UnknownTypeException("Unknown pojo id: " + id); return wrapper.getSchema().typeClass(); }
@Override public Pipe.Schema<T> getPipeSchema() { Pipe.Schema<T> pipeSchema = this.pipeSchema; if (pipeSchema == null) { synchronized (this) { if ((pipeSchema = this.pipeSchema) == null) { this.pipeSchema = pipeSchema = RuntimeSchema .resolvePipeSchema(schema, schema.typeClass(), true); } } } return pipeSchema; } }
@Override protected Class<?> pojoClass(int id) { final BaseHS<?> wrapper = id < pojos.size() ? pojos.get(id) : null; if (wrapper == null) { throw new UnknownTypeException("pojo id: " + id + " (Outdated registry)"); } return wrapper.getSchema().typeClass(); }
@Override public Object readFrom(Input input, Object owner) throws IOException { if (ID_ARRAY_LEN != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); final int len = input.readInt32(); Object[] array = (Object[])Array.newInstance(hs.getSchema().typeClass(), len); if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(array, owner); } for (int i = 0; i < len;) { switch (input.readFieldNumber(this)) { case ID_ARRAY_DATA: array[i++] = input.mergeObject(null, hs.getSchema()); break; case ID_ARRAY_NULLCOUNT: i += input.readUInt32(); break; default: throw new ProtostuffException("Corrupt input."); } } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
@Override public Object readFrom(Input input, Object owner) throws IOException { if (ID_ARRAY_LEN != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); final int len = input.readInt32(); Object[] array = (Object[])Array.newInstance(hs.getSchema().typeClass(), len); if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(array, owner); } for (int i = 0; i < len;) { switch (input.readFieldNumber(this)) { case ID_ARRAY_DATA: array[i++] = input.mergeObject(null, hs.getSchema()); break; case ID_ARRAY_NULLCOUNT: i += input.readUInt32(); break; default: throw new ProtostuffException("Corrupt input."); } } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
@Override protected void transferValue(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException { if (vPipeSchema == null) { throw new RuntimeException("No pipe schema for value: " + vSchema.typeClass().getName()); } output.writeObject(number, pipe, vPipeSchema, repeated); }
@Override protected void transferKey(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException { if (kPipeSchema == null) { throw new RuntimeException("No pipe schema for key: " + kSchema.typeClass().getName()); } output.writeObject(number, pipe, kPipeSchema, repeated); }
/** * Note: Not intended for direct use. Instead, use {@link ConnectionReader#of(ScanResult, SabotConfig)} */ ConnectionReaderImpl(ImmutableMap<String, Schema<? extends ConnectionConf<?, ?>>> schemaByName) { this.schemaByName = schemaByName; final ImmutableMap.Builder<String, Class<? extends ConnectionConf<?, ?>>> builder = ImmutableMap.builder(); schemaByName.entrySet().stream() .forEach(entry -> builder.put(entry.getKey(), (Class<? extends ConnectionConf<?, ?>>) entry.getValue().typeClass())); this.connectionConfClasses = builder.build(); }
@Override protected void transferValue(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException { if (vPipeSchema == null) { throw new RuntimeException("No pipe schema for value: " + vSchema.typeClass().getName()); } output.writeObject(number, pipe, vPipeSchema, repeated); }
@Override protected void transferValue(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException { if (pipeSchema == null) { throw new RuntimeException("No pipe schema for value: " + schema.typeClass().getName()); } output.writeObject(number, pipe, pipeSchema, repeated); }
@Override protected Class<?> pojoClass(int id) { final BaseHS<?> wrapper = id < pojos.size() ? pojos.get(id) : null; if (wrapper == null) throw new UnknownTypeException("Unknown pojo id: " + id); return wrapper.getSchema().typeClass(); }
@Override protected Class<?> pojoClass(int id) { final BaseHS<?> wrapper = id < pojos.size() ? pojos.get(id) : null; if (wrapper == null) { throw new UnknownTypeException("pojo id: " + id + " (Outdated registry)"); } return wrapper.getSchema().typeClass(); }