private byte[] extractJNodeValue(final JsonNode n){ if (n.isBoolean()){ //boolean return clientService.toBytes(n.asBoolean()); }else if(n.isNumber()){ if(n.isIntegralNumber()){ //interpret as Long return clientService.toBytes(n.asLong()); }else{ //interpret as Double return clientService.toBytes(n.asDouble()); } }else{ //if all else fails, interpret as String return clientService.toBytes(n.asText()); } }
default: final String value = record.getAsString(field); retVal = clientService.toBytes(value); break; break; case BOOLEAN: retVal = clientService.toBytes(record.getAsBoolean(field)); break; case DOUBLE: retVal = clientService.toBytes(record.getAsDouble(field)); break; case FLOAT: retVal = clientService.toBytes(record.getAsFloat(field)); break; case INT: retVal = clientService.toBytes(record.getAsInt(field)); break; case LONG: retVal = clientService.toBytes(record.getAsLong(field)); break; default: final String value = record.getAsString(field); retVal = clientService.toBytes(value); break;
private byte[] handleComplexField(Record record, String field, String complexFieldStrategy) throws PutCreationFailedInvokedException { switch (complexFieldStrategy) { case FAIL_VALUE: getLogger().error("Complex value found for {}; routing to failure", new Object[]{field}); throw new PutCreationFailedInvokedException(String.format("Complex value found for %s; routing to failure", field)); case WARN_VALUE: getLogger().warn("Complex value found for {}; skipping", new Object[]{field}); return null; case TEXT_VALUE: final String value = record.getAsString(field); return clientService.toBytes(value); case IGNORE_VALUE: // silently skip return null; default: return null; } }