Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Reformatted with spaces instead of tabs
  • Loading branch information
johanoskarsson committed May 22, 2010
1 parent ee88bbf commit eaa3ad7
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 137 deletions.
70 changes: 35 additions & 35 deletions db/cassandra-0.7/src/com/yahoo/ycsb/db/CassandraClient7.java
Expand Up @@ -144,14 +144,14 @@ public int read(String table, String key, Set<String> fields, HashMap<String, St
{ {
Exception errorexception = null; Exception errorexception = null;
try try
{ {
client.set_keyspace(table); client.set_keyspace(table);
} catch (Exception e) } catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
e.printStackTrace(System.out); e.printStackTrace(System.out);
return Error; return Error;
} }


for (int i = 0; i < OperationRetries; i++) for (int i = 0; i < OperationRetries; i++)
{ {
Expand Down Expand Up @@ -249,14 +249,14 @@ public int scan(String table, String startkey, int recordcount, Set<String> fiel
Exception errorexception = null; Exception errorexception = null;


try try
{ {
client.set_keyspace(table); client.set_keyspace(table);
} catch (Exception e) } catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
e.printStackTrace(System.out); e.printStackTrace(System.out);
return Error; return Error;
} }


for (int i = 0; i < OperationRetries; i++) for (int i = 0; i < OperationRetries; i++)
{ {
Expand Down Expand Up @@ -368,14 +368,14 @@ public int insert(String table, String key, HashMap<String, String> values)
Exception errorexception = null; Exception errorexception = null;


try try
{ {
client.set_keyspace(table); client.set_keyspace(table);
} catch (Exception e) } catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
e.printStackTrace(System.out); e.printStackTrace(System.out);
return Error; return Error;
} }


for (int i = 0; i < OperationRetries; i++) for (int i = 0; i < OperationRetries; i++)
{ {
Expand All @@ -389,8 +389,8 @@ public int insert(String table, String key, HashMap<String, String> values)
Map<String, List<Mutation>> cfMutationMap = new HashMap<String, List<Mutation>>(); Map<String, List<Mutation>> cfMutationMap = new HashMap<String, List<Mutation>>();
cfMutationMap.put("data", v); cfMutationMap.put("data", v);
batch_mutation.put(key.getBytes("UTF-8"), cfMutationMap); batch_mutation.put(key.getBytes("UTF-8"), cfMutationMap);

for (String field : values.keySet()) for (String field : values.keySet())
{ {
String val = values.get(field); String val = values.get(field);
Column col = new Column(field.getBytes("UTF-8"), val.getBytes("UTF-8"), timestamp); Column col = new Column(field.getBytes("UTF-8"), val.getBytes("UTF-8"), timestamp);
Expand Down Expand Up @@ -442,15 +442,15 @@ public int delete(String table, String key)
Exception errorexception = null; Exception errorexception = null;


try try
{ {
client.set_keyspace(table); client.set_keyspace(table);
} catch (Exception e) } catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
e.printStackTrace(System.out); e.printStackTrace(System.out);
return Error; return Error;
} }

for (int i = 0; i < OperationRetries; i++) for (int i = 0; i < OperationRetries; i++)
{ {
try try
Expand Down
19 changes: 10 additions & 9 deletions src/com/yahoo/ycsb/measurements/Measurements.java
Expand Up @@ -137,18 +137,19 @@ public void reportReturnCode(String operation, int code)
data.get(operation).reportReturnCode(code); data.get(operation).reportReturnCode(code);
} }


/** /**
* Export the current measurements to a suitable format. * Export the current measurements to a suitable format.
* @param exporter Exporter representing the type of format to write to. *
* @throws IOException Thrown if the export failed. * @param exporter Exporter representing the type of format to write to.
*/ * @throws IOException Thrown if the export failed.
public void exportMeasurements(MeasurementsExporter exporter) throws IOException */
{ public void exportMeasurements(MeasurementsExporter exporter) throws IOException
for (OneMeasurement measurement : data.values()) {
for (OneMeasurement measurement : data.values())
{ {
measurement.exportMeasurements(exporter); measurement.exportMeasurements(exporter);
} }
} }


/** /**
* Return a one line summary of the measurements. * Return a one line summary of the measurements.
Expand Down
14 changes: 7 additions & 7 deletions src/com/yahoo/ycsb/measurements/OneMeasurement.java
Expand Up @@ -45,11 +45,11 @@ public OneMeasurement(String _name) {


public abstract String getSummary(); public abstract String getSummary();


/** /**
* Export the current measurements to a suitable format. * Export the current measurements to a suitable format.
* *
* @param exporter Exporter representing the type of format to write to. * @param exporter Exporter representing the type of format to write to.
* @throws IOException Thrown if the export failed. * @throws IOException Thrown if the export failed.
*/ */
public abstract void exportMeasurements(MeasurementsExporter exporter) throws IOException; public abstract void exportMeasurements(MeasurementsExporter exporter) throws IOException;
} }
Expand Up @@ -31,44 +31,44 @@
public class JSONMeasurementsExporter implements MeasurementsExporter public class JSONMeasurementsExporter implements MeasurementsExporter
{ {


private JsonFactory factory = new JsonFactory(); private JsonFactory factory = new JsonFactory();
private JsonGenerator g; private JsonGenerator g;


public JSONMeasurementsExporter(OutputStream os) throws IOException public JSONMeasurementsExporter(OutputStream os) throws IOException
{ {


BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
g = factory.createJsonGenerator(bw); g = factory.createJsonGenerator(bw);
g.setPrettyPrinter(new DefaultPrettyPrinter()); g.setPrettyPrinter(new DefaultPrettyPrinter());
} }


@Override @Override
public void write(String metric, String measurement, int i) throws IOException public void write(String metric, String measurement, int i) throws IOException
{ {
g.writeStartObject(); g.writeStartObject();
g.writeStringField("metric", metric); g.writeStringField("metric", metric);
g.writeStringField("measurement", measurement); g.writeStringField("measurement", measurement);
g.writeNumberField("value", i); g.writeNumberField("value", i);
g.writeEndObject(); g.writeEndObject();
} }


@Override @Override
public void write(String metric, String measurement, double d) throws IOException public void write(String metric, String measurement, double d) throws IOException
{ {
g.writeStartObject(); g.writeStartObject();
g.writeStringField("metric", metric); g.writeStringField("metric", metric);
g.writeStringField("measurement", measurement); g.writeStringField("measurement", measurement);
g.writeNumberField("value", d); g.writeNumberField("value", d);
g.writeEndObject(); g.writeEndObject();
} }


@Override @Override
public void close() throws IOException public void close() throws IOException
{ {
if (g != null) if (g != null)
{ {
g.close(); g.close();
} }
} }


} }
44 changes: 18 additions & 26 deletions src/com/yahoo/ycsb/measurements/exporter/MeasurementsExporter.java
Expand Up @@ -26,32 +26,24 @@
public interface MeasurementsExporter extends Closeable public interface MeasurementsExporter extends Closeable
{ {


/** /**
* Write a measurement to the exported format. * Write a measurement to the exported format.
* *
* @param metric * @param metric Metric name, for example "READ LATENCY".
* Metric name, for example "READ LATENCY". * @param measurement Measurement name, for example "Average latency".
* @param measurement * @param i Measurement to write.
* Measurement name, for example "Average latency". * @throws IOException if writing failed
* @param i */
* Measurement to write. public void write(String metric, String measurement, int i) throws IOException;
* @throws IOException
* if writing failed
*/
public void write(String metric, String measurement, int i) throws IOException;


/** /**
* Write a measurement to the exported format. * Write a measurement to the exported format.
* *
* @param metric * @param metric Metric name, for example "READ LATENCY".
* Metric name, for example "READ LATENCY". * @param measurement Measurement name, for example "Average latency".
* @param measurement * @param d Measurement to write.
* Measurement name, for example "Average latency". * @throws IOException if writing failed
* @param d */
* Measurement to write. public void write(String metric, String measurement, double d) throws IOException;
* @throws IOException
* if writing failed
*/
public void write(String metric, String measurement, double d) throws IOException;


} }
Expand Up @@ -27,31 +27,31 @@
public class TextMeasurementsExporter implements MeasurementsExporter public class TextMeasurementsExporter implements MeasurementsExporter
{ {


private BufferedWriter bw; private BufferedWriter bw;


public TextMeasurementsExporter(OutputStream os) public TextMeasurementsExporter(OutputStream os)
{ {
this.bw = new BufferedWriter(new OutputStreamWriter(os)); this.bw = new BufferedWriter(new OutputStreamWriter(os));
} }


@Override @Override
public void write(String metric, String measurement, int i) throws IOException public void write(String metric, String measurement, int i) throws IOException
{ {
bw.write("[" + metric + "], " + measurement + ", " + i); bw.write("[" + metric + "], " + measurement + ", " + i);
bw.newLine(); bw.newLine();
} }


@Override @Override
public void write(String metric, String measurement, double d) throws IOException public void write(String metric, String measurement, double d) throws IOException
{ {
bw.write("[" + metric + "], " + measurement + ", " + d); bw.write("[" + metric + "], " + measurement + ", " + d);
bw.newLine(); bw.newLine();
} }


@Override @Override
public void close() throws IOException public void close() throws IOException
{ {
this.bw.close(); this.bw.close();
} }


} }

0 comments on commit eaa3ad7

Please sign in to comment.