Skip to content

Instantly share code, notes, and snippets.

if (!groups.isEmpty()) {
// lets see if we can filter based on groups
boolean filter = true;
for (String group : reservation.getGroupNames()) {
if (groups.contains(group)) {
filter = false;
break;
}
}
if (filter) {
if (!groups.isEmpty()) {
// lets see if we can filter based on groups
List<String> groupNames = reservation.getGroupNames();
if (Collections.disjoint(groups, groupNames)) {
logger.trace("filtering out reservation {} based on groups {}, not part of {}", reservation.getReservationId(), groupNames, groups);
// continue to the next reservation
continue;
}
}
public class WritableSequenceFile extends SequenceFile
{
protected Class<? extends Writable> writableType;
public WritableSequenceFile( Class<? extends Writable> writableType, Fields fields )
{
super( fields );
this.writableType = writableType;
}
public void testComplexLogic() throws Exception
{
if( !new File( inputFileLhs ).exists() )
fail( "data file not found" );
copyFromLocal( inputFileLhs );
Tap source = new Hfs( new TextDelimited( new Fields( "num", "char" ), " " ), inputFileLhs );
Pipe pipe = new Pipe( "test" );
@cwensel
cwensel / gist:1182739
Created August 31, 2011 03:19
Properties builder
Map<Object, Object> properties = getProperties();
properties = appProps()
.setName( appName )
.setVersion( appVersion )
.addTag( stamp )
.addTag( appName )
.addTag( "app-tag" )
.build( properties ); // or buildProperties() or ?
@Test
public void testSameSourceMergeThreeChainGroup() throws Exception
{
getPlatform().copyFromLocal( inputFileLower );
Tap sourceLower = getPlatform().getTextFile( inputFileLower );
Map sources = new HashMap();
sources.put( "split", sourceLower );
#!/bin/bash
curl -s -XPUT localhost:9200/_template/template_tags -d '{
"template" : "tags*",
"settings" : {
"index.analysis.analyzer.csv.type" : "pattern",
"index.analysis.analyzer.csv.pattern" : ","
},
"mappings" : {
"_default_" : {
String statement = "select *\n"
+ "from \"example\".\"sales_fact_1997\" as s\n"
+ "join \"example\".\"employee\" as e\n"
+ "on e.\"EMPID\" = s.\"CUST_ID\"";
Tap empTap = getPlatform().getDelimitedFile( ",", "\"", new SQLTypeResolver(), DATA_EMPLOYEE, SinkMode.KEEP );
Tap salesTap = getPlatform().getDelimitedFile( ",", "\"", new SQLTypeResolver(), DATA_SALESFACT, SinkMode.KEEP );
Tap resultsTap = getPlatform().getDelimitedFile( ",", "\"", new SQLTypeResolver(), getOutputPath( "dynamic" ), SinkMode.REPLACE );
@Test
public void testTrapTapSourceSinkCopy() throws Exception
{
getPlatform().copyFromLocal( inputFileApache );
Scheme scheme = getPlatform().getTestFailScheme();
Tap source = getPlatform().getTap( scheme, inputFileApache, SinkMode.KEEP );
Pipe pipe = new Pipe( "map" );
@cwensel
cwensel / gist:9102c10d24823b6ba3b5
Last active August 29, 2015 14:04
A prototype fluent API for Cascading
// Factories for all Operations (Functions, Filters, Aggregators, and Buffers)
Function splitter = Fluid.function()
.RegexSplitter()
.fieldDeclaration( fields( "num", "char" ) )
.patternString( " " )
.end();
// An assembly builder chaining Pipes into complex assemblies
AssemblyBuilder.Start assembly = Fluid.assembly();