Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added list-variable and range-variable support git-svn-id: http://developer.marklogic.com/svn/performance-meters/trunk@746 e04f4502-82db-0310-b1af-f799f365da79
- Loading branch information
Mike
committed
Dec 7, 2007
1 parent
c8c9b0d
commit 12405f5
Showing
22 changed files
with
312 additions
and
86 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Copyright (c) 2007 Mark Logic Corporation. All rights reserved. | ||
*/ | ||
package com.marklogic.performance; | ||
|
||
import com.marklogic.xcc.types.XName; | ||
import com.marklogic.xcc.types.XdmValue; | ||
import com.marklogic.xcc.types.XdmVariable; | ||
|
||
/** | ||
* @author Michael Blakeley, michael.blakeley@marklogic.com | ||
* | ||
*/ | ||
public class ListVariable implements XdmVariable { | ||
|
||
private XName xname; | ||
private XdmValue[] xvalues; | ||
|
||
/** | ||
* @param name | ||
* @param namespace | ||
* @param type | ||
* @param values | ||
*/ | ||
public ListVariable(String name, String namespace, String type, | ||
String[] values) { | ||
xname = new XName(namespace, name); | ||
xvalues = new XdmValue[values.length]; | ||
// copy the input values | ||
for (int i = 0; i < values.length; i++) { | ||
xvalues[i] = XMLFileTest.newValue(type, values[i]); | ||
} | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see com.marklogic.xcc.types.XdmVariable#getName() | ||
*/ | ||
public XName getName() { | ||
return xname; | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see com.marklogic.xcc.types.XdmVariable#getValue() | ||
*/ | ||
public XdmValue getValue() { | ||
// return a random value from the sequence | ||
// TODO also allow sequential values? | ||
return xvalues[(int)(Math.random() * xvalues.length)]; | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* Copyright (c) 2007 Mark Logic Corporation. All rights reserved. | ||
*/ | ||
package com.marklogic.performance; | ||
|
||
import com.marklogic.xcc.ValueFactory; | ||
import com.marklogic.xcc.exceptions.UnimplementedFeatureException; | ||
import com.marklogic.xcc.types.ValueType; | ||
import com.marklogic.xcc.types.XName; | ||
import com.marklogic.xcc.types.XSDouble; | ||
import com.marklogic.xcc.types.XSInteger; | ||
import com.marklogic.xcc.types.XdmValue; | ||
import com.marklogic.xcc.types.XdmVariable; | ||
|
||
/** | ||
* @author Michael Blakeley, michael.blakeley@marklogic.com | ||
* | ||
*/ | ||
public class RangeVariable implements XdmVariable { | ||
|
||
private XName xname; | ||
|
||
private XdmValue xMin; | ||
|
||
private XdmValue xMax; | ||
|
||
private String type; | ||
|
||
/** | ||
* @param name | ||
* @param namespace | ||
* @param type | ||
* @param minValue | ||
* @param maxValue | ||
*/ | ||
public RangeVariable(String name, String namespace, String type, | ||
String minValue, String maxValue) { | ||
// TODO Auto-generated constructor stub | ||
xname = new XName(namespace, name); | ||
// prepare min, max values | ||
xMin = XMLFileTest.newValue(type, minValue); | ||
xMax = XMLFileTest.newValue(type, maxValue); | ||
this.type = type; | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see com.marklogic.xcc.types.XdmVariable#getName() | ||
*/ | ||
public XName getName() { | ||
return xname; | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see com.marklogic.xcc.types.XdmVariable#getValue() | ||
*/ | ||
public XdmValue getValue() { | ||
if (xMin instanceof XSInteger) { | ||
long min = ((XSInteger) xMin).asPrimitiveLong(); | ||
long range = ((XSInteger) xMax).asPrimitiveLong() - min; | ||
return ValueFactory.newXSInteger(min | ||
+ (long) (Math.random() * range)); | ||
} | ||
|
||
if (xMin instanceof XSDouble) { | ||
double min = ((XSDouble) xMin).asPrimitiveDouble(); | ||
double range = ((XSDouble) xMax).asPrimitiveDouble() - min; | ||
return ValueFactory.newValue(ValueType.XS_DOUBLE, min | ||
+ (Math.random() * range)); | ||
} | ||
|
||
// TODO implement types as needed | ||
|
||
throw new UnimplementedFeatureException( | ||
"cannot use ranges of type " + type); | ||
} | ||
} |
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
Oops, something went wrong.