Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.hadoop.serialization.builder;
import org.elasticsearch.hadoop.cfg.Settings;
import org.elasticsearch.hadoop.serialization.FieldType;
import org.elasticsearch.hadoop.serialization.Parser;
import org.elasticsearch.hadoop.serialization.Parser.Token;
import org.elasticsearch.hadoop.serialization.SettingsAware;
import org.elasticsearch.hadoop.serialization.field.FieldFilter;
import org.elasticsearch.hadoop.serialization.field.FieldFilter.NumberedInclude;
import org.elasticsearch.hadoop.serialization.field.FieldFilter.Result;
import org.elasticsearch.hadoop.util.DateUtils;
import org.elasticsearch.hadoop.util.SettingsUtils;
import org.elasticsearch.hadoop.util.StringUtils;
import org.elasticsearch.hadoop.util.unit.Booleans;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* Basic value reader handling using the implied JSON type.
*/
public class JdkValueReader extends AbstractValueReader implements SettingsAware {
private boolean emptyAsNull = true;
private boolean richDate = true;
protected Collection arrayInclude = Collections. emptyList();
protected Collection arrayExclude = Collections.emptyList();
@Override
public Object readValue(Parser parser, String value, FieldType esType) {
if (esType == null) {
return nullValue();
}
switch (esType) {
case NULL:
return nullValue();
case STRING:
case TEXT:
case KEYWORD:
return textValue(value);
case BYTE:
return byteValue(value, parser);
case SHORT:
return shortValue(value, parser);
case INTEGER:
return intValue(value, parser);
case TOKEN_COUNT:
case LONG:
return longValue(value, parser);
case HALF_FLOAT:
case FLOAT:
return floatValue(value, parser);
case SCALED_FLOAT:
case DOUBLE:
return doubleValue(value, parser);
case BOOLEAN:
return booleanValue(value, parser);
case BINARY:
byte[] binValue = parser.binaryValue();
if(binValue == null) binValue = value.getBytes();
return binaryValue(binValue);
case DATE:
return date(value, parser);
case DATE_NANOS:
return dateNanos(value, parser);
case JOIN:
// In the case of a join field reaching this point it is because it is the short-hand form for a parent.
// construct a container and place the short form name into the name subfield.
Object container = createMap();
addToMap(container, "name", textValue(value));
return container;
// catch-all - exists really for the other custom types that might be introduced
// compound types should have been handled earlier in the stream
default:
return textValue(value);
}
}
@Override
public Object createMap() {
return new LinkedHashMap