Skip to content

Commit

Permalink
initial draft of parent_child support
Browse files Browse the repository at this point in the history
  • Loading branch information
costin committed Nov 7, 2013
1 parent 6c4518b commit 1333d53
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
Expand Up @@ -70,6 +70,11 @@ public interface ConfigurationOptions {
String ES_INDEX_READ_MISSING_AS_EMPTY = "es.index.read.missing.as.empty";
String ES_INDEX_READ_MISSING_AS_EMPTY_DEFAULT = "false";

/** Mapping types */
String ES_MAPPING_ID = "es.mapping.id";
String ES_MAPPING_ID_EXTRACTOR_CLASS = "es.mapping.id.extractor.class";
String ES_MAPPING_PARENT = "es.mapping.parent";

/** Operation types */
String ES_WRITE_OPERATION = "es.write.operation";
String ES_OPERATION_INDEX = "index";
Expand All @@ -78,9 +83,6 @@ public interface ConfigurationOptions {
String ES_OPERATION_DELETE = "delete";
String ES_WRITE_OPERATION_DEFAULT = ES_OPERATION_INDEX;

String ES_MAPPING_ID = "es.mapping.id";
String ES_MAPPING_ID_EXTRACTOR_CLASS = "es.mapping.id.extractor.class";

String ES_UPSERT_DOC = "es.upsert.doc";
String ES_UPSERT_DOC_DEFAULT = "true";
}
5 changes: 5 additions & 0 deletions src/main/java/org/elasticsearch/hadoop/util/BytesArray.java
Expand Up @@ -28,6 +28,11 @@ public BytesArray(int size) {
this(new byte[size], 0);
}

public BytesArray(byte[] data) {
this.bytes = data;
this.size = data.length;
}

public BytesArray(byte[] data, int size) {
this.bytes = data;
this.size = size;
Expand Down
Expand Up @@ -35,6 +35,7 @@
import org.elasticsearch.hadoop.cfg.ConfigurationOptions;
import org.elasticsearch.hadoop.integration.HdpBootstrap;
import org.elasticsearch.hadoop.mr.ESOutputFormat;
import org.elasticsearch.hadoop.util.RestUtils;
import org.elasticsearch.hadoop.util.WritableUtils;
import org.junit.FixMethodOrder;
import org.junit.Test;
Expand Down Expand Up @@ -140,6 +141,18 @@ public void testIndexAutoCreateDisabled() throws Exception {
JobClient.runJob(conf);
}

public void testParentChild() throws Exception {
JobConf conf = createJobConf();
conf.set(ConfigurationOptions.ES_RESOURCE, "mroldapi/child");
conf.set(ConfigurationOptions.ES_INDEX_AUTO_CREATE, "no");
conf.set(ConfigurationOptions.ES_MAPPING_PARENT, "number");

RestUtils.putMapping("mroldapi/child", "org/elasticsearch/hadoop/integration/mr-child.json");

JobClient.runJob(conf);
}


private JobConf createJobConf() {
JobConf conf = HdpBootstrap.hadoopConfig();

Expand Down
@@ -0,0 +1,7 @@
{
"child" : {
"_parent" : {
"type" : "parent"
}
}
}

0 comments on commit 1333d53

Please sign in to comment.