forked from apache/druid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
874 additions
and
1,035 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
client/src/main/java/com/metamx/druid/query/metadata/AllColumnIncluderator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Druid - a distributed column store. | ||
* Copyright (C) 2012 Metamarkets Group Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
package com.metamx.druid.query.metadata; | ||
|
||
/** | ||
*/ | ||
public class AllColumnIncluderator implements ColumnIncluderator | ||
{ | ||
@Override | ||
public boolean include(String columnName) | ||
{ | ||
return true; | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
client/src/main/java/com/metamx/druid/query/metadata/ColumnAnalysis.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* Druid - a distributed column store. | ||
* Copyright (C) 2012 Metamarkets Group Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
package com.metamx.druid.query.metadata; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.metamx.druid.index.column.ValueType; | ||
import org.codehaus.jackson.annotate.JsonCreator; | ||
import org.codehaus.jackson.annotate.JsonProperty; | ||
|
||
/** | ||
*/ | ||
public class ColumnAnalysis | ||
{ | ||
private static final String ERROR_PREFIX = "error:"; | ||
|
||
public static ColumnAnalysis error(String reason) | ||
{ | ||
return new ColumnAnalysis(ERROR_PREFIX + reason, -1, null); | ||
} | ||
|
||
private final String type; | ||
private final long size; | ||
private final Integer cardinality; | ||
|
||
@JsonCreator | ||
public ColumnAnalysis( | ||
@JsonProperty("type") ValueType type, | ||
@JsonProperty("size") long size, | ||
@JsonProperty("cardinality") Integer cardinality | ||
) | ||
{ | ||
this(type.name(), size, cardinality); | ||
} | ||
|
||
private ColumnAnalysis( | ||
String type, | ||
long size, | ||
Integer cardinality | ||
) | ||
{ | ||
this.type = type; | ||
this.size = size; | ||
this.cardinality = cardinality; | ||
} | ||
|
||
@JsonProperty | ||
public String getType() | ||
{ | ||
return type; | ||
} | ||
|
||
@JsonProperty | ||
public long getSize() | ||
{ | ||
return size; | ||
} | ||
|
||
@JsonProperty | ||
public Integer getCardinality() | ||
{ | ||
return cardinality; | ||
} | ||
|
||
public boolean isError() | ||
{ | ||
return type.startsWith(ERROR_PREFIX); | ||
} | ||
|
||
public ColumnAnalysis fold(ColumnAnalysis rhs) | ||
{ | ||
if (rhs == null) { | ||
return this; | ||
} | ||
|
||
if (!type.equals(rhs.getType())) { | ||
return ColumnAnalysis.error("cannot_merge_diff_types"); | ||
} | ||
|
||
Integer cardinality = getCardinality(); | ||
final Integer rhsCardinality = rhs.getCardinality(); | ||
if (cardinality == null) { | ||
cardinality = rhsCardinality; | ||
} | ||
else { | ||
if (rhsCardinality != null) { | ||
cardinality = Math.max(cardinality, rhsCardinality); | ||
} | ||
} | ||
|
||
return new ColumnAnalysis(type, size + rhs.getSize(), cardinality); | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
return "ColumnAnalysis{" + | ||
"type='" + type + '\'' + | ||
", size=" + size + | ||
", cardinality=" + cardinality + | ||
'}'; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
client/src/main/java/com/metamx/druid/query/metadata/ColumnIncluderator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Druid - a distributed column store. | ||
* Copyright (C) 2012 Metamarkets Group Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
package com.metamx.druid.query.metadata; | ||
|
||
import org.codehaus.jackson.annotate.JsonSubTypes; | ||
import org.codehaus.jackson.annotate.JsonTypeInfo; | ||
|
||
/** | ||
*/ | ||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") | ||
@JsonSubTypes(value = { | ||
@JsonSubTypes.Type(name = "none", value= NoneColumnIncluderator.class), | ||
@JsonSubTypes.Type(name = "all", value= AllColumnIncluderator.class), | ||
@JsonSubTypes.Type(name = "list", value= ListColumnIncluderator.class) | ||
}) | ||
public interface ColumnIncluderator | ||
{ | ||
public boolean include(String columnName); | ||
} |
56 changes: 56 additions & 0 deletions
56
client/src/main/java/com/metamx/druid/query/metadata/ListColumnIncluderator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Druid - a distributed column store. | ||
* Copyright (C) 2012 Metamarkets Group Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
package com.metamx.druid.query.metadata; | ||
|
||
import com.google.common.collect.Sets; | ||
import org.codehaus.jackson.annotate.JsonCreator; | ||
import org.codehaus.jackson.annotate.JsonProperty; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
*/ | ||
public class ListColumnIncluderator implements ColumnIncluderator | ||
{ | ||
private final Set<String> columns; | ||
|
||
@JsonCreator | ||
public ListColumnIncluderator( | ||
@JsonProperty("columns") List<String> columns | ||
) | ||
{ | ||
this.columns = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER); | ||
this.columns.addAll(columns); | ||
} | ||
|
||
@JsonProperty | ||
public Set<String> getColumns() | ||
{ | ||
return Collections.unmodifiableSet(columns); | ||
} | ||
|
||
@Override | ||
public boolean include(String columnName) | ||
{ | ||
return columns.contains(columnName); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
client/src/main/java/com/metamx/druid/query/metadata/NoneColumnIncluderator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Druid - a distributed column store. | ||
* Copyright (C) 2012 Metamarkets Group Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
package com.metamx.druid.query.metadata; | ||
|
||
/** | ||
*/ | ||
public class NoneColumnIncluderator implements ColumnIncluderator | ||
{ | ||
@Override | ||
public boolean include(String columnName) | ||
{ | ||
return false; | ||
} | ||
} |
Oops, something went wrong.