Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. import java.io.ObjectInputStream;
  2. import java.io.ObjectOutputStream;
  3. import java.util.List;
  4.  
  5. interface Row {
  6. /*
  7. Single row of data. An implementation of this interface is, roughly, a table schema.
  8. */
  9.  
  10. // Get the row's partition key. This can be any value (not necessarily unique). We try to put
  11. // rows with similar partition keys in the same index.
  12. public int getPartitionKey();
  13. }
  14.  
  15. interface QueryEngine {
  16. /*
  17. Lives on a query server. Generates a query plan (query functions and target keys) for any user-submitted query.
  18. */
  19.  
  20. // Generate a query plan for a user-submitted query.
  21. public queryPlan planQuery(String query);
  22. }
  23.  
  24. interface Index {
  25. /*
  26. Stores a shard of data. Probably contains an internal index structure for fast queries.
  27. For durability, can be saved as files to persistent storage (S3?) and reconstructed.
  28. */
  29.  
  30. // Add a new row to the index.
  31. public int addRow(Row row);
  32. // Create files from which index can be reconstructed.
  33. public List<String> indexToData();
  34. // Reconstruct index from files.
  35. public int indexFromData(List<String> data);
  36. }
  37.  
  38. interface queryPlan {
  39. /*
  40. Map a query on indexes, then reduce into a result.
  41. */
  42.  
  43. // On which keys should the query execute?
  44. public List<Integer> keysForQuery();
  45. // Execute the query on an index (Map).
  46. public ObjectOutputStream queryIndex(Index index);
  47. // Aggregate the outputs of queries on indexes (Reduce).
  48. public String aggregateIndexQueries(List<ObjectInputStream> indexQueryResults);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement