public LiteralParseNode literal(Object value) { return new LiteralParseNode(value); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; OffsetNode other = (OffsetNode)obj; if (bindNode == null) { if (other.bindNode != null) return false; } else if (!bindNode.equals(other.bindNode)) return false; if (offsetNode == null) { if (other.offsetNode != null) return false; } else if (!offsetNode.equals(other.offsetNode)) return false; return true; } }
public NamedTableNode namedTable(String alias, TableName name, List<ColumnDef> dyn_columns, LiteralParseNode tableSampleNode) { Double tableSamplingRate; if(tableSampleNode==null||tableSampleNode.getValue()==null){ tableSamplingRate=ConcreteTableNode.DEFAULT_TABLE_SAMPLING_RATE; }else if(tableSampleNode.getValue() instanceof Integer){ tableSamplingRate=(double)((int)tableSampleNode.getValue()); }else{ tableSamplingRate=((BigDecimal) tableSampleNode.getValue()).doubleValue(); } return new NamedTableNode(alias, name, dyn_columns, tableSamplingRate); }
FunctionArgument arg = new FunctionArgument(type.getString(), isArrayType, isConstant, defaultValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(defaultValue)).getValue()), minValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(minValue)).getValue()), maxValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(maxValue)).getValue()), argPosition); arguments.add(arg);
@Override public E visit(LiteralParseNode node) throws SQLException { throw new SQLFeatureNotSupportedException(node.toString()); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((bindNode == null) ? 0 : bindNode.hashCode()); result = prime * result + ((limitNode == null) ? 0 : limitNode.hashCode()); return result; }
public ParseNode negate(ParseNode child) { // Prevents reparsing of -1 from becoming 1*-1 and 1*1*-1 with each re-parsing if (LiteralParseNode.ONE.equals(child) && ((LiteralParseNode)child).getType().isCoercibleTo( PLong.INSTANCE)) { return LiteralParseNode.MINUS_ONE; } // Special case to convert Long.MIN_VALUE back to a Long. We can't initially represent it // as a Long in the parser because we only represent positive values as constants in the // parser, and ABS(Long.MIN_VALUE) is too big to fit into a Long. So we convert it back here. if (LiteralParseNode.MIN_LONG_AS_BIG_DECIMAL.equals(child)) { return LiteralParseNode.MIN_LONG; } return new MultiplyParseNode(Arrays.asList(child,LiteralParseNode.MINUS_ONE)); }
@Override public MutationState execute() throws SQLException { String dynamicJarsDir = stmt.getConnection().getQueryServices().getProps().get(QueryServices.DYNAMIC_JARS_DIR_KEY); if(dynamicJarsDir == null) { throw new SQLException(QueryServices.DYNAMIC_JARS_DIR_KEY+" is not configured for placing the jars."); } dynamicJarsDir = dynamicJarsDir.endsWith("/") ? dynamicJarsDir : dynamicJarsDir + '/'; Configuration conf = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(); Path dynamicJarsDirPath = new Path(dynamicJarsDir); for (LiteralParseNode jarPath : getJarPaths()) { String jarPathStr = (String)jarPath.getValue(); if(!jarPathStr.endsWith(".jar")) { throw new SQLException(jarPathStr + " is not a valid jar file path."); } } try { FileSystem fs = dynamicJarsDirPath.getFileSystem(conf); List<LiteralParseNode> jarPaths = getJarPaths(); for (LiteralParseNode jarPath : jarPaths) { File f = new File((String) jarPath.getValue()); fs.copyFromLocalFile(new Path(f.getAbsolutePath()), new Path( dynamicJarsDir + f.getName())); } } catch(IOException e) { throw new SQLException(e); } return new MutationState(0, 0, context.getConnection()); } };
String maxValue = arg.hasMaxValue()?arg.getMaxValue():null; args.add(new FunctionArgument(argType, isArrayType, isConstant, defaultValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(dataType.toObject(defaultValue))).getValue()), minValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(dataType.toObject(minValue))).getValue()), maxValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(dataType.toObject(maxValue))).getValue())));
@Override public String toString() { return bindNode == null ? offsetNode.toString() : bindNode.toString(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((bindNode == null) ? 0 : bindNode.hashCode()); result = prime * result + ((offsetNode == null) ? 0 : offsetNode.hashCode()); return result; }
public ParseNode negate(ParseNode child) { // Prevents reparsing of -1 from becoming 1*-1 and 1*1*-1 with each re-parsing if (LiteralParseNode.ONE.equals(child) && ((LiteralParseNode)child).getType().isCoercibleTo( PLong.INSTANCE)) { return LiteralParseNode.MINUS_ONE; } // Special case to convert Long.MIN_VALUE back to a Long. We can't initially represent it // as a Long in the parser because we only represent positive values as constants in the // parser, and ABS(Long.MIN_VALUE) is too big to fit into a Long. So we convert it back here. if (LiteralParseNode.MIN_LONG_AS_BIG_DECIMAL.equals(child)) { return LiteralParseNode.MIN_LONG; } return new MultiplyParseNode(Arrays.asList(child,LiteralParseNode.MINUS_ONE)); }
@Override public Void visit(LiteralParseNode node) throws SQLException { Object offsetValue = node.getValue(); if (offsetValue != null) { Integer offset = (Integer)OFFSET_DATUM.getDataType().toObject(offsetValue, node.getType()); if (offset.intValue() >= 0) { this.offset = offset; } } return null; }
protected CreateSequenceStatement(TableName sequenceName, ParseNode startWith, ParseNode incrementBy, ParseNode cacheSize, ParseNode minValue, ParseNode maxValue, boolean cycle, boolean ifNotExists, int bindCount) { this.sequenceName = sequenceName; // if MINVALUE, MAXVALUE and START WITH are not specified, set START WITH to 1 in order to // maintain backward compatibility this.startWith = (minValue == null && maxValue == null && startWith == null) ? LiteralParseNode.ONE : startWith; this.minValue = minValue == null ? new LiteralParseNode(Long.MIN_VALUE) : minValue; this.maxValue = maxValue == null ? new LiteralParseNode(Long.MAX_VALUE) : maxValue; this.incrementBy = incrementBy == null ? LiteralParseNode.ONE : incrementBy; this.cacheSize = cacheSize; this.cycle = cycle; this.ifNotExists = ifNotExists; this.bindCount = bindCount; }
@Override public MutationState execute() throws SQLException { String dynamicJarsDir = stmt.getConnection().getQueryServices().getProps().get(QueryServices.DYNAMIC_JARS_DIR_KEY); if (dynamicJarsDir == null) { throw new SQLException(QueryServices.DYNAMIC_JARS_DIR_KEY + " is not configured."); } dynamicJarsDir = dynamicJarsDir.endsWith("/") ? dynamicJarsDir : dynamicJarsDir + '/'; Configuration conf = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(); Path dynamicJarsDirPath = new Path(dynamicJarsDir); try { FileSystem fs = dynamicJarsDirPath.getFileSystem(conf); String jarPathStr = (String)getJarPath().getValue(); if(!jarPathStr.endsWith(".jar")) { throw new SQLException(jarPathStr + " is not a valid jar file path."); } Path p = new Path(jarPathStr); if(fs.exists(p)) { fs.delete(p, false); } } catch(IOException e) { throw new SQLException(e); } return new MutationState(0, 0, context.getConnection()); } };
FunctionArgument arg = new FunctionArgument(type.getString(), isArrayType, isConstant, defaultValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(defaultValue)).getValue()), minValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(minValue)).getValue()), maxValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(maxValue)).getValue()), argPosition); arguments.add(arg);
@Override public String toString() { return bindNode == null ? limitNode.toString() : bindNode.toString(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((bindNode == null) ? 0 : bindNode.hashCode()); result = prime * result + ((offsetNode == null) ? 0 : offsetNode.hashCode()); return result; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; LimitNode other = (LimitNode)obj; if (bindNode == null) { if (other.bindNode != null) return false; } else if (!bindNode.equals(other.bindNode)) return false; if (limitNode == null) { if (other.limitNode != null) return false; } else if (!limitNode.equals(other.limitNode)) return false; return true; } }