@Override public void transform(TrieParserReader templateParserReader, DataOutputBlobWriter<RawDataSchema> outputStream) { activeRouteDef.setIndexCount( convertEncoding(activeRouteDef.getFieldParamParser(), templateParserReader, templateParser, outputStream)); } };
public int[] paramIndexArray(int pathId) { return pathToRoute[pathId].paramIndexArray(); }
public Object[] paramIndexArrayValidator(int pathId) { return pathToRoute[pathId].paramIndexArrayValidator(); }
@Override public CompositeRoute path(CharSequence path) { int pathsId = pathCounter.getAndIncrement(); //logger.trace("pathId: {} assinged for path: {}",pathsId, path); FieldExtractionDefinitions fieldExDef = parser.addPath(path, routeId, pathsId, structId);//hold for defaults.. activePathFieldIndexPosLookup = new int[fieldExDef.getIndexCount()]; activePathFieldValidator = new Object[fieldExDef.getIndexCount()]; //this visitor will populate the above 2 member arrays we just created fieldExDef.getFieldParamParser().visitPatterns(modifyStructVisitor); fieldExDef.setPathFieldLookup(activePathFieldIndexPosLookup, activePathFieldValidator); config.storeRequestExtractionParsers(pathsId, fieldExDef); //this looked up by pathId config.storeRequestedJSONMapping(routeId, extractor); assert(structId == config.getStructIdForRouteId(routeId)); defs.add(fieldExDef); //System.out.println("added path:"+path); //System.out.println("known routes defined:\n"+parser.debugRouterMap()); return this; }
private static boolean captureAllArgsFromURL(HTTPRouterStageConfig<?,?,?,?> config, TrieParserReader trieReader, final int pathId, DataOutputBlobWriter<HTTPRequestSchema> writer) { final FieldExtractionDefinitions fed = HTTPRouterStageConfig.fieldExDef(config,pathId); if (0 == fed.paramIndexArray().length) { //load any defaults fed.processDefaults(writer); return true; } else { if (TrieParserReader.writeCapturedValuesToDataOutput(trieReader, writer, fed.paramIndexArray(), fed.paramIndexArrayValidator() )) { //load any defaults if what was passed in has been validated fed.processDefaults(writer); return true; } } return false; }
public final int routeExtractionParserIndexCount(int route) { return routerConfig().extractionParser(route).getIndexCount(); }
public void processDefaults(DataOutputBlobWriter<HTTPRequestSchema> writer, int pathId) { pathToRoute[pathId].processDefaults(writer); }
@Override public CompositeRouteFinish defaultDecimal(String key, long m, byte e) { byte[] keyBytes = key.getBytes(); scs.registry.modifyStruct(structId, keyBytes, 0, keyBytes.length, StructType.Decimal, 0); int i = defs.size(); while (--i>=0) { defs.get(i).defaultDecimal(keyBytes, m, e, scs.registry); } return this; }
@Override public CompositeRouteFinish defaultText(String key, String value) { byte[] keyBytes = key.getBytes(); scs.registry.modifyStruct(structId, keyBytes, 0, keyBytes.length, StructType.Text, 0); int i = defs.size(); while (--i>=0) { defs.get(i).defaultText(keyBytes, value, scs.registry); } return this; }
@Override public CompositeRouteFinish defaultInteger(String key, long value) { byte[] keyBytes = key.getBytes(); //logger.info("\nModify struct {} add key {} ", structId, key); scs.registry.modifyStruct(structId, keyBytes, 0, keyBytes.length, StructType.Long, 0); int i = defs.size(); assert(i>0); while (--i>=0) { defs.get(i).defaultInteger(keyBytes, value, scs.registry); } return this; }
@Override public CompositeRouteFinish defaultRational(String key, long numerator, long denominator) { byte[] keyBytes = key.getBytes(); scs.registry.modifyStruct(structId, keyBytes, 0, keyBytes.length, StructType.Rational, 0); int i = defs.size(); while (--i>=0) { defs.get(i).defaultRational(keyBytes, numerator, denominator, scs.registry); } return this; }
/** * Parse template format and inject TrieParser key into the routerMap. * eg. converts from * @param path */ public FieldExtractionDefinitions addPath(CharSequence path, int routeId, int pathId, int structId) { //////////////////////////////////// //convert public supported route format eg ${} and #{} into the //internal trie parser format, field names are extracted and added to lookup parser //////////////////////////////////// activePathId = pathId; activeRouteDef = new FieldExtractionDefinitions(trustText, routeId, pathId, structId); converter.convert(path, et, es); return activeRouteDef; }