Package org.elasticsearch.hadoop.cfg

Examples of org.elasticsearch.hadoop.cfg.Settings


        assertEquals(result, ba.toString());
    }

    @Test
    public void testParent() throws Exception {
        Settings settings = settings();
        settings.setProperty(ConfigurationOptions.ES_MAPPING_PARENT, "<5>");

        create(settings).write(map).copyTo(ba);
        String result = prefix() + "\"_parent\":\"5\"}}" + map();
        assertEquals(result, ba.toString());
    }
View Full Code Here


        assertEquals(result, ba.toString());
    }

    @Test
    public void testVersion() throws Exception {
        Settings settings = settings();
        settings.setProperty(ConfigurationOptions.ES_MAPPING_VERSION, "<3>");

        create(settings).write(map).copyTo(ba);
        String result = prefix() + "\"_version\":\"3\"}}" + map();
        assertEquals(result, ba.toString());
    }
View Full Code Here

        assertEquals(result, ba.toString());
    }

    @Test
    public void testTtl() throws Exception {
        Settings settings = settings();
        settings.setProperty(ConfigurationOptions.ES_MAPPING_TTL, "<2>");

        create(settings).write(map).copyTo(ba);
        String result = prefix() + "\"_ttl\":\"2\"}}" + map();
        assertEquals(result, ba.toString());
    }
View Full Code Here

        assertEquals(result, ba.toString());
    }

    @Test
    public void testTimestamp() throws Exception {
        Settings settings = settings();
        settings.setProperty(ConfigurationOptions.ES_MAPPING_TIMESTAMP, "<3>");
        create(settings).write(map).copyTo(ba);
        String result = prefix() + "\"_timestamp\":\"3\"}}" + map();
        assertEquals(result, ba.toString());
    }
View Full Code Here

        assertEquals(result, ba.toString());
    }

    @Test
    public void testRouting() throws Exception {
        Settings settings = settings();
        settings.setProperty(ConfigurationOptions.ES_MAPPING_ROUTING, "<4>");

        create(settings).write(map).copyTo(ba);
        String result = prefix() + "\"_routing\":\"4\"}}" + map();
        assertEquals(result, ba.toString());
    }
View Full Code Here

    }


    @Test
    public void testAll() throws Exception {
        Settings settings = settings();
        settings.setProperty(ConfigurationOptions.ES_MAPPING_ID, "n");
        settings.setProperty(ConfigurationOptions.ES_MAPPING_TTL, "<2>");
        settings.setProperty(ConfigurationOptions.ES_MAPPING_ROUTING, "s");

        create(settings).write(map).copyTo(ba);
        String result = "{\"" + operation + "\":{\"_id\":\"1\",\"_routing\":\"v\",\"_ttl\":\"2\"}}" + map();
        assertEquals(result, ba.toString());
    }
View Full Code Here

    }

    @Test(expected = EsHadoopIllegalArgumentException.class)
    public void testIdMandatory() throws Exception {
        assumeTrue(ConfigurationOptions.ES_OPERATION_UPDATE.equals(operation));
        Settings set = settings();
        set.setProperty(ConfigurationOptions.ES_MAPPING_ID, "");
        create(set).write(map).copyTo(ba);
    }
View Full Code Here

        settings.setProperty(ConfigurationOptions.ES_WRITE_OPERATION, operation);
        return BulkCommands.create(settings);
    }

    private Settings settings() {
        Settings set = new TestSettings();
        InitializationUtils.setValueWriterIfNotSet(set, JdkValueWriter.class, null);
        InitializationUtils.setFieldExtractorIfNotSet(set, MapFieldExtractor.class, null);
        set.setResourceWrite("foo/bar");
        if (isUpdateOp()) {
            set.setProperty(ConfigurationOptions.ES_MAPPING_ID, "<2>");
        }
        return set;
    }
View Full Code Here

    }

    public EsHiveRecordWriter getHiveRecordWriter(JobConf jc, Path finalOutPath, Class valueClass, boolean isCompressed, Properties tableProperties, Progressable progress) {
        // force the table properties to be merged into the configuration
        // NB: the properties are also available in HiveConstants#OUTPUT_TBL_PROPERTIES
        Settings settings = HadoopSettingsManager.loadFrom(jc).merge(tableProperties);

        Log log = LogFactory.getLog(getClass());

        // NB: ESSerDe is already initialized at this stage but should still have a reference to the same cfg object
        // NB: the value writer is not needed by Hive but it's set for consistency and debugging purposes

        InitializationUtils.setValueWriterIfNotSet(settings, HiveValueWriter.class, log);
        InitializationUtils.setBytesConverterIfNeeded(settings, HiveBytesConverter.class, log);
        // set write resource
        settings.setResourceWrite(settings.getResourceWrite());

        HiveUtils.init(settings, log);

        return new EsHiveRecordWriter(jc, progress);
    }
View Full Code Here

    }

    @Override
    public FileSplit[] getSplits(JobConf job, int numSplits) throws IOException {
        // first, merge input table properties (since there's no access to them ...)
        Settings settings = HadoopSettingsManager.loadFrom(job);
        //settings.merge(IOUtils.propsFromString(settings.getProperty(HiveConstants.INPUT_TBL_PROPERTIES)));

        Log log = LogFactory.getLog(getClass());
        // move on to initialization
        InitializationUtils.setValueReaderIfNotSet(settings, HiveValueReader.class, log);
        settings.setProperty(InternalConfigurationOptions.INTERNAL_ES_TARGET_FIELDS, StringUtils.concatenateAndUriEncode(HiveUtils.columnToAlias(settings), ","));
        // set read resource
        settings.setResourceRead(settings.getResourceRead());
        HiveUtils.init(settings, log);

        // decorate original splits as FileSplit
        InputSplit[] shardSplits = super.getSplits(job, numSplits);
        FileSplit[] wrappers = new FileSplit[shardSplits.length];
View Full Code Here

TOP

Related Classes of org.elasticsearch.hadoop.cfg.Settings

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.