public int minimumFragmentsOnPipe() { return (1<<slabBits)/FieldReferenceOffsetManager.maxFragmentSize(schema.from); }
private static boolean testForMatchingFROMs(String templateFile, FieldReferenceOffsetManager encodedFrom, Appendable target) throws ParserConfigurationException, SAXException, IOException { boolean result = true; FieldReferenceOffsetManager expectedFrom = TemplateHandler.loadFrom(templateFile); if (null==expectedFrom) { logger.error("Unable to find: "+templateFile); result = false; } else if (null==encodedFrom || !expectedFrom.equals(encodedFrom)) { logger.error("Encoded source:"+expectedFrom); if (null!=encodedFrom) { logger.error("Template file:"+encodedFrom); } logger.error("//replacement source"); String nameOfFROM = templateFile.substring(1+templateFile.lastIndexOf('/') ); FieldReferenceOffsetManager.buildFROMConstructionSource(target, expectedFrom, "FROM", nameOfFROM); result = false; } return result; }
public int getLoc(long messageId, long fieldId) { return lookupFieldLocator(fieldId, lookupTemplateLocator(messageId, this), this); }
public PipeConfig(T messageSchema, int minimumFragmentsOnRing, int maximumLenghOfVariableLengthFields, byte[] byteConst) { int biggestFragment = FieldReferenceOffsetManager.maxFragmentSize(MessageSchema.from(messageSchema)); int primaryMinSize = minimumFragmentsOnRing*biggestFragment; this.slabBits = (byte)(32 - Integer.numberOfLeadingZeros(primaryMinSize - 1)); int maxVarFieldsInRingAtOnce = FieldReferenceOffsetManager.maxVarLenFieldsPerPrimaryRingSize(MessageSchema.from(messageSchema), 1<<slabBits); int secondaryMinSize = maxVarFieldsInRingAtOnce * maximumLenghOfVariableLengthFields; this.blobBits = ((0==maximumLenghOfVariableLengthFields) | (0==maxVarFieldsInRingAtOnce))? (byte)0 : (byte)(32 - Integer.numberOfLeadingZeros(secondaryMinSize - 1)); this.byteConst = byteConst; this.schema = messageSchema; validate(messageSchema, minimumFragmentsOnRing, maximumLenghOfVariableLengthFields ); }
int minMessagesOnPipe = -1; if (null != from) { maxMessagesOnPipe = pipe.sizeOfSlabRing/FieldReferenceOffsetManager.minFragmentSize(from); minMessagesOnPipe = pipe.sizeOfSlabRing/FieldReferenceOffsetManager.maxFragmentSize(from);
public StreamingWriteVisitorGenerator(FieldReferenceOffsetManager from, Random random, int maxChars, int maxBytes) { this.random = random; this.starts = from.messageStarts(); this.maxLenChars = maxChars; this.maxBytes = maxBytes; this.workingChar = new char[maxLenChars]; //TODO: need to add generation based on operators found in template file or bound }
private static <T> T slowCreate(final EventConsumer consumer, Class<T> clazz) { int msgIdx = FieldReferenceOffsetManager.lookupTemplateLocator(clazz.getAnnotation(ProngTemplateMessage.class).templateId(), Pipe.from(consumer.output)); if (PipeWriter.tryWriteFragment(consumer.output, msgIdx)) { T result = (T) Proxy.newProxyInstance( clazz.getClassLoader(), new Class[] { clazz }, new OutputPipeInvocationHandler(consumer.output, msgIdx, clazz)); consumer.cached = result; //TODO: needs smarter pool but this is fine for now. consumer.cachedMsgId = msgIdx; return result; } else { return null; } }
from.appendConstuctionSource(bodyTarget); additionalMembers(bodyTarget); from.appendGUID( bodyTarget.append("private static final int[] FROM_GUID = ")).append(";\n"); bodyTarget.append("private static final long BUILD_TIME = "); Appendables.appendValue(bodyTarget, System.currentTimeMillis()).append("L;\n");
target.append(" "); try { from.appendLongDefaults(target); } catch (IOException e) { throw new RuntimeException(e); target.append(" "); try { from.appendIntDefaults(target); } catch (IOException e) { throw new RuntimeException(e);
sizeOfSlabRing / FieldReferenceOffsetManager.minFragmentSize(MessageSchema.from(schema)) ));
public static FieldReferenceOffsetManager from(TemplateHandler handler, short preambleBytes, String name) { return new FieldReferenceOffsetManager( Arrays.copyOfRange(handler.catalogScriptTokens,0,handler.catalogTemplateScriptIdx), preambleBytes, Arrays.copyOfRange(handler.catalogScriptFieldNames,0,handler.catalogTemplateScriptIdx), Arrays.copyOfRange(handler.catalogScriptFieldIds,0,handler.catalogTemplateScriptIdx), Arrays.copyOfRange(handler.catalogScriptDictionaryNames,0,handler.catalogTemplateScriptIdx), name, RLESparseArray.rlEncodeSparseArray(handler.defaultConstValues.longDictionary()), RLESparseArray.rlEncodeSparseArray(handler.defaultConstValues.integerDictionary())); }
/** * * @param graphManager * @param input _in_ MQTT IDs ranges that should be generated * @param control _in_ Fine-tunes generation * @param output _out_ Outputs the IDs */ public IdGenStage(GraphManager graphManager, Pipe<MQTTIdRangeSchema> input, Pipe<MQTTIdRangeControllerSchema> control, Pipe<MQTTIdRangeSchema> output) { super(graphManager, join(input, control), output); this.inputs = new Pipe[]{input}; this.outputs = new Pipe[]{output}; this.control = control; assert(Pipe.from(input).equals(Pipe.from(output))) : "Both must have same message types "; this.sizeOfFragment = Pipe.from(input).fragDataSize[theOneMsg]; //must be set so this stage will get shut down and ignore the fact that is has un-consumed messages coming in GraphManager.addNota(graphManager,GraphManager.PRODUCER, GraphManager.PRODUCER, this); }
protected void defineMembers() throws IOException { final FieldReferenceOffsetManager from = MessageSchema.from(schema); if (!from.hasSimpleMessagesOnly) { bodyTarget.append("private ").append(LowLevelStateManager.class.getSimpleName()).append(" navState;\n"); } if (buildFullStageWritingToPipe()) { appendClass(bodyTarget.append("private "), pipeClass, schema.getClass()).append(pipeVarName).append(";\n"); } additionalMembers(bodyTarget); from.appendConstuctionSource(bodyTarget); }
from.appendGUID( bodyTarget.append("private final int[] FROM_GUID = ")).append(";\n");
public PipeConfig(T messageSchema, int minimumFragmentsOnRing, int maximumLenghOfVariableLengthFields, byte[] byteConst) { this.maximumLenghOfVariableLengthFields = maximumLenghOfVariableLengthFields; int biggestFragment = FieldReferenceOffsetManager.maxFragmentSize(MessageSchema.from(messageSchema)); int primaryMinSize = minimumFragmentsOnRing * biggestFragment; this.slabBits = (byte)(32 - Integer.numberOfLeadingZeros(primaryMinSize - 1)); int maxVarFieldsInRingAtOnce = FieldReferenceOffsetManager.maxVarLenFieldsPerPrimaryRingSize(MessageSchema.from(messageSchema), 1<<slabBits); int secondaryMinSize = maxVarFieldsInRingAtOnce * maximumLenghOfVariableLengthFields; this.blobBits = ((0==maximumLenghOfVariableLengthFields) | (0==maxVarFieldsInRingAtOnce))? (byte)0 : (byte)(32 - Integer.numberOfLeadingZeros(secondaryMinSize - 1)); this.byteConst = byteConst; this.schema = messageSchema; validate(messageSchema, minimumFragmentsOnRing, maximumLenghOfVariableLengthFields ); }
public StreamingWriteVisitorGenerator(FieldReferenceOffsetManager from, Random random, int maxChars, int maxBytes) { this.random = random; this.starts = from.messageStarts(); this.maxLenChars = maxChars; this.maxBytes = maxBytes; this.workingChar = new char[maxLenChars]; //TODO: need to add generation based on operators found in template file or bound }
private static <T> T slowCreate(final EventConsumer consumer, Class<T> clazz) { int msgIdx = FieldReferenceOffsetManager.lookupTemplateLocator(clazz.getAnnotation(ProngTemplateMessage.class).templateId(), Pipe.from(consumer.output)); if (PipeWriter.tryWriteFragment(consumer.output, msgIdx)) { T result = (T) Proxy.newProxyInstance( clazz.getClassLoader(), new Class[] { clazz }, new OutputPipeInvocationHandler(consumer.output, msgIdx, clazz)); consumer.cached = result; //TODO: needs smarter pool but this is fine for now. consumer.cachedMsgId = msgIdx; return result; } else { return null; } }
from.appendConstuctionSource(bodyTarget); additionalMembers(bodyTarget); from.appendGUID( bodyTarget.append("private static final int[] FROM_GUID = ")).append(";\n"); bodyTarget.append("private static final long BUILD_TIME = "); Appendables.appendValue(bodyTarget, System.currentTimeMillis()).append("L;\n");
target.append(" "); try { from.appendLongDefaults(target); } catch (IOException e) { throw new RuntimeException(e); target.append(" "); try { from.appendIntDefaults(target); } catch (IOException e) { throw new RuntimeException(e);
sizeOfSlabRing / FieldReferenceOffsetManager.minFragmentSize(MessageSchema.from(schema)) ));