id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
18,000
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/DoubleColumn.java
|
DoubleColumn.map
|
public DoubleColumn map(ToDoubleFunction<Double> fun) {
DoubleColumn result = DoubleColumn.create(name());
for (double t : this) {
try {
result.append(fun.applyAsDouble(t));
} catch (Exception e) {
result.appendMissing();
}
}
return result;
}
|
java
|
public DoubleColumn map(ToDoubleFunction<Double> fun) {
DoubleColumn result = DoubleColumn.create(name());
for (double t : this) {
try {
result.append(fun.applyAsDouble(t));
} catch (Exception e) {
result.appendMissing();
}
}
return result;
}
|
[
"public",
"DoubleColumn",
"map",
"(",
"ToDoubleFunction",
"<",
"Double",
">",
"fun",
")",
"{",
"DoubleColumn",
"result",
"=",
"DoubleColumn",
".",
"create",
"(",
"name",
"(",
")",
")",
";",
"for",
"(",
"double",
"t",
":",
"this",
")",
"{",
"try",
"{",
"result",
".",
"append",
"(",
"fun",
".",
"applyAsDouble",
"(",
"t",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"result",
".",
"appendMissing",
"(",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Maps the function across all rows, appending the results to a new NumberColumn
@param fun function to map
@return the NumberColumn with the results
|
[
"Maps",
"the",
"function",
"across",
"all",
"rows",
"appending",
"the",
"results",
"to",
"a",
"new",
"NumberColumn"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/DoubleColumn.java#L331-L341
|
18,001
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/DoubleColumn.java
|
DoubleColumn.filter
|
public DoubleColumn filter(DoublePredicate test) {
DoubleColumn result = DoubleColumn.create(name());
for (int i = 0; i < size(); i++) {
double d = getDouble(i);
if (test.test(d)) {
result.append(d);
}
}
return result;
}
|
java
|
public DoubleColumn filter(DoublePredicate test) {
DoubleColumn result = DoubleColumn.create(name());
for (int i = 0; i < size(); i++) {
double d = getDouble(i);
if (test.test(d)) {
result.append(d);
}
}
return result;
}
|
[
"public",
"DoubleColumn",
"filter",
"(",
"DoublePredicate",
"test",
")",
"{",
"DoubleColumn",
"result",
"=",
"DoubleColumn",
".",
"create",
"(",
"name",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"double",
"d",
"=",
"getDouble",
"(",
"i",
")",
";",
"if",
"(",
"test",
".",
"test",
"(",
"d",
")",
")",
"{",
"result",
".",
"append",
"(",
"d",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Returns a new NumberColumn with only those rows satisfying the predicate
@param test the predicate
@return a new NumberColumn with only those rows satisfying the predicate
|
[
"Returns",
"a",
"new",
"NumberColumn",
"with",
"only",
"those",
"rows",
"satisfying",
"the",
"predicate"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/DoubleColumn.java#L349-L358
|
18,002
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/DoubleColumn.java
|
DoubleColumn.asLongColumn
|
@Override
public LongColumn asLongColumn() {
LongArrayList values = new LongArrayList();
for (double d : data) {
values.add((long) d);
}
values.trim();
return LongColumn.create(this.name(), values.elements());
}
|
java
|
@Override
public LongColumn asLongColumn() {
LongArrayList values = new LongArrayList();
for (double d : data) {
values.add((long) d);
}
values.trim();
return LongColumn.create(this.name(), values.elements());
}
|
[
"@",
"Override",
"public",
"LongColumn",
"asLongColumn",
"(",
")",
"{",
"LongArrayList",
"values",
"=",
"new",
"LongArrayList",
"(",
")",
";",
"for",
"(",
"double",
"d",
":",
"data",
")",
"{",
"values",
".",
"add",
"(",
"(",
"long",
")",
"d",
")",
";",
"}",
"values",
".",
"trim",
"(",
")",
";",
"return",
"LongColumn",
".",
"create",
"(",
"this",
".",
"name",
"(",
")",
",",
"values",
".",
"elements",
"(",
")",
")",
";",
"}"
] |
Returns a new LongColumn containing a value for each value in this column, truncating if necessary
A narrowing primitive conversion such as this one may lose information about the overall magnitude of a
numeric value and may also lose precision and range. Specifically, if the value is too small (a negative value
of large magnitude or negative infinity), the result is the smallest representable value of type long.
Similarly, if the value is too large (a positive value of large magnitude or positive infinity), the result is the
largest representable value of type long.
Despite the fact that overflow, underflow, or other loss of information may occur, a narrowing primitive
conversion never results in a run-time exception.
A missing value in the receiver is converted to a missing value in the result
|
[
"Returns",
"a",
"new",
"LongColumn",
"containing",
"a",
"value",
"for",
"each",
"value",
"in",
"this",
"column",
"truncating",
"if",
"necessary"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/DoubleColumn.java#L576-L584
|
18,003
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/table/Relation.java
|
Relation.columnIndex
|
public int columnIndex(String columnName) {
for (int i = 0; i < columnCount(); i++) {
if (columnNames().get(i).equalsIgnoreCase(columnName)) {
return i;
}
}
throw new IllegalArgumentException(String.format("Column %s is not present in table %s", columnName, name
()));
}
|
java
|
public int columnIndex(String columnName) {
for (int i = 0; i < columnCount(); i++) {
if (columnNames().get(i).equalsIgnoreCase(columnName)) {
return i;
}
}
throw new IllegalArgumentException(String.format("Column %s is not present in table %s", columnName, name
()));
}
|
[
"public",
"int",
"columnIndex",
"(",
"String",
"columnName",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"columnCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"columnNames",
"(",
")",
".",
"get",
"(",
"i",
")",
".",
"equalsIgnoreCase",
"(",
"columnName",
")",
")",
"{",
"return",
"i",
";",
"}",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Column %s is not present in table %s\"",
",",
"columnName",
",",
"name",
"(",
")",
")",
")",
";",
"}"
] |
Returns the index of the column with the given columnName
|
[
"Returns",
"the",
"index",
"of",
"the",
"column",
"with",
"the",
"given",
"columnName"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/table/Relation.java#L96-L104
|
18,004
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/table/Relation.java
|
Relation.column
|
public Column<?> column(String columnName) {
for (Column<?> column : columns()) {
String name = column.name().trim();
if (name.equalsIgnoreCase(columnName)) {
return column;
}
}
throw new IllegalStateException(String.format("Column %s does not exist in table %s", columnName, name()));
}
|
java
|
public Column<?> column(String columnName) {
for (Column<?> column : columns()) {
String name = column.name().trim();
if (name.equalsIgnoreCase(columnName)) {
return column;
}
}
throw new IllegalStateException(String.format("Column %s does not exist in table %s", columnName, name()));
}
|
[
"public",
"Column",
"<",
"?",
">",
"column",
"(",
"String",
"columnName",
")",
"{",
"for",
"(",
"Column",
"<",
"?",
">",
"column",
":",
"columns",
"(",
")",
")",
"{",
"String",
"name",
"=",
"column",
".",
"name",
"(",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"name",
".",
"equalsIgnoreCase",
"(",
"columnName",
")",
")",
"{",
"return",
"column",
";",
"}",
"}",
"throw",
"new",
"IllegalStateException",
"(",
"String",
".",
"format",
"(",
"\"Column %s does not exist in table %s\"",
",",
"columnName",
",",
"name",
"(",
")",
")",
")",
";",
"}"
] |
Returns the column with the given columnName, ignoring case
|
[
"Returns",
"the",
"column",
"with",
"the",
"given",
"columnName",
"ignoring",
"case"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/table/Relation.java#L109-L117
|
18,005
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/table/Relation.java
|
Relation.columns
|
public List<Column<?>> columns(int... columnIndices) {
List<Column<?>> cols = new ArrayList<>(columnIndices.length);
for (int i : columnIndices) {
cols.add(column(i));
}
return cols;
}
|
java
|
public List<Column<?>> columns(int... columnIndices) {
List<Column<?>> cols = new ArrayList<>(columnIndices.length);
for (int i : columnIndices) {
cols.add(column(i));
}
return cols;
}
|
[
"public",
"List",
"<",
"Column",
"<",
"?",
">",
">",
"columns",
"(",
"int",
"...",
"columnIndices",
")",
"{",
"List",
"<",
"Column",
"<",
"?",
">",
">",
"cols",
"=",
"new",
"ArrayList",
"<>",
"(",
"columnIndices",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
":",
"columnIndices",
")",
"{",
"cols",
".",
"add",
"(",
"column",
"(",
"i",
")",
")",
";",
"}",
"return",
"cols",
";",
"}"
] |
Returns the columns whose indices are given in the input array
|
[
"Returns",
"the",
"columns",
"whose",
"indices",
"are",
"given",
"in",
"the",
"input",
"array"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/table/Relation.java#L156-L162
|
18,006
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/table/Relation.java
|
Relation.get
|
public Object get(int r, int c) {
Column<?> column = column(c);
return column.get(r);
}
|
java
|
public Object get(int r, int c) {
Column<?> column = column(c);
return column.get(r);
}
|
[
"public",
"Object",
"get",
"(",
"int",
"r",
",",
"int",
"c",
")",
"{",
"Column",
"<",
"?",
">",
"column",
"=",
"column",
"(",
"c",
")",
";",
"return",
"column",
".",
"get",
"(",
"r",
")",
";",
"}"
] |
Returns the value at the given row and column indexes
@param r the row index, 0 based
@param c the column index, 0 based
|
[
"Returns",
"the",
"value",
"at",
"the",
"given",
"row",
"and",
"column",
"indexes"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/table/Relation.java#L175-L178
|
18,007
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/table/Relation.java
|
Relation.columnTypes
|
public ColumnType[] columnTypes() {
ColumnType[] columnTypes = new ColumnType[columnCount()];
for (int i = 0; i < columnCount(); i++) {
columnTypes[i] = columns().get(i).type();
}
return columnTypes;
}
|
java
|
public ColumnType[] columnTypes() {
ColumnType[] columnTypes = new ColumnType[columnCount()];
for (int i = 0; i < columnCount(); i++) {
columnTypes[i] = columns().get(i).type();
}
return columnTypes;
}
|
[
"public",
"ColumnType",
"[",
"]",
"columnTypes",
"(",
")",
"{",
"ColumnType",
"[",
"]",
"columnTypes",
"=",
"new",
"ColumnType",
"[",
"columnCount",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"columnCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"columnTypes",
"[",
"i",
"]",
"=",
"columns",
"(",
")",
".",
"get",
"(",
"i",
")",
".",
"type",
"(",
")",
";",
"}",
"return",
"columnTypes",
";",
"}"
] |
Returns an array of the column types of all columns in the relation, including duplicates as appropriate,
and maintaining order
|
[
"Returns",
"an",
"array",
"of",
"the",
"column",
"types",
"of",
"all",
"columns",
"in",
"the",
"relation",
"including",
"duplicates",
"as",
"appropriate",
"and",
"maintaining",
"order"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/table/Relation.java#L196-L202
|
18,008
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/table/Relation.java
|
Relation.colWidths
|
public int[] colWidths() {
int cols = columnCount();
int[] widths = new int[cols];
for (int i = 0; i < columnCount(); i++) {
widths[i] = columns().get(i).columnWidth();
}
return widths;
}
|
java
|
public int[] colWidths() {
int cols = columnCount();
int[] widths = new int[cols];
for (int i = 0; i < columnCount(); i++) {
widths[i] = columns().get(i).columnWidth();
}
return widths;
}
|
[
"public",
"int",
"[",
"]",
"colWidths",
"(",
")",
"{",
"int",
"cols",
"=",
"columnCount",
"(",
")",
";",
"int",
"[",
"]",
"widths",
"=",
"new",
"int",
"[",
"cols",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"columnCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"widths",
"[",
"i",
"]",
"=",
"columns",
"(",
")",
".",
"get",
"(",
"i",
")",
".",
"columnWidth",
"(",
")",
";",
"}",
"return",
"widths",
";",
"}"
] |
Returns an array of column widths for printing tables
|
[
"Returns",
"an",
"array",
"of",
"column",
"widths",
"for",
"printing",
"tables"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/table/Relation.java#L207-L215
|
18,009
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/index/ShortIndex.java
|
ShortIndex.get
|
public Selection get(short value) {
Selection selection = new BitmapBackedSelection();
IntArrayList list = index.get(value);
if (list != null) {
addAllToSelection(list, selection);
}
return selection;
}
|
java
|
public Selection get(short value) {
Selection selection = new BitmapBackedSelection();
IntArrayList list = index.get(value);
if (list != null) {
addAllToSelection(list, selection);
}
return selection;
}
|
[
"public",
"Selection",
"get",
"(",
"short",
"value",
")",
"{",
"Selection",
"selection",
"=",
"new",
"BitmapBackedSelection",
"(",
")",
";",
"IntArrayList",
"list",
"=",
"index",
".",
"get",
"(",
"value",
")",
";",
"if",
"(",
"list",
"!=",
"null",
")",
"{",
"addAllToSelection",
"(",
"list",
",",
"selection",
")",
";",
"}",
"return",
"selection",
";",
"}"
] |
Returns a bitmap containing row numbers of all cells matching the given int
@param value This is a 'key' from the index perspective, meaning it is a value from the standpoint of the column
|
[
"Returns",
"a",
"bitmap",
"containing",
"row",
"numbers",
"of",
"all",
"cells",
"matching",
"the",
"given",
"int"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/index/ShortIndex.java#L66-L73
|
18,010
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/columns/datetimes/PackedLocalDateTime.java
|
PackedLocalDateTime.plus
|
public static long plus(long packedDateTime, long amountToAdd, TemporalUnit unit) {
LocalDateTime dateTime = asLocalDateTime(packedDateTime);
return pack(dateTime.plus(amountToAdd, unit));
}
|
java
|
public static long plus(long packedDateTime, long amountToAdd, TemporalUnit unit) {
LocalDateTime dateTime = asLocalDateTime(packedDateTime);
return pack(dateTime.plus(amountToAdd, unit));
}
|
[
"public",
"static",
"long",
"plus",
"(",
"long",
"packedDateTime",
",",
"long",
"amountToAdd",
",",
"TemporalUnit",
"unit",
")",
"{",
"LocalDateTime",
"dateTime",
"=",
"asLocalDateTime",
"(",
"packedDateTime",
")",
";",
"return",
"pack",
"(",
"dateTime",
".",
"plus",
"(",
"amountToAdd",
",",
"unit",
")",
")",
";",
"}"
] |
Returns the given packedDateTime with amtToAdd of temporal units added
TODO(lwhite): Replace with a native implementation that doesn't convert everything to LocalDateTime
|
[
"Returns",
"the",
"given",
"packedDateTime",
"with",
"amtToAdd",
"of",
"temporal",
"units",
"added"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/columns/datetimes/PackedLocalDateTime.java#L214-L218
|
18,011
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/LongColumn.java
|
LongColumn.asShortColumn
|
@Override
public ShortColumn asShortColumn() {
ShortArrayList values = new ShortArrayList();
for (long f : data) {
values.add((short) f);
}
values.trim();
return ShortColumn.create(this.name(), values.elements());
}
|
java
|
@Override
public ShortColumn asShortColumn() {
ShortArrayList values = new ShortArrayList();
for (long f : data) {
values.add((short) f);
}
values.trim();
return ShortColumn.create(this.name(), values.elements());
}
|
[
"@",
"Override",
"public",
"ShortColumn",
"asShortColumn",
"(",
")",
"{",
"ShortArrayList",
"values",
"=",
"new",
"ShortArrayList",
"(",
")",
";",
"for",
"(",
"long",
"f",
":",
"data",
")",
"{",
"values",
".",
"add",
"(",
"(",
"short",
")",
"f",
")",
";",
"}",
"values",
".",
"trim",
"(",
")",
";",
"return",
"ShortColumn",
".",
"create",
"(",
"this",
".",
"name",
"(",
")",
",",
"values",
".",
"elements",
"(",
")",
")",
";",
"}"
] |
Returns a new ShortColumn containing a value for each value in this column
A narrowing conversion of a signed long to an integral type T simply discards all but the n lowest order bits,
where n is the number of bits used to represent type T. In addition to a possible loss of information about
the magnitude of the numeric value, this may cause the sign of the resulting value to differ from the sign of
the input value.
In other words, if the element being converted is larger (or smaller) than Short.MAX_VALUE
(or Short.MIN_VALUE) you will not get a conventionally good conversion.
Despite the fact that overflow, underflow, or other loss of information may occur, a narrowing primitive
conversion never results in a run-time exception.
A missing value in the receiver is converted to a missing value in the result
|
[
"Returns",
"a",
"new",
"ShortColumn",
"containing",
"a",
"value",
"for",
"each",
"value",
"in",
"this",
"column"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/LongColumn.java#L530-L538
|
18,012
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/table/TableSliceGroup.java
|
TableSliceGroup.splitGroupingColumn
|
private Table splitGroupingColumn(Table groupTable) {
if (splitColumnNames.length > 0) {
List<Column<?>> newColumns = new ArrayList<>();
List<Column<?>> columns = sourceTable.columns(splitColumnNames);
for (Column<?> column : columns) {
Column<?> newColumn = column.emptyCopy();
newColumns.add(newColumn);
}
// iterate through the rows in the table and split each of the grouping columns into multiple columns
for (int row = 0; row < groupTable.rowCount(); row++) {
List<String> strings = SPLITTER.splitToList(groupTable.stringColumn("Group").get(row));
for (int col = 0; col < newColumns.size(); col++) {
newColumns.get(col).appendCell(strings.get(col));
}
}
for (int col = 0; col < newColumns.size(); col++) {
Column<?> c = newColumns.get(col);
groupTable.insertColumn(col, c);
}
groupTable.removeColumns("Group");
}
return groupTable;
}
|
java
|
private Table splitGroupingColumn(Table groupTable) {
if (splitColumnNames.length > 0) {
List<Column<?>> newColumns = new ArrayList<>();
List<Column<?>> columns = sourceTable.columns(splitColumnNames);
for (Column<?> column : columns) {
Column<?> newColumn = column.emptyCopy();
newColumns.add(newColumn);
}
// iterate through the rows in the table and split each of the grouping columns into multiple columns
for (int row = 0; row < groupTable.rowCount(); row++) {
List<String> strings = SPLITTER.splitToList(groupTable.stringColumn("Group").get(row));
for (int col = 0; col < newColumns.size(); col++) {
newColumns.get(col).appendCell(strings.get(col));
}
}
for (int col = 0; col < newColumns.size(); col++) {
Column<?> c = newColumns.get(col);
groupTable.insertColumn(col, c);
}
groupTable.removeColumns("Group");
}
return groupTable;
}
|
[
"private",
"Table",
"splitGroupingColumn",
"(",
"Table",
"groupTable",
")",
"{",
"if",
"(",
"splitColumnNames",
".",
"length",
">",
"0",
")",
"{",
"List",
"<",
"Column",
"<",
"?",
">",
">",
"newColumns",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"Column",
"<",
"?",
">",
">",
"columns",
"=",
"sourceTable",
".",
"columns",
"(",
"splitColumnNames",
")",
";",
"for",
"(",
"Column",
"<",
"?",
">",
"column",
":",
"columns",
")",
"{",
"Column",
"<",
"?",
">",
"newColumn",
"=",
"column",
".",
"emptyCopy",
"(",
")",
";",
"newColumns",
".",
"add",
"(",
"newColumn",
")",
";",
"}",
"// iterate through the rows in the table and split each of the grouping columns into multiple columns",
"for",
"(",
"int",
"row",
"=",
"0",
";",
"row",
"<",
"groupTable",
".",
"rowCount",
"(",
")",
";",
"row",
"++",
")",
"{",
"List",
"<",
"String",
">",
"strings",
"=",
"SPLITTER",
".",
"splitToList",
"(",
"groupTable",
".",
"stringColumn",
"(",
"\"Group\"",
")",
".",
"get",
"(",
"row",
")",
")",
";",
"for",
"(",
"int",
"col",
"=",
"0",
";",
"col",
"<",
"newColumns",
".",
"size",
"(",
")",
";",
"col",
"++",
")",
"{",
"newColumns",
".",
"get",
"(",
"col",
")",
".",
"appendCell",
"(",
"strings",
".",
"get",
"(",
"col",
")",
")",
";",
"}",
"}",
"for",
"(",
"int",
"col",
"=",
"0",
";",
"col",
"<",
"newColumns",
".",
"size",
"(",
")",
";",
"col",
"++",
")",
"{",
"Column",
"<",
"?",
">",
"c",
"=",
"newColumns",
".",
"get",
"(",
"col",
")",
";",
"groupTable",
".",
"insertColumn",
"(",
"col",
",",
"c",
")",
";",
"}",
"groupTable",
".",
"removeColumns",
"(",
"\"Group\"",
")",
";",
"}",
"return",
"groupTable",
";",
"}"
] |
For a subtable that is grouped by the values in more than one column, split the grouping column into separate
cols and return the revised view
|
[
"For",
"a",
"subtable",
"that",
"is",
"grouped",
"by",
"the",
"values",
"in",
"more",
"than",
"one",
"column",
"split",
"the",
"grouping",
"column",
"into",
"separate",
"cols",
"and",
"return",
"the",
"revised",
"view"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/table/TableSliceGroup.java#L109-L132
|
18,013
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/table/TableSliceGroup.java
|
TableSliceGroup.aggregate
|
public Table aggregate(String colName1, AggregateFunction<?,?>... functions) {
ArrayListMultimap<String, AggregateFunction<?,?>> columnFunctionMap = ArrayListMultimap.create();
columnFunctionMap.putAll(colName1, Lists.newArrayList(functions));
return aggregate(columnFunctionMap);
}
|
java
|
public Table aggregate(String colName1, AggregateFunction<?,?>... functions) {
ArrayListMultimap<String, AggregateFunction<?,?>> columnFunctionMap = ArrayListMultimap.create();
columnFunctionMap.putAll(colName1, Lists.newArrayList(functions));
return aggregate(columnFunctionMap);
}
|
[
"public",
"Table",
"aggregate",
"(",
"String",
"colName1",
",",
"AggregateFunction",
"<",
"?",
",",
"?",
">",
"...",
"functions",
")",
"{",
"ArrayListMultimap",
"<",
"String",
",",
"AggregateFunction",
"<",
"?",
",",
"?",
">",
">",
"columnFunctionMap",
"=",
"ArrayListMultimap",
".",
"create",
"(",
")",
";",
"columnFunctionMap",
".",
"putAll",
"(",
"colName1",
",",
"Lists",
".",
"newArrayList",
"(",
"functions",
")",
")",
";",
"return",
"aggregate",
"(",
"columnFunctionMap",
")",
";",
"}"
] |
Applies the given aggregation to the given column.
The apply and combine steps of a split-apply-combine.
|
[
"Applies",
"the",
"given",
"aggregation",
"to",
"the",
"given",
"column",
".",
"The",
"apply",
"and",
"combine",
"steps",
"of",
"a",
"split",
"-",
"apply",
"-",
"combine",
"."
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/table/TableSliceGroup.java#L138-L142
|
18,014
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/table/TableSliceGroup.java
|
TableSliceGroup.aggregate
|
@SuppressWarnings({ "unchecked", "rawtypes" })
public Table aggregate(ListMultimap<String, AggregateFunction<?,?>> functions) {
Preconditions.checkArgument(!getSlices().isEmpty());
Table groupTable = summaryTableName(sourceTable);
StringColumn groupColumn = StringColumn.create("Group");
groupTable.addColumns(groupColumn);
for (Map.Entry<String, Collection<AggregateFunction<?,?>>> entry : functions.asMap().entrySet()) {
String columnName = entry.getKey();
int functionCount = 0;
for (AggregateFunction function : entry.getValue()) {
String colName = aggregateColumnName(columnName, function.functionName());
ColumnType type = function.returnType();
Column resultColumn = type.create(colName);
for (TableSlice subTable : getSlices()) {
Object result = function.summarize(subTable.column(columnName));
if (functionCount == 0) {
groupColumn.append(subTable.name());
}
if (result instanceof Number) {
Number number = (Number) result;
resultColumn.append(number.doubleValue());
} else {
resultColumn.append(result);
}
}
groupTable.addColumns(resultColumn);
functionCount++;
}
}
return splitGroupingColumn(groupTable);
}
|
java
|
@SuppressWarnings({ "unchecked", "rawtypes" })
public Table aggregate(ListMultimap<String, AggregateFunction<?,?>> functions) {
Preconditions.checkArgument(!getSlices().isEmpty());
Table groupTable = summaryTableName(sourceTable);
StringColumn groupColumn = StringColumn.create("Group");
groupTable.addColumns(groupColumn);
for (Map.Entry<String, Collection<AggregateFunction<?,?>>> entry : functions.asMap().entrySet()) {
String columnName = entry.getKey();
int functionCount = 0;
for (AggregateFunction function : entry.getValue()) {
String colName = aggregateColumnName(columnName, function.functionName());
ColumnType type = function.returnType();
Column resultColumn = type.create(colName);
for (TableSlice subTable : getSlices()) {
Object result = function.summarize(subTable.column(columnName));
if (functionCount == 0) {
groupColumn.append(subTable.name());
}
if (result instanceof Number) {
Number number = (Number) result;
resultColumn.append(number.doubleValue());
} else {
resultColumn.append(result);
}
}
groupTable.addColumns(resultColumn);
functionCount++;
}
}
return splitGroupingColumn(groupTable);
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"Table",
"aggregate",
"(",
"ListMultimap",
"<",
"String",
",",
"AggregateFunction",
"<",
"?",
",",
"?",
">",
">",
"functions",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"!",
"getSlices",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
";",
"Table",
"groupTable",
"=",
"summaryTableName",
"(",
"sourceTable",
")",
";",
"StringColumn",
"groupColumn",
"=",
"StringColumn",
".",
"create",
"(",
"\"Group\"",
")",
";",
"groupTable",
".",
"addColumns",
"(",
"groupColumn",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Collection",
"<",
"AggregateFunction",
"<",
"?",
",",
"?",
">",
">",
">",
"entry",
":",
"functions",
".",
"asMap",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"columnName",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"int",
"functionCount",
"=",
"0",
";",
"for",
"(",
"AggregateFunction",
"function",
":",
"entry",
".",
"getValue",
"(",
")",
")",
"{",
"String",
"colName",
"=",
"aggregateColumnName",
"(",
"columnName",
",",
"function",
".",
"functionName",
"(",
")",
")",
";",
"ColumnType",
"type",
"=",
"function",
".",
"returnType",
"(",
")",
";",
"Column",
"resultColumn",
"=",
"type",
".",
"create",
"(",
"colName",
")",
";",
"for",
"(",
"TableSlice",
"subTable",
":",
"getSlices",
"(",
")",
")",
"{",
"Object",
"result",
"=",
"function",
".",
"summarize",
"(",
"subTable",
".",
"column",
"(",
"columnName",
")",
")",
";",
"if",
"(",
"functionCount",
"==",
"0",
")",
"{",
"groupColumn",
".",
"append",
"(",
"subTable",
".",
"name",
"(",
")",
")",
";",
"}",
"if",
"(",
"result",
"instanceof",
"Number",
")",
"{",
"Number",
"number",
"=",
"(",
"Number",
")",
"result",
";",
"resultColumn",
".",
"append",
"(",
"number",
".",
"doubleValue",
"(",
")",
")",
";",
"}",
"else",
"{",
"resultColumn",
".",
"append",
"(",
"result",
")",
";",
"}",
"}",
"groupTable",
".",
"addColumns",
"(",
"resultColumn",
")",
";",
"functionCount",
"++",
";",
"}",
"}",
"return",
"splitGroupingColumn",
"(",
"groupTable",
")",
";",
"}"
] |
Applies the given aggregations to the given columns.
The apply and combine steps of a split-apply-combine.
@param functions map from column name to aggregation to apply on that function
|
[
"Applies",
"the",
"given",
"aggregations",
"to",
"the",
"given",
"columns",
".",
"The",
"apply",
"and",
"combine",
"steps",
"of",
"a",
"split",
"-",
"apply",
"-",
"combine",
"."
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/table/TableSliceGroup.java#L150-L180
|
18,015
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/table/TableSliceGroup.java
|
TableSliceGroup.aggregateColumnName
|
public static String aggregateColumnName(String columnName, String functionName) {
return String.format("%s [%s]", functionName, columnName);
}
|
java
|
public static String aggregateColumnName(String columnName, String functionName) {
return String.format("%s [%s]", functionName, columnName);
}
|
[
"public",
"static",
"String",
"aggregateColumnName",
"(",
"String",
"columnName",
",",
"String",
"functionName",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%s [%s]\"",
",",
"functionName",
",",
"columnName",
")",
";",
"}"
] |
Returns a column name for aggregated data based on the given source column name and function
|
[
"Returns",
"a",
"column",
"name",
"for",
"aggregated",
"data",
"based",
"on",
"the",
"given",
"source",
"column",
"name",
"and",
"function"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/table/TableSliceGroup.java#L199-L201
|
18,016
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/FloatColumn.java
|
FloatColumn.asIntColumn
|
@Override
public IntColumn asIntColumn() {
IntArrayList values = new IntArrayList();
for (float d : data) {
values.add((int) d);
}
values.trim();
return IntColumn.create(this.name(), values.elements());
}
|
java
|
@Override
public IntColumn asIntColumn() {
IntArrayList values = new IntArrayList();
for (float d : data) {
values.add((int) d);
}
values.trim();
return IntColumn.create(this.name(), values.elements());
}
|
[
"@",
"Override",
"public",
"IntColumn",
"asIntColumn",
"(",
")",
"{",
"IntArrayList",
"values",
"=",
"new",
"IntArrayList",
"(",
")",
";",
"for",
"(",
"float",
"d",
":",
"data",
")",
"{",
"values",
".",
"add",
"(",
"(",
"int",
")",
"d",
")",
";",
"}",
"values",
".",
"trim",
"(",
")",
";",
"return",
"IntColumn",
".",
"create",
"(",
"this",
".",
"name",
"(",
")",
",",
"values",
".",
"elements",
"(",
")",
")",
";",
"}"
] |
Returns a new IntColumn containing a value for each value in this column, truncating if necessary.
A narrowing primitive conversion such as this one may lose information about the overall magnitude of a
numeric value and may also lose precision and range. Specifically, if the value is too small (a negative value
of large magnitude or negative infinity), the result is the smallest representable value of type int.
Similarly, if the value is too large (a positive value of large magnitude or positive infinity), the result is the
largest representable value of type int.
Despite the fact that overflow, underflow, or other loss of information may occur, a narrowing primitive
conversion never results in a run-time exception.
A missing value in the receiver is converted to a missing value in the result
|
[
"Returns",
"a",
"new",
"IntColumn",
"containing",
"a",
"value",
"for",
"each",
"value",
"in",
"this",
"column",
"truncating",
"if",
"necessary",
"."
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/FloatColumn.java#L461-L469
|
18,017
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/columns/dates/PackedLocalDate.java
|
PackedLocalDate.toEpochDay
|
public static long toEpochDay(int packedDate) {
long y = getYear(packedDate);
long m = getMonthValue(packedDate);
long total = 0;
total += 365 * y;
if (y >= 0) {
total += (y + 3) / 4 - (y + 99) / 100 + (y + 399) / 400;
} else {
total -= y / -4 - y / -100 + y / -400;
}
total += ((367 * m - 362) / 12);
total += getDayOfMonth(packedDate) - 1;
if (m > 2) {
total--;
if (!isLeapYear(packedDate)) {
total--;
}
}
return total - DAYS_0000_TO_1970;
}
|
java
|
public static long toEpochDay(int packedDate) {
long y = getYear(packedDate);
long m = getMonthValue(packedDate);
long total = 0;
total += 365 * y;
if (y >= 0) {
total += (y + 3) / 4 - (y + 99) / 100 + (y + 399) / 400;
} else {
total -= y / -4 - y / -100 + y / -400;
}
total += ((367 * m - 362) / 12);
total += getDayOfMonth(packedDate) - 1;
if (m > 2) {
total--;
if (!isLeapYear(packedDate)) {
total--;
}
}
return total - DAYS_0000_TO_1970;
}
|
[
"public",
"static",
"long",
"toEpochDay",
"(",
"int",
"packedDate",
")",
"{",
"long",
"y",
"=",
"getYear",
"(",
"packedDate",
")",
";",
"long",
"m",
"=",
"getMonthValue",
"(",
"packedDate",
")",
";",
"long",
"total",
"=",
"0",
";",
"total",
"+=",
"365",
"*",
"y",
";",
"if",
"(",
"y",
">=",
"0",
")",
"{",
"total",
"+=",
"(",
"y",
"+",
"3",
")",
"/",
"4",
"-",
"(",
"y",
"+",
"99",
")",
"/",
"100",
"+",
"(",
"y",
"+",
"399",
")",
"/",
"400",
";",
"}",
"else",
"{",
"total",
"-=",
"y",
"/",
"-",
"4",
"-",
"y",
"/",
"-",
"100",
"+",
"y",
"/",
"-",
"400",
";",
"}",
"total",
"+=",
"(",
"(",
"367",
"*",
"m",
"-",
"362",
")",
"/",
"12",
")",
";",
"total",
"+=",
"getDayOfMonth",
"(",
"packedDate",
")",
"-",
"1",
";",
"if",
"(",
"m",
">",
"2",
")",
"{",
"total",
"--",
";",
"if",
"(",
"!",
"isLeapYear",
"(",
"packedDate",
")",
")",
"{",
"total",
"--",
";",
"}",
"}",
"return",
"total",
"-",
"DAYS_0000_TO_1970",
";",
"}"
] |
Returns the epoch day in a form consistent with the java standard
|
[
"Returns",
"the",
"epoch",
"day",
"in",
"a",
"form",
"consistent",
"with",
"the",
"java",
"standard"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/columns/dates/PackedLocalDate.java#L181-L200
|
18,018
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/columns/dates/PackedLocalDate.java
|
PackedLocalDate.getQuarter
|
public static int getQuarter(int packedDate) {
if (packedDate == DateColumnType.missingValueIndicator()) {
return -1;
}
Month month = getMonth(packedDate);
switch (month) {
case JANUARY:
case FEBRUARY:
case MARCH:
return 1;
case APRIL:
case MAY:
case JUNE:
return 2;
case JULY:
case AUGUST:
case SEPTEMBER:
return 3;
case OCTOBER:
case NOVEMBER:
default: // must be december
return 4;
}
}
|
java
|
public static int getQuarter(int packedDate) {
if (packedDate == DateColumnType.missingValueIndicator()) {
return -1;
}
Month month = getMonth(packedDate);
switch (month) {
case JANUARY:
case FEBRUARY:
case MARCH:
return 1;
case APRIL:
case MAY:
case JUNE:
return 2;
case JULY:
case AUGUST:
case SEPTEMBER:
return 3;
case OCTOBER:
case NOVEMBER:
default: // must be december
return 4;
}
}
|
[
"public",
"static",
"int",
"getQuarter",
"(",
"int",
"packedDate",
")",
"{",
"if",
"(",
"packedDate",
"==",
"DateColumnType",
".",
"missingValueIndicator",
"(",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"Month",
"month",
"=",
"getMonth",
"(",
"packedDate",
")",
";",
"switch",
"(",
"month",
")",
"{",
"case",
"JANUARY",
":",
"case",
"FEBRUARY",
":",
"case",
"MARCH",
":",
"return",
"1",
";",
"case",
"APRIL",
":",
"case",
"MAY",
":",
"case",
"JUNE",
":",
"return",
"2",
";",
"case",
"JULY",
":",
"case",
"AUGUST",
":",
"case",
"SEPTEMBER",
":",
"return",
"3",
";",
"case",
"OCTOBER",
":",
"case",
"NOVEMBER",
":",
"default",
":",
"// must be december",
"return",
"4",
";",
"}",
"}"
] |
Returns the quarter of the year of the given date as an int from 1 to 4, or -1, if the argument is the
MISSING_VALUE for DateColumn
|
[
"Returns",
"the",
"quarter",
"of",
"the",
"year",
"of",
"the",
"given",
"date",
"as",
"an",
"int",
"from",
"1",
"to",
"4",
"or",
"-",
"1",
"if",
"the",
"argument",
"is",
"the",
"MISSING_VALUE",
"for",
"DateColumn"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/columns/dates/PackedLocalDate.java#L211-L234
|
18,019
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/table/TableSlice.java
|
TableSlice.reduce
|
public double reduce(String numberColumnName, NumericAggregateFunction function) {
NumberColumn<?> column = table.numberColumn(numberColumnName);
return function.summarize(column.where(selection));
}
|
java
|
public double reduce(String numberColumnName, NumericAggregateFunction function) {
NumberColumn<?> column = table.numberColumn(numberColumnName);
return function.summarize(column.where(selection));
}
|
[
"public",
"double",
"reduce",
"(",
"String",
"numberColumnName",
",",
"NumericAggregateFunction",
"function",
")",
"{",
"NumberColumn",
"<",
"?",
">",
"column",
"=",
"table",
".",
"numberColumn",
"(",
"numberColumnName",
")",
";",
"return",
"function",
".",
"summarize",
"(",
"column",
".",
"where",
"(",
"selection",
")",
")",
";",
"}"
] |
Returns the result of applying the given function to the specified column
@param numberColumnName The name of a numeric column in this table
@param function A numeric reduce function
@return the function result
@throws IllegalArgumentException if numberColumnName doesn't name a numeric column in this table
|
[
"Returns",
"the",
"result",
"of",
"applying",
"the",
"given",
"function",
"to",
"the",
"specified",
"column"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/table/TableSlice.java#L163-L166
|
18,020
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.getSort
|
private static Sort getSort(String... columnNames) {
Sort key = null;
for (String s : columnNames) {
if (key == null) {
key = first(s, Sort.Order.DESCEND);
} else {
key.next(s, Sort.Order.DESCEND);
}
}
return key;
}
|
java
|
private static Sort getSort(String... columnNames) {
Sort key = null;
for (String s : columnNames) {
if (key == null) {
key = first(s, Sort.Order.DESCEND);
} else {
key.next(s, Sort.Order.DESCEND);
}
}
return key;
}
|
[
"private",
"static",
"Sort",
"getSort",
"(",
"String",
"...",
"columnNames",
")",
"{",
"Sort",
"key",
"=",
"null",
";",
"for",
"(",
"String",
"s",
":",
"columnNames",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"key",
"=",
"first",
"(",
"s",
",",
"Sort",
".",
"Order",
".",
"DESCEND",
")",
";",
"}",
"else",
"{",
"key",
".",
"next",
"(",
"s",
",",
"Sort",
".",
"Order",
".",
"DESCEND",
")",
";",
"}",
"}",
"return",
"key",
";",
"}"
] |
Returns an object that can be used to sort this table in the order specified for by the given column names
|
[
"Returns",
"an",
"object",
"that",
"can",
"be",
"used",
"to",
"sort",
"this",
"table",
"in",
"the",
"order",
"specified",
"for",
"by",
"the",
"given",
"column",
"names"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L178-L188
|
18,021
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.addColumns
|
@Override
public Table addColumns(final Column<?>... cols) {
for (final Column<?> c : cols) {
validateColumn(c);
columnList.add(c);
}
return this;
}
|
java
|
@Override
public Table addColumns(final Column<?>... cols) {
for (final Column<?> c : cols) {
validateColumn(c);
columnList.add(c);
}
return this;
}
|
[
"@",
"Override",
"public",
"Table",
"addColumns",
"(",
"final",
"Column",
"<",
"?",
">",
"...",
"cols",
")",
"{",
"for",
"(",
"final",
"Column",
"<",
"?",
">",
"c",
":",
"cols",
")",
"{",
"validateColumn",
"(",
"c",
")",
";",
"columnList",
".",
"add",
"(",
"c",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Adds the given column to this table
|
[
"Adds",
"the",
"given",
"column",
"to",
"this",
"table"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L201-L208
|
18,022
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.validateColumn
|
private void validateColumn(final Column<?> newColumn) {
Preconditions.checkNotNull(newColumn, "Attempted to add a null to the columns in table " + name);
List<String> stringList = new ArrayList<>();
for (String name : columnNames()) {
stringList.add(name.toLowerCase());
}
if (stringList.contains(newColumn.name().toLowerCase())) {
String message = String.format("Cannot add column with duplicate name %s to table %s", newColumn, name);
throw new IllegalArgumentException(message);
}
checkColumnSize(newColumn);
}
|
java
|
private void validateColumn(final Column<?> newColumn) {
Preconditions.checkNotNull(newColumn, "Attempted to add a null to the columns in table " + name);
List<String> stringList = new ArrayList<>();
for (String name : columnNames()) {
stringList.add(name.toLowerCase());
}
if (stringList.contains(newColumn.name().toLowerCase())) {
String message = String.format("Cannot add column with duplicate name %s to table %s", newColumn, name);
throw new IllegalArgumentException(message);
}
checkColumnSize(newColumn);
}
|
[
"private",
"void",
"validateColumn",
"(",
"final",
"Column",
"<",
"?",
">",
"newColumn",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"newColumn",
",",
"\"Attempted to add a null to the columns in table \"",
"+",
"name",
")",
";",
"List",
"<",
"String",
">",
"stringList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"name",
":",
"columnNames",
"(",
")",
")",
"{",
"stringList",
".",
"add",
"(",
"name",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"if",
"(",
"stringList",
".",
"contains",
"(",
"newColumn",
".",
"name",
"(",
")",
".",
"toLowerCase",
"(",
")",
")",
")",
"{",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Cannot add column with duplicate name %s to table %s\"",
",",
"newColumn",
",",
"name",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
")",
";",
"}",
"checkColumnSize",
"(",
"newColumn",
")",
";",
"}"
] |
Throws an IllegalArgumentException if a column with the given name is already in the table, or if the number of
rows in the column does not match the number of rows in the table
|
[
"Throws",
"an",
"IllegalArgumentException",
"if",
"a",
"column",
"with",
"the",
"given",
"name",
"is",
"already",
"in",
"the",
"table",
"or",
"if",
"the",
"number",
"of",
"rows",
"in",
"the",
"column",
"does",
"not",
"match",
"the",
"number",
"of",
"rows",
"in",
"the",
"table"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L214-L226
|
18,023
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.insertColumn
|
public Table insertColumn(int index, Column<?> column) {
validateColumn(column);
columnList.add(index, column);
return this;
}
|
java
|
public Table insertColumn(int index, Column<?> column) {
validateColumn(column);
columnList.add(index, column);
return this;
}
|
[
"public",
"Table",
"insertColumn",
"(",
"int",
"index",
",",
"Column",
"<",
"?",
">",
"column",
")",
"{",
"validateColumn",
"(",
"column",
")",
";",
"columnList",
".",
"add",
"(",
"index",
",",
"column",
")",
";",
"return",
"this",
";",
"}"
] |
Adds the given column to this table at the given position in the column list
@param index Zero-based index into the column list
@param column Column to be added
|
[
"Adds",
"the",
"given",
"column",
"to",
"this",
"table",
"at",
"the",
"given",
"position",
"in",
"the",
"column",
"list"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L245-L249
|
18,024
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.rowCount
|
@Override
public int rowCount() {
int result = 0;
if (!columnList.isEmpty()) {
// all the columns have the same number of elements, so we can check any of them
result = columnList.get(0).size();
}
return result;
}
|
java
|
@Override
public int rowCount() {
int result = 0;
if (!columnList.isEmpty()) {
// all the columns have the same number of elements, so we can check any of them
result = columnList.get(0).size();
}
return result;
}
|
[
"@",
"Override",
"public",
"int",
"rowCount",
"(",
")",
"{",
"int",
"result",
"=",
"0",
";",
"if",
"(",
"!",
"columnList",
".",
"isEmpty",
"(",
")",
")",
"{",
"// all the columns have the same number of elements, so we can check any of them",
"result",
"=",
"columnList",
".",
"get",
"(",
"0",
")",
".",
"size",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Returns the number of rows in the table
|
[
"Returns",
"the",
"number",
"of",
"rows",
"in",
"the",
"table"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L303-L311
|
18,025
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.categoricalColumns
|
public List<CategoricalColumn<?>> categoricalColumns(String... columnNames) {
List<CategoricalColumn<?>> columns = new ArrayList<>();
for (String columnName : columnNames) {
columns.add(categoricalColumn(columnName));
}
return columns;
}
|
java
|
public List<CategoricalColumn<?>> categoricalColumns(String... columnNames) {
List<CategoricalColumn<?>> columns = new ArrayList<>();
for (String columnName : columnNames) {
columns.add(categoricalColumn(columnName));
}
return columns;
}
|
[
"public",
"List",
"<",
"CategoricalColumn",
"<",
"?",
">",
">",
"categoricalColumns",
"(",
"String",
"...",
"columnNames",
")",
"{",
"List",
"<",
"CategoricalColumn",
"<",
"?",
">",
">",
"columns",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"columnName",
":",
"columnNames",
")",
"{",
"columns",
".",
"add",
"(",
"categoricalColumn",
"(",
"columnName",
")",
")",
";",
"}",
"return",
"columns",
";",
"}"
] |
Returns only the columns whose names are given in the input array
|
[
"Returns",
"only",
"the",
"columns",
"whose",
"names",
"are",
"given",
"in",
"the",
"input",
"array"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L328-L334
|
18,026
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.columnIndex
|
public int columnIndex(String columnName) {
int columnIndex = -1;
for (int i = 0; i < columnList.size(); i++) {
if (columnList.get(i).name().equalsIgnoreCase(columnName)) {
columnIndex = i;
break;
}
}
if (columnIndex == -1) {
throw new IllegalArgumentException(String.format("Column %s is not present in table %s", columnName, name));
}
return columnIndex;
}
|
java
|
public int columnIndex(String columnName) {
int columnIndex = -1;
for (int i = 0; i < columnList.size(); i++) {
if (columnList.get(i).name().equalsIgnoreCase(columnName)) {
columnIndex = i;
break;
}
}
if (columnIndex == -1) {
throw new IllegalArgumentException(String.format("Column %s is not present in table %s", columnName, name));
}
return columnIndex;
}
|
[
"public",
"int",
"columnIndex",
"(",
"String",
"columnName",
")",
"{",
"int",
"columnIndex",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"columnList",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"columnList",
".",
"get",
"(",
"i",
")",
".",
"name",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"columnName",
")",
")",
"{",
"columnIndex",
"=",
"i",
";",
"break",
";",
"}",
"}",
"if",
"(",
"columnIndex",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Column %s is not present in table %s\"",
",",
"columnName",
",",
"name",
")",
")",
";",
"}",
"return",
"columnIndex",
";",
"}"
] |
Returns the index of the column with the given name
@throws IllegalArgumentException if the input string is not the name of any column in the table
|
[
"Returns",
"the",
"index",
"of",
"the",
"column",
"with",
"the",
"given",
"name"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L341-L353
|
18,027
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.columnNames
|
public List<String> columnNames() {
return columnList.stream().map(Column::name).collect(toList());
}
|
java
|
public List<String> columnNames() {
return columnList.stream().map(Column::name).collect(toList());
}
|
[
"public",
"List",
"<",
"String",
">",
"columnNames",
"(",
")",
"{",
"return",
"columnList",
".",
"stream",
"(",
")",
".",
"map",
"(",
"Column",
"::",
"name",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
";",
"}"
] |
Returns a List of the names of all the columns in this table
|
[
"Returns",
"a",
"List",
"of",
"the",
"names",
"of",
"all",
"the",
"columns",
"in",
"this",
"table"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L387-L389
|
18,028
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.copy
|
public Table copy() {
Table copy = new Table(name);
for (Column<?> column : columnList) {
copy.addColumns(column.emptyCopy(rowCount()));
}
int[] rows = new int[rowCount()];
for (int i = 0; i < rowCount(); i++) {
rows[i] = i;
}
Rows.copyRowsToTable(rows, this, copy);
return copy;
}
|
java
|
public Table copy() {
Table copy = new Table(name);
for (Column<?> column : columnList) {
copy.addColumns(column.emptyCopy(rowCount()));
}
int[] rows = new int[rowCount()];
for (int i = 0; i < rowCount(); i++) {
rows[i] = i;
}
Rows.copyRowsToTable(rows, this, copy);
return copy;
}
|
[
"public",
"Table",
"copy",
"(",
")",
"{",
"Table",
"copy",
"=",
"new",
"Table",
"(",
"name",
")",
";",
"for",
"(",
"Column",
"<",
"?",
">",
"column",
":",
"columnList",
")",
"{",
"copy",
".",
"addColumns",
"(",
"column",
".",
"emptyCopy",
"(",
"rowCount",
"(",
")",
")",
")",
";",
"}",
"int",
"[",
"]",
"rows",
"=",
"new",
"int",
"[",
"rowCount",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rowCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"rows",
"[",
"i",
"]",
"=",
"i",
";",
"}",
"Rows",
".",
"copyRowsToTable",
"(",
"rows",
",",
"this",
",",
"copy",
")",
";",
"return",
"copy",
";",
"}"
] |
Returns a table with the same columns as this table
|
[
"Returns",
"a",
"table",
"with",
"the",
"same",
"columns",
"as",
"this",
"table"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L394-L406
|
18,029
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.emptyCopy
|
public Table emptyCopy() {
Table copy = new Table(name);
for (Column<?> column : columnList) {
copy.addColumns(column.emptyCopy());
}
return copy;
}
|
java
|
public Table emptyCopy() {
Table copy = new Table(name);
for (Column<?> column : columnList) {
copy.addColumns(column.emptyCopy());
}
return copy;
}
|
[
"public",
"Table",
"emptyCopy",
"(",
")",
"{",
"Table",
"copy",
"=",
"new",
"Table",
"(",
"name",
")",
";",
"for",
"(",
"Column",
"<",
"?",
">",
"column",
":",
"columnList",
")",
"{",
"copy",
".",
"addColumns",
"(",
"column",
".",
"emptyCopy",
"(",
")",
")",
";",
"}",
"return",
"copy",
";",
"}"
] |
Returns a table with the same columns as this table, but no data
|
[
"Returns",
"a",
"table",
"with",
"the",
"same",
"columns",
"as",
"this",
"table",
"but",
"no",
"data"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L411-L417
|
18,030
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.sampleSplit
|
public Table[] sampleSplit(double table1Proportion) {
Table[] tables = new Table[2];
int table1Count = (int) Math.round(rowCount() * table1Proportion);
Selection table2Selection = new BitmapBackedSelection();
for (int i = 0; i < rowCount(); i++) {
table2Selection.add(i);
}
Selection table1Selection = new BitmapBackedSelection();
Selection table1Records = selectNRowsAtRandom(table1Count, rowCount());
for (int table1Record : table1Records) {
table1Selection.add(table1Record);
}
table2Selection.andNot(table1Selection);
tables[0] = where(table1Selection);
tables[1] = where(table2Selection);
return tables;
}
|
java
|
public Table[] sampleSplit(double table1Proportion) {
Table[] tables = new Table[2];
int table1Count = (int) Math.round(rowCount() * table1Proportion);
Selection table2Selection = new BitmapBackedSelection();
for (int i = 0; i < rowCount(); i++) {
table2Selection.add(i);
}
Selection table1Selection = new BitmapBackedSelection();
Selection table1Records = selectNRowsAtRandom(table1Count, rowCount());
for (int table1Record : table1Records) {
table1Selection.add(table1Record);
}
table2Selection.andNot(table1Selection);
tables[0] = where(table1Selection);
tables[1] = where(table2Selection);
return tables;
}
|
[
"public",
"Table",
"[",
"]",
"sampleSplit",
"(",
"double",
"table1Proportion",
")",
"{",
"Table",
"[",
"]",
"tables",
"=",
"new",
"Table",
"[",
"2",
"]",
";",
"int",
"table1Count",
"=",
"(",
"int",
")",
"Math",
".",
"round",
"(",
"rowCount",
"(",
")",
"*",
"table1Proportion",
")",
";",
"Selection",
"table2Selection",
"=",
"new",
"BitmapBackedSelection",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rowCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"table2Selection",
".",
"add",
"(",
"i",
")",
";",
"}",
"Selection",
"table1Selection",
"=",
"new",
"BitmapBackedSelection",
"(",
")",
";",
"Selection",
"table1Records",
"=",
"selectNRowsAtRandom",
"(",
"table1Count",
",",
"rowCount",
"(",
")",
")",
";",
"for",
"(",
"int",
"table1Record",
":",
"table1Records",
")",
"{",
"table1Selection",
".",
"add",
"(",
"table1Record",
")",
";",
"}",
"table2Selection",
".",
"andNot",
"(",
"table1Selection",
")",
";",
"tables",
"[",
"0",
"]",
"=",
"where",
"(",
"table1Selection",
")",
";",
"tables",
"[",
"1",
"]",
"=",
"where",
"(",
"table2Selection",
")",
";",
"return",
"tables",
";",
"}"
] |
Splits the table into two, randomly assigning records to each according to the proportion given in
trainingProportion
@param table1Proportion The proportion to go in the first table
@return An array two tables, with the first table having the proportion specified in the method parameter,
and the second table having the balance of the rows
|
[
"Splits",
"the",
"table",
"into",
"two",
"randomly",
"assigning",
"records",
"to",
"each",
"according",
"to",
"the",
"proportion",
"given",
"in",
"trainingProportion"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L438-L456
|
18,031
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.sampleX
|
public Table sampleX(double proportion) {
Preconditions.checkArgument(proportion <= 1 && proportion >= 0,
"The sample proportion must be between 0 and 1");
int tableSize = (int) Math.round(rowCount() * proportion);
return where(selectNRowsAtRandom(tableSize, rowCount()));
}
|
java
|
public Table sampleX(double proportion) {
Preconditions.checkArgument(proportion <= 1 && proportion >= 0,
"The sample proportion must be between 0 and 1");
int tableSize = (int) Math.round(rowCount() * proportion);
return where(selectNRowsAtRandom(tableSize, rowCount()));
}
|
[
"public",
"Table",
"sampleX",
"(",
"double",
"proportion",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"proportion",
"<=",
"1",
"&&",
"proportion",
">=",
"0",
",",
"\"The sample proportion must be between 0 and 1\"",
")",
";",
"int",
"tableSize",
"=",
"(",
"int",
")",
"Math",
".",
"round",
"(",
"rowCount",
"(",
")",
"*",
"proportion",
")",
";",
"return",
"where",
"(",
"selectNRowsAtRandom",
"(",
"tableSize",
",",
"rowCount",
"(",
")",
")",
")",
";",
"}"
] |
Returns a table consisting of randomly selected records from this table. The sample size is based on the
given proportion
@param proportion The proportion to go in the sample
|
[
"Returns",
"a",
"table",
"consisting",
"of",
"randomly",
"selected",
"records",
"from",
"this",
"table",
".",
"The",
"sample",
"size",
"is",
"based",
"on",
"the",
"given",
"proportion"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L464-L470
|
18,032
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.sampleN
|
public Table sampleN(int nRows) {
Preconditions.checkArgument(nRows > 0 && nRows < rowCount(),
"The number of rows sampled must be greater than 0 and less than the number of rows in the table.");
return where(selectNRowsAtRandom(nRows, rowCount()));
}
|
java
|
public Table sampleN(int nRows) {
Preconditions.checkArgument(nRows > 0 && nRows < rowCount(),
"The number of rows sampled must be greater than 0 and less than the number of rows in the table.");
return where(selectNRowsAtRandom(nRows, rowCount()));
}
|
[
"public",
"Table",
"sampleN",
"(",
"int",
"nRows",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"nRows",
">",
"0",
"&&",
"nRows",
"<",
"rowCount",
"(",
")",
",",
"\"The number of rows sampled must be greater than 0 and less than the number of rows in the table.\"",
")",
";",
"return",
"where",
"(",
"selectNRowsAtRandom",
"(",
"nRows",
",",
"rowCount",
"(",
")",
")",
")",
";",
"}"
] |
Returns a table consisting of randomly selected records from this table
@param nRows The number of rows to go in the sample
|
[
"Returns",
"a",
"table",
"consisting",
"of",
"randomly",
"selected",
"records",
"from",
"this",
"table"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L477-L481
|
18,033
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.rows
|
private int[] rows() {
int[] rowIndexes = new int[rowCount()];
for (int i = 0; i < rowCount(); i++) {
rowIndexes[i] = i;
}
return rowIndexes;
}
|
java
|
private int[] rows() {
int[] rowIndexes = new int[rowCount()];
for (int i = 0; i < rowCount(); i++) {
rowIndexes[i] = i;
}
return rowIndexes;
}
|
[
"private",
"int",
"[",
"]",
"rows",
"(",
")",
"{",
"int",
"[",
"]",
"rowIndexes",
"=",
"new",
"int",
"[",
"rowCount",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rowCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"rowIndexes",
"[",
"i",
"]",
"=",
"i",
";",
"}",
"return",
"rowIndexes",
";",
"}"
] |
Returns an array of ints of the same number of rows as the table
|
[
"Returns",
"an",
"array",
"of",
"ints",
"of",
"the",
"same",
"number",
"of",
"rows",
"as",
"the",
"table"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L628-L634
|
18,034
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.addRow
|
public void addRow(int rowIndex, Table sourceTable) {
for (int i = 0; i < columnCount(); i++) {
column(i).appendObj(sourceTable.column(i).get(rowIndex));
}
}
|
java
|
public void addRow(int rowIndex, Table sourceTable) {
for (int i = 0; i < columnCount(); i++) {
column(i).appendObj(sourceTable.column(i).get(rowIndex));
}
}
|
[
"public",
"void",
"addRow",
"(",
"int",
"rowIndex",
",",
"Table",
"sourceTable",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"columnCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"column",
"(",
"i",
")",
".",
"appendObj",
"(",
"sourceTable",
".",
"column",
"(",
"i",
")",
".",
"get",
"(",
"rowIndex",
")",
")",
";",
"}",
"}"
] |
Adds a single row to this table from sourceTable, copying every column in sourceTable
@param rowIndex The row in sourceTable to add to this table
@param sourceTable A table with the same column structure as this table
|
[
"Adds",
"a",
"single",
"row",
"to",
"this",
"table",
"from",
"sourceTable",
"copying",
"every",
"column",
"in",
"sourceTable"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L642-L646
|
18,035
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.splitOn
|
public TableSliceGroup splitOn(String... columns) {
return splitOn(categoricalColumns(columns).toArray(new CategoricalColumn<?>[columns.length]));
}
|
java
|
public TableSliceGroup splitOn(String... columns) {
return splitOn(categoricalColumns(columns).toArray(new CategoricalColumn<?>[columns.length]));
}
|
[
"public",
"TableSliceGroup",
"splitOn",
"(",
"String",
"...",
"columns",
")",
"{",
"return",
"splitOn",
"(",
"categoricalColumns",
"(",
"columns",
")",
".",
"toArray",
"(",
"new",
"CategoricalColumn",
"<",
"?",
">",
"[",
"columns",
".",
"length",
"]",
")",
")",
";",
"}"
] |
Returns a non-overlapping and exhaustive collection of "slices" over this table.
Each slice is like a virtual table containing a subset of the records in this table
This method is intended for advanced or unusual operations on the subtables.
If you want to calculate summary statistics for each subtable, the summarize methods (e.g)
table.summarize(myColumn, mean, median).by(columns)
are preferred
|
[
"Returns",
"a",
"non",
"-",
"overlapping",
"and",
"exhaustive",
"collection",
"of",
"slices",
"over",
"this",
"table",
".",
"Each",
"slice",
"is",
"like",
"a",
"virtual",
"table",
"containing",
"a",
"subset",
"of",
"the",
"records",
"in",
"this",
"table"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L734-L736
|
18,036
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.dropRowsWithMissingValues
|
public Table dropRowsWithMissingValues() {
Selection missing = new BitmapBackedSelection();
for (int row = 0; row < rowCount(); row++) {
for (int col = 0; col < columnCount(); col++) {
Column<?> c = column(col);
if (c.isMissing(row)) {
missing.add(row);
break;
}
}
}
Selection notMissing = Selection.withRange(0, rowCount());
notMissing.andNot(missing);
Table temp = emptyCopy(notMissing.size());
Rows.copyRowsToTable(notMissing, this, temp);
return temp;
}
|
java
|
public Table dropRowsWithMissingValues() {
Selection missing = new BitmapBackedSelection();
for (int row = 0; row < rowCount(); row++) {
for (int col = 0; col < columnCount(); col++) {
Column<?> c = column(col);
if (c.isMissing(row)) {
missing.add(row);
break;
}
}
}
Selection notMissing = Selection.withRange(0, rowCount());
notMissing.andNot(missing);
Table temp = emptyCopy(notMissing.size());
Rows.copyRowsToTable(notMissing, this, temp);
return temp;
}
|
[
"public",
"Table",
"dropRowsWithMissingValues",
"(",
")",
"{",
"Selection",
"missing",
"=",
"new",
"BitmapBackedSelection",
"(",
")",
";",
"for",
"(",
"int",
"row",
"=",
"0",
";",
"row",
"<",
"rowCount",
"(",
")",
";",
"row",
"++",
")",
"{",
"for",
"(",
"int",
"col",
"=",
"0",
";",
"col",
"<",
"columnCount",
"(",
")",
";",
"col",
"++",
")",
"{",
"Column",
"<",
"?",
">",
"c",
"=",
"column",
"(",
"col",
")",
";",
"if",
"(",
"c",
".",
"isMissing",
"(",
"row",
")",
")",
"{",
"missing",
".",
"add",
"(",
"row",
")",
";",
"break",
";",
"}",
"}",
"}",
"Selection",
"notMissing",
"=",
"Selection",
".",
"withRange",
"(",
"0",
",",
"rowCount",
"(",
")",
")",
";",
"notMissing",
".",
"andNot",
"(",
"missing",
")",
";",
"Table",
"temp",
"=",
"emptyCopy",
"(",
"notMissing",
".",
"size",
"(",
")",
")",
";",
"Rows",
".",
"copyRowsToTable",
"(",
"notMissing",
",",
"this",
",",
"temp",
")",
";",
"return",
"temp",
";",
"}"
] |
Returns only those records in this table that have no columns with missing values
|
[
"Returns",
"only",
"those",
"records",
"in",
"this",
"table",
"that",
"have",
"no",
"columns",
"with",
"missing",
"values"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L790-L808
|
18,037
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.removeColumns
|
@Override
public Table removeColumns(Column<?>... columns) {
columnList.removeAll(Arrays.asList(columns));
return this;
}
|
java
|
@Override
public Table removeColumns(Column<?>... columns) {
columnList.removeAll(Arrays.asList(columns));
return this;
}
|
[
"@",
"Override",
"public",
"Table",
"removeColumns",
"(",
"Column",
"<",
"?",
">",
"...",
"columns",
")",
"{",
"columnList",
".",
"removeAll",
"(",
"Arrays",
".",
"asList",
"(",
"columns",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Removes the given columns
|
[
"Removes",
"the",
"given",
"columns"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L821-L825
|
18,038
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.removeColumnsWithMissingValues
|
public Table removeColumnsWithMissingValues() {
removeColumns(columnList.stream().filter(x -> x.countMissing() > 0).toArray(Column<?>[]::new));
return this;
}
|
java
|
public Table removeColumnsWithMissingValues() {
removeColumns(columnList.stream().filter(x -> x.countMissing() > 0).toArray(Column<?>[]::new));
return this;
}
|
[
"public",
"Table",
"removeColumnsWithMissingValues",
"(",
")",
"{",
"removeColumns",
"(",
"columnList",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"x",
"->",
"x",
".",
"countMissing",
"(",
")",
">",
"0",
")",
".",
"toArray",
"(",
"Column",
"<",
"?",
">",
"[",
"]",
"::",
"new",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Removes the given columns with missing values
|
[
"Removes",
"the",
"given",
"columns",
"with",
"missing",
"values"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L830-L833
|
18,039
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.xTabCounts
|
public Table xTabCounts(String column1Name, String column2Name) {
return CrossTab.counts(this, categoricalColumn(column1Name), categoricalColumn(column2Name));
}
|
java
|
public Table xTabCounts(String column1Name, String column2Name) {
return CrossTab.counts(this, categoricalColumn(column1Name), categoricalColumn(column2Name));
}
|
[
"public",
"Table",
"xTabCounts",
"(",
"String",
"column1Name",
",",
"String",
"column2Name",
")",
"{",
"return",
"CrossTab",
".",
"counts",
"(",
"this",
",",
"categoricalColumn",
"(",
"column1Name",
")",
",",
"categoricalColumn",
"(",
"column2Name",
")",
")",
";",
"}"
] |
Returns a table with n by m + 1 cells. The first column contains labels, the other cells contains the counts for every unique
combination of values from the two specified columns in this table
|
[
"Returns",
"a",
"table",
"with",
"n",
"by",
"m",
"+",
"1",
"cells",
".",
"The",
"first",
"column",
"contains",
"labels",
"the",
"other",
"cells",
"contains",
"the",
"counts",
"for",
"every",
"unique",
"combination",
"of",
"values",
"from",
"the",
"two",
"specified",
"columns",
"in",
"this",
"table"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L923-L925
|
18,040
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.xTabTablePercents
|
public Table xTabTablePercents(String column1Name, String column2Name) {
return CrossTab.tablePercents(this, column1Name, column2Name);
}
|
java
|
public Table xTabTablePercents(String column1Name, String column2Name) {
return CrossTab.tablePercents(this, column1Name, column2Name);
}
|
[
"public",
"Table",
"xTabTablePercents",
"(",
"String",
"column1Name",
",",
"String",
"column2Name",
")",
"{",
"return",
"CrossTab",
".",
"tablePercents",
"(",
"this",
",",
"column1Name",
",",
"column2Name",
")",
";",
"}"
] |
Returns a table with n by m + 1 cells. The first column contains labels, the other cells contains the proportion
for a unique combination of values from the two specified columns in this table
|
[
"Returns",
"a",
"table",
"with",
"n",
"by",
"m",
"+",
"1",
"cells",
".",
"The",
"first",
"column",
"contains",
"labels",
"the",
"other",
"cells",
"contains",
"the",
"proportion",
"for",
"a",
"unique",
"combination",
"of",
"values",
"from",
"the",
"two",
"specified",
"columns",
"in",
"this",
"table"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L939-L941
|
18,041
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/api/Table.java
|
Table.detect
|
public boolean detect(Predicate<Row> predicate) {
Row row = new Row(this);
while (row.hasNext()) {
if (predicate.test(row.next())) {
return true;
}
}
return false;
}
|
java
|
public boolean detect(Predicate<Row> predicate) {
Row row = new Row(this);
while (row.hasNext()) {
if (predicate.test(row.next())) {
return true;
}
}
return false;
}
|
[
"public",
"boolean",
"detect",
"(",
"Predicate",
"<",
"Row",
">",
"predicate",
")",
"{",
"Row",
"row",
"=",
"new",
"Row",
"(",
"this",
")",
";",
"while",
"(",
"row",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"predicate",
".",
"test",
"(",
"row",
".",
"next",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Applies the predicate to each row, and return true if any row returns true
|
[
"Applies",
"the",
"predicate",
"to",
"each",
"row",
"and",
"return",
"true",
"if",
"any",
"row",
"returns",
"true"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L1012-L1020
|
18,042
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/io/fixed/FixedWidthReader.java
|
FixedWidthReader.getReaderAndColumnTypes
|
private Pair<Reader, ColumnType[]> getReaderAndColumnTypes(FixedWidthReadOptions options) throws IOException {
ColumnType[] types = options.columnTypes();
byte[] bytesCache = null;
if (types == null) {
Reader reader = options.source().createReader(bytesCache);
if (options.source().file() == null) {
bytesCache = CharStreams.toString(reader).getBytes();
// create a new reader since we just exhausted the existing one
reader = options.source().createReader(bytesCache);
}
types = detectColumnTypes(reader, options);
}
return Pair.create(options.source().createReader(bytesCache), types);
}
|
java
|
private Pair<Reader, ColumnType[]> getReaderAndColumnTypes(FixedWidthReadOptions options) throws IOException {
ColumnType[] types = options.columnTypes();
byte[] bytesCache = null;
if (types == null) {
Reader reader = options.source().createReader(bytesCache);
if (options.source().file() == null) {
bytesCache = CharStreams.toString(reader).getBytes();
// create a new reader since we just exhausted the existing one
reader = options.source().createReader(bytesCache);
}
types = detectColumnTypes(reader, options);
}
return Pair.create(options.source().createReader(bytesCache), types);
}
|
[
"private",
"Pair",
"<",
"Reader",
",",
"ColumnType",
"[",
"]",
">",
"getReaderAndColumnTypes",
"(",
"FixedWidthReadOptions",
"options",
")",
"throws",
"IOException",
"{",
"ColumnType",
"[",
"]",
"types",
"=",
"options",
".",
"columnTypes",
"(",
")",
";",
"byte",
"[",
"]",
"bytesCache",
"=",
"null",
";",
"if",
"(",
"types",
"==",
"null",
")",
"{",
"Reader",
"reader",
"=",
"options",
".",
"source",
"(",
")",
".",
"createReader",
"(",
"bytesCache",
")",
";",
"if",
"(",
"options",
".",
"source",
"(",
")",
".",
"file",
"(",
")",
"==",
"null",
")",
"{",
"bytesCache",
"=",
"CharStreams",
".",
"toString",
"(",
"reader",
")",
".",
"getBytes",
"(",
")",
";",
"// create a new reader since we just exhausted the existing one",
"reader",
"=",
"options",
".",
"source",
"(",
")",
".",
"createReader",
"(",
"bytesCache",
")",
";",
"}",
"types",
"=",
"detectColumnTypes",
"(",
"reader",
",",
"options",
")",
";",
"}",
"return",
"Pair",
".",
"create",
"(",
"options",
".",
"source",
"(",
")",
".",
"createReader",
"(",
"bytesCache",
")",
",",
"types",
")",
";",
"}"
] |
Determines column types if not provided by the user
Reads all input into memory unless File was provided
|
[
"Determines",
"column",
"types",
"if",
"not",
"provided",
"by",
"the",
"user",
"Reads",
"all",
"input",
"into",
"memory",
"unless",
"File",
"was",
"provided"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/io/fixed/FixedWidthReader.java#L68-L83
|
18,043
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/io/jdbc/SqlResultSetReader.java
|
SqlResultSetReader.read
|
public static Table read(ResultSet resultSet) throws SQLException {
ResultSetMetaData metaData = resultSet.getMetaData();
Table table = Table.create();
// Setup the columns and add to the table
for (int i = 1; i <= metaData.getColumnCount(); i++) {
String name = metaData.getColumnName(i);
int columnType = metaData.getColumnType(i);
ColumnType type = SQL_TYPE_TO_TABLESAW_TYPE.get(columnType);
// Try to improve on the initial type assigned to 'type' to minimize size/space of type needed.
// For all generic numeric columns inspect closer, checking the precision and
// scale to more accurately determine the appropriate java type to use.
if (columnType == Types.NUMERIC || columnType == Types.DECIMAL) {
int s = metaData.getScale(i);
// When scale is 0 then column is a type of integer
if (s == 0) {
int p = metaData.getPrecision(i);
/* Mapping to java integer types based on integer precision defined:
Java type TypeMinVal TypeMaxVal p MaxIntVal
-----------------------------------------------------------------------------------------
byte, Byte: -128 127 NUMBER(2) 99
short, Short: -32768 32767 NUMBER(4) 9_999
int, Integer: -2147483648 2147483647 NUMBER(9) 999_999_999
long, Long: -9223372036854775808 9223372036854775807 NUMBER(18) 999_999_999_999_999_999
*/
// Start with SHORT (since ColumnType.BYTE isn't supported yet)
// and find the smallest java integer type that fits
if (p <= 4) {
type = ShortColumnType.instance();
} else if (p <= 9) {
type = ColumnType.INTEGER;
} else if (p <= 18) {
type = ColumnType.LONG;
}
} else { // s is not zero, so a decimal value is expected. First try float, then double
if (s <= 7) {
type = ColumnType.FLOAT;
} else if (s <= 16) {
type = ColumnType.DOUBLE;
}
}
}
Preconditions.checkState(type != null,
"No column type found for %s as specified for column %s", metaData.getColumnType(i), name);
Column<?> newColumn = type.create(name);
table.addColumns(newColumn);
}
// Add the rows
while (resultSet.next()) {
for (int i = 1; i <= metaData.getColumnCount(); i++) {
Column<?> column = table.column(i - 1); // subtract 1 because results sets originate at 1 not 0
if (column instanceof ShortColumn) {
column.appendObj(resultSet.getShort(i));
} else if (column instanceof IntColumn) {
column.appendObj(resultSet.getInt(i));
} else if (column instanceof LongColumn) {
column.appendObj(resultSet.getLong(i));
} else if (column instanceof FloatColumn) {
column.appendObj(resultSet.getFloat(i));
} else if (column instanceof DoubleColumn) {
column.appendObj(resultSet.getDouble(i));
} else {
column.appendObj(resultSet.getObject(i));
}
}
}
return table;
}
|
java
|
public static Table read(ResultSet resultSet) throws SQLException {
ResultSetMetaData metaData = resultSet.getMetaData();
Table table = Table.create();
// Setup the columns and add to the table
for (int i = 1; i <= metaData.getColumnCount(); i++) {
String name = metaData.getColumnName(i);
int columnType = metaData.getColumnType(i);
ColumnType type = SQL_TYPE_TO_TABLESAW_TYPE.get(columnType);
// Try to improve on the initial type assigned to 'type' to minimize size/space of type needed.
// For all generic numeric columns inspect closer, checking the precision and
// scale to more accurately determine the appropriate java type to use.
if (columnType == Types.NUMERIC || columnType == Types.DECIMAL) {
int s = metaData.getScale(i);
// When scale is 0 then column is a type of integer
if (s == 0) {
int p = metaData.getPrecision(i);
/* Mapping to java integer types based on integer precision defined:
Java type TypeMinVal TypeMaxVal p MaxIntVal
-----------------------------------------------------------------------------------------
byte, Byte: -128 127 NUMBER(2) 99
short, Short: -32768 32767 NUMBER(4) 9_999
int, Integer: -2147483648 2147483647 NUMBER(9) 999_999_999
long, Long: -9223372036854775808 9223372036854775807 NUMBER(18) 999_999_999_999_999_999
*/
// Start with SHORT (since ColumnType.BYTE isn't supported yet)
// and find the smallest java integer type that fits
if (p <= 4) {
type = ShortColumnType.instance();
} else if (p <= 9) {
type = ColumnType.INTEGER;
} else if (p <= 18) {
type = ColumnType.LONG;
}
} else { // s is not zero, so a decimal value is expected. First try float, then double
if (s <= 7) {
type = ColumnType.FLOAT;
} else if (s <= 16) {
type = ColumnType.DOUBLE;
}
}
}
Preconditions.checkState(type != null,
"No column type found for %s as specified for column %s", metaData.getColumnType(i), name);
Column<?> newColumn = type.create(name);
table.addColumns(newColumn);
}
// Add the rows
while (resultSet.next()) {
for (int i = 1; i <= metaData.getColumnCount(); i++) {
Column<?> column = table.column(i - 1); // subtract 1 because results sets originate at 1 not 0
if (column instanceof ShortColumn) {
column.appendObj(resultSet.getShort(i));
} else if (column instanceof IntColumn) {
column.appendObj(resultSet.getInt(i));
} else if (column instanceof LongColumn) {
column.appendObj(resultSet.getLong(i));
} else if (column instanceof FloatColumn) {
column.appendObj(resultSet.getFloat(i));
} else if (column instanceof DoubleColumn) {
column.appendObj(resultSet.getDouble(i));
} else {
column.appendObj(resultSet.getObject(i));
}
}
}
return table;
}
|
[
"public",
"static",
"Table",
"read",
"(",
"ResultSet",
"resultSet",
")",
"throws",
"SQLException",
"{",
"ResultSetMetaData",
"metaData",
"=",
"resultSet",
".",
"getMetaData",
"(",
")",
";",
"Table",
"table",
"=",
"Table",
".",
"create",
"(",
")",
";",
"// Setup the columns and add to the table",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"metaData",
".",
"getColumnCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"String",
"name",
"=",
"metaData",
".",
"getColumnName",
"(",
"i",
")",
";",
"int",
"columnType",
"=",
"metaData",
".",
"getColumnType",
"(",
"i",
")",
";",
"ColumnType",
"type",
"=",
"SQL_TYPE_TO_TABLESAW_TYPE",
".",
"get",
"(",
"columnType",
")",
";",
"// Try to improve on the initial type assigned to 'type' to minimize size/space of type needed.",
"// For all generic numeric columns inspect closer, checking the precision and ",
"// scale to more accurately determine the appropriate java type to use.",
"if",
"(",
"columnType",
"==",
"Types",
".",
"NUMERIC",
"||",
"columnType",
"==",
"Types",
".",
"DECIMAL",
")",
"{",
"int",
"s",
"=",
"metaData",
".",
"getScale",
"(",
"i",
")",
";",
"// When scale is 0 then column is a type of integer",
"if",
"(",
"s",
"==",
"0",
")",
"{",
"int",
"p",
"=",
"metaData",
".",
"getPrecision",
"(",
"i",
")",
";",
"/* Mapping to java integer types based on integer precision defined:\n\nJava type TypeMinVal TypeMaxVal p MaxIntVal\n-----------------------------------------------------------------------------------------\nbyte, Byte: -128 127 NUMBER(2) 99\nshort, Short: -32768 32767 NUMBER(4) 9_999\nint, Integer: -2147483648 2147483647 NUMBER(9) 999_999_999 \nlong, Long: -9223372036854775808 9223372036854775807 NUMBER(18) 999_999_999_999_999_999\n\n*/",
"// Start with SHORT (since ColumnType.BYTE isn't supported yet)",
"// and find the smallest java integer type that fits",
"if",
"(",
"p",
"<=",
"4",
")",
"{",
"type",
"=",
"ShortColumnType",
".",
"instance",
"(",
")",
";",
"}",
"else",
"if",
"(",
"p",
"<=",
"9",
")",
"{",
"type",
"=",
"ColumnType",
".",
"INTEGER",
";",
"}",
"else",
"if",
"(",
"p",
"<=",
"18",
")",
"{",
"type",
"=",
"ColumnType",
".",
"LONG",
";",
"}",
"}",
"else",
"{",
"// s is not zero, so a decimal value is expected. First try float, then double",
"if",
"(",
"s",
"<=",
"7",
")",
"{",
"type",
"=",
"ColumnType",
".",
"FLOAT",
";",
"}",
"else",
"if",
"(",
"s",
"<=",
"16",
")",
"{",
"type",
"=",
"ColumnType",
".",
"DOUBLE",
";",
"}",
"}",
"}",
"Preconditions",
".",
"checkState",
"(",
"type",
"!=",
"null",
",",
"\"No column type found for %s as specified for column %s\"",
",",
"metaData",
".",
"getColumnType",
"(",
"i",
")",
",",
"name",
")",
";",
"Column",
"<",
"?",
">",
"newColumn",
"=",
"type",
".",
"create",
"(",
"name",
")",
";",
"table",
".",
"addColumns",
"(",
"newColumn",
")",
";",
"}",
"// Add the rows",
"while",
"(",
"resultSet",
".",
"next",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"metaData",
".",
"getColumnCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"Column",
"<",
"?",
">",
"column",
"=",
"table",
".",
"column",
"(",
"i",
"-",
"1",
")",
";",
"// subtract 1 because results sets originate at 1 not 0",
"if",
"(",
"column",
"instanceof",
"ShortColumn",
")",
"{",
"column",
".",
"appendObj",
"(",
"resultSet",
".",
"getShort",
"(",
"i",
")",
")",
";",
"}",
"else",
"if",
"(",
"column",
"instanceof",
"IntColumn",
")",
"{",
"column",
".",
"appendObj",
"(",
"resultSet",
".",
"getInt",
"(",
"i",
")",
")",
";",
"}",
"else",
"if",
"(",
"column",
"instanceof",
"LongColumn",
")",
"{",
"column",
".",
"appendObj",
"(",
"resultSet",
".",
"getLong",
"(",
"i",
")",
")",
";",
"}",
"else",
"if",
"(",
"column",
"instanceof",
"FloatColumn",
")",
"{",
"column",
".",
"appendObj",
"(",
"resultSet",
".",
"getFloat",
"(",
"i",
")",
")",
";",
"}",
"else",
"if",
"(",
"column",
"instanceof",
"DoubleColumn",
")",
"{",
"column",
".",
"appendObj",
"(",
"resultSet",
".",
"getDouble",
"(",
"i",
")",
")",
";",
"}",
"else",
"{",
"column",
".",
"appendObj",
"(",
"resultSet",
".",
"getObject",
"(",
"i",
")",
")",
";",
"}",
"}",
"}",
"return",
"table",
";",
"}"
] |
Returns a new table with the given tableName, constructed from the given result set
@throws SQLException if there is a problem detected in the database
|
[
"Returns",
"a",
"new",
"table",
"with",
"the",
"given",
"tableName",
"constructed",
"from",
"the",
"given",
"result",
"set"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/io/jdbc/SqlResultSetReader.java#L90-L162
|
18,044
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/sorting/SortUtils.java
|
SortUtils.getChain
|
public static IntComparatorChain getChain(Table table, Sort key) {
Iterator<Map.Entry<String, Sort.Order>> entries = key.iterator();
Map.Entry<String, Sort.Order> sort = entries.next();
Column<?> column = table.column(sort.getKey());
IntComparator comparator = rowComparator(column, sort.getValue());
IntComparatorChain chain = new IntComparatorChain(comparator);
while (entries.hasNext()) {
sort = entries.next();
chain.addComparator(rowComparator(table.column(sort.getKey()), sort.getValue()));
}
return chain;
}
|
java
|
public static IntComparatorChain getChain(Table table, Sort key) {
Iterator<Map.Entry<String, Sort.Order>> entries = key.iterator();
Map.Entry<String, Sort.Order> sort = entries.next();
Column<?> column = table.column(sort.getKey());
IntComparator comparator = rowComparator(column, sort.getValue());
IntComparatorChain chain = new IntComparatorChain(comparator);
while (entries.hasNext()) {
sort = entries.next();
chain.addComparator(rowComparator(table.column(sort.getKey()), sort.getValue()));
}
return chain;
}
|
[
"public",
"static",
"IntComparatorChain",
"getChain",
"(",
"Table",
"table",
",",
"Sort",
"key",
")",
"{",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"Sort",
".",
"Order",
">",
">",
"entries",
"=",
"key",
".",
"iterator",
"(",
")",
";",
"Map",
".",
"Entry",
"<",
"String",
",",
"Sort",
".",
"Order",
">",
"sort",
"=",
"entries",
".",
"next",
"(",
")",
";",
"Column",
"<",
"?",
">",
"column",
"=",
"table",
".",
"column",
"(",
"sort",
".",
"getKey",
"(",
")",
")",
";",
"IntComparator",
"comparator",
"=",
"rowComparator",
"(",
"column",
",",
"sort",
".",
"getValue",
"(",
")",
")",
";",
"IntComparatorChain",
"chain",
"=",
"new",
"IntComparatorChain",
"(",
"comparator",
")",
";",
"while",
"(",
"entries",
".",
"hasNext",
"(",
")",
")",
"{",
"sort",
"=",
"entries",
".",
"next",
"(",
")",
";",
"chain",
".",
"addComparator",
"(",
"rowComparator",
"(",
"table",
".",
"column",
"(",
"sort",
".",
"getKey",
"(",
")",
")",
",",
"sort",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"return",
"chain",
";",
"}"
] |
Returns a comparator chain for sorting according to the given key
|
[
"Returns",
"a",
"comparator",
"chain",
"for",
"sorting",
"according",
"to",
"the",
"given",
"key"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/sorting/SortUtils.java#L17-L29
|
18,045
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/sorting/SortUtils.java
|
SortUtils.rowComparator
|
public static IntComparator rowComparator(Column<?> column, Sort.Order order) {
IntComparator rowComparator = column.rowComparator();
if (order == Sort.Order.DESCEND) {
return ReversingIntComparator.reverse(rowComparator);
} else {
return rowComparator;
}
}
|
java
|
public static IntComparator rowComparator(Column<?> column, Sort.Order order) {
IntComparator rowComparator = column.rowComparator();
if (order == Sort.Order.DESCEND) {
return ReversingIntComparator.reverse(rowComparator);
} else {
return rowComparator;
}
}
|
[
"public",
"static",
"IntComparator",
"rowComparator",
"(",
"Column",
"<",
"?",
">",
"column",
",",
"Sort",
".",
"Order",
"order",
")",
"{",
"IntComparator",
"rowComparator",
"=",
"column",
".",
"rowComparator",
"(",
")",
";",
"if",
"(",
"order",
"==",
"Sort",
".",
"Order",
".",
"DESCEND",
")",
"{",
"return",
"ReversingIntComparator",
".",
"reverse",
"(",
"rowComparator",
")",
";",
"}",
"else",
"{",
"return",
"rowComparator",
";",
"}",
"}"
] |
Returns a comparator for the column matching the specified name
@param column The column to sort
@param order Specifies whether the sort should be in ascending or descending order
|
[
"Returns",
"a",
"comparator",
"for",
"the",
"column",
"matching",
"the",
"specified",
"name"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/sorting/SortUtils.java#L37-L44
|
18,046
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/sorting/SortUtils.java
|
SortUtils.getComparator
|
public static IntComparator getComparator(Table table, Sort key) {
Iterator<Map.Entry<String, Sort.Order>> entries = key.iterator();
Map.Entry<String, Sort.Order> sort = entries.next();
Column<?> column = table.column(sort.getKey());
return SortUtils.rowComparator(column, sort.getValue());
}
|
java
|
public static IntComparator getComparator(Table table, Sort key) {
Iterator<Map.Entry<String, Sort.Order>> entries = key.iterator();
Map.Entry<String, Sort.Order> sort = entries.next();
Column<?> column = table.column(sort.getKey());
return SortUtils.rowComparator(column, sort.getValue());
}
|
[
"public",
"static",
"IntComparator",
"getComparator",
"(",
"Table",
"table",
",",
"Sort",
"key",
")",
"{",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"Sort",
".",
"Order",
">",
">",
"entries",
"=",
"key",
".",
"iterator",
"(",
")",
";",
"Map",
".",
"Entry",
"<",
"String",
",",
"Sort",
".",
"Order",
">",
"sort",
"=",
"entries",
".",
"next",
"(",
")",
";",
"Column",
"<",
"?",
">",
"column",
"=",
"table",
".",
"column",
"(",
"sort",
".",
"getKey",
"(",
")",
")",
";",
"return",
"SortUtils",
".",
"rowComparator",
"(",
"column",
",",
"sort",
".",
"getValue",
"(",
")",
")",
";",
"}"
] |
Returns a comparator that can be used to sort the records in this table according to the given sort key
|
[
"Returns",
"a",
"comparator",
"that",
"can",
"be",
"used",
"to",
"sort",
"the",
"records",
"in",
"this",
"table",
"according",
"to",
"the",
"given",
"sort",
"key"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/sorting/SortUtils.java#L49-L54
|
18,047
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/io/ColumnTypeDetector.java
|
ColumnTypeDetector.detectType
|
private ColumnType detectType(List<String> valuesList, ReadOptions options) {
CopyOnWriteArrayList<AbstractColumnParser<?>> parsers = new CopyOnWriteArrayList<>(getParserList(typeArray, options));
CopyOnWriteArrayList<ColumnType> typeCandidates = new CopyOnWriteArrayList<>(typeArray);
for (String s : valuesList) {
for (AbstractColumnParser<?> parser : parsers) {
if (!parser.canParse(s)) {
typeCandidates.remove(parser.columnType());
parsers.remove(parser);
}
}
}
return selectType(typeCandidates);
}
|
java
|
private ColumnType detectType(List<String> valuesList, ReadOptions options) {
CopyOnWriteArrayList<AbstractColumnParser<?>> parsers = new CopyOnWriteArrayList<>(getParserList(typeArray, options));
CopyOnWriteArrayList<ColumnType> typeCandidates = new CopyOnWriteArrayList<>(typeArray);
for (String s : valuesList) {
for (AbstractColumnParser<?> parser : parsers) {
if (!parser.canParse(s)) {
typeCandidates.remove(parser.columnType());
parsers.remove(parser);
}
}
}
return selectType(typeCandidates);
}
|
[
"private",
"ColumnType",
"detectType",
"(",
"List",
"<",
"String",
">",
"valuesList",
",",
"ReadOptions",
"options",
")",
"{",
"CopyOnWriteArrayList",
"<",
"AbstractColumnParser",
"<",
"?",
">",
">",
"parsers",
"=",
"new",
"CopyOnWriteArrayList",
"<>",
"(",
"getParserList",
"(",
"typeArray",
",",
"options",
")",
")",
";",
"CopyOnWriteArrayList",
"<",
"ColumnType",
">",
"typeCandidates",
"=",
"new",
"CopyOnWriteArrayList",
"<>",
"(",
"typeArray",
")",
";",
"for",
"(",
"String",
"s",
":",
"valuesList",
")",
"{",
"for",
"(",
"AbstractColumnParser",
"<",
"?",
">",
"parser",
":",
"parsers",
")",
"{",
"if",
"(",
"!",
"parser",
".",
"canParse",
"(",
"s",
")",
")",
"{",
"typeCandidates",
".",
"remove",
"(",
"parser",
".",
"columnType",
"(",
")",
")",
";",
"parsers",
".",
"remove",
"(",
"parser",
")",
";",
"}",
"}",
"}",
"return",
"selectType",
"(",
"typeCandidates",
")",
";",
"}"
] |
Returns a predicted ColumnType derived by analyzing the given list of undifferentiated strings read from a
column in the file and applying the given Locale and options
|
[
"Returns",
"a",
"predicted",
"ColumnType",
"derived",
"by",
"analyzing",
"the",
"given",
"list",
"of",
"undifferentiated",
"strings",
"read",
"from",
"a",
"column",
"in",
"the",
"file",
"and",
"applying",
"the",
"given",
"Locale",
"and",
"options"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/io/ColumnTypeDetector.java#L161-L176
|
18,048
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/io/ColumnTypeDetector.java
|
ColumnTypeDetector.getParserList
|
private List<AbstractColumnParser<?>> getParserList(List<ColumnType> typeArray, ReadOptions options) {
// Types to choose from. When more than one would work, we pick the first of the options
List<AbstractColumnParser<?>> parsers = new ArrayList<>();
for (ColumnType type : typeArray) {
parsers.add(type.customParser(options));
}
return parsers;
}
|
java
|
private List<AbstractColumnParser<?>> getParserList(List<ColumnType> typeArray, ReadOptions options) {
// Types to choose from. When more than one would work, we pick the first of the options
List<AbstractColumnParser<?>> parsers = new ArrayList<>();
for (ColumnType type : typeArray) {
parsers.add(type.customParser(options));
}
return parsers;
}
|
[
"private",
"List",
"<",
"AbstractColumnParser",
"<",
"?",
">",
">",
"getParserList",
"(",
"List",
"<",
"ColumnType",
">",
"typeArray",
",",
"ReadOptions",
"options",
")",
"{",
"// Types to choose from. When more than one would work, we pick the first of the options",
"List",
"<",
"AbstractColumnParser",
"<",
"?",
">",
">",
"parsers",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"ColumnType",
"type",
":",
"typeArray",
")",
"{",
"parsers",
".",
"add",
"(",
"type",
".",
"customParser",
"(",
"options",
")",
")",
";",
"}",
"return",
"parsers",
";",
"}"
] |
Returns the list of parsers to use for type detection
@param typeArray Array of column types. The order specifies the order the types are applied
@param options CsvReadOptions to use to modify the default parsers for each type
@return A list of parsers in the order they should be used for type detection
|
[
"Returns",
"the",
"list",
"of",
"parsers",
"to",
"use",
"for",
"type",
"detection"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/io/ColumnTypeDetector.java#L194-L202
|
18,049
|
jtablesaw/tablesaw
|
html/src/main/java/tech/tablesaw/io/html/HtmlReadOptions.java
|
HtmlReadOptions.builder
|
public static Builder builder(Reader reader, String tableName) {
Builder builder = new Builder(reader);
return builder.tableName(tableName);
}
|
java
|
public static Builder builder(Reader reader, String tableName) {
Builder builder = new Builder(reader);
return builder.tableName(tableName);
}
|
[
"public",
"static",
"Builder",
"builder",
"(",
"Reader",
"reader",
",",
"String",
"tableName",
")",
"{",
"Builder",
"builder",
"=",
"new",
"Builder",
"(",
"reader",
")",
";",
"return",
"builder",
".",
"tableName",
"(",
"tableName",
")",
";",
"}"
] |
This method may cause tablesaw to buffer the entire InputStream.
<p>
If you have a large amount of data, you can do one of the following:
1. Use the method taking a File instead of a reader, or
2. Provide the array of column types as an option. If you provide the columnType array,
we skip type detection and can avoid reading the entire file
|
[
"This",
"method",
"may",
"cause",
"tablesaw",
"to",
"buffer",
"the",
"entire",
"InputStream",
"."
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/html/src/main/java/tech/tablesaw/io/html/HtmlReadOptions.java#L70-L73
|
18,050
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java
|
DataFramePrinter.getWidths
|
private static int[] getWidths(String[] headers, String[][] data) {
final int[] widths = new int[headers.length];
for (int j = 0; j < headers.length; j++) {
final String header = headers[j];
widths[j] = Math.max(widths[j], header != null ? header.length() : 0);
}
for (String[] rowValues : data) {
for (int j = 0; j < rowValues.length; j++) {
final String value = rowValues[j];
widths[j] = Math.max(widths[j], value != null ? value.length() : 0);
}
}
return widths;
}
|
java
|
private static int[] getWidths(String[] headers, String[][] data) {
final int[] widths = new int[headers.length];
for (int j = 0; j < headers.length; j++) {
final String header = headers[j];
widths[j] = Math.max(widths[j], header != null ? header.length() : 0);
}
for (String[] rowValues : data) {
for (int j = 0; j < rowValues.length; j++) {
final String value = rowValues[j];
widths[j] = Math.max(widths[j], value != null ? value.length() : 0);
}
}
return widths;
}
|
[
"private",
"static",
"int",
"[",
"]",
"getWidths",
"(",
"String",
"[",
"]",
"headers",
",",
"String",
"[",
"]",
"[",
"]",
"data",
")",
"{",
"final",
"int",
"[",
"]",
"widths",
"=",
"new",
"int",
"[",
"headers",
".",
"length",
"]",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"headers",
".",
"length",
";",
"j",
"++",
")",
"{",
"final",
"String",
"header",
"=",
"headers",
"[",
"j",
"]",
";",
"widths",
"[",
"j",
"]",
"=",
"Math",
".",
"max",
"(",
"widths",
"[",
"j",
"]",
",",
"header",
"!=",
"null",
"?",
"header",
".",
"length",
"(",
")",
":",
"0",
")",
";",
"}",
"for",
"(",
"String",
"[",
"]",
"rowValues",
":",
"data",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"rowValues",
".",
"length",
";",
"j",
"++",
")",
"{",
"final",
"String",
"value",
"=",
"rowValues",
"[",
"j",
"]",
";",
"widths",
"[",
"j",
"]",
"=",
"Math",
".",
"max",
"(",
"widths",
"[",
"j",
"]",
",",
"value",
"!=",
"null",
"?",
"value",
".",
"length",
"(",
")",
":",
"0",
")",
";",
"}",
"}",
"return",
"widths",
";",
"}"
] |
Returns the column widths required to print the header and data
@param headers the headers to print
@param data the data items to print
@return the required column widths
|
[
"Returns",
"the",
"column",
"widths",
"required",
"to",
"print",
"the",
"header",
"and",
"data"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java#L53-L66
|
18,051
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java
|
DataFramePrinter.getHeaderTemplate
|
private static String getHeaderTemplate(int[] widths, String[] headers) {
return IntStream.range(0, widths.length).mapToObj(i -> {
final int width = widths[i];
final int length = headers[i].length();
final int leading = (width - length) / 2;
final int trailing = width - (length + leading);
final StringBuilder text = new StringBuilder();
whitespace(text, leading + 1);
text.append("%").append(i + 1).append("$s");
whitespace(text, trailing);
text.append(" |");
return text.toString();
}).reduce((left, right) -> left + " " + right).orElse("");
}
|
java
|
private static String getHeaderTemplate(int[] widths, String[] headers) {
return IntStream.range(0, widths.length).mapToObj(i -> {
final int width = widths[i];
final int length = headers[i].length();
final int leading = (width - length) / 2;
final int trailing = width - (length + leading);
final StringBuilder text = new StringBuilder();
whitespace(text, leading + 1);
text.append("%").append(i + 1).append("$s");
whitespace(text, trailing);
text.append(" |");
return text.toString();
}).reduce((left, right) -> left + " " + right).orElse("");
}
|
[
"private",
"static",
"String",
"getHeaderTemplate",
"(",
"int",
"[",
"]",
"widths",
",",
"String",
"[",
"]",
"headers",
")",
"{",
"return",
"IntStream",
".",
"range",
"(",
"0",
",",
"widths",
".",
"length",
")",
".",
"mapToObj",
"(",
"i",
"->",
"{",
"final",
"int",
"width",
"=",
"widths",
"[",
"i",
"]",
";",
"final",
"int",
"length",
"=",
"headers",
"[",
"i",
"]",
".",
"length",
"(",
")",
";",
"final",
"int",
"leading",
"=",
"(",
"width",
"-",
"length",
")",
"/",
"2",
";",
"final",
"int",
"trailing",
"=",
"width",
"-",
"(",
"length",
"+",
"leading",
")",
";",
"final",
"StringBuilder",
"text",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"whitespace",
"(",
"text",
",",
"leading",
"+",
"1",
")",
";",
"text",
".",
"append",
"(",
"\"%\"",
")",
".",
"append",
"(",
"i",
"+",
"1",
")",
".",
"append",
"(",
"\"$s\"",
")",
";",
"whitespace",
"(",
"text",
",",
"trailing",
")",
";",
"text",
".",
"append",
"(",
"\" |\"",
")",
";",
"return",
"text",
".",
"toString",
"(",
")",
";",
"}",
")",
".",
"reduce",
"(",
"(",
"left",
",",
"right",
")",
"->",
"left",
"+",
"\" \"",
"+",
"right",
")",
".",
"orElse",
"(",
"\"\"",
")",
";",
"}"
] |
Returns the header template given the widths specified
@param widths the token widths
@return the line format template
|
[
"Returns",
"the",
"header",
"template",
"given",
"the",
"widths",
"specified"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java#L74-L87
|
18,052
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java
|
DataFramePrinter.getDataTemplate
|
private static String getDataTemplate(int[] widths) {
return IntStream.range(0, widths.length)
.mapToObj(i -> " %" + (i + 1) + "$" + widths[i] + "s |")
.reduce((left, right) -> left + " " + right)
.orElse("");
}
|
java
|
private static String getDataTemplate(int[] widths) {
return IntStream.range(0, widths.length)
.mapToObj(i -> " %" + (i + 1) + "$" + widths[i] + "s |")
.reduce((left, right) -> left + " " + right)
.orElse("");
}
|
[
"private",
"static",
"String",
"getDataTemplate",
"(",
"int",
"[",
"]",
"widths",
")",
"{",
"return",
"IntStream",
".",
"range",
"(",
"0",
",",
"widths",
".",
"length",
")",
".",
"mapToObj",
"(",
"i",
"->",
"\" %\"",
"+",
"(",
"i",
"+",
"1",
")",
"+",
"\"$\"",
"+",
"widths",
"[",
"i",
"]",
"+",
"\"s |\"",
")",
".",
"reduce",
"(",
"(",
"left",
",",
"right",
")",
"->",
"left",
"+",
"\" \"",
"+",
"right",
")",
".",
"orElse",
"(",
"\"\"",
")",
";",
"}"
] |
Returns the data template given the widths specified
@param widths the token widths
@return the line format template
|
[
"Returns",
"the",
"data",
"template",
"given",
"the",
"widths",
"specified"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java#L95-L100
|
18,053
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java
|
DataFramePrinter.whitespace
|
private static void whitespace(StringBuilder text, int length) {
IntStream.range(0, length).forEach(i -> text.append(" "));
}
|
java
|
private static void whitespace(StringBuilder text, int length) {
IntStream.range(0, length).forEach(i -> text.append(" "));
}
|
[
"private",
"static",
"void",
"whitespace",
"(",
"StringBuilder",
"text",
",",
"int",
"length",
")",
"{",
"IntStream",
".",
"range",
"(",
"0",
",",
"length",
")",
".",
"forEach",
"(",
"i",
"->",
"text",
".",
"append",
"(",
"\" \"",
")",
")",
";",
"}"
] |
Returns a whitespace string of the length specified
@param length the length for whitespace
|
[
"Returns",
"a",
"whitespace",
"string",
"of",
"the",
"length",
"specified"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java#L107-L109
|
18,054
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java
|
DataFramePrinter.print
|
public void print(Relation frame) {
try {
final String[] headers = getHeaderTokens(frame);
final String[][] data = getDataTokens(frame);
final int[] widths = getWidths(headers, data);
final String dataTemplate = getDataTemplate(widths);
final String headerTemplate = getHeaderTemplate(widths, headers);
final int totalWidth = IntStream.of(widths).map(w -> w + 5).sum() - 1;
final int totalHeight = data.length + 1;
int capacity = totalWidth * totalHeight;
if (capacity < 0) {
capacity = 0;
}
final StringBuilder text = new StringBuilder(capacity);
if (frame.name() != null) {
text.append(tableName(frame, totalWidth)).append(System.lineSeparator());
}
final String headerLine = String.format(headerTemplate, (Object[]) headers);
text.append(headerLine).append(System.lineSeparator());
for (int j = 0; j < totalWidth; j++) {
text.append("-");
}
for (String[] row : data) {
final String dataLine = String.format(dataTemplate, (Object[]) row);
text.append(System.lineSeparator());
text.append(dataLine);
}
final byte[] bytes = text.toString().getBytes();
this.stream.write(bytes);
this.stream.flush();
} catch (IOException ex) {
throw new IllegalStateException("Failed to print DataFrame", ex);
}
}
|
java
|
public void print(Relation frame) {
try {
final String[] headers = getHeaderTokens(frame);
final String[][] data = getDataTokens(frame);
final int[] widths = getWidths(headers, data);
final String dataTemplate = getDataTemplate(widths);
final String headerTemplate = getHeaderTemplate(widths, headers);
final int totalWidth = IntStream.of(widths).map(w -> w + 5).sum() - 1;
final int totalHeight = data.length + 1;
int capacity = totalWidth * totalHeight;
if (capacity < 0) {
capacity = 0;
}
final StringBuilder text = new StringBuilder(capacity);
if (frame.name() != null) {
text.append(tableName(frame, totalWidth)).append(System.lineSeparator());
}
final String headerLine = String.format(headerTemplate, (Object[]) headers);
text.append(headerLine).append(System.lineSeparator());
for (int j = 0; j < totalWidth; j++) {
text.append("-");
}
for (String[] row : data) {
final String dataLine = String.format(dataTemplate, (Object[]) row);
text.append(System.lineSeparator());
text.append(dataLine);
}
final byte[] bytes = text.toString().getBytes();
this.stream.write(bytes);
this.stream.flush();
} catch (IOException ex) {
throw new IllegalStateException("Failed to print DataFrame", ex);
}
}
|
[
"public",
"void",
"print",
"(",
"Relation",
"frame",
")",
"{",
"try",
"{",
"final",
"String",
"[",
"]",
"headers",
"=",
"getHeaderTokens",
"(",
"frame",
")",
";",
"final",
"String",
"[",
"]",
"[",
"]",
"data",
"=",
"getDataTokens",
"(",
"frame",
")",
";",
"final",
"int",
"[",
"]",
"widths",
"=",
"getWidths",
"(",
"headers",
",",
"data",
")",
";",
"final",
"String",
"dataTemplate",
"=",
"getDataTemplate",
"(",
"widths",
")",
";",
"final",
"String",
"headerTemplate",
"=",
"getHeaderTemplate",
"(",
"widths",
",",
"headers",
")",
";",
"final",
"int",
"totalWidth",
"=",
"IntStream",
".",
"of",
"(",
"widths",
")",
".",
"map",
"(",
"w",
"->",
"w",
"+",
"5",
")",
".",
"sum",
"(",
")",
"-",
"1",
";",
"final",
"int",
"totalHeight",
"=",
"data",
".",
"length",
"+",
"1",
";",
"int",
"capacity",
"=",
"totalWidth",
"*",
"totalHeight",
";",
"if",
"(",
"capacity",
"<",
"0",
")",
"{",
"capacity",
"=",
"0",
";",
"}",
"final",
"StringBuilder",
"text",
"=",
"new",
"StringBuilder",
"(",
"capacity",
")",
";",
"if",
"(",
"frame",
".",
"name",
"(",
")",
"!=",
"null",
")",
"{",
"text",
".",
"append",
"(",
"tableName",
"(",
"frame",
",",
"totalWidth",
")",
")",
".",
"append",
"(",
"System",
".",
"lineSeparator",
"(",
")",
")",
";",
"}",
"final",
"String",
"headerLine",
"=",
"String",
".",
"format",
"(",
"headerTemplate",
",",
"(",
"Object",
"[",
"]",
")",
"headers",
")",
";",
"text",
".",
"append",
"(",
"headerLine",
")",
".",
"append",
"(",
"System",
".",
"lineSeparator",
"(",
")",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"totalWidth",
";",
"j",
"++",
")",
"{",
"text",
".",
"append",
"(",
"\"-\"",
")",
";",
"}",
"for",
"(",
"String",
"[",
"]",
"row",
":",
"data",
")",
"{",
"final",
"String",
"dataLine",
"=",
"String",
".",
"format",
"(",
"dataTemplate",
",",
"(",
"Object",
"[",
"]",
")",
"row",
")",
";",
"text",
".",
"append",
"(",
"System",
".",
"lineSeparator",
"(",
")",
")",
";",
"text",
".",
"append",
"(",
"dataLine",
")",
";",
"}",
"final",
"byte",
"[",
"]",
"bytes",
"=",
"text",
".",
"toString",
"(",
")",
".",
"getBytes",
"(",
")",
";",
"this",
".",
"stream",
".",
"write",
"(",
"bytes",
")",
";",
"this",
".",
"stream",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Failed to print DataFrame\"",
",",
"ex",
")",
";",
"}",
"}"
] |
Prints the specified DataFrame to the stream bound to this printer
@param frame the DataFrame to print
|
[
"Prints",
"the",
"specified",
"DataFrame",
"to",
"the",
"stream",
"bound",
"to",
"this",
"printer"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java#L116-L149
|
18,055
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java
|
DataFramePrinter.getHeaderTokens
|
private String[] getHeaderTokens(Relation frame) {
final int colCount = frame.columnCount();
final String[] header = new String[colCount];
IntStream.range(0, colCount).forEach(colIndex -> {
header[colIndex] = frame.column(colIndex).name();
});
return header;
}
|
java
|
private String[] getHeaderTokens(Relation frame) {
final int colCount = frame.columnCount();
final String[] header = new String[colCount];
IntStream.range(0, colCount).forEach(colIndex -> {
header[colIndex] = frame.column(colIndex).name();
});
return header;
}
|
[
"private",
"String",
"[",
"]",
"getHeaderTokens",
"(",
"Relation",
"frame",
")",
"{",
"final",
"int",
"colCount",
"=",
"frame",
".",
"columnCount",
"(",
")",
";",
"final",
"String",
"[",
"]",
"header",
"=",
"new",
"String",
"[",
"colCount",
"]",
";",
"IntStream",
".",
"range",
"(",
"0",
",",
"colCount",
")",
".",
"forEach",
"(",
"colIndex",
"->",
"{",
"header",
"[",
"colIndex",
"]",
"=",
"frame",
".",
"column",
"(",
"colIndex",
")",
".",
"name",
"(",
")",
";",
"}",
")",
";",
"return",
"header",
";",
"}"
] |
Returns the header string tokens for the frame
@param frame the frame to create header tokens
@return the header tokens
|
[
"Returns",
"the",
"header",
"string",
"tokens",
"for",
"the",
"frame"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java#L166-L173
|
18,056
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java
|
DataFramePrinter.getDataTokens
|
private String[][] getDataTokens(Relation frame) {
if (frame.rowCount() == 0) return new String[0][0];
final int rowCount = Math.min(maxRows, frame.rowCount());
final boolean truncated = frame.rowCount() > maxRows;
final int colCount = frame.columnCount();
final String[][] data;
if (truncated) {
data = new String[rowCount + 1][colCount];
int i;
for (i = 0; i < Math.ceil((double) rowCount / 2); i++) {
for (int j = 0; j < colCount; j++) {
data[i][j] = frame.getString(i, j);
}
}
for (int j = 0; j < colCount; j++) {
data[i][j] = "...";
}
for (++i; i <= rowCount; i++) {
for (int j = 0; j < colCount; j++) {
data[i][j] = frame.getString(frame.rowCount() - maxRows + i - 1, j);
}
}
} else {
data = new String[rowCount][colCount];
for (int i = 0; i < rowCount; i++) {
for (int j = 0; j < colCount; j++) {
String value = frame.getString(i, j);
data[i][j] = value == null ? "" : value;
}
}
}
return data;
}
|
java
|
private String[][] getDataTokens(Relation frame) {
if (frame.rowCount() == 0) return new String[0][0];
final int rowCount = Math.min(maxRows, frame.rowCount());
final boolean truncated = frame.rowCount() > maxRows;
final int colCount = frame.columnCount();
final String[][] data;
if (truncated) {
data = new String[rowCount + 1][colCount];
int i;
for (i = 0; i < Math.ceil((double) rowCount / 2); i++) {
for (int j = 0; j < colCount; j++) {
data[i][j] = frame.getString(i, j);
}
}
for (int j = 0; j < colCount; j++) {
data[i][j] = "...";
}
for (++i; i <= rowCount; i++) {
for (int j = 0; j < colCount; j++) {
data[i][j] = frame.getString(frame.rowCount() - maxRows + i - 1, j);
}
}
} else {
data = new String[rowCount][colCount];
for (int i = 0; i < rowCount; i++) {
for (int j = 0; j < colCount; j++) {
String value = frame.getString(i, j);
data[i][j] = value == null ? "" : value;
}
}
}
return data;
}
|
[
"private",
"String",
"[",
"]",
"[",
"]",
"getDataTokens",
"(",
"Relation",
"frame",
")",
"{",
"if",
"(",
"frame",
".",
"rowCount",
"(",
")",
"==",
"0",
")",
"return",
"new",
"String",
"[",
"0",
"]",
"[",
"0",
"]",
";",
"final",
"int",
"rowCount",
"=",
"Math",
".",
"min",
"(",
"maxRows",
",",
"frame",
".",
"rowCount",
"(",
")",
")",
";",
"final",
"boolean",
"truncated",
"=",
"frame",
".",
"rowCount",
"(",
")",
">",
"maxRows",
";",
"final",
"int",
"colCount",
"=",
"frame",
".",
"columnCount",
"(",
")",
";",
"final",
"String",
"[",
"]",
"[",
"]",
"data",
";",
"if",
"(",
"truncated",
")",
"{",
"data",
"=",
"new",
"String",
"[",
"rowCount",
"+",
"1",
"]",
"[",
"colCount",
"]",
";",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"Math",
".",
"ceil",
"(",
"(",
"double",
")",
"rowCount",
"/",
"2",
")",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"colCount",
";",
"j",
"++",
")",
"{",
"data",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"frame",
".",
"getString",
"(",
"i",
",",
"j",
")",
";",
"}",
"}",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"colCount",
";",
"j",
"++",
")",
"{",
"data",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"\"...\"",
";",
"}",
"for",
"(",
"++",
"i",
";",
"i",
"<=",
"rowCount",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"colCount",
";",
"j",
"++",
")",
"{",
"data",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"frame",
".",
"getString",
"(",
"frame",
".",
"rowCount",
"(",
")",
"-",
"maxRows",
"+",
"i",
"-",
"1",
",",
"j",
")",
";",
"}",
"}",
"}",
"else",
"{",
"data",
"=",
"new",
"String",
"[",
"rowCount",
"]",
"[",
"colCount",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rowCount",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"colCount",
";",
"j",
"++",
")",
"{",
"String",
"value",
"=",
"frame",
".",
"getString",
"(",
"i",
",",
"j",
")",
";",
"data",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"value",
"==",
"null",
"?",
"\"\"",
":",
"value",
";",
"}",
"}",
"}",
"return",
"data",
";",
"}"
] |
Returns the 2-D array of data tokens from the frame specified
@param frame the DataFrame from which to create 2D array of formatted tokens
@return the array of data tokens
|
[
"Returns",
"the",
"2",
"-",
"D",
"array",
"of",
"data",
"tokens",
"from",
"the",
"frame",
"specified"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/io/string/DataFramePrinter.java#L181-L213
|
18,057
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/joining/DataFrameJoiner.java
|
DataFrameJoiner.fullOuter
|
public Table fullOuter(boolean allowDuplicateColumnNames, Table... tables) {
Table joined = table;
for (Table currT : tables) {
joined = fullOuter(joined, currT, allowDuplicateColumnNames, columnNames);
}
return joined;
}
|
java
|
public Table fullOuter(boolean allowDuplicateColumnNames, Table... tables) {
Table joined = table;
for (Table currT : tables) {
joined = fullOuter(joined, currT, allowDuplicateColumnNames, columnNames);
}
return joined;
}
|
[
"public",
"Table",
"fullOuter",
"(",
"boolean",
"allowDuplicateColumnNames",
",",
"Table",
"...",
"tables",
")",
"{",
"Table",
"joined",
"=",
"table",
";",
"for",
"(",
"Table",
"currT",
":",
"tables",
")",
"{",
"joined",
"=",
"fullOuter",
"(",
"joined",
",",
"currT",
",",
"allowDuplicateColumnNames",
",",
"columnNames",
")",
";",
"}",
"return",
"joined",
";",
"}"
] |
Full outer join to the given tables assuming that they have a column of the name we're joining on
@param allowDuplicateColumnNames if {@code false} the join will fail if any columns other than the join column have the same name
if {@code true} the join will succeed and duplicate columns are renamed*
@param tables The tables to join with
@return The resulting table
|
[
"Full",
"outer",
"join",
"to",
"the",
"given",
"tables",
"assuming",
"that",
"they",
"have",
"a",
"column",
"of",
"the",
"name",
"we",
"re",
"joining",
"on"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/joining/DataFrameJoiner.java#L352-L359
|
18,058
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/joining/DataFrameJoiner.java
|
DataFrameJoiner.fullOuter
|
public Table fullOuter(Table table2, String col2Name) {
return fullOuter(table, table2, false, col2Name);
}
|
java
|
public Table fullOuter(Table table2, String col2Name) {
return fullOuter(table, table2, false, col2Name);
}
|
[
"public",
"Table",
"fullOuter",
"(",
"Table",
"table2",
",",
"String",
"col2Name",
")",
"{",
"return",
"fullOuter",
"(",
"table",
",",
"table2",
",",
"false",
",",
"col2Name",
")",
";",
"}"
] |
Full outer join the joiner to the table2, using the given column for the second table and returns the resulting table
@param table2 The table to join with
@param col2Name The column to join on. If col2Name refers to a double column, the join is performed after
rounding to integers.
@return The resulting table
|
[
"Full",
"outer",
"join",
"the",
"joiner",
"to",
"the",
"table2",
"using",
"the",
"given",
"column",
"for",
"the",
"second",
"table",
"and",
"returns",
"the",
"resulting",
"table"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/joining/DataFrameJoiner.java#L369-L371
|
18,059
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/joining/DataFrameJoiner.java
|
DataFrameJoiner.withMissingLeftJoin
|
@SuppressWarnings({"rawtypes", "unchecked"})
private void withMissingLeftJoin(Table destination, Table table1) {
for (int c = 0; c < destination.columnCount(); c++) {
if (c < table1.columnCount()) {
Column t1Col = table1.column(c);
destination.column(c).append(t1Col);
} else {
for (int r1 = 0; r1 < table1.rowCount(); r1++) {
destination.column(c).appendMissing();
}
}
}
}
|
java
|
@SuppressWarnings({"rawtypes", "unchecked"})
private void withMissingLeftJoin(Table destination, Table table1) {
for (int c = 0; c < destination.columnCount(); c++) {
if (c < table1.columnCount()) {
Column t1Col = table1.column(c);
destination.column(c).append(t1Col);
} else {
for (int r1 = 0; r1 < table1.rowCount(); r1++) {
destination.column(c).appendMissing();
}
}
}
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"rawtypes\"",
",",
"\"unchecked\"",
"}",
")",
"private",
"void",
"withMissingLeftJoin",
"(",
"Table",
"destination",
",",
"Table",
"table1",
")",
"{",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"destination",
".",
"columnCount",
"(",
")",
";",
"c",
"++",
")",
"{",
"if",
"(",
"c",
"<",
"table1",
".",
"columnCount",
"(",
")",
")",
"{",
"Column",
"t1Col",
"=",
"table1",
".",
"column",
"(",
"c",
")",
";",
"destination",
".",
"column",
"(",
"c",
")",
".",
"append",
"(",
"t1Col",
")",
";",
"}",
"else",
"{",
"for",
"(",
"int",
"r1",
"=",
"0",
";",
"r1",
"<",
"table1",
".",
"rowCount",
"(",
")",
";",
"r1",
"++",
")",
"{",
"destination",
".",
"column",
"(",
"c",
")",
".",
"appendMissing",
"(",
")",
";",
"}",
"}",
"}",
"}"
] |
Adds rows to destination for each row in table1, with the columns from table2 added as missing values in each
|
[
"Adds",
"rows",
"to",
"destination",
"for",
"each",
"row",
"in",
"table1",
"with",
"the",
"columns",
"from",
"table2",
"added",
"as",
"missing",
"values",
"in",
"each"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/joining/DataFrameJoiner.java#L656-L668
|
18,060
|
jtablesaw/tablesaw
|
core/src/main/java/tech/tablesaw/joining/DataFrameJoiner.java
|
DataFrameJoiner.withMissingRightJoin
|
@SuppressWarnings({"rawtypes", "unchecked"})
private void withMissingRightJoin(Table destination, List<Column<?>> joinColumns, Table table2) {
int t2StartCol = destination.columnCount() - table2.columnCount();
for (int c = 0; c < destination.columnCount(); c++) {
boolean addedJoinColumns = false;
for (Column joinColumn : joinColumns) {
if (destination.column(c).name().equalsIgnoreCase(joinColumn.name())) {
destination.column(c).append(joinColumn);
addedJoinColumns = true;
}
}
if (!addedJoinColumns) {
if (c < t2StartCol) {
for (int r2 = 0; r2 < table2.rowCount(); r2++) {
destination.column(c).appendMissing();
}
} else {
Column t2Col = table2.column(c - t2StartCol);
destination.column(c).append(t2Col);
}
}
}
}
|
java
|
@SuppressWarnings({"rawtypes", "unchecked"})
private void withMissingRightJoin(Table destination, List<Column<?>> joinColumns, Table table2) {
int t2StartCol = destination.columnCount() - table2.columnCount();
for (int c = 0; c < destination.columnCount(); c++) {
boolean addedJoinColumns = false;
for (Column joinColumn : joinColumns) {
if (destination.column(c).name().equalsIgnoreCase(joinColumn.name())) {
destination.column(c).append(joinColumn);
addedJoinColumns = true;
}
}
if (!addedJoinColumns) {
if (c < t2StartCol) {
for (int r2 = 0; r2 < table2.rowCount(); r2++) {
destination.column(c).appendMissing();
}
} else {
Column t2Col = table2.column(c - t2StartCol);
destination.column(c).append(t2Col);
}
}
}
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"rawtypes\"",
",",
"\"unchecked\"",
"}",
")",
"private",
"void",
"withMissingRightJoin",
"(",
"Table",
"destination",
",",
"List",
"<",
"Column",
"<",
"?",
">",
">",
"joinColumns",
",",
"Table",
"table2",
")",
"{",
"int",
"t2StartCol",
"=",
"destination",
".",
"columnCount",
"(",
")",
"-",
"table2",
".",
"columnCount",
"(",
")",
";",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"destination",
".",
"columnCount",
"(",
")",
";",
"c",
"++",
")",
"{",
"boolean",
"addedJoinColumns",
"=",
"false",
";",
"for",
"(",
"Column",
"joinColumn",
":",
"joinColumns",
")",
"{",
"if",
"(",
"destination",
".",
"column",
"(",
"c",
")",
".",
"name",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"joinColumn",
".",
"name",
"(",
")",
")",
")",
"{",
"destination",
".",
"column",
"(",
"c",
")",
".",
"append",
"(",
"joinColumn",
")",
";",
"addedJoinColumns",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"addedJoinColumns",
")",
"{",
"if",
"(",
"c",
"<",
"t2StartCol",
")",
"{",
"for",
"(",
"int",
"r2",
"=",
"0",
";",
"r2",
"<",
"table2",
".",
"rowCount",
"(",
")",
";",
"r2",
"++",
")",
"{",
"destination",
".",
"column",
"(",
"c",
")",
".",
"appendMissing",
"(",
")",
";",
"}",
"}",
"else",
"{",
"Column",
"t2Col",
"=",
"table2",
".",
"column",
"(",
"c",
"-",
"t2StartCol",
")",
";",
"destination",
".",
"column",
"(",
"c",
")",
".",
"append",
"(",
"t2Col",
")",
";",
"}",
"}",
"}",
"}"
] |
Adds rows to destination for each row in the joinColumn and table2
|
[
"Adds",
"rows",
"to",
"destination",
"for",
"each",
"row",
"in",
"the",
"joinColumn",
"and",
"table2"
] |
68a75b4098ac677e9486df5572cf13ec39f9f701
|
https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/joining/DataFrameJoiner.java#L673-L695
|
18,061
|
querydsl/querydsl
|
querydsl-sql/src/main/java/com/querydsl/sql/teradata/TeradataQuery.java
|
TeradataQuery.qualify
|
public TeradataQuery<T> qualify(Predicate predicate) {
predicate = ExpressionUtils.predicate(SQLOps.QUALIFY, predicate);
return queryMixin.addFlag(new QueryFlag(QueryFlag.Position.BEFORE_ORDER, predicate));
}
|
java
|
public TeradataQuery<T> qualify(Predicate predicate) {
predicate = ExpressionUtils.predicate(SQLOps.QUALIFY, predicate);
return queryMixin.addFlag(new QueryFlag(QueryFlag.Position.BEFORE_ORDER, predicate));
}
|
[
"public",
"TeradataQuery",
"<",
"T",
">",
"qualify",
"(",
"Predicate",
"predicate",
")",
"{",
"predicate",
"=",
"ExpressionUtils",
".",
"predicate",
"(",
"SQLOps",
".",
"QUALIFY",
",",
"predicate",
")",
";",
"return",
"queryMixin",
".",
"addFlag",
"(",
"new",
"QueryFlag",
"(",
"QueryFlag",
".",
"Position",
".",
"BEFORE_ORDER",
",",
"predicate",
")",
")",
";",
"}"
] |
Adds a qualify expression
@param predicate qualify expression
@return the current object
|
[
"Adds",
"a",
"qualify",
"expression"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-sql/src/main/java/com/querydsl/sql/teradata/TeradataQuery.java#L73-L76
|
18,062
|
querydsl/querydsl
|
querydsl-jpa/src/main/java/com/querydsl/jpa/JPAMapAccessVisitor.java
|
JPAMapAccessVisitor.shorten
|
private Path<?> shorten(Path<?> path, boolean outer) {
if (aliases.containsKey(path)) {
return aliases.get(path);
} else if (path.getMetadata().isRoot()) {
return path;
} else if (path.getMetadata().getParent().getMetadata().isRoot() && outer) {
return path;
} else {
Class<?> type = JPAQueryMixin.getElementTypeOrType(path);
Path<?> parent = shorten(path.getMetadata().getParent(), false);
Path oldPath = ExpressionUtils.path(path.getType(),
new PathMetadata(parent, path.getMetadata().getElement(), path.getMetadata().getPathType()));
if (oldPath.getMetadata().getParent().getMetadata().isRoot() && outer) {
return oldPath;
} else {
Path newPath = ExpressionUtils.path(type, ExpressionUtils.createRootVariable(oldPath));
aliases.put(path, newPath);
metadata.addJoin(JoinType.LEFTJOIN, ExpressionUtils.as(oldPath, newPath));
return newPath;
}
}
}
|
java
|
private Path<?> shorten(Path<?> path, boolean outer) {
if (aliases.containsKey(path)) {
return aliases.get(path);
} else if (path.getMetadata().isRoot()) {
return path;
} else if (path.getMetadata().getParent().getMetadata().isRoot() && outer) {
return path;
} else {
Class<?> type = JPAQueryMixin.getElementTypeOrType(path);
Path<?> parent = shorten(path.getMetadata().getParent(), false);
Path oldPath = ExpressionUtils.path(path.getType(),
new PathMetadata(parent, path.getMetadata().getElement(), path.getMetadata().getPathType()));
if (oldPath.getMetadata().getParent().getMetadata().isRoot() && outer) {
return oldPath;
} else {
Path newPath = ExpressionUtils.path(type, ExpressionUtils.createRootVariable(oldPath));
aliases.put(path, newPath);
metadata.addJoin(JoinType.LEFTJOIN, ExpressionUtils.as(oldPath, newPath));
return newPath;
}
}
}
|
[
"private",
"Path",
"<",
"?",
">",
"shorten",
"(",
"Path",
"<",
"?",
">",
"path",
",",
"boolean",
"outer",
")",
"{",
"if",
"(",
"aliases",
".",
"containsKey",
"(",
"path",
")",
")",
"{",
"return",
"aliases",
".",
"get",
"(",
"path",
")",
";",
"}",
"else",
"if",
"(",
"path",
".",
"getMetadata",
"(",
")",
".",
"isRoot",
"(",
")",
")",
"{",
"return",
"path",
";",
"}",
"else",
"if",
"(",
"path",
".",
"getMetadata",
"(",
")",
".",
"getParent",
"(",
")",
".",
"getMetadata",
"(",
")",
".",
"isRoot",
"(",
")",
"&&",
"outer",
")",
"{",
"return",
"path",
";",
"}",
"else",
"{",
"Class",
"<",
"?",
">",
"type",
"=",
"JPAQueryMixin",
".",
"getElementTypeOrType",
"(",
"path",
")",
";",
"Path",
"<",
"?",
">",
"parent",
"=",
"shorten",
"(",
"path",
".",
"getMetadata",
"(",
")",
".",
"getParent",
"(",
")",
",",
"false",
")",
";",
"Path",
"oldPath",
"=",
"ExpressionUtils",
".",
"path",
"(",
"path",
".",
"getType",
"(",
")",
",",
"new",
"PathMetadata",
"(",
"parent",
",",
"path",
".",
"getMetadata",
"(",
")",
".",
"getElement",
"(",
")",
",",
"path",
".",
"getMetadata",
"(",
")",
".",
"getPathType",
"(",
")",
")",
")",
";",
"if",
"(",
"oldPath",
".",
"getMetadata",
"(",
")",
".",
"getParent",
"(",
")",
".",
"getMetadata",
"(",
")",
".",
"isRoot",
"(",
")",
"&&",
"outer",
")",
"{",
"return",
"oldPath",
";",
"}",
"else",
"{",
"Path",
"newPath",
"=",
"ExpressionUtils",
".",
"path",
"(",
"type",
",",
"ExpressionUtils",
".",
"createRootVariable",
"(",
"oldPath",
")",
")",
";",
"aliases",
".",
"put",
"(",
"path",
",",
"newPath",
")",
";",
"metadata",
".",
"addJoin",
"(",
"JoinType",
".",
"LEFTJOIN",
",",
"ExpressionUtils",
".",
"as",
"(",
"oldPath",
",",
"newPath",
")",
")",
";",
"return",
"newPath",
";",
"}",
"}",
"}"
] |
Shorten the parent path to a length of max 2 elements
|
[
"Shorten",
"the",
"parent",
"path",
"to",
"a",
"length",
"of",
"max",
"2",
"elements"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-jpa/src/main/java/com/querydsl/jpa/JPAMapAccessVisitor.java#L91-L112
|
18,063
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/util/ArrayUtils.java
|
ArrayUtils.subarray
|
public static Object[] subarray(Object[] array, int startIndexInclusive, int endIndexExclusive) {
int newSize = endIndexExclusive - startIndexInclusive;
Class<?> type = array.getClass().getComponentType();
if (newSize <= 0) {
return (Object[]) Array.newInstance(type, 0);
}
Object[] subarray = (Object[]) Array.newInstance(type, newSize);
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
}
|
java
|
public static Object[] subarray(Object[] array, int startIndexInclusive, int endIndexExclusive) {
int newSize = endIndexExclusive - startIndexInclusive;
Class<?> type = array.getClass().getComponentType();
if (newSize <= 0) {
return (Object[]) Array.newInstance(type, 0);
}
Object[] subarray = (Object[]) Array.newInstance(type, newSize);
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
}
|
[
"public",
"static",
"Object",
"[",
"]",
"subarray",
"(",
"Object",
"[",
"]",
"array",
",",
"int",
"startIndexInclusive",
",",
"int",
"endIndexExclusive",
")",
"{",
"int",
"newSize",
"=",
"endIndexExclusive",
"-",
"startIndexInclusive",
";",
"Class",
"<",
"?",
">",
"type",
"=",
"array",
".",
"getClass",
"(",
")",
".",
"getComponentType",
"(",
")",
";",
"if",
"(",
"newSize",
"<=",
"0",
")",
"{",
"return",
"(",
"Object",
"[",
"]",
")",
"Array",
".",
"newInstance",
"(",
"type",
",",
"0",
")",
";",
"}",
"Object",
"[",
"]",
"subarray",
"=",
"(",
"Object",
"[",
"]",
")",
"Array",
".",
"newInstance",
"(",
"type",
",",
"newSize",
")",
";",
"System",
".",
"arraycopy",
"(",
"array",
",",
"startIndexInclusive",
",",
"subarray",
",",
"0",
",",
"newSize",
")",
";",
"return",
"subarray",
";",
"}"
] |
originally licensed under ASL 2.0
|
[
"originally",
"licensed",
"under",
"ASL",
"2",
".",
"0"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/util/ArrayUtils.java#L47-L56
|
18,064
|
querydsl/querydsl
|
querydsl-jdo/src/main/java/com/querydsl/jdo/AbstractJDOQuery.java
|
AbstractJDOQuery.addFetchGroup
|
@Override
public Q addFetchGroup(String fetchGroupName) {
fetchGroups.add(fetchGroupName);
return queryMixin.getSelf();
}
|
java
|
@Override
public Q addFetchGroup(String fetchGroupName) {
fetchGroups.add(fetchGroupName);
return queryMixin.getSelf();
}
|
[
"@",
"Override",
"public",
"Q",
"addFetchGroup",
"(",
"String",
"fetchGroupName",
")",
"{",
"fetchGroups",
".",
"add",
"(",
"fetchGroupName",
")",
";",
"return",
"queryMixin",
".",
"getSelf",
"(",
")",
";",
"}"
] |
Add the fetch group to the set of active fetch groups.
@param fetchGroupName fetch group name
@return the current object
|
[
"Add",
"the",
"fetch",
"group",
"to",
"the",
"set",
"of",
"active",
"fetch",
"groups",
"."
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-jdo/src/main/java/com/querydsl/jdo/AbstractJDOQuery.java#L96-L100
|
18,065
|
querydsl/querydsl
|
querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneSerializer.java
|
LuceneSerializer.createBooleanClause
|
private BooleanClause createBooleanClause(Query query, Occur occur) {
if (query instanceof BooleanQuery) {
BooleanClause[] clauses = ((BooleanQuery) query).getClauses();
if (clauses.length == 1
&& clauses[0].getOccur().equals(Occur.MUST_NOT)) {
return clauses[0];
}
}
return new BooleanClause(query, occur);
}
|
java
|
private BooleanClause createBooleanClause(Query query, Occur occur) {
if (query instanceof BooleanQuery) {
BooleanClause[] clauses = ((BooleanQuery) query).getClauses();
if (clauses.length == 1
&& clauses[0].getOccur().equals(Occur.MUST_NOT)) {
return clauses[0];
}
}
return new BooleanClause(query, occur);
}
|
[
"private",
"BooleanClause",
"createBooleanClause",
"(",
"Query",
"query",
",",
"Occur",
"occur",
")",
"{",
"if",
"(",
"query",
"instanceof",
"BooleanQuery",
")",
"{",
"BooleanClause",
"[",
"]",
"clauses",
"=",
"(",
"(",
"BooleanQuery",
")",
"query",
")",
".",
"getClauses",
"(",
")",
";",
"if",
"(",
"clauses",
".",
"length",
"==",
"1",
"&&",
"clauses",
"[",
"0",
"]",
".",
"getOccur",
"(",
")",
".",
"equals",
"(",
"Occur",
".",
"MUST_NOT",
")",
")",
"{",
"return",
"clauses",
"[",
"0",
"]",
";",
"}",
"}",
"return",
"new",
"BooleanClause",
"(",
"query",
",",
"occur",
")",
";",
"}"
] |
If the query is a BooleanQuery and it contains a single Occur.MUST_NOT
clause it will be returned as is. Otherwise it will be wrapped in a
BooleanClause with the given Occur.
|
[
"If",
"the",
"query",
"is",
"a",
"BooleanQuery",
"and",
"it",
"contains",
"a",
"single",
"Occur",
".",
"MUST_NOT",
"clause",
"it",
"will",
"be",
"returned",
"as",
"is",
".",
"Otherwise",
"it",
"will",
"be",
"wrapped",
"in",
"a",
"BooleanClause",
"with",
"the",
"given",
"Occur",
"."
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneSerializer.java#L179-L188
|
18,066
|
querydsl/querydsl
|
querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneSerializer.java
|
LuceneSerializer.toField
|
protected String toField(Path<?> path) {
PathMetadata md = path.getMetadata();
if (md.getPathType() == PathType.COLLECTION_ANY) {
return toField(md.getParent());
} else {
String rv = md.getName();
if (md.getParent() != null) {
Path<?> parent = md.getParent();
if (parent.getMetadata().getPathType() != PathType.VARIABLE) {
rv = toField(parent) + "." + rv;
}
}
return rv;
}
}
|
java
|
protected String toField(Path<?> path) {
PathMetadata md = path.getMetadata();
if (md.getPathType() == PathType.COLLECTION_ANY) {
return toField(md.getParent());
} else {
String rv = md.getName();
if (md.getParent() != null) {
Path<?> parent = md.getParent();
if (parent.getMetadata().getPathType() != PathType.VARIABLE) {
rv = toField(parent) + "." + rv;
}
}
return rv;
}
}
|
[
"protected",
"String",
"toField",
"(",
"Path",
"<",
"?",
">",
"path",
")",
"{",
"PathMetadata",
"md",
"=",
"path",
".",
"getMetadata",
"(",
")",
";",
"if",
"(",
"md",
".",
"getPathType",
"(",
")",
"==",
"PathType",
".",
"COLLECTION_ANY",
")",
"{",
"return",
"toField",
"(",
"md",
".",
"getParent",
"(",
")",
")",
";",
"}",
"else",
"{",
"String",
"rv",
"=",
"md",
".",
"getName",
"(",
")",
";",
"if",
"(",
"md",
".",
"getParent",
"(",
")",
"!=",
"null",
")",
"{",
"Path",
"<",
"?",
">",
"parent",
"=",
"md",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"parent",
".",
"getMetadata",
"(",
")",
".",
"getPathType",
"(",
")",
"!=",
"PathType",
".",
"VARIABLE",
")",
"{",
"rv",
"=",
"toField",
"(",
"parent",
")",
"+",
"\".\"",
"+",
"rv",
";",
"}",
"}",
"return",
"rv",
";",
"}",
"}"
] |
template method, override to customize
@param path
path
@return field name
|
[
"template",
"method",
"override",
"to",
"customize"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneSerializer.java#L484-L498
|
18,067
|
querydsl/querydsl
|
querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java
|
AbstractSQLQuery.forShare
|
public Q forShare(boolean fallbackToForUpdate) {
SQLTemplates sqlTemplates = configuration.getTemplates();
if (sqlTemplates.isForShareSupported()) {
QueryFlag forShareFlag = sqlTemplates.getForShareFlag();
return addFlag(forShareFlag);
}
if (fallbackToForUpdate) {
return forUpdate();
}
throw new QueryException("Using forShare() is not supported");
}
|
java
|
public Q forShare(boolean fallbackToForUpdate) {
SQLTemplates sqlTemplates = configuration.getTemplates();
if (sqlTemplates.isForShareSupported()) {
QueryFlag forShareFlag = sqlTemplates.getForShareFlag();
return addFlag(forShareFlag);
}
if (fallbackToForUpdate) {
return forUpdate();
}
throw new QueryException("Using forShare() is not supported");
}
|
[
"public",
"Q",
"forShare",
"(",
"boolean",
"fallbackToForUpdate",
")",
"{",
"SQLTemplates",
"sqlTemplates",
"=",
"configuration",
".",
"getTemplates",
"(",
")",
";",
"if",
"(",
"sqlTemplates",
".",
"isForShareSupported",
"(",
")",
")",
"{",
"QueryFlag",
"forShareFlag",
"=",
"sqlTemplates",
".",
"getForShareFlag",
"(",
")",
";",
"return",
"addFlag",
"(",
"forShareFlag",
")",
";",
"}",
"if",
"(",
"fallbackToForUpdate",
")",
"{",
"return",
"forUpdate",
"(",
")",
";",
"}",
"throw",
"new",
"QueryException",
"(",
"\"Using forShare() is not supported\"",
")",
";",
"}"
] |
FOR SHARE causes the rows retrieved by the SELECT statement to be locked as though for update.
Supported by MySQL, PostgreSQL, SQLServer.
@param fallbackToForUpdate
if the FOR SHARE is not supported and this parameter is <code>true</code>, the
{@link #forUpdate()} functionality will be used.
@return the current object
@throws QueryException
if the FOR SHARE is not supported and <i>fallbackToForUpdate</i> is set to
<code>false</code>.
|
[
"FOR",
"SHARE",
"causes",
"the",
"rows",
"retrieved",
"by",
"the",
"SELECT",
"statement",
"to",
"be",
"locked",
"as",
"though",
"for",
"update",
"."
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java#L182-L195
|
18,068
|
querydsl/querydsl
|
querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java
|
AbstractSQLQuery.onException
|
protected void onException(SQLListenerContextImpl context, Exception e) {
context.setException(e);
listeners.exception(context);
}
|
java
|
protected void onException(SQLListenerContextImpl context, Exception e) {
context.setException(e);
listeners.exception(context);
}
|
[
"protected",
"void",
"onException",
"(",
"SQLListenerContextImpl",
"context",
",",
"Exception",
"e",
")",
"{",
"context",
".",
"setException",
"(",
"e",
")",
";",
"listeners",
".",
"exception",
"(",
"context",
")",
";",
"}"
] |
Called to make the call back to listeners when an exception happens
@param context the current context in play
@param e the exception
|
[
"Called",
"to",
"make",
"the",
"call",
"back",
"to",
"listeners",
"when",
"an",
"exception",
"happens"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java#L235-L238
|
18,069
|
querydsl/querydsl
|
querydsl-spatial/src/main/java/com/querydsl/spatial/jts/JTSSurfaceExpression.java
|
JTSSurfaceExpression.area
|
public NumberExpression<Double> area() {
if (area == null) {
area = Expressions.numberOperation(Double.class, SpatialOps.AREA, mixin);
}
return area;
}
|
java
|
public NumberExpression<Double> area() {
if (area == null) {
area = Expressions.numberOperation(Double.class, SpatialOps.AREA, mixin);
}
return area;
}
|
[
"public",
"NumberExpression",
"<",
"Double",
">",
"area",
"(",
")",
"{",
"if",
"(",
"area",
"==",
"null",
")",
"{",
"area",
"=",
"Expressions",
".",
"numberOperation",
"(",
"Double",
".",
"class",
",",
"SpatialOps",
".",
"AREA",
",",
"mixin",
")",
";",
"}",
"return",
"area",
";",
"}"
] |
The area of this Surface, as measured in the spatial reference system of this Surface.
@return area
|
[
"The",
"area",
"of",
"this",
"Surface",
"as",
"measured",
"in",
"the",
"spatial",
"reference",
"system",
"of",
"this",
"Surface",
"."
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-spatial/src/main/java/com/querydsl/spatial/jts/JTSSurfaceExpression.java#L51-L56
|
18,070
|
querydsl/querydsl
|
querydsl-spatial/src/main/java/com/querydsl/spatial/jts/JTSSurfaceExpression.java
|
JTSSurfaceExpression.centroid
|
public JTSPointExpression<Point> centroid() {
if (centroid == null) {
centroid = JTSGeometryExpressions.pointOperation(SpatialOps.CENTROID, mixin);
}
return centroid;
}
|
java
|
public JTSPointExpression<Point> centroid() {
if (centroid == null) {
centroid = JTSGeometryExpressions.pointOperation(SpatialOps.CENTROID, mixin);
}
return centroid;
}
|
[
"public",
"JTSPointExpression",
"<",
"Point",
">",
"centroid",
"(",
")",
"{",
"if",
"(",
"centroid",
"==",
"null",
")",
"{",
"centroid",
"=",
"JTSGeometryExpressions",
".",
"pointOperation",
"(",
"SpatialOps",
".",
"CENTROID",
",",
"mixin",
")",
";",
"}",
"return",
"centroid",
";",
"}"
] |
The mathematical centroid for this Surface as a Point. The result is not guaranteed to
be on this Surface.
@return centroid
|
[
"The",
"mathematical",
"centroid",
"for",
"this",
"Surface",
"as",
"a",
"Point",
".",
"The",
"result",
"is",
"not",
"guaranteed",
"to",
"be",
"on",
"this",
"Surface",
"."
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-spatial/src/main/java/com/querydsl/spatial/jts/JTSSurfaceExpression.java#L64-L69
|
18,071
|
querydsl/querydsl
|
querydsl-spatial/src/main/java/com/querydsl/spatial/jts/JTSSurfaceExpression.java
|
JTSSurfaceExpression.pointOnSurface
|
public JTSPointExpression<Point> pointOnSurface() {
if (pointOnSurface == null) {
pointOnSurface = JTSGeometryExpressions.pointOperation(SpatialOps.POINT_ON_SURFACE, mixin);
}
return pointOnSurface;
}
|
java
|
public JTSPointExpression<Point> pointOnSurface() {
if (pointOnSurface == null) {
pointOnSurface = JTSGeometryExpressions.pointOperation(SpatialOps.POINT_ON_SURFACE, mixin);
}
return pointOnSurface;
}
|
[
"public",
"JTSPointExpression",
"<",
"Point",
">",
"pointOnSurface",
"(",
")",
"{",
"if",
"(",
"pointOnSurface",
"==",
"null",
")",
"{",
"pointOnSurface",
"=",
"JTSGeometryExpressions",
".",
"pointOperation",
"(",
"SpatialOps",
".",
"POINT_ON_SURFACE",
",",
"mixin",
")",
";",
"}",
"return",
"pointOnSurface",
";",
"}"
] |
A Point guaranteed to be on this Surface.
@return point on surface
|
[
"A",
"Point",
"guaranteed",
"to",
"be",
"on",
"this",
"Surface",
"."
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-spatial/src/main/java/com/querydsl/spatial/jts/JTSSurfaceExpression.java#L76-L81
|
18,072
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java
|
ExpressionUtils.anyOf
|
@Nullable
public static Predicate anyOf(Collection<Predicate> exprs) {
Predicate rv = null;
for (Predicate b : exprs) {
if (b != null) {
rv = rv == null ? b : ExpressionUtils.or(rv,b);
}
}
return rv;
}
|
java
|
@Nullable
public static Predicate anyOf(Collection<Predicate> exprs) {
Predicate rv = null;
for (Predicate b : exprs) {
if (b != null) {
rv = rv == null ? b : ExpressionUtils.or(rv,b);
}
}
return rv;
}
|
[
"@",
"Nullable",
"public",
"static",
"Predicate",
"anyOf",
"(",
"Collection",
"<",
"Predicate",
">",
"exprs",
")",
"{",
"Predicate",
"rv",
"=",
"null",
";",
"for",
"(",
"Predicate",
"b",
":",
"exprs",
")",
"{",
"if",
"(",
"b",
"!=",
"null",
")",
"{",
"rv",
"=",
"rv",
"==",
"null",
"?",
"b",
":",
"ExpressionUtils",
".",
"or",
"(",
"rv",
",",
"b",
")",
";",
"}",
"}",
"return",
"rv",
";",
"}"
] |
Create the union of the given arguments
@param exprs predicate
@return union
|
[
"Create",
"the",
"union",
"of",
"the",
"given",
"arguments"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java#L399-L408
|
18,073
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java
|
ExpressionUtils.as
|
public static <D> Expression<D> as(Expression<D> source, Path<D> alias) {
return operation(alias.getType(), Ops.ALIAS, source, alias);
}
|
java
|
public static <D> Expression<D> as(Expression<D> source, Path<D> alias) {
return operation(alias.getType(), Ops.ALIAS, source, alias);
}
|
[
"public",
"static",
"<",
"D",
">",
"Expression",
"<",
"D",
">",
"as",
"(",
"Expression",
"<",
"D",
">",
"source",
",",
"Path",
"<",
"D",
">",
"alias",
")",
"{",
"return",
"operation",
"(",
"alias",
".",
"getType",
"(",
")",
",",
"Ops",
".",
"ALIAS",
",",
"source",
",",
"alias",
")",
";",
"}"
] |
Create an alias expression with the given source and alias
@param <D> type of expression
@param source source
@param alias alias
@return source as alias
|
[
"Create",
"an",
"alias",
"expression",
"with",
"the",
"given",
"source",
"and",
"alias"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java#L435-L437
|
18,074
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java
|
ExpressionUtils.likeToRegex
|
@SuppressWarnings("unchecked")
public static Expression<String> likeToRegex(Expression<String> expr, boolean matchStartAndEnd) {
// TODO : this should take the escape character into account
if (expr instanceof Constant<?>) {
final String like = expr.toString();
final StringBuilder rv = new StringBuilder(like.length() + 4);
if (matchStartAndEnd && !like.startsWith("%")) {
rv.append('^');
}
for (int i = 0; i < like.length(); i++) {
char ch = like.charAt(i);
if (ch == '.' || ch == '*' || ch == '?') {
rv.append('\\');
} else if (ch == '%') {
rv.append(".*");
continue;
} else if (ch == '_') {
rv.append('.');
continue;
}
rv.append(ch);
}
if (matchStartAndEnd && !like.endsWith("%")) {
rv.append('$');
}
if (!like.equals(rv.toString())) {
return ConstantImpl.create(rv.toString());
}
} else if (expr instanceof Operation<?>) {
Operation<?> o = (Operation<?>) expr;
if (o.getOperator() == Ops.CONCAT) {
Expression<String> lhs = likeToRegex((Expression<String>) o.getArg(0), false);
Expression<String> rhs = likeToRegex((Expression<String>) o.getArg(1), false);
if (lhs != o.getArg(0) || rhs != o.getArg(1)) {
return operation(String.class, Ops.CONCAT, lhs, rhs);
}
}
}
return expr;
}
|
java
|
@SuppressWarnings("unchecked")
public static Expression<String> likeToRegex(Expression<String> expr, boolean matchStartAndEnd) {
// TODO : this should take the escape character into account
if (expr instanceof Constant<?>) {
final String like = expr.toString();
final StringBuilder rv = new StringBuilder(like.length() + 4);
if (matchStartAndEnd && !like.startsWith("%")) {
rv.append('^');
}
for (int i = 0; i < like.length(); i++) {
char ch = like.charAt(i);
if (ch == '.' || ch == '*' || ch == '?') {
rv.append('\\');
} else if (ch == '%') {
rv.append(".*");
continue;
} else if (ch == '_') {
rv.append('.');
continue;
}
rv.append(ch);
}
if (matchStartAndEnd && !like.endsWith("%")) {
rv.append('$');
}
if (!like.equals(rv.toString())) {
return ConstantImpl.create(rv.toString());
}
} else if (expr instanceof Operation<?>) {
Operation<?> o = (Operation<?>) expr;
if (o.getOperator() == Ops.CONCAT) {
Expression<String> lhs = likeToRegex((Expression<String>) o.getArg(0), false);
Expression<String> rhs = likeToRegex((Expression<String>) o.getArg(1), false);
if (lhs != o.getArg(0) || rhs != o.getArg(1)) {
return operation(String.class, Ops.CONCAT, lhs, rhs);
}
}
}
return expr;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"Expression",
"<",
"String",
">",
"likeToRegex",
"(",
"Expression",
"<",
"String",
">",
"expr",
",",
"boolean",
"matchStartAndEnd",
")",
"{",
"// TODO : this should take the escape character into account",
"if",
"(",
"expr",
"instanceof",
"Constant",
"<",
"?",
">",
")",
"{",
"final",
"String",
"like",
"=",
"expr",
".",
"toString",
"(",
")",
";",
"final",
"StringBuilder",
"rv",
"=",
"new",
"StringBuilder",
"(",
"like",
".",
"length",
"(",
")",
"+",
"4",
")",
";",
"if",
"(",
"matchStartAndEnd",
"&&",
"!",
"like",
".",
"startsWith",
"(",
"\"%\"",
")",
")",
"{",
"rv",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"like",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"ch",
"=",
"like",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"ch",
"==",
"'",
"'",
"||",
"ch",
"==",
"'",
"'",
"||",
"ch",
"==",
"'",
"'",
")",
"{",
"rv",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"if",
"(",
"ch",
"==",
"'",
"'",
")",
"{",
"rv",
".",
"append",
"(",
"\".*\"",
")",
";",
"continue",
";",
"}",
"else",
"if",
"(",
"ch",
"==",
"'",
"'",
")",
"{",
"rv",
".",
"append",
"(",
"'",
"'",
")",
";",
"continue",
";",
"}",
"rv",
".",
"append",
"(",
"ch",
")",
";",
"}",
"if",
"(",
"matchStartAndEnd",
"&&",
"!",
"like",
".",
"endsWith",
"(",
"\"%\"",
")",
")",
"{",
"rv",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"if",
"(",
"!",
"like",
".",
"equals",
"(",
"rv",
".",
"toString",
"(",
")",
")",
")",
"{",
"return",
"ConstantImpl",
".",
"create",
"(",
"rv",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"expr",
"instanceof",
"Operation",
"<",
"?",
">",
")",
"{",
"Operation",
"<",
"?",
">",
"o",
"=",
"(",
"Operation",
"<",
"?",
">",
")",
"expr",
";",
"if",
"(",
"o",
".",
"getOperator",
"(",
")",
"==",
"Ops",
".",
"CONCAT",
")",
"{",
"Expression",
"<",
"String",
">",
"lhs",
"=",
"likeToRegex",
"(",
"(",
"Expression",
"<",
"String",
">",
")",
"o",
".",
"getArg",
"(",
"0",
")",
",",
"false",
")",
";",
"Expression",
"<",
"String",
">",
"rhs",
"=",
"likeToRegex",
"(",
"(",
"Expression",
"<",
"String",
">",
")",
"o",
".",
"getArg",
"(",
"1",
")",
",",
"false",
")",
";",
"if",
"(",
"lhs",
"!=",
"o",
".",
"getArg",
"(",
"0",
")",
"||",
"rhs",
"!=",
"o",
".",
"getArg",
"(",
"1",
")",
")",
"{",
"return",
"operation",
"(",
"String",
".",
"class",
",",
"Ops",
".",
"CONCAT",
",",
"lhs",
",",
"rhs",
")",
";",
"}",
"}",
"}",
"return",
"expr",
";",
"}"
] |
Convert the given like pattern to a regex pattern
@param expr expression to be converted
@param matchStartAndEnd if start and end should be matched as well
@return converted expression
|
[
"Convert",
"the",
"given",
"like",
"pattern",
"to",
"a",
"regex",
"pattern"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java#L578-L617
|
18,075
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java
|
ExpressionUtils.regexToLike
|
@SuppressWarnings("unchecked")
public static Expression<String> regexToLike(Expression<String> expr) {
if (expr instanceof Constant<?>) {
final String str = expr.toString();
final StringBuilder rv = new StringBuilder(str.length() + 2);
boolean escape = false;
for (int i = 0; i < str.length(); i++) {
final char ch = str.charAt(i);
if (!escape && ch == '.') {
if (i < str.length() - 1 && str.charAt(i + 1) == '*') {
rv.append('%');
i++;
} else {
rv.append('_');
}
continue;
} else if (!escape && ch == '\\') {
escape = true;
continue;
} else if (!escape && (ch == '[' || ch == ']' || ch == '^' || ch == '.' || ch == '*')) {
throw new QueryException("'" + str + "' can't be converted to like form");
} else if (escape && (ch == 'd' || ch == 'D' || ch == 's' || ch == 'S' || ch == 'w' || ch == 'W')) {
throw new QueryException("'" + str + "' can't be converted to like form");
}
rv.append(ch);
escape = false;
}
if (!rv.toString().equals(str)) {
return ConstantImpl.create(rv.toString());
}
} else if (expr instanceof Operation<?>) {
Operation<?> o = (Operation<?>) expr;
if (o.getOperator() == Ops.CONCAT) {
Expression<String> lhs = regexToLike((Expression<String>) o.getArg(0));
Expression<String> rhs = regexToLike((Expression<String>) o.getArg(1));
if (lhs != o.getArg(0) || rhs != o.getArg(1)) {
return operation(String.class, Ops.CONCAT, lhs, rhs);
}
}
}
return expr;
}
|
java
|
@SuppressWarnings("unchecked")
public static Expression<String> regexToLike(Expression<String> expr) {
if (expr instanceof Constant<?>) {
final String str = expr.toString();
final StringBuilder rv = new StringBuilder(str.length() + 2);
boolean escape = false;
for (int i = 0; i < str.length(); i++) {
final char ch = str.charAt(i);
if (!escape && ch == '.') {
if (i < str.length() - 1 && str.charAt(i + 1) == '*') {
rv.append('%');
i++;
} else {
rv.append('_');
}
continue;
} else if (!escape && ch == '\\') {
escape = true;
continue;
} else if (!escape && (ch == '[' || ch == ']' || ch == '^' || ch == '.' || ch == '*')) {
throw new QueryException("'" + str + "' can't be converted to like form");
} else if (escape && (ch == 'd' || ch == 'D' || ch == 's' || ch == 'S' || ch == 'w' || ch == 'W')) {
throw new QueryException("'" + str + "' can't be converted to like form");
}
rv.append(ch);
escape = false;
}
if (!rv.toString().equals(str)) {
return ConstantImpl.create(rv.toString());
}
} else if (expr instanceof Operation<?>) {
Operation<?> o = (Operation<?>) expr;
if (o.getOperator() == Ops.CONCAT) {
Expression<String> lhs = regexToLike((Expression<String>) o.getArg(0));
Expression<String> rhs = regexToLike((Expression<String>) o.getArg(1));
if (lhs != o.getArg(0) || rhs != o.getArg(1)) {
return operation(String.class, Ops.CONCAT, lhs, rhs);
}
}
}
return expr;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"Expression",
"<",
"String",
">",
"regexToLike",
"(",
"Expression",
"<",
"String",
">",
"expr",
")",
"{",
"if",
"(",
"expr",
"instanceof",
"Constant",
"<",
"?",
">",
")",
"{",
"final",
"String",
"str",
"=",
"expr",
".",
"toString",
"(",
")",
";",
"final",
"StringBuilder",
"rv",
"=",
"new",
"StringBuilder",
"(",
"str",
".",
"length",
"(",
")",
"+",
"2",
")",
";",
"boolean",
"escape",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"final",
"char",
"ch",
"=",
"str",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"!",
"escape",
"&&",
"ch",
"==",
"'",
"'",
")",
"{",
"if",
"(",
"i",
"<",
"str",
".",
"length",
"(",
")",
"-",
"1",
"&&",
"str",
".",
"charAt",
"(",
"i",
"+",
"1",
")",
"==",
"'",
"'",
")",
"{",
"rv",
".",
"append",
"(",
"'",
"'",
")",
";",
"i",
"++",
";",
"}",
"else",
"{",
"rv",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"continue",
";",
"}",
"else",
"if",
"(",
"!",
"escape",
"&&",
"ch",
"==",
"'",
"'",
")",
"{",
"escape",
"=",
"true",
";",
"continue",
";",
"}",
"else",
"if",
"(",
"!",
"escape",
"&&",
"(",
"ch",
"==",
"'",
"'",
"||",
"ch",
"==",
"'",
"'",
"||",
"ch",
"==",
"'",
"'",
"||",
"ch",
"==",
"'",
"'",
"||",
"ch",
"==",
"'",
"'",
")",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"\"'\"",
"+",
"str",
"+",
"\"' can't be converted to like form\"",
")",
";",
"}",
"else",
"if",
"(",
"escape",
"&&",
"(",
"ch",
"==",
"'",
"'",
"||",
"ch",
"==",
"'",
"'",
"||",
"ch",
"==",
"'",
"'",
"||",
"ch",
"==",
"'",
"'",
"||",
"ch",
"==",
"'",
"'",
"||",
"ch",
"==",
"'",
"'",
")",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"\"'\"",
"+",
"str",
"+",
"\"' can't be converted to like form\"",
")",
";",
"}",
"rv",
".",
"append",
"(",
"ch",
")",
";",
"escape",
"=",
"false",
";",
"}",
"if",
"(",
"!",
"rv",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"str",
")",
")",
"{",
"return",
"ConstantImpl",
".",
"create",
"(",
"rv",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"expr",
"instanceof",
"Operation",
"<",
"?",
">",
")",
"{",
"Operation",
"<",
"?",
">",
"o",
"=",
"(",
"Operation",
"<",
"?",
">",
")",
"expr",
";",
"if",
"(",
"o",
".",
"getOperator",
"(",
")",
"==",
"Ops",
".",
"CONCAT",
")",
"{",
"Expression",
"<",
"String",
">",
"lhs",
"=",
"regexToLike",
"(",
"(",
"Expression",
"<",
"String",
">",
")",
"o",
".",
"getArg",
"(",
"0",
")",
")",
";",
"Expression",
"<",
"String",
">",
"rhs",
"=",
"regexToLike",
"(",
"(",
"Expression",
"<",
"String",
">",
")",
"o",
".",
"getArg",
"(",
"1",
")",
")",
";",
"if",
"(",
"lhs",
"!=",
"o",
".",
"getArg",
"(",
"0",
")",
"||",
"rhs",
"!=",
"o",
".",
"getArg",
"(",
"1",
")",
")",
"{",
"return",
"operation",
"(",
"String",
".",
"class",
",",
"Ops",
".",
"CONCAT",
",",
"lhs",
",",
"rhs",
")",
";",
"}",
"}",
"}",
"return",
"expr",
";",
"}"
] |
Convert the given expression from regex form to like
@param expr expression to convert
@return converted expression
|
[
"Convert",
"the",
"given",
"expression",
"from",
"regex",
"form",
"to",
"like"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java#L656-L697
|
18,076
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java
|
ExpressionUtils.distinctList
|
public static ImmutableList<Expression<?>> distinctList(Expression<?>... args) {
final ImmutableList.Builder<Expression<?>> builder = ImmutableList.builder();
final Set<Expression<?>> set = new HashSet<Expression<?>>(args.length);
for (Expression<?> arg : args) {
if (set.add(arg)) {
builder.add(arg);
}
}
return builder.build();
}
|
java
|
public static ImmutableList<Expression<?>> distinctList(Expression<?>... args) {
final ImmutableList.Builder<Expression<?>> builder = ImmutableList.builder();
final Set<Expression<?>> set = new HashSet<Expression<?>>(args.length);
for (Expression<?> arg : args) {
if (set.add(arg)) {
builder.add(arg);
}
}
return builder.build();
}
|
[
"public",
"static",
"ImmutableList",
"<",
"Expression",
"<",
"?",
">",
">",
"distinctList",
"(",
"Expression",
"<",
"?",
">",
"...",
"args",
")",
"{",
"final",
"ImmutableList",
".",
"Builder",
"<",
"Expression",
"<",
"?",
">",
">",
"builder",
"=",
"ImmutableList",
".",
"builder",
"(",
")",
";",
"final",
"Set",
"<",
"Expression",
"<",
"?",
">",
">",
"set",
"=",
"new",
"HashSet",
"<",
"Expression",
"<",
"?",
">",
">",
"(",
"args",
".",
"length",
")",
";",
"for",
"(",
"Expression",
"<",
"?",
">",
"arg",
":",
"args",
")",
"{",
"if",
"(",
"set",
".",
"add",
"(",
"arg",
")",
")",
"{",
"builder",
".",
"add",
"(",
"arg",
")",
";",
"}",
"}",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}"
] |
Create a distinct list of the given args
@param args elements
@return list with distinct elements
|
[
"Create",
"a",
"distinct",
"list",
"of",
"the",
"given",
"args"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java#L804-L813
|
18,077
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java
|
ExpressionUtils.extract
|
@SuppressWarnings("unchecked")
public static <T> Expression<T> extract(Expression<T> expr) {
if (expr != null) {
final Class<?> clazz = expr.getClass();
if (clazz == PathImpl.class || clazz == PredicateOperation.class || clazz == ConstantImpl.class) {
return expr;
} else {
return (Expression<T>) expr.accept(ExtractorVisitor.DEFAULT, null);
}
} else {
return null;
}
}
|
java
|
@SuppressWarnings("unchecked")
public static <T> Expression<T> extract(Expression<T> expr) {
if (expr != null) {
final Class<?> clazz = expr.getClass();
if (clazz == PathImpl.class || clazz == PredicateOperation.class || clazz == ConstantImpl.class) {
return expr;
} else {
return (Expression<T>) expr.accept(ExtractorVisitor.DEFAULT, null);
}
} else {
return null;
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"Expression",
"<",
"T",
">",
"extract",
"(",
"Expression",
"<",
"T",
">",
"expr",
")",
"{",
"if",
"(",
"expr",
"!=",
"null",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"clazz",
"=",
"expr",
".",
"getClass",
"(",
")",
";",
"if",
"(",
"clazz",
"==",
"PathImpl",
".",
"class",
"||",
"clazz",
"==",
"PredicateOperation",
".",
"class",
"||",
"clazz",
"==",
"ConstantImpl",
".",
"class",
")",
"{",
"return",
"expr",
";",
"}",
"else",
"{",
"return",
"(",
"Expression",
"<",
"T",
">",
")",
"expr",
".",
"accept",
"(",
"ExtractorVisitor",
".",
"DEFAULT",
",",
"null",
")",
";",
"}",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Get the potentially wrapped expression
@param expr expression to analyze
@return inner expression
|
[
"Get",
"the",
"potentially",
"wrapped",
"expression"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java#L840-L852
|
18,078
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java
|
ExpressionUtils.createRootVariable
|
public static String createRootVariable(Path<?> path, int suffix) {
String variable = path.accept(ToStringVisitor.DEFAULT, TEMPLATES);
return variable + "_" + suffix;
}
|
java
|
public static String createRootVariable(Path<?> path, int suffix) {
String variable = path.accept(ToStringVisitor.DEFAULT, TEMPLATES);
return variable + "_" + suffix;
}
|
[
"public",
"static",
"String",
"createRootVariable",
"(",
"Path",
"<",
"?",
">",
"path",
",",
"int",
"suffix",
")",
"{",
"String",
"variable",
"=",
"path",
".",
"accept",
"(",
"ToStringVisitor",
".",
"DEFAULT",
",",
"TEMPLATES",
")",
";",
"return",
"variable",
"+",
"\"_\"",
"+",
"suffix",
";",
"}"
] |
Create a new root variable based on the given path and suffix
@param path base path
@param suffix suffix for variable name
@return path expression
|
[
"Create",
"a",
"new",
"root",
"variable",
"based",
"on",
"the",
"given",
"path",
"and",
"suffix"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java#L861-L864
|
18,079
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java
|
ExpressionUtils.toExpression
|
public static Expression<?> toExpression(Object o) {
if (o instanceof Expression) {
return (Expression<?>) o;
} else {
return ConstantImpl.create(o);
}
}
|
java
|
public static Expression<?> toExpression(Object o) {
if (o instanceof Expression) {
return (Expression<?>) o;
} else {
return ConstantImpl.create(o);
}
}
|
[
"public",
"static",
"Expression",
"<",
"?",
">",
"toExpression",
"(",
"Object",
"o",
")",
"{",
"if",
"(",
"o",
"instanceof",
"Expression",
")",
"{",
"return",
"(",
"Expression",
"<",
"?",
">",
")",
"o",
";",
"}",
"else",
"{",
"return",
"ConstantImpl",
".",
"create",
"(",
"o",
")",
";",
"}",
"}"
] |
Converts the given object to an Expression
<p>Casts expressions and wraps everything else into co</p>
@param o object to convert
@return converted argument
|
[
"Converts",
"the",
"given",
"object",
"to",
"an",
"Expression"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java#L884-L890
|
18,080
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java
|
ExpressionUtils.orderBy
|
public static Expression<?> orderBy(List<OrderSpecifier<?>> args) {
return operation(Object.class, Ops.ORDER, ConstantImpl.create(args));
}
|
java
|
public static Expression<?> orderBy(List<OrderSpecifier<?>> args) {
return operation(Object.class, Ops.ORDER, ConstantImpl.create(args));
}
|
[
"public",
"static",
"Expression",
"<",
"?",
">",
"orderBy",
"(",
"List",
"<",
"OrderSpecifier",
"<",
"?",
">",
">",
"args",
")",
"{",
"return",
"operation",
"(",
"Object",
".",
"class",
",",
"Ops",
".",
"ORDER",
",",
"ConstantImpl",
".",
"create",
"(",
"args",
")",
")",
";",
"}"
] |
Create an expression out of the given order specifiers
@param args order
@return expression for order
|
[
"Create",
"an",
"expression",
"out",
"of",
"the",
"given",
"order",
"specifiers"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java#L915-L917
|
18,081
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/alias/AliasFactory.java
|
AliasFactory.createAliasForExpr
|
@SuppressWarnings("unchecked")
public <A> A createAliasForExpr(Class<A> cl, Expression<? extends A> expr) {
try {
return (A) proxyCache.get(Pair.<Class<?>, Expression<?>>of(cl, expr));
} catch (ExecutionException e) {
throw new QueryException(e);
}
}
|
java
|
@SuppressWarnings("unchecked")
public <A> A createAliasForExpr(Class<A> cl, Expression<? extends A> expr) {
try {
return (A) proxyCache.get(Pair.<Class<?>, Expression<?>>of(cl, expr));
} catch (ExecutionException e) {
throw new QueryException(e);
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"A",
">",
"A",
"createAliasForExpr",
"(",
"Class",
"<",
"A",
">",
"cl",
",",
"Expression",
"<",
"?",
"extends",
"A",
">",
"expr",
")",
"{",
"try",
"{",
"return",
"(",
"A",
")",
"proxyCache",
".",
"get",
"(",
"Pair",
".",
"<",
"Class",
"<",
"?",
">",
",",
"Expression",
"<",
"?",
">",
">",
"of",
"(",
"cl",
",",
"expr",
")",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"e",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"e",
")",
";",
"}",
"}"
] |
Create an alias instance for the given class and Expression
@param <A>
@param cl type for alias
@param expr underlying expression
@return alias instance
|
[
"Create",
"an",
"alias",
"instance",
"for",
"the",
"given",
"class",
"and",
"Expression"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/alias/AliasFactory.java#L79-L86
|
18,082
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/alias/AliasFactory.java
|
AliasFactory.createAliasForProperty
|
public <A> A createAliasForProperty(Class<A> cl, Expression<?> path) {
return createProxy(cl, path);
}
|
java
|
public <A> A createAliasForProperty(Class<A> cl, Expression<?> path) {
return createProxy(cl, path);
}
|
[
"public",
"<",
"A",
">",
"A",
"createAliasForProperty",
"(",
"Class",
"<",
"A",
">",
"cl",
",",
"Expression",
"<",
"?",
">",
"path",
")",
"{",
"return",
"createProxy",
"(",
"cl",
",",
"path",
")",
";",
"}"
] |
Create an alias instance for the given class, parent and path
@param <A>
@param cl type for alias
@param path underlying expression
@return alias instance
|
[
"Create",
"an",
"alias",
"instance",
"for",
"the",
"given",
"class",
"parent",
"and",
"path"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/alias/AliasFactory.java#L96-L98
|
18,083
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/alias/AliasFactory.java
|
AliasFactory.createAliasForVariable
|
@SuppressWarnings("unchecked")
public <A> A createAliasForVariable(Class<A> cl, String var) {
try {
Expression<?> path = pathCache.get(Pair.<Class<?>, String>of(cl, var));
return (A) proxyCache.get(Pair.<Class<?>, Expression<?>>of(cl, path));
} catch (ExecutionException e) {
throw new QueryException(e);
}
}
|
java
|
@SuppressWarnings("unchecked")
public <A> A createAliasForVariable(Class<A> cl, String var) {
try {
Expression<?> path = pathCache.get(Pair.<Class<?>, String>of(cl, var));
return (A) proxyCache.get(Pair.<Class<?>, Expression<?>>of(cl, path));
} catch (ExecutionException e) {
throw new QueryException(e);
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"A",
">",
"A",
"createAliasForVariable",
"(",
"Class",
"<",
"A",
">",
"cl",
",",
"String",
"var",
")",
"{",
"try",
"{",
"Expression",
"<",
"?",
">",
"path",
"=",
"pathCache",
".",
"get",
"(",
"Pair",
".",
"<",
"Class",
"<",
"?",
">",
",",
"String",
">",
"of",
"(",
"cl",
",",
"var",
")",
")",
";",
"return",
"(",
"A",
")",
"proxyCache",
".",
"get",
"(",
"Pair",
".",
"<",
"Class",
"<",
"?",
">",
",",
"Expression",
"<",
"?",
">",
">",
"of",
"(",
"cl",
",",
"path",
")",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"e",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"e",
")",
";",
"}",
"}"
] |
Create an alias instance for the given class and variable name
@param <A>
@param cl type for alias
@param var variable name for the underlying expression
@return alias instance
|
[
"Create",
"an",
"alias",
"instance",
"for",
"the",
"given",
"class",
"and",
"variable",
"name"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/alias/AliasFactory.java#L108-L116
|
18,084
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/alias/AliasFactory.java
|
AliasFactory.createProxy
|
@SuppressWarnings("unchecked")
protected <A> A createProxy(Class<A> cl, Expression<?> path) {
Enhancer enhancer = new Enhancer();
enhancer.setClassLoader(AliasFactory.class.getClassLoader());
if (cl.isInterface()) {
enhancer.setInterfaces(new Class<?>[] {cl, ManagedObject.class});
} else {
enhancer.setSuperclass(cl);
enhancer.setInterfaces(new Class<?>[] {ManagedObject.class});
}
// creates one handler per proxy
MethodInterceptor handler = new PropertyAccessInvocationHandler(path, this, pathFactory, typeSystem);
enhancer.setCallback(handler);
return (A) enhancer.create();
}
|
java
|
@SuppressWarnings("unchecked")
protected <A> A createProxy(Class<A> cl, Expression<?> path) {
Enhancer enhancer = new Enhancer();
enhancer.setClassLoader(AliasFactory.class.getClassLoader());
if (cl.isInterface()) {
enhancer.setInterfaces(new Class<?>[] {cl, ManagedObject.class});
} else {
enhancer.setSuperclass(cl);
enhancer.setInterfaces(new Class<?>[] {ManagedObject.class});
}
// creates one handler per proxy
MethodInterceptor handler = new PropertyAccessInvocationHandler(path, this, pathFactory, typeSystem);
enhancer.setCallback(handler);
return (A) enhancer.create();
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"<",
"A",
">",
"A",
"createProxy",
"(",
"Class",
"<",
"A",
">",
"cl",
",",
"Expression",
"<",
"?",
">",
"path",
")",
"{",
"Enhancer",
"enhancer",
"=",
"new",
"Enhancer",
"(",
")",
";",
"enhancer",
".",
"setClassLoader",
"(",
"AliasFactory",
".",
"class",
".",
"getClassLoader",
"(",
")",
")",
";",
"if",
"(",
"cl",
".",
"isInterface",
"(",
")",
")",
"{",
"enhancer",
".",
"setInterfaces",
"(",
"new",
"Class",
"<",
"?",
">",
"[",
"]",
"{",
"cl",
",",
"ManagedObject",
".",
"class",
"}",
")",
";",
"}",
"else",
"{",
"enhancer",
".",
"setSuperclass",
"(",
"cl",
")",
";",
"enhancer",
".",
"setInterfaces",
"(",
"new",
"Class",
"<",
"?",
">",
"[",
"]",
"{",
"ManagedObject",
".",
"class",
"}",
")",
";",
"}",
"// creates one handler per proxy",
"MethodInterceptor",
"handler",
"=",
"new",
"PropertyAccessInvocationHandler",
"(",
"path",
",",
"this",
",",
"pathFactory",
",",
"typeSystem",
")",
";",
"enhancer",
".",
"setCallback",
"(",
"handler",
")",
";",
"return",
"(",
"A",
")",
"enhancer",
".",
"create",
"(",
")",
";",
"}"
] |
Create a proxy instance for the given class and path
@param <A>
@param cl type of the proxy
@param path underlying expression
@return proxy instance
|
[
"Create",
"a",
"proxy",
"instance",
"for",
"the",
"given",
"class",
"and",
"path"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/alias/AliasFactory.java#L126-L140
|
18,085
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/alias/AliasFactory.java
|
AliasFactory.getCurrentAndReset
|
@Nullable
public <A extends Expression<?>> A getCurrentAndReset() {
A rv = this.getCurrent();
reset();
return rv;
}
|
java
|
@Nullable
public <A extends Expression<?>> A getCurrentAndReset() {
A rv = this.getCurrent();
reset();
return rv;
}
|
[
"@",
"Nullable",
"public",
"<",
"A",
"extends",
"Expression",
"<",
"?",
">",
">",
"A",
"getCurrentAndReset",
"(",
")",
"{",
"A",
"rv",
"=",
"this",
".",
"getCurrent",
"(",
")",
";",
"reset",
"(",
")",
";",
"return",
"rv",
";",
"}"
] |
Get the current thread bound expression and reset it
@param <A>
@return expression
|
[
"Get",
"the",
"current",
"thread",
"bound",
"expression",
"and",
"reset",
"it"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/alias/AliasFactory.java#L160-L165
|
18,086
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/dsl/NumberExpression.java
|
NumberExpression.stringValue
|
public StringExpression stringValue() {
if (stringCast == null) {
stringCast = Expressions.stringOperation(Ops.STRING_CAST, mixin);
}
return stringCast;
}
|
java
|
public StringExpression stringValue() {
if (stringCast == null) {
stringCast = Expressions.stringOperation(Ops.STRING_CAST, mixin);
}
return stringCast;
}
|
[
"public",
"StringExpression",
"stringValue",
"(",
")",
"{",
"if",
"(",
"stringCast",
"==",
"null",
")",
"{",
"stringCast",
"=",
"Expressions",
".",
"stringOperation",
"(",
"Ops",
".",
"STRING_CAST",
",",
"mixin",
")",
";",
"}",
"return",
"stringCast",
";",
"}"
] |
Create a cast to String expression
@see java.lang.Object#toString()
@return string representation
|
[
"Create",
"a",
"cast",
"to",
"String",
"expression"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/dsl/NumberExpression.java#L106-L111
|
18,087
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java
|
GroupBy.groupBy
|
public static <K> GroupByBuilder<K> groupBy(Expression<K> key) {
return new GroupByBuilder<K>(key);
}
|
java
|
public static <K> GroupByBuilder<K> groupBy(Expression<K> key) {
return new GroupByBuilder<K>(key);
}
|
[
"public",
"static",
"<",
"K",
">",
"GroupByBuilder",
"<",
"K",
">",
"groupBy",
"(",
"Expression",
"<",
"K",
">",
"key",
")",
"{",
"return",
"new",
"GroupByBuilder",
"<",
"K",
">",
"(",
"key",
")",
";",
"}"
] |
Create a new GroupByBuilder for the given key expression
@param key key for aggregation
@return builder for further specification
|
[
"Create",
"a",
"new",
"GroupByBuilder",
"for",
"the",
"given",
"key",
"expression"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java#L47-L49
|
18,088
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java
|
GroupBy.groupBy
|
public static GroupByBuilder<List<?>> groupBy(Expression<?>... keys) {
return new GroupByBuilder<List<?>>(Projections.list(keys));
}
|
java
|
public static GroupByBuilder<List<?>> groupBy(Expression<?>... keys) {
return new GroupByBuilder<List<?>>(Projections.list(keys));
}
|
[
"public",
"static",
"GroupByBuilder",
"<",
"List",
"<",
"?",
">",
">",
"groupBy",
"(",
"Expression",
"<",
"?",
">",
"...",
"keys",
")",
"{",
"return",
"new",
"GroupByBuilder",
"<",
"List",
"<",
"?",
">",
">",
"(",
"Projections",
".",
"list",
"(",
"keys",
")",
")",
";",
"}"
] |
Create a new GroupByBuilder for the given key expressions
@param keys keys for aggregation
@return builder for further specification
|
[
"Create",
"a",
"new",
"GroupByBuilder",
"for",
"the",
"given",
"key",
"expressions"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java#L57-L59
|
18,089
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java
|
GroupBy.min
|
public static <E extends Comparable<? super E>> AbstractGroupExpression<E, E> min(Expression<E> expression) {
return new GMin<E>(expression);
}
|
java
|
public static <E extends Comparable<? super E>> AbstractGroupExpression<E, E> min(Expression<E> expression) {
return new GMin<E>(expression);
}
|
[
"public",
"static",
"<",
"E",
"extends",
"Comparable",
"<",
"?",
"super",
"E",
">",
">",
"AbstractGroupExpression",
"<",
"E",
",",
"E",
">",
"min",
"(",
"Expression",
"<",
"E",
">",
"expression",
")",
"{",
"return",
"new",
"GMin",
"<",
"E",
">",
"(",
"expression",
")",
";",
"}"
] |
Create a new aggregating min expression
@param expression expression for which the minimum value will be used in the group by projection
@return wrapper expression
|
[
"Create",
"a",
"new",
"aggregating",
"min",
"expression"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java#L67-L69
|
18,090
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java
|
GroupBy.sum
|
public static <E extends Number> AbstractGroupExpression<E, E> sum(Expression<E> expression) {
return new GSum<E>(expression);
}
|
java
|
public static <E extends Number> AbstractGroupExpression<E, E> sum(Expression<E> expression) {
return new GSum<E>(expression);
}
|
[
"public",
"static",
"<",
"E",
"extends",
"Number",
">",
"AbstractGroupExpression",
"<",
"E",
",",
"E",
">",
"sum",
"(",
"Expression",
"<",
"E",
">",
"expression",
")",
"{",
"return",
"new",
"GSum",
"<",
"E",
">",
"(",
"expression",
")",
";",
"}"
] |
Create a new aggregating sum expression
@param expression expression a for which the accumulated sum will be used in the group by projection
@return wrapper expression
|
[
"Create",
"a",
"new",
"aggregating",
"sum",
"expression"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java#L77-L79
|
18,091
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java
|
GroupBy.avg
|
public static <E extends Number> AbstractGroupExpression<E, E> avg(Expression<E> expression) {
return new GAvg<E>(expression);
}
|
java
|
public static <E extends Number> AbstractGroupExpression<E, E> avg(Expression<E> expression) {
return new GAvg<E>(expression);
}
|
[
"public",
"static",
"<",
"E",
"extends",
"Number",
">",
"AbstractGroupExpression",
"<",
"E",
",",
"E",
">",
"avg",
"(",
"Expression",
"<",
"E",
">",
"expression",
")",
"{",
"return",
"new",
"GAvg",
"<",
"E",
">",
"(",
"expression",
")",
";",
"}"
] |
Create a new aggregating avg expression
@param expression expression for which the accumulated average value will be used in the group by projection
@return wrapper expression
|
[
"Create",
"a",
"new",
"aggregating",
"avg",
"expression"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java#L87-L89
|
18,092
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java
|
GroupBy.max
|
public static <E extends Comparable<? super E>> AbstractGroupExpression<E, E> max(Expression<E> expression) {
return new GMax<E>(expression);
}
|
java
|
public static <E extends Comparable<? super E>> AbstractGroupExpression<E, E> max(Expression<E> expression) {
return new GMax<E>(expression);
}
|
[
"public",
"static",
"<",
"E",
"extends",
"Comparable",
"<",
"?",
"super",
"E",
">",
">",
"AbstractGroupExpression",
"<",
"E",
",",
"E",
">",
"max",
"(",
"Expression",
"<",
"E",
">",
"expression",
")",
"{",
"return",
"new",
"GMax",
"<",
"E",
">",
"(",
"expression",
")",
";",
"}"
] |
Create a new aggregating max expression
@param expression expression for which the maximum value will be used in the group by projection
@return wrapper expression
|
[
"Create",
"a",
"new",
"aggregating",
"max",
"expression"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java#L97-L99
|
18,093
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java
|
GroupBy.sortedMap
|
public static <K, V> AbstractGroupExpression<Pair<K, V>, SortedMap<K, V>> sortedMap(Expression<K> key,
Expression<V> value,
Comparator<? super K> comparator) {
return GMap.createSorted(QPair.create(key, value), comparator);
}
|
java
|
public static <K, V> AbstractGroupExpression<Pair<K, V>, SortedMap<K, V>> sortedMap(Expression<K> key,
Expression<V> value,
Comparator<? super K> comparator) {
return GMap.createSorted(QPair.create(key, value), comparator);
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"AbstractGroupExpression",
"<",
"Pair",
"<",
"K",
",",
"V",
">",
",",
"SortedMap",
"<",
"K",
",",
"V",
">",
">",
"sortedMap",
"(",
"Expression",
"<",
"K",
">",
"key",
",",
"Expression",
"<",
"V",
">",
"value",
",",
"Comparator",
"<",
"?",
"super",
"K",
">",
"comparator",
")",
"{",
"return",
"GMap",
".",
"createSorted",
"(",
"QPair",
".",
"create",
"(",
"key",
",",
"value",
")",
",",
"comparator",
")",
";",
"}"
] |
Create a new aggregating map expression using a backing TreeMap using the given comparator
@param key key for the map entries
@param value value for the map entries
@param comparator comparator for the created TreeMap instances
@return wrapper expression
|
[
"Create",
"a",
"new",
"aggregating",
"map",
"expression",
"using",
"a",
"backing",
"TreeMap",
"using",
"the",
"given",
"comparator"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java#L295-L299
|
18,094
|
querydsl/querydsl
|
querydsl-lucene5/src/main/java/com/querydsl/lucene5/AbstractLuceneQuery.java
|
AbstractLuceneQuery.filter
|
@SuppressWarnings("unchecked")
public Q filter(Filter filter) {
if (filters.isEmpty()) {
this.filter = filter;
filters = ImmutableList.of(filter);
} else {
this.filter = null;
if (filters.size() == 1) {
filters = new ArrayList<Filter>();
}
filters.add(filter);
}
return (Q) this;
}
|
java
|
@SuppressWarnings("unchecked")
public Q filter(Filter filter) {
if (filters.isEmpty()) {
this.filter = filter;
filters = ImmutableList.of(filter);
} else {
this.filter = null;
if (filters.size() == 1) {
filters = new ArrayList<Filter>();
}
filters.add(filter);
}
return (Q) this;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Q",
"filter",
"(",
"Filter",
"filter",
")",
"{",
"if",
"(",
"filters",
".",
"isEmpty",
"(",
")",
")",
"{",
"this",
".",
"filter",
"=",
"filter",
";",
"filters",
"=",
"ImmutableList",
".",
"of",
"(",
"filter",
")",
";",
"}",
"else",
"{",
"this",
".",
"filter",
"=",
"null",
";",
"if",
"(",
"filters",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"filters",
"=",
"new",
"ArrayList",
"<",
"Filter",
">",
"(",
")",
";",
"}",
"filters",
".",
"add",
"(",
"filter",
")",
";",
"}",
"return",
"(",
"Q",
")",
"this",
";",
"}"
] |
Apply the given Lucene filter to the search results
@param filter
filter
@return the current object
|
[
"Apply",
"the",
"given",
"Lucene",
"filter",
"to",
"the",
"search",
"results"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-lucene5/src/main/java/com/querydsl/lucene5/AbstractLuceneQuery.java#L165-L178
|
18,095
|
querydsl/querydsl
|
querydsl-sql/src/main/java/com/querydsl/sql/postgresql/AbstractPostgreSQLQuery.java
|
AbstractPostgreSQLQuery.noWait
|
@WithBridgeMethods(value = PostgreSQLQuery.class, castRequired = true)
public C noWait() {
QueryFlag noWaitFlag = configuration.getTemplates().getNoWaitFlag();
return addFlag(noWaitFlag);
}
|
java
|
@WithBridgeMethods(value = PostgreSQLQuery.class, castRequired = true)
public C noWait() {
QueryFlag noWaitFlag = configuration.getTemplates().getNoWaitFlag();
return addFlag(noWaitFlag);
}
|
[
"@",
"WithBridgeMethods",
"(",
"value",
"=",
"PostgreSQLQuery",
".",
"class",
",",
"castRequired",
"=",
"true",
")",
"public",
"C",
"noWait",
"(",
")",
"{",
"QueryFlag",
"noWaitFlag",
"=",
"configuration",
".",
"getTemplates",
"(",
")",
".",
"getNoWaitFlag",
"(",
")",
";",
"return",
"addFlag",
"(",
"noWaitFlag",
")",
";",
"}"
] |
With NOWAIT, the statement reports an error, rather than waiting, if a selected row cannot
be locked immediately.
@return the current object
|
[
"With",
"NOWAIT",
"the",
"statement",
"reports",
"an",
"error",
"rather",
"than",
"waiting",
"if",
"a",
"selected",
"row",
"cannot",
"be",
"locked",
"immediately",
"."
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-sql/src/main/java/com/querydsl/sql/postgresql/AbstractPostgreSQLQuery.java#L67-L71
|
18,096
|
querydsl/querydsl
|
querydsl-sql/src/main/java/com/querydsl/sql/postgresql/AbstractPostgreSQLQuery.java
|
AbstractPostgreSQLQuery.distinctOn
|
@WithBridgeMethods(value = PostgreSQLQuery.class, castRequired = true)
public C distinctOn(Expression<?>... exprs) {
return addFlag(Position.AFTER_SELECT,
Expressions.template(Object.class, "distinct on({0}) ",
ExpressionUtils.list(Object.class, exprs)));
}
|
java
|
@WithBridgeMethods(value = PostgreSQLQuery.class, castRequired = true)
public C distinctOn(Expression<?>... exprs) {
return addFlag(Position.AFTER_SELECT,
Expressions.template(Object.class, "distinct on({0}) ",
ExpressionUtils.list(Object.class, exprs)));
}
|
[
"@",
"WithBridgeMethods",
"(",
"value",
"=",
"PostgreSQLQuery",
".",
"class",
",",
"castRequired",
"=",
"true",
")",
"public",
"C",
"distinctOn",
"(",
"Expression",
"<",
"?",
">",
"...",
"exprs",
")",
"{",
"return",
"addFlag",
"(",
"Position",
".",
"AFTER_SELECT",
",",
"Expressions",
".",
"template",
"(",
"Object",
".",
"class",
",",
"\"distinct on({0}) \"",
",",
"ExpressionUtils",
".",
"list",
"(",
"Object",
".",
"class",
",",
"exprs",
")",
")",
")",
";",
"}"
] |
adds a DISTINCT ON clause
@param exprs
@return
|
[
"adds",
"a",
"DISTINCT",
"ON",
"clause"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-sql/src/main/java/com/querydsl/sql/postgresql/AbstractPostgreSQLQuery.java#L97-L102
|
18,097
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/dsl/TimeExpression.java
|
TimeExpression.currentTime
|
public static <T extends Comparable> TimeExpression<T> currentTime(Class<T> cl) {
return Expressions.timeOperation(cl, Ops.DateTimeOps.CURRENT_TIME);
}
|
java
|
public static <T extends Comparable> TimeExpression<T> currentTime(Class<T> cl) {
return Expressions.timeOperation(cl, Ops.DateTimeOps.CURRENT_TIME);
}
|
[
"public",
"static",
"<",
"T",
"extends",
"Comparable",
">",
"TimeExpression",
"<",
"T",
">",
"currentTime",
"(",
"Class",
"<",
"T",
">",
"cl",
")",
"{",
"return",
"Expressions",
".",
"timeOperation",
"(",
"cl",
",",
"Ops",
".",
"DateTimeOps",
".",
"CURRENT_TIME",
")",
";",
"}"
] |
Create an expression representing the current time as a TimeExpression instance
@return current time
|
[
"Create",
"an",
"expression",
"representing",
"the",
"current",
"time",
"as",
"a",
"TimeExpression",
"instance"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/dsl/TimeExpression.java#L120-L122
|
18,098
|
querydsl/querydsl
|
querydsl-spatial/src/main/java/com/querydsl/spatial/GeometryCollectionExpression.java
|
GeometryCollectionExpression.numGeometries
|
public NumberExpression<Integer> numGeometries() {
if (numGeometries == null) {
numGeometries = Expressions.numberOperation(Integer.class, SpatialOps.NUM_GEOMETRIES, mixin);
}
return numGeometries;
}
|
java
|
public NumberExpression<Integer> numGeometries() {
if (numGeometries == null) {
numGeometries = Expressions.numberOperation(Integer.class, SpatialOps.NUM_GEOMETRIES, mixin);
}
return numGeometries;
}
|
[
"public",
"NumberExpression",
"<",
"Integer",
">",
"numGeometries",
"(",
")",
"{",
"if",
"(",
"numGeometries",
"==",
"null",
")",
"{",
"numGeometries",
"=",
"Expressions",
".",
"numberOperation",
"(",
"Integer",
".",
"class",
",",
"SpatialOps",
".",
"NUM_GEOMETRIES",
",",
"mixin",
")",
";",
"}",
"return",
"numGeometries",
";",
"}"
] |
Returns the number of geometries in this GeometryCollection.
@return number of geometries
|
[
"Returns",
"the",
"number",
"of",
"geometries",
"in",
"this",
"GeometryCollection",
"."
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-spatial/src/main/java/com/querydsl/spatial/GeometryCollectionExpression.java#L49-L54
|
18,099
|
querydsl/querydsl
|
querydsl-collections/src/main/java/com/querydsl/collections/GuavaHelpers.java
|
GuavaHelpers.wrap
|
public static <T> com.google.common.base.Predicate<T> wrap(Predicate predicate) {
Path<?> path = predicate.accept(PathExtractor.DEFAULT, null);
if (path != null) {
final Evaluator<Boolean> ev = createEvaluator(path.getRoot(), predicate);
return new com.google.common.base.Predicate<T>() {
@Override
public boolean apply(T input) {
return ev.evaluate(input);
}
};
} else {
throw new IllegalArgumentException("No path in " + predicate);
}
}
|
java
|
public static <T> com.google.common.base.Predicate<T> wrap(Predicate predicate) {
Path<?> path = predicate.accept(PathExtractor.DEFAULT, null);
if (path != null) {
final Evaluator<Boolean> ev = createEvaluator(path.getRoot(), predicate);
return new com.google.common.base.Predicate<T>() {
@Override
public boolean apply(T input) {
return ev.evaluate(input);
}
};
} else {
throw new IllegalArgumentException("No path in " + predicate);
}
}
|
[
"public",
"static",
"<",
"T",
">",
"com",
".",
"google",
".",
"common",
".",
"base",
".",
"Predicate",
"<",
"T",
">",
"wrap",
"(",
"Predicate",
"predicate",
")",
"{",
"Path",
"<",
"?",
">",
"path",
"=",
"predicate",
".",
"accept",
"(",
"PathExtractor",
".",
"DEFAULT",
",",
"null",
")",
";",
"if",
"(",
"path",
"!=",
"null",
")",
"{",
"final",
"Evaluator",
"<",
"Boolean",
">",
"ev",
"=",
"createEvaluator",
"(",
"path",
".",
"getRoot",
"(",
")",
",",
"predicate",
")",
";",
"return",
"new",
"com",
".",
"google",
".",
"common",
".",
"base",
".",
"Predicate",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"apply",
"(",
"T",
"input",
")",
"{",
"return",
"ev",
".",
"evaluate",
"(",
"input",
")",
";",
"}",
"}",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No path in \"",
"+",
"predicate",
")",
";",
"}",
"}"
] |
Wrap a Querydsl predicate into a Guava predicate
@param predicate predicate to wrapped
@return Guava predicate
|
[
"Wrap",
"a",
"Querydsl",
"predicate",
"into",
"a",
"Guava",
"predicate"
] |
2bf234caf78549813a1e0f44d9c30ecc5ef734e3
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-collections/src/main/java/com/querydsl/collections/GuavaHelpers.java#L44-L57
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.