Skip to content

Commit

Permalink
Added sub-projects cascading-nested and cascading-nested-json providi…
Browse files Browse the repository at this point in the history
…ng base support for nested data types and direct support for JSON data processing.
  • Loading branch information
cwensel committed Nov 18, 2017
1 parent 453b808 commit 9165be6
Show file tree
Hide file tree
Showing 41 changed files with 3,833 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Expand Up @@ -2,6 +2,9 @@ Cascading Change Log

4.0 [unreleased]

Added sub-projects cascading-nested and cascading-nested-json providing base support for nested data types and
direct support for JSON data processing.

Removed cascading-xml sub-project.

Updated c.s.l.TextDelimited to detect if data is being appended to an existing file before writing the header.
Expand Down
23 changes: 23 additions & 0 deletions cascading-core/src/main/java/cascading/tuple/Tuples.java
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2016-2017 Chris K Wensel. All Rights Reserved.
* Copyright (c) 2007-2017 Xplenty, Inc. All Rights Reserved.
*
* Project and contact information: http://www.cascading.org/
Expand All @@ -22,7 +23,9 @@

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cascading.operation.OperationException;
import cascading.tuple.type.CoercibleType;
Expand Down Expand Up @@ -177,6 +180,26 @@ public static Object[] asArray( Tuple tuple, CoercibleType[] coercions, Class[]
return destination;
}

public static Map<String, Object> asMap( Fields fields, TupleEntry arguments )
{
Map<String, Object> result = new HashMap<>();

for( Comparable comparable : fields )
result.put( comparable.toString(), arguments.getObject( comparable ) );

return result;
}

public static Map<Comparable, Object> asComparableMap( Fields fields, TupleEntry arguments )
{
Map<Comparable, Object> result = new HashMap<>();

for( Comparable comparable : fields )
result.put( comparable, arguments.getObject( comparable ) );

return result;
}

public static Collection asCollection( Tuple tuple )
{
return Collections.unmodifiableCollection( tuple.elements );
Expand Down
5 changes: 5 additions & 0 deletions cascading-core/src/main/java/cascading/util/Util.java
Expand Up @@ -714,6 +714,11 @@ public static void writeDOT( Writer writer, DirectedGraph graph, IntegerNameProv
new DOTExporter( vertexIdProvider, vertexNameProvider, edgeNameProvider, vertexAttributeProvider, edgeAttributeProvider ).export( writer, graph );
}

public static String asString( Object object )
{
return object == null ? null : object.toString();
}

public static boolean isEmpty( String string )
{
return string == null || string.isEmpty();
Expand Down
44 changes: 44 additions & 0 deletions cascading-nested-json/build.gradle
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2016-2017 Chris K Wensel. All Rights Reserved.
*
* Project and contact information: http://www.cascading.org/
*
* This file is part of the Cascading project.
*
* Licensed 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.
*/

ext.jacksonDatabindVersion = '2.8.7'
ext.jacksonDatatypeGuavaVersion = jacksonDatabindVersion
ext.jacksonDataFormatsVersion = jacksonDatabindVersion

dependencies {
compile project( ':cascading-core' )
compile project( ':cascading-nested' )

compile group: 'io.heretical', name: 'pointer-path-json', version: '1.0.0-wip-8'

provided group: 'org.slf4j', name: 'slf4j-api', version: '1.7.5'

testCompile project( path: ':cascading-core', configuration: 'testArtifacts' )
}

javadoc {
configure( options ) {
links << "http://${rootProject.s3UploadDocs.destination}javadoc/cascading-core".toString()

// linksOffline( '../../../cascading-core', "http://${rootProject.s3UploadDocs.destination}javadoc/cascading-core".toString() )
}
}

platformTest.enabled = false
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2016-2017 Chris K Wensel. All Rights Reserved.
*
* Project and contact information: http://www.cascading.org/
*
* This file is part of the Cascading project.
*
* Licensed 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 cascading.nested.json;

import java.beans.ConstructorProperties;

import cascading.nested.core.BuildSpec;
import cascading.nested.core.NestedBaseBuildAggregator;
import cascading.tuple.Fields;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;

/**
* Class JSONBuildAsAggregator provides for the ability to create new JSON objects from aggregated tuple values.
*
* @see NestedBaseBuildAggregator for more details.
*/
public class JSONBuildAsAggregator extends NestedBaseBuildAggregator<JsonNode, ArrayNode>
{
/**
* Constructor JSONBuildAsAggregator creates a new JSONBuildAsAggregator instance.
*
* @param fieldDeclaration of Fields
* @param buildSpecs of BuildSpec...
*/
@ConstructorProperties({"fieldDeclaration", "buildSpecs"})
public JSONBuildAsAggregator( Fields fieldDeclaration, BuildSpec... buildSpecs )
{
super( JSONCoercibleType.TYPE, fieldDeclaration, buildSpecs );
}

@Override
protected boolean isInto()
{
return false;
}
}
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2016-2017 Chris K Wensel. All Rights Reserved.
*
* Project and contact information: http://www.cascading.org/
*
* This file is part of the Cascading project.
*
* Licensed 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 cascading.nested.json;

import java.beans.ConstructorProperties;

import cascading.nested.core.BuildSpec;
import cascading.nested.core.NestedBaseBuildFunction;
import cascading.tuple.Fields;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;

/**
* Class JSONBuildAsFunction provides for the ability to create new JSON objects from streamed tuple values.
*
* @see NestedBaseBuildFunction for more details.
*/
public class JSONBuildAsFunction extends NestedBaseBuildFunction<JsonNode, ArrayNode>
{
/**
* Constructor JSONBuildAsFunction creates a new JSONBuildAsFunction instance.
*
* @param fieldDeclaration of Fields
* @param buildSpecs of BuildSpec...
*/
@ConstructorProperties({"fieldDeclaration", "buildSpecs"})
public JSONBuildAsFunction( Fields fieldDeclaration, BuildSpec... buildSpecs )
{
super( JSONCoercibleType.TYPE, fieldDeclaration, buildSpecs );
}

/**
* Method isInto returns the into of this JSONBuildAsFunction object.
*
* @return the into (type boolean) of this JSONBuildAsFunction object.
*/
@Override
protected boolean isInto()
{
return false;
}
}
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2016-2017 Chris K Wensel. All Rights Reserved.
*
* Project and contact information: http://www.cascading.org/
*
* This file is part of the Cascading project.
*
* Licensed 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 cascading.nested.json;

import java.beans.ConstructorProperties;

import cascading.nested.core.BuildSpec;
import cascading.nested.core.NestedBaseBuildFunction;
import cascading.tuple.Fields;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;

/**
* Class JSONBuildIntoFunction provides for the ability to update existing JSON objects from streamed tuple values.
*
* @see NestedBaseBuildFunction for more details.
*/
public class JSONBuildIntoFunction extends NestedBaseBuildFunction<JsonNode, ArrayNode>
{
/**
* Constructor JSONBuildIntoFunction creates a new JSONBuildIntoFunction instance.
*
* @param fieldDeclaration of Fields
* @param buildSpecs of BuildSpec...
*/
@ConstructorProperties({"fieldDeclaration", "buildSpecs"})
public JSONBuildIntoFunction( Fields fieldDeclaration, BuildSpec... buildSpecs )
{
super( JSONCoercibleType.TYPE, fieldDeclaration, buildSpecs );
}

@Override
protected boolean isInto()
{
return true;
}
}

0 comments on commit 9165be6

Please sign in to comment.