-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
s3 uri add, encoding bug fix, tests in progress
- Loading branch information
Showing
6 changed files
with
138 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* | ||
*/ | ||
package edu.washington.escience.myria.io; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
|
||
/** | ||
* | ||
*/ | ||
public class ByteSink implements DataSink { | ||
/** Required for Java serialization. */ | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public OutputStream getOutputStream() throws IOException { | ||
return new ByteArrayOutputStream(); | ||
} | ||
} |
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
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
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
51 changes: 51 additions & 0 deletions
51
systemtest/edu/washington/escience/myria/systemtest/DataSinkTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* | ||
*/ | ||
package edu.washington.escience.myria.systemtest; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.nio.file.Paths; | ||
|
||
import org.junit.Test; | ||
|
||
import edu.washington.escience.myria.PostgresBinaryTupleWriter; | ||
import edu.washington.escience.myria.RelationKey; | ||
import edu.washington.escience.myria.Schema; | ||
import edu.washington.escience.myria.Type; | ||
import edu.washington.escience.myria.io.DataSink; | ||
import edu.washington.escience.myria.io.DataSource; | ||
import edu.washington.escience.myria.io.FileSource; | ||
import edu.washington.escience.myria.io.UriSink; | ||
import edu.washington.escience.myria.operator.DataOutput; | ||
import edu.washington.escience.myria.operator.DbQueryScan; | ||
import edu.washington.escience.myria.operator.network.partition.RoundRobinPartitionFunction; | ||
import edu.washington.escience.myria.util.JsonAPIUtils; | ||
|
||
/** | ||
*/ | ||
public class DataSinkTest extends SystemTestBase { | ||
|
||
@Test | ||
public void s3UploadTest() throws Exception { | ||
/* Ingest test data */ | ||
DataSource relationSource = new FileSource(Paths.get("testdata", "filescan", "simple_two_col_int.txt").toString()); | ||
RelationKey relationKey = RelationKey.of("public", "adhoc", "testIngest"); | ||
Schema relationSchema = Schema.ofFields("x", Type.INT_TYPE, "y", Type.INT_TYPE); | ||
JsonAPIUtils.ingestData("localhost", masterDaemonPort, ingest(relationKey, relationSchema, relationSource, ' ', | ||
new RoundRobinPartitionFunction(workerIDs.length))); | ||
|
||
/* Construct the query programmatically -- for the workers */ | ||
DbQueryScan dbScan = new DbQueryScan(relationKey, relationSchema); | ||
DataSink sink = new UriSink("s3://myria-test/"); | ||
DataOutput dataOutput = new DataOutput(dbScan, new PostgresBinaryTupleWriter(), sink); | ||
|
||
// finish the query plan | ||
// server.submitQueryPlan(serverPlan, workerPlans).get(); | ||
|
||
/* Read the data back in from S3 and verify results */ | ||
String data = ""; // S3 download via JsonUtils? | ||
String expectedData = ""; | ||
assertEquals(data, expectedData); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
test/edu/washington/escience/myria/operator/DataOutputTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* | ||
*/ | ||
package edu.washington.escience.myria.operator; | ||
|
||
import org.junit.Test; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
|
||
import edu.washington.escience.myria.CsvTupleWriter; | ||
import edu.washington.escience.myria.Schema; | ||
import edu.washington.escience.myria.Type; | ||
import edu.washington.escience.myria.io.ByteSink; | ||
import edu.washington.escience.myria.io.DataSink; | ||
import edu.washington.escience.myria.io.FileSource; | ||
import edu.washington.escience.myria.storage.TupleBatch; | ||
import edu.washington.escience.myria.util.TestEnvVars; | ||
|
||
/** | ||
* | ||
*/ | ||
public class DataOutputTest { | ||
|
||
@Test | ||
public void readCSVTest() throws Exception { | ||
/* Read a CSV and construct the query */ | ||
final String filename = "testdata/twitter/TwitterK.csv"; | ||
final Schema schema = new Schema(ImmutableList.of(Type.INT_TYPE, Type.INT_TYPE)); | ||
|
||
FileScan scanCSV = new FileScan(new FileSource(filename), schema); | ||
DataSink byteSink = new ByteSink(); | ||
DataOutput dataOutput = new DataOutput(scanCSV, new CsvTupleWriter(), byteSink); | ||
|
||
dataOutput.open(TestEnvVars.get()); | ||
|
||
/* Read the data */ | ||
String result = null; | ||
TupleBatch tb = null; | ||
while (!dataOutput.eos()) { | ||
tb = dataOutput.nextReady(); | ||
if (tb != null) { | ||
// add to result | ||
} | ||
} | ||
|
||
/* Verify results */ | ||
} | ||
} |