-
-
Save msukmanowsky/198c878e1deaf4e470a9 to your computer and use it in GitHub Desktop.
Excerpt of the MetadataLookup EvalFunc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.parsely.pig.cache; | |
import java.io.IOException; | |
import java.net.UnknownHostException; | |
import java.security.NoSuchAlgorithmException; | |
import java.text.DateFormat; | |
import java.text.SimpleDateFormat; | |
import java.util.Arrays; | |
import org.apache.commons.logging.Log; | |
import org.apache.pig.EvalFunc; | |
import org.apache.pig.PigWarning; | |
import org.apache.pig.data.DataType; | |
import org.apache.pig.data.Tuple; | |
import org.apache.pig.data.TupleFactory; | |
import org.apache.pig.impl.logicalLayer.schema.Schema; | |
import org.apache.pig.impl.logicalLayer.schema.Schema.FieldSchema; | |
import com.parsely.util.cache.Metadata; | |
import com.parsely.util.cache.ParselyMetadataService; | |
public class MetadataLookup extends EvalFunc<Tuple> { | |
private ParselyMetadataService meta; | |
private TupleFactory mTupleFactory = TupleFactory.getInstance(); | |
private DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ"); | |
private Log logger; | |
public MetadataLookup(int lruSize) throws UnknownHostException { | |
// This service opens up a connection to both mongo and redis | |
this.meta = new ParselyMetadataService(lruSize); | |
this.logger = getLogger(); | |
} | |
public MetadataLookup() throws UnknownHostException { | |
this(500); | |
} | |
@Override | |
public Tuple exec(Tuple input) throws IOException { | |
// Returns a 5 element tuple by using calls to meta.fetch() | |
// which queries Redis/Mongo depending on the parameters | |
} | |
@Override | |
public void finish() { | |
// Closes the private mongo and redis connections within meta | |
meta.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment